| ... |
... |
@@ -320,18 +320,23 @@ class GroupchatControl(ChatControlBase): |
|
320
|
320
|
# Keep error dialog instance to be sure to have only once at a time
|
|
321
|
321
|
self.error_dialog = None
|
|
322
|
322
|
|
|
|
323
|
+ # Source id for saving the handle position
|
|
|
324
|
+ self._handle_timeout_id = None
|
|
|
325
|
+
|
|
323
|
326
|
self.emoticons_button = self.xml.get_object('emoticons_button')
|
|
324
|
327
|
self.toggle_emoticons()
|
|
325
|
328
|
|
|
326
|
329
|
formattings_button = self.xml.get_object('formattings_button')
|
|
327
|
330
|
formattings_button.set_sensitive(False)
|
|
328
|
331
|
|
|
|
332
|
+ self._state_change_handler_id = None
|
|
329
|
333
|
if parent_win is not None:
|
|
330
|
334
|
# On AutoJoin with minimize Groupchats are created without parent
|
|
331
|
335
|
# Tooltip Window and Actions have to be created with parent
|
|
332
|
336
|
self.set_tooltip()
|
|
333
|
337
|
self.add_actions()
|
|
334
|
338
|
self.scale_factor = parent_win.window.get_scale_factor()
|
|
|
339
|
+ self._connect_window_state_change(parent_win)
|
|
335
|
340
|
else:
|
|
336
|
341
|
self.scale_factor = app.interface.roster.scale_factor
|
|
337
|
342
|
|
| ... |
... |
@@ -400,17 +405,12 @@ class GroupchatControl(ChatControlBase): |
|
400
|
405
|
id_ = self.list_treeview.connect('style-set',
|
|
401
|
406
|
self.on_list_treeview_style_set)
|
|
402
|
407
|
self.handlers[id_] = self.list_treeview
|
|
403
|
|
- self.resize_from_another_muc = False
|
|
404
|
|
- # we want to know when the the widget resizes, because that is
|
|
405
|
|
- # an indication that the hpaned has moved...
|
|
406
|
|
- self.hpaned = self.xml.get_object('hpaned')
|
|
407
|
|
- id_ = self.hpaned.connect('notify', self.on_hpaned_notify)
|
|
408
|
|
- self.handlers[id_] = self.hpaned
|
|
409
|
408
|
|
|
410
|
|
- if app.config.get('hide_groupchat_occupants_list'):
|
|
411
|
|
- # Hide the roster by default
|
|
412
|
|
- self.hpaned.get_child2().set_no_show_all(True)
|
|
413
|
|
- self.hpaned.get_child2().hide()
|
|
|
409
|
+ # flag that stops hpaned position event
|
|
|
410
|
+ # when the handle gets resized in another control
|
|
|
411
|
+ self._resize_from_another_muc = False
|
|
|
412
|
+
|
|
|
413
|
+ self.hpaned = self.xml.get_object('hpaned')
|
|
414
|
414
|
|
|
415
|
415
|
# set the position of the current hpaned
|
|
416
|
416
|
hpaned_position = app.config.get('gc-hpaned-position')
|
| ... |
... |
@@ -490,7 +490,7 @@ class GroupchatControl(ChatControlBase): |
|
490
|
490
|
# Banner
|
|
491
|
491
|
self.banner_actionbar = self.xml.get_object('banner_actionbar')
|
|
492
|
492
|
self.hide_roster_button = Gtk.Button.new_from_icon_name(
|
|
493
|
|
- 'go-previous-symbolic', Gtk.IconSize.MENU)
|
|
|
493
|
+ 'go-next-symbolic', Gtk.IconSize.MENU)
|
|
494
|
494
|
self.hide_roster_button.connect('clicked',
|
|
495
|
495
|
lambda *args: self.show_roster())
|
|
496
|
496
|
self.subject_button = Gtk.MenuButton()
|
| ... |
... |
@@ -534,6 +534,11 @@ class GroupchatControl(ChatControlBase): |
|
534
|
534
|
|
|
535
|
535
|
self.update_ui()
|
|
536
|
536
|
self.widget.show_all()
|
|
|
537
|
+
|
|
|
538
|
+ if app.config.get('hide_groupchat_occupants_list'):
|
|
|
539
|
+ # Roster is shown by default, so toggle the roster button to hide it
|
|
|
540
|
+ self.show_roster()
|
|
|
541
|
+
|
|
537
|
542
|
# PluginSystem: adding GUI extension point for this GroupchatControl
|
|
538
|
543
|
# instance object
|
|
539
|
544
|
app.plugin_manager.gui_extension_point('groupchat_control', self)
|
| ... |
... |
@@ -636,6 +641,13 @@ class GroupchatControl(ChatControlBase): |
|
636
|
641
|
tooltip_text = _('No File Transfer available')
|
|
637
|
642
|
self.sendfile_button.set_tooltip_text(tooltip_text)
|
|
638
|
643
|
|
|
|
644
|
+
|
|
|
645
|
+ def _connect_window_state_change(self, parent_win):
|
|
|
646
|
+ if self._state_change_handler_id is None:
|
|
|
647
|
+ id_ = parent_win.window.connect('notify::is-maximized',
|
|
|
648
|
+ self._on_window_state_change)
|
|
|
649
|
+ self._state_change_handler_id = id_
|
|
|
650
|
+
|
|
639
|
651
|
# Actions
|
|
640
|
652
|
|
|
641
|
653
|
def _on_change_subject(self, action, param):
|
| ... |
... |
@@ -756,6 +768,7 @@ class GroupchatControl(ChatControlBase): |
|
756
|
768
|
self.update_actions()
|
|
757
|
769
|
self.set_lock_image()
|
|
758
|
770
|
self._schedule_activity_timers()
|
|
|
771
|
+ self._connect_window_state_change(self.parent_win)
|
|
759
|
772
|
|
|
760
|
773
|
def set_tooltip(self):
|
|
761
|
774
|
widget = self.xml.get_object('list_treeview')
|
| ... |
... |
@@ -875,27 +888,37 @@ class GroupchatControl(ChatControlBase): |
|
875
|
888
|
menu.show_all()
|
|
876
|
889
|
|
|
877
|
890
|
def resize_occupant_treeview(self, position):
|
|
878
|
|
- self.resize_from_another_muc = True
|
|
|
891
|
+ if self.hpaned.get_position() == position:
|
|
|
892
|
+ return
|
|
|
893
|
+ self._resize_from_another_muc = True
|
|
879
|
894
|
self.hpaned.set_position(position)
|
|
880
|
|
- def reset_flag():
|
|
881
|
|
- self.resize_from_another_muc = False
|
|
|
895
|
+ def _reset_flag():
|
|
|
896
|
+ self._resize_from_another_muc = False
|
|
882
|
897
|
# Reset the flag when everything will be redrawn, and in particular when
|
|
883
|
898
|
# on_treeview_size_allocate will have been called.
|
|
884
|
|
- GLib.idle_add(reset_flag)
|
|
|
899
|
+ GLib.timeout_add(500, _reset_flag)
|
|
885
|
900
|
|
|
886
|
|
- def on_hpaned_notify(self, pane, gparamspec):
|
|
887
|
|
- """
|
|
888
|
|
- The MUC treeview has resized. Move the hpaned in all tabs to match
|
|
889
|
|
- """
|
|
890
|
|
- # print pane, dir(pane)
|
|
891
|
|
- #if gparamspec.name != 'position':
|
|
892
|
|
- #return
|
|
893
|
|
- if self.resize_from_another_muc:
|
|
894
|
|
- # Don't send the event to other MUC
|
|
|
901
|
+ def _on_window_state_change(self, win, param):
|
|
|
902
|
+ # Add with timeout, because state change happens before
|
|
|
903
|
+ # the hpaned notifys us about a new handle position
|
|
|
904
|
+ GLib.timeout_add(100, self._check_for_resize)
|
|
|
905
|
+
|
|
|
906
|
+ def _on_hpaned_release_button(self, hpaned, event):
|
|
|
907
|
+ if event.get_button()[1] != 1:
|
|
|
908
|
+ # We want only to catch the left mouse button
|
|
895
|
909
|
return
|
|
|
910
|
+ self._check_for_resize()
|
|
896
|
911
|
|
|
897
|
|
- hpaned_position = self.hpaned.get_position()
|
|
898
|
|
- app.config.set('gc-hpaned-position', hpaned_position)
|
|
|
912
|
+ def _check_for_resize(self):
|
|
|
913
|
+ # Check if we have a new position
|
|
|
914
|
+ pos = self.hpaned.get_position()
|
|
|
915
|
+ if pos == app.config.get('gc-hpaned-position'):
|
|
|
916
|
+ return
|
|
|
917
|
+
|
|
|
918
|
+ # Save new position
|
|
|
919
|
+ self._remove_handle_timeout()
|
|
|
920
|
+ app.config.set('gc-hpaned-position', pos)
|
|
|
921
|
+ # Resize other MUC rosters
|
|
899
|
922
|
for account in app.gc_connected:
|
|
900
|
923
|
for room_jid in [i for i in app.gc_connected[account] if \
|
|
901
|
924
|
app.gc_connected[account][i] and i != self.room_jid]:
|
| ... |
... |
@@ -905,7 +928,28 @@ class GroupchatControl(ChatControlBase): |
|
905
|
928
|
app.interface.minimized_controls[account]:
|
|
906
|
929
|
ctrl = app.interface.minimized_controls[account][room_jid]
|
|
907
|
930
|
if ctrl and app.config.get('one_message_window') != 'never':
|
|
908
|
|
- ctrl.resize_occupant_treeview(hpaned_position)
|
|
|
931
|
+ ctrl.resize_occupant_treeview(pos)
|
|
|
932
|
+
|
|
|
933
|
+ def _on_hpaned_handle_change(self, hpaned, param):
|
|
|
934
|
+ if self._resize_from_another_muc:
|
|
|
935
|
+ return
|
|
|
936
|
+ # Window was resized, save new handle pos
|
|
|
937
|
+ pos = hpaned.get_position()
|
|
|
938
|
+ if pos != app.config.get('gc-hpaned-position'):
|
|
|
939
|
+ self._remove_handle_timeout(renew=True)
|
|
|
940
|
+
|
|
|
941
|
+ def _remove_handle_timeout(self, renew=False):
|
|
|
942
|
+ if self._handle_timeout_id is not None:
|
|
|
943
|
+ GLib.source_remove(self._handle_timeout_id)
|
|
|
944
|
+ self._handle_timeout_id = None
|
|
|
945
|
+ if renew:
|
|
|
946
|
+ pos = self.hpaned.get_position()
|
|
|
947
|
+ self._handle_timeout_id = GLib.timeout_add_seconds(
|
|
|
948
|
+ 2, self._save_handle_position, pos)
|
|
|
949
|
+
|
|
|
950
|
+ def _save_handle_position(self, pos):
|
|
|
951
|
+ self._handle_timeout_id = None
|
|
|
952
|
+ app.config.set('gc-hpaned-position', pos)
|
|
909
|
953
|
|
|
910
|
954
|
def iter_contact_rows(self):
|
|
911
|
955
|
"""
|