Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
2e3b3d64
by lovetox at 2020-08-29T21:25:50+02:00
-
9c256c42
by lovetox at 2020-08-29T21:34:10+02:00
-
79c5f872
by lovetox at 2020-08-29T21:37:07+02:00
-
59db443a
by lovetox at 2020-08-29T22:01:25+02:00
-
32d3c3cd
by lovetox at 2020-08-29T23:27:39+02:00
-
42953fb1
by lovetox at 2020-08-29T23:34:06+02:00
-
acbce41f
by lovetox at 2020-08-29T23:34:32+02:00
9 changed files:
- gajim/chat_control.py
- gajim/chat_control_base.py
- gajim/conversation_textview.py
- gajim/data/gui/chat_control.ui
- gajim/groupchat_control.py
- gajim/gtk/htmltextview.py
- gajim/gtk/message_input.py
- gajim/gtk/util.py
- gajim/message_window.py
Changes:
| ... | ... | @@ -1104,16 +1104,7 @@ class ChatControl(ChatControlBase): |
| 1104 | 1104 |
self.account,
|
| 1105 | 1105 |
force=True,
|
| 1106 | 1106 |
backend=backend)
|
| 1107 |
- # remove all register handlers on widgets, created by self.xml
|
|
| 1108 |
- # to prevent circular references among objects
|
|
| 1109 |
- for i in list(self.handlers.keys()):
|
|
| 1110 |
- if self.handlers[i].handler_is_connected(i):
|
|
| 1111 |
- self.handlers[i].disconnect(i)
|
|
| 1112 |
- del self.handlers[i]
|
|
| 1113 |
- self.conv_textview.del_handlers()
|
|
| 1114 |
- self.msg_textview.destroy()
|
|
| 1115 |
- # PluginSystem: calling shutdown of super class (ChatControlBase) to let
|
|
| 1116 |
- # it remove it's GUI extension points
|
|
| 1107 |
+ |
|
| 1117 | 1108 |
super(ChatControl, self).shutdown()
|
| 1118 | 1109 |
|
| 1119 | 1110 |
def minimizable(self):
|
| ... | ... | @@ -33,7 +33,6 @@ from gi.repository import Gtk |
| 33 | 33 |
from gi.repository import Gdk
|
| 34 | 34 |
from gi.repository import GLib
|
| 35 | 35 |
from gi.repository import Gio
|
| 36 |
-from gi.repository import GObject
|
|
| 37 | 36 |
|
| 38 | 37 |
from gajim.common import events
|
| 39 | 38 |
from gajim.common import app
|
| ... | ... | @@ -136,19 +135,6 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper): |
| 136 | 135 |
self.xml.connect_signals(self)
|
| 137 | 136 |
self.widget = self.xml.get_object('%s_hbox' % widget_name)
|
| 138 | 137 |
|
| 139 |
- if not self._type.is_groupchat:
|
|
| 140 |
- # Create banner and connect signals
|
|
| 141 |
- id_ = self.xml.banner_eventbox.connect(
|
|
| 142 |
- 'button-press-event',
|
|
| 143 |
- self._on_banner_eventbox_button_press_event)
|
|
| 144 |
- self.handlers[id_] = self.xml.banner_eventbox
|
|
| 145 |
- |
|
| 146 |
- if self.xml.banner_label is not None:
|
|
| 147 |
- id_ = self.xml.banner_label.connect(
|
|
| 148 |
- 'populate_popup',
|
|
| 149 |
- self.on_banner_label_populate_popup)
|
|
| 150 |
- self.handlers[id_] = self.xml.banner_label
|
|
| 151 |
- |
|
| 152 | 138 |
self._accounts = app.get_enabled_accounts_with_labels()
|
| 153 | 139 |
if len(self._accounts) > 1:
|
| 154 | 140 |
account_badge = generate_account_badge(self.account)
|
| ... | ... | @@ -174,15 +160,6 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper): |
| 174 | 160 |
Gtk.TargetFlags.SAME_APP,
|
| 175 | 161 |
0)]
|
| 176 | 162 |
|
| 177 |
- id_ = self.xml.overlay.connect('drag_data_received',
|
|
| 178 |
- self._on_drag_data_received)
|
|
| 179 |
- |
|
| 180 |
- self.handlers[id_] = self.xml.overlay
|
|
| 181 |
- id_ = self.xml.overlay.connect('drag_motion', self._on_drag_motion)
|
|
| 182 |
- self.handlers[id_] = self.xml.overlay
|
|
| 183 |
- id_ = self.xml.overlay.connect('drag_leave', self._on_drag_leave)
|
|
| 184 |
- self.handlers[id_] = self.xml.overlay
|
|
| 185 |
- |
|
| 186 | 163 |
self.xml.overlay.drag_dest_set(
|
| 187 | 164 |
Gtk.DestDefaults.ALL,
|
| 188 | 165 |
self._dnd_list,
|
| ... | ... | @@ -191,47 +168,36 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper): |
| 191 | 168 |
|
| 192 | 169 |
# Create textviews and connect signals
|
| 193 | 170 |
self.conv_textview = ConversationTextview(self.account)
|
| 194 |
- self.conv_textview.tv.drag_dest_unset()
|
|
| 171 |
+ |
|
| 195 | 172 |
id_ = self.conv_textview.connect('quote', self.on_quote)
|
| 196 |
- self.handlers[id_] = self.conv_textview.tv
|
|
| 173 |
+ self.handlers[id_] = self.conv_textview
|
|
| 197 | 174 |
|
| 198 | 175 |
self.conv_textview.tv.connect('key-press-event',
|
| 199 | 176 |
self._on_conv_textview_key_press_event)
|
| 200 | 177 |
|
| 201 |
- self.conv_scrolledwindow = self.xml.conversation_scrolledwindow
|
|
| 202 |
- self.conv_scrolledwindow.add(self.conv_textview.tv)
|
|
| 203 |
- widget = self.conv_scrolledwindow.get_vadjustment()
|
|
| 204 |
- id_ = widget.connect('changed',
|
|
| 205 |
- self.on_conversation_vadjustment_changed)
|
|
| 206 |
- self.handlers[id_] = widget
|
|
| 178 |
+ self.xml.conversation_scrolledwindow.add(self.conv_textview.tv)
|
|
| 179 |
+ widget = self.xml.conversation_scrolledwindow.get_vadjustment()
|
|
| 180 |
+ widget.connect('changed', self.on_conversation_vadjustment_changed)
|
|
| 207 | 181 |
|
| 208 |
- vscrollbar = self.conv_scrolledwindow.get_vscrollbar()
|
|
| 209 |
- id_ = vscrollbar.connect('button-release-event',
|
|
| 210 |
- self._on_scrollbar_button_release)
|
|
| 211 |
- self.handlers[id_] = vscrollbar
|
|
| 182 |
+ vscrollbar = self.xml.conversation_scrolledwindow.get_vscrollbar()
|
|
| 183 |
+ vscrollbar.connect('button-release-event',
|
|
| 184 |
+ self._on_scrollbar_button_release)
|
|
| 212 | 185 |
|
| 213 |
- self.correcting = False
|
|
| 214 |
- self.last_sent_msg = None
|
|
| 215 |
- |
|
| 216 |
- # add MessageInputTextView to UI and connect signals
|
|
| 217 | 186 |
self.msg_textview = MessageInputTextView()
|
| 218 |
- self.msg_textview.drag_dest_unset()
|
|
| 187 |
+ self.msg_textview.connect('paste-clipboard',
|
|
| 188 |
+ self._on_message_textview_paste_event)
|
|
| 189 |
+ self.msg_textview.connect('key-press-event',
|
|
| 190 |
+ self._on_message_textview_key_press_event)
|
|
| 191 |
+ self.msg_textview.connect('populate-popup',
|
|
| 192 |
+ self.on_msg_textview_populate_popup)
|
|
| 193 |
+ self.msg_textview.connect('text-changed',
|
|
| 194 |
+ self._on_message_tv_buffer_changed)
|
|
| 195 |
+ |
|
| 219 | 196 |
self.msg_scrolledwindow = ScrolledWindow()
|
| 220 | 197 |
self.msg_scrolledwindow.add(self.msg_textview)
|
| 221 | 198 |
|
| 222 | 199 |
self.xml.hbox.pack_start(self.msg_scrolledwindow, True, True, 0)
|
| 223 | 200 |
|
| 224 |
- id_ = self.msg_textview.connect('paste-clipboard',
|
|
| 225 |
- self._on_message_textview_paste_event)
|
|
| 226 |
- self.handlers[id_] = self.msg_textview
|
|
| 227 |
- id_ = self.msg_textview.connect(
|
|
| 228 |
- 'key_press_event',
|
|
| 229 |
- self._on_message_textview_key_press_event)
|
|
| 230 |
- self.handlers[id_] = self.msg_textview
|
|
| 231 |
- id_ = self.msg_textview.connect('populate_popup',
|
|
| 232 |
- self.on_msg_textview_populate_popup)
|
|
| 233 |
- self.handlers[id_] = self.msg_textview
|
|
| 234 |
- |
|
| 235 | 201 |
# the following vars are used to keep history of user's messages
|
| 236 | 202 |
self.sent_history = []
|
| 237 | 203 |
self.sent_history_pos = 0
|
| ... | ... | @@ -239,6 +205,9 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper): |
| 239 | 205 |
self.received_history_pos = 0
|
| 240 | 206 |
self.orig_msg = None
|
| 241 | 207 |
|
| 208 |
+ self.correcting = False
|
|
| 209 |
+ self.last_sent_msg = None
|
|
| 210 |
+ |
|
| 242 | 211 |
self.set_emoticon_popover()
|
| 243 | 212 |
|
| 244 | 213 |
# Attach speller
|
| ... | ... | @@ -256,9 +225,6 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper): |
| 256 | 225 |
con = app.connections[self.account]
|
| 257 | 226 |
con.get_module('Chatstate').set_active(self.contact)
|
| 258 | 227 |
|
| 259 |
- id_ = self.msg_textview.connect('text-changed',
|
|
| 260 |
- self._on_message_tv_buffer_changed)
|
|
| 261 |
- self.handlers[id_] = self.msg_textview
|
|
| 262 | 228 |
if parent_win is not None:
|
| 263 | 229 |
id_ = parent_win.window.connect('motion-notify-event',
|
| 264 | 230 |
self._on_window_motion_notify)
|
| ... | ... | @@ -301,7 +267,7 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper): |
| 301 | 267 |
if textview.get_buffer().props.has_selection:
|
| 302 | 268 |
return Gdk.EVENT_PROPAGATE
|
| 303 | 269 |
|
| 304 |
- # Focus the Messsage Input and resend the event
|
|
| 270 |
+ # Focus the Message Input and resend the event
|
|
| 305 | 271 |
textview.unselect()
|
| 306 | 272 |
self.msg_textview.grab_focus()
|
| 307 | 273 |
self.msg_textview.get_toplevel().propagate_key_event(event)
|
| ... | ... | @@ -684,6 +650,21 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper): |
| 684 | 650 |
menu.show_all()
|
| 685 | 651 |
|
| 686 | 652 |
def shutdown(self):
|
| 653 |
+ for i in list(self.handlers.keys()):
|
|
| 654 |
+ if self.handlers[i].handler_is_connected(i):
|
|
| 655 |
+ self.handlers[i].disconnect(i)
|
|
| 656 |
+ self.handlers.clear()
|
|
| 657 |
+ |
|
| 658 |
+ self.conv_textview.del_handlers()
|
|
| 659 |
+ del self.conv_textview
|
|
| 660 |
+ del self.msg_textview
|
|
| 661 |
+ del self.msg_scrolledwindow
|
|
| 662 |
+ |
|
| 663 |
+ self.widget.destroy()
|
|
| 664 |
+ del self.widget
|
|
| 665 |
+ |
|
| 666 |
+ del self.xml
|
|
| 667 |
+ |
|
| 687 | 668 |
# PluginSystem: removing GUI extension points
|
| 688 | 669 |
# connected with ChatControlBase instance object
|
| 689 | 670 |
app.plugin_manager.remove_gui_extension_point('chat_control_base', self)
|
| ... | ... | @@ -1441,7 +1422,7 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper): |
| 1441 | 1422 |
if direction != Gdk.ScrollDirection.UP:
|
| 1442 | 1423 |
return
|
| 1443 | 1424 |
# Check if we have a Scrollbar
|
| 1444 |
- adjustment = self.conv_scrolledwindow.get_vadjustment()
|
|
| 1425 |
+ adjustment = self.xml.conversation_scrolledwindow.get_vadjustment()
|
|
| 1445 | 1426 |
if adjustment.get_upper() != adjustment.get_page_size():
|
| 1446 | 1427 |
app.log('autoscroll').info('Autoscroll disabled')
|
| 1447 | 1428 |
self.conv_textview.autoscroll = False
|
| ... | ... | @@ -100,14 +100,6 @@ class ConversationTextview(GObject.GObject): |
| 100 | 100 |
self.tv = HtmlTextView(account)
|
| 101 | 101 |
self.tv.connect('query-tooltip', self._query_tooltip)
|
| 102 | 102 |
|
| 103 |
- # set properties
|
|
| 104 |
- self.tv.set_border_width(1)
|
|
| 105 |
- self.tv.set_accepts_tab(True)
|
|
| 106 |
- self.tv.set_editable(False)
|
|
| 107 |
- self.tv.set_cursor_visible(False)
|
|
| 108 |
- self.tv.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
|
|
| 109 |
- self.tv.set_left_margin(2)
|
|
| 110 |
- self.tv.set_right_margin(2)
|
|
| 111 | 103 |
self._buffer = self.tv.get_buffer()
|
| 112 | 104 |
self.handlers = {}
|
| 113 | 105 |
self.image_cache = {}
|
| 1 | 1 |
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
-<!-- Generated with glade 3.36.0 -->
|
|
| 2 |
+<!-- Generated with glade 3.22.2 -->
|
|
| 3 | 3 |
<interface>
|
| 4 | 4 |
<requires lib="gtk+" version="3.22"/>
|
| 5 | 5 |
<object class="GtkAdjustment" id="adjustment1">
|
| ... | ... | @@ -398,6 +398,9 @@ |
| 398 | 398 |
<object class="GtkOverlay" id="overlay">
|
| 399 | 399 |
<property name="visible">True</property>
|
| 400 | 400 |
<property name="can_focus">False</property>
|
| 401 |
+ <signal name="drag-data-received" handler="_on_drag_data_received" swapped="no"/>
|
|
| 402 |
+ <signal name="drag-leave" handler="_on_drag_leave" swapped="no"/>
|
|
| 403 |
+ <signal name="drag-motion" handler="_on_drag_motion" swapped="no"/>
|
|
| 401 | 404 |
<child>
|
| 402 | 405 |
<object class="GtkPaned" id="paned1">
|
| 403 | 406 |
<property name="visible">True</property>
|
| ... | ... | @@ -412,6 +415,7 @@ |
| 412 | 415 |
<property name="name">ChatControl-BannerEventBox</property>
|
| 413 | 416 |
<property name="can_focus">False</property>
|
| 414 | 417 |
<property name="no_show_all">True</property>
|
| 418 |
+ <signal name="button-press-event" handler="_on_banner_eventbox_button_press_event" swapped="no"/>
|
|
| 415 | 419 |
<child>
|
| 416 | 420 |
<object class="GtkBox">
|
| 417 | 421 |
<property name="visible">True</property>
|
| ... | ... | @@ -1638,9 +1638,6 @@ class GroupchatControl(ChatControlBase): |
| 1638 | 1638 |
app.connections[self.account].get_module('MUC').leave(
|
| 1639 | 1639 |
self.room_jid, reason=reason)
|
| 1640 | 1640 |
|
| 1641 |
- # PluginSystem: calling shutdown of super class (ChatControlBase)
|
|
| 1642 |
- # to let it remove it's GUI extension points
|
|
| 1643 |
- super(GroupchatControl, self).shutdown()
|
|
| 1644 | 1641 |
# PluginSystem: removing GUI extension points connected with
|
| 1645 | 1642 |
# GrouphatControl instance object
|
| 1646 | 1643 |
app.plugin_manager.remove_gui_extension_point(
|
| ... | ... | @@ -1668,15 +1665,11 @@ class GroupchatControl(ChatControlBase): |
| 1668 | 1665 |
self.roster.destroy()
|
| 1669 | 1666 |
self.roster = None
|
| 1670 | 1667 |
|
| 1671 |
- # remove all register handlers on wigets, created by self.xml
|
|
| 1672 |
- # to prevent circular references among objects
|
|
| 1673 |
- for i in list(self.handlers.keys()):
|
|
| 1674 |
- if self.handlers[i].handler_is_connected(i):
|
|
| 1675 |
- self.handlers[i].disconnect(i)
|
|
| 1676 |
- del self.handlers[i]
|
|
| 1677 | 1668 |
# Remove unread events from systray
|
| 1678 | 1669 |
app.events.remove_events(self.account, self.room_jid)
|
| 1679 | 1670 |
|
| 1671 |
+ super(GroupchatControl, self).shutdown()
|
|
| 1672 |
+ |
|
| 1680 | 1673 |
def safe_shutdown(self):
|
| 1681 | 1674 |
if self.minimizable():
|
| 1682 | 1675 |
return True
|
| ... | ... | @@ -703,9 +703,18 @@ class HtmlTextView(Gtk.TextView): |
| 703 | 703 |
|
| 704 | 704 |
def __init__(self, account, standalone=False):
|
| 705 | 705 |
Gtk.TextView.__init__(self)
|
| 706 |
- self.set_wrap_mode(Gtk.WrapMode.CHAR)
|
|
| 707 |
- self.set_editable(False)
|
|
| 706 |
+ |
|
| 708 | 707 |
self.set_has_tooltip(True)
|
| 708 |
+ self.set_border_width(1)
|
|
| 709 |
+ self.set_accepts_tab(True)
|
|
| 710 |
+ self.set_editable(False)
|
|
| 711 |
+ self.set_cursor_visible(False)
|
|
| 712 |
+ self.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
|
|
| 713 |
+ self.set_left_margin(2)
|
|
| 714 |
+ self.set_right_margin(2)
|
|
| 715 |
+ |
|
| 716 |
+ self.drag_dest_unset()
|
|
| 717 |
+ |
|
| 709 | 718 |
self.connect('copy-clipboard', self._on_copy_clipboard)
|
| 710 | 719 |
self.get_buffer().eol_tag = self.get_buffer().create_tag('eol')
|
| 711 | 720 |
|
| ... | ... | @@ -61,6 +61,8 @@ class MessageInputTextView(Gtk.TextView): |
| 61 | 61 |
self.set_pixels_below_lines(2)
|
| 62 | 62 |
self.get_style_context().add_class('gajim-conversation-font')
|
| 63 | 63 |
|
| 64 |
+ self.drag_dest_unset()
|
|
| 65 |
+ |
|
| 64 | 66 |
# set undo list
|
| 65 | 67 |
self.undo_list = []
|
| 66 | 68 |
# needed to know if we undid something
|
| ... | ... | @@ -21,6 +21,7 @@ from typing import Tuple |
| 21 | 21 |
from typing import Optional
|
| 22 | 22 |
|
| 23 | 23 |
import sys
|
| 24 |
+import weakref
|
|
| 24 | 25 |
import logging
|
| 25 | 26 |
import textwrap
|
| 26 | 27 |
from importlib import import_module
|
| ... | ... | @@ -811,3 +812,13 @@ class EventHelper(CommonEventHelper): |
| 811 | 812 |
|
| 812 | 813 |
def __on_destroy(self, *args):
|
| 813 | 814 |
self.unregister_events()
|
| 815 |
+ |
|
| 816 |
+ |
|
| 817 |
+def check_destroy(widget):
|
|
| 818 |
+ def _destroy(*args):
|
|
| 819 |
+ print('DESTROYED', args)
|
|
| 820 |
+ widget.connect('destroy', _destroy)
|
|
| 821 |
+ |
|
| 822 |
+ |
|
| 823 |
+def check_finalize(obj, name):
|
|
| 824 |
+ weakref.finalize(obj, print, f'{name} has been finalized')
|
| ... | ... | @@ -561,10 +561,6 @@ class MessageWindow(EventHelper): |
| 561 | 561 |
ask any confirmation
|
| 562 | 562 |
"""
|
| 563 | 563 |
def close(ctrl):
|
| 564 |
- if reason is not None: # We are leaving gc with a status message
|
|
| 565 |
- ctrl.shutdown(reason)
|
|
| 566 |
- else: # We are leaving gc without status message or it's a chat
|
|
| 567 |
- ctrl.shutdown()
|
|
| 568 | 564 |
# Update external state
|
| 569 | 565 |
app.events.remove_events(
|
| 570 | 566 |
ctrl.account, ctrl.get_full_jid,
|
| ... | ... | @@ -588,6 +584,11 @@ class MessageWindow(EventHelper): |
| 588 | 584 |
if not self._controls[ctrl.account]:
|
| 589 | 585 |
del self._controls[ctrl.account]
|
| 590 | 586 |
|
| 587 |
+ if reason is not None: # We are leaving gc with a status message
|
|
| 588 |
+ ctrl.shutdown(reason)
|
|
| 589 |
+ else: # We are leaving gc without status message or it's a chat
|
|
| 590 |
+ ctrl.shutdown()
|
|
| 591 |
+ |
|
| 591 | 592 |
self.check_tabs()
|
| 592 | 593 |
self.show_title()
|
| 593 | 594 |
|