[Git][gajim/gajim][master] 2 commits: MUC: Update menu after preference change

Philipp Hörist gitlab at dev.gajim.org
Sat Jan 5 20:10:29 CET 2019


Philipp Hörist pushed to branch master at gajim / gajim


Commits:
7b558d69 by Philipp Hörist at 2019-01-05T18:43:11Z
MUC: Update menu after preference change

- Simplify action lookup

- - - - -
4aa26545 by Philipp Hörist at 2019-01-05T19:10:08Z
MUC: Use default value when printing the status

- - - - -


3 changed files:

- gajim/groupchat_control.py
- gajim/gtk/preferences.py
- gajim/privatechat_control.py


Changes:

=====================================
gajim/groupchat_control.py
=====================================
@@ -437,48 +437,45 @@ class GroupchatControl(ChatControlBase):
         con = app.connections[self.account]
 
         # Destroy Room
-        win.lookup_action('destroy-' + self.control_id).set_enabled(
-            self.is_connected and contact.affiliation.is_owner)
+        self._get_action('destroy-').set_enabled(self.is_connected and
+                                                 contact.affiliation.is_owner)
 
         # Configure Room
-        win.lookup_action('configure-' + self.control_id).set_enabled(
+        self._get_action('configure-').set_enabled(
             self.is_connected and contact.affiliation in (Affiliation.ADMIN,
                                                           Affiliation.OWNER))
 
         # Bookmarks
         con = app.connections[self.account]
         bookmarked = self.room_jid in con.get_module('Bookmarks').bookmarks
-        win.lookup_action('bookmark-' + self.control_id).set_enabled(
-            self.is_connected and not bookmarked)
+        self._get_action('bookmark-').set_enabled(self.is_connected and
+                                                  not bookmarked)
 
         # Request Voice
         role = self.get_role(self.nick)
-        win.lookup_action('request-voice-' + self.control_id).set_enabled(
-            self.is_connected and role.is_visitor)
+        self._get_action('request-voice-').set_enabled(self.is_connected and
+                                                       role.is_visitor)
 
         # Change Subject
         subject = False
         if contact is not None:
             subject = muc_caps_cache.is_subject_change_allowed(
                 self.room_jid, contact.affiliation)
-        win.lookup_action('change-subject-' + self.control_id).set_enabled(
-            self.is_connected and subject)
+        self._get_action('change-subject-').set_enabled(self.is_connected and
+                                                        subject)
 
         # Change Nick
-        win.lookup_action('change-nick-' + self.control_id).set_enabled(
-            self.is_connected)
+        self._get_action('change-nick-').set_enabled(self.is_connected)
 
         # Execute command
-        win.lookup_action('execute-command-' + self.control_id).set_enabled(
-            self.is_connected)
+        self._get_action('execute-command-').set_enabled(self.is_connected)
 
         # Send file (HTTP File Upload)
-        httpupload = win.lookup_action(
-            'send-file-httpupload-' + self.control_id)
-        httpupload.set_enabled(
-            self.is_connected and con.get_module('HTTPUpload').available)
-        win.lookup_action('send-file-' + self.control_id).set_enabled(
-            httpupload.get_enabled())
+        httpupload = self._get_action(
+            'send-file-httpupload-')
+        httpupload.set_enabled(self.is_connected and
+                               con.get_module('HTTPUpload').available)
+        self._get_action('send-file-').set_enabled(httpupload.get_enabled())
 
         if self.is_connected and httpupload.get_enabled():
             tooltip_text = _('Send File…')
@@ -488,12 +485,32 @@ class GroupchatControl(ChatControlBase):
 
         # Upload Avatar
         vcard_support = muc_caps_cache.supports(self.room_jid, nbxmpp.NS_VCARD)
-        win.lookup_action('upload-avatar-' + self.control_id).set_enabled(
-            self.is_connected and vcard_support and contact.affiliation.is_owner)
+        self._get_action('upload-avatar-').set_enabled(
+            self.is_connected and
+            vcard_support and
+            contact.affiliation.is_owner)
 
         # Sync Threshold
         has_mam = muc_caps_cache.has_mam(self.room_jid)
-        win.lookup_action('choose-sync-' + self.control_id).set_enabled(has_mam)
+        self._get_action('choose-sync-').set_enabled(has_mam)
+
+        # Print join/left
+        join_default = app.config.get('print_join_left_default')
+        value = app.config.get_per('rooms', self.contact.jid,
+                                   'print_join_left', join_default)
+        self._get_action('print-join-left-').set_state(
+            GLib.Variant.new_boolean(value))
+
+        # Print join/left
+        status_default = app.config.get('print_status_muc_default')
+        value = app.config.get_per('rooms', self.contact.jid,
+                                   'print_status', status_default)
+        self._get_action('print-status-').set_state(
+            GLib.Variant.new_boolean(value))
+
+    def _get_action(self, name):
+        win = self.parent_win.window
+        return win.lookup_action(name + self.control_id)
 
     def _cell_data_func(self, column, renderer, model, iter_, user_data):
         # Background color has to be rendered for all cells
@@ -1845,12 +1862,15 @@ class GroupchatControl(ChatControlBase):
         status = '' if status is None else ' (%s)' % status
         show = helpers.get_uf_show(event.properties.show.value)
 
+        status_default = app.config.get('print_status_muc_default')
+
         if event.properties.is_muc_self_presence:
             message = _('You are now {show}{status}').format(show=show,
                                                              status=status)
             self.print_conversation(message, 'info', graphics=False)
 
-        elif app.config.get_per('rooms', self.room_jid, 'print_status'):
+        elif app.config.get_per('rooms', self.room_jid,
+                                'print_status', status_default):
             message = _('{nick} is now {show}{status}').format(nick=nick,
                                                                show=show,
                                                                status=status)


=====================================
gajim/gtk/preferences.py
=====================================
@@ -621,9 +621,13 @@ class Preferences(Gtk.ApplicationWindow):
 
     def _on_join_leave_toggled(self, widget):
         self.on_checkbutton_toggled(widget, 'print_join_left_default')
+        for control in self._get_all_muc_controls():
+            control.update_actions()
 
     def _on_status_change_toggled(self, widget):
         self.on_checkbutton_toggled(widget, 'print_status_muc_default')
+        for control in self._get_all_muc_controls():
+            control.update_actions()
 
     def on_show_chatstate_in_tabs_toggled(self, widget):
         self.on_checkbutton_toggled(widget, 'show_chatstate_in_tabs')


=====================================
gajim/privatechat_control.py
=====================================
@@ -135,12 +135,15 @@ class PrivateChatControl(ChatControl):
         status = '' if status is None else ' (%s)' % status
         show = helpers.get_uf_show(event.properties.show.value)
 
+        status_default = app.config.get('print_status_muc_default')
+
         if event.properties.is_muc_self_presence:
             message = _('You are now {show}{status}').format(show=show,
                                                              status=status)
             self.print_conversation(message, 'info')
 
-        elif app.config.get_per('rooms', self.room_name, 'print_status'):
+        elif app.config.get_per('rooms', self.room_name,
+                                'print_status', status_default):
             message = _('{nick} is now {show}{status}').format(nick=nick,
                                                                show=show,
                                                                status=status)



View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/19c45510a03bd771238038f61657f460df7c28cc...4aa265451dfebe3991fc0496bb76baa05d9faab8

-- 
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/19c45510a03bd771238038f61657f460df7c28cc...4aa265451dfebe3991fc0496bb76baa05d9faab8
You're receiving this email because of your account on dev.gajim.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gajim.org/pipermail/commits/attachments/20190105/fab23345/attachment-0001.html>


More information about the Commits mailing list