[Git][gajim/gajim][master] Preferences: Add some default options

Philipp Hörist gitlab at dev.gajim.org
Fri Jan 4 09:00:30 CET 2019


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


Commits:
67318a49 by Philipp Hörist at 2019-01-04T08:00:12Z
Preferences: Add some default options

- Option to set default sync threshold
- Option to set default show join/leave
- Option to set default show status message change

- - - - -


4 changed files:

- gajim/common/config.py
- gajim/data/gui/preferences_window.ui
- gajim/groupchat_control.py
- gajim/gtk/preferences.py


Changes:

=====================================
gajim/common/config.py
=====================================
@@ -235,6 +235,8 @@ class Config:
         'show_location_in_roster': [opt_bool, True, '', True],
         'avatar_position_in_roster': [opt_str, 'right', _('Define the position of the avatar in roster. Can be left or right'), True],
         'print_status_in_chats': [opt_bool, False, _('If False, Gajim will no longer print status line in chats when a contact changes their status and/or their status message.')],
+        'print_join_leave_in_mucs': [opt_bool, False, _('Default Setting: Show a status message for every join or leave in a group chat')],
+        'print_status_in_mucs': [opt_bool, False, _('Default Setting: Show a status message for all status (away, dnd, etc.) changes of users in a group chat')],
         'log_contact_status_changes': [opt_bool, False],
         'log_xhtml_messages': [opt_bool, False, _('Log XHTML messages instead of plain text messages.')],
         'restored_messages_small': [opt_bool, True, _('If true, restored messages will use a smaller font than the default one.')],
@@ -719,6 +721,11 @@ class Config:
         room = self.get_per('rooms', room, 'notify_on_all_messages')
         return all_ or room
 
+    def get_options(self, optname, return_type=str):
+        options = self.get(optname).split(',')
+        options = [return_type(option.strip()) for option in options]
+        return options
+
     def _init_options(self):
         for opt in self.__options[0]:
             self.__options[1][opt] = self.__options[0][opt][Option.VAL]


=====================================
gajim/data/gui/preferences_window.ui
=====================================
@@ -179,6 +179,14 @@
       <column type="gchararray"/>
     </columns>
   </object>
+  <object class="GtkListStore" id="sync_threshold_liststore">
+    <columns>
+      <!-- column-name days -->
+      <column type="gchararray"/>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkListStore" id="systray_combobox_liststore">
     <columns>
       <!-- column-name item -->
@@ -702,10 +710,104 @@
                         <property name="row_spacing">6</property>
                         <property name="column_spacing">12</property>
                         <child>
-                          <placeholder/>
+                          <object class="GtkLabel">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label" translatable="yes">Group Chat Settings</property>
+                            <property name="use_markup">True</property>
+                            <property name="xalign">0</property>
+                            <style>
+                              <class name="bold"/>
+                              <class name="margin-top6"/>
+                            </style>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">0</property>
+                          </packing>
                         </child>
                         <child>
-                          <placeholder/>
+                          <object class="GtkCheckButton" id="join_leave_checkbutton">
+                            <property name="label" translatable="yes">Show join/leave (Default)</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="tooltip_text" translatable="yes">If join/leave status messages are shown in the group chat. This setting can be overridden in the groupchat menu.</property>
+                            <property name="draw_indicator">True</property>
+                            <signal name="toggled" handler="_on_join_leave_toggled" swapped="no"/>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkBox">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="halign">start</property>
+                            <property name="spacing">12</property>
+                            <child>
+                              <object class="GtkLabel">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="tooltip_text" translatable="yes">The default sync threshold for new public group chats. This setting can be overridden in the groupchat menu.</property>
+                                <property name="halign">start</property>
+                                <property name="label" translatable="yes">Default Sync Threshold</property>
+                                <property name="use_underline">True</property>
+                                <property name="justify">right</property>
+                                <property name="mnemonic_widget">outgoing_chat_states_combobox</property>
+                                <style>
+                                  <class name="dim-label"/>
+                                </style>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBox" id="sync_threshold_combobox">
+                                <property name="width_request">200</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="halign">start</property>
+                                <property name="model">sync_threshold_liststore</property>
+                                <signal name="changed" handler="_on_sync_threshold_changed" swapped="no"/>
+                                <child>
+                                  <object class="GtkCellRendererText"/>
+                                  <attributes>
+                                    <attribute name="text">1</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkCheckButton" id="status_change_checkbutton">
+                            <property name="label" translatable="yes">Show status changes (Default)</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="tooltip_text" translatable="yes">If status change messages are shown in the group chat. This setting can be overridden in the groupchat menu.</property>
+                            <property name="draw_indicator">True</property>
+                            <signal name="toggled" handler="_on_status_change_toggled" swapped="no"/>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">3</property>
+                          </packing>
                         </child>
                       </object>
                       <packing>


=====================================
gajim/groupchat_control.py
=====================================
@@ -397,7 +397,9 @@ class GroupchatControl(ChatControlBase):
         act.connect('change-state', self._on_notify_on_all_messages)
         self.parent_win.window.add_action(act)
 
-        value = app.config.get_per('rooms', self.contact.jid, 'print_status')
+        status_default = app.config.get('print_status_in_mucs')
+        value = app.config.get_per('rooms', self.contact.jid,
+                                   'print_status', status_default)
 
         act = Gio.SimpleAction.new_stateful(
             'print-status-' + self.control_id,
@@ -405,7 +407,9 @@ class GroupchatControl(ChatControlBase):
         act.connect('change-state', self._on_print_status)
         self.parent_win.window.add_action(act)
 
-        value = app.config.get_per('rooms', self.contact.jid, 'print_join_left')
+        join_default = app.config.get('print_join_leave_in_mucs')
+        value = app.config.get_per('rooms', self.contact.jid,
+                                   'print_join_left', join_default)
 
         act = Gio.SimpleAction.new_stateful(
             'print-join-left-' + self.control_id,


=====================================
gajim/gtk/preferences.py
=====================================
@@ -24,6 +24,7 @@ from gajim.common import helpers
 from gajim.common import config as c_config
 from gajim.common import idle
 from gajim.common.i18n import _
+from gajim.common.i18n import ngettext
 
 from gajim import message_control
 
@@ -147,6 +148,25 @@ class Preferences(Gtk.ApplicationWindow):
         st = app.config.get('show_subject_on_join')
         self._ui.subject_on_join_checkbutton.set_active(st)
 
+
+        # Group chat settings
+        threshold_model = self._ui.sync_threshold_combobox.get_model()
+        for day in app.config.get_options('threshold_options'):
+            if day == '0':
+                label = _('No threshold')
+            else:
+                label = ngettext('%s day' % day, '%s days' % day, int(day))
+            threshold_model.append([day, label])
+        public_threshold = app.config.get('public_room_sync_threshold')
+        self._ui.sync_threshold_combobox.set_id_column(0)
+        self._ui.sync_threshold_combobox.set_active_id(str(public_threshold))
+
+        st = app.config.get('print_join_leave_in_mucs')
+        self._ui.join_leave_checkbutton.set_active(st)
+
+        st = app.config.get('print_status_in_mucs')
+        self._ui.status_change_checkbutton.set_active(st)
+
         # Displayed chat state notifications
         st = app.config.get('show_chatstate_in_tabs')
         self._ui.show_chatstate_in_tabs.set_active(st)
@@ -595,6 +615,16 @@ class Preferences(Gtk.ApplicationWindow):
     def on_subject_on_join_checkbutton_toggled(self, widget):
         self.on_checkbutton_toggled(widget, 'show_subject_on_join')
 
+    def _on_sync_threshold_changed(self, widget):
+        active = widget.get_active_id()
+        app.config.set('public_room_sync_threshold', int(active))
+
+    def _on_join_leave_toggled(self, widget):
+        self.on_checkbutton_toggled(widget, 'print_join_leave_in_mucs')
+
+    def _on_status_change_toggled(self, widget):
+        self.on_checkbutton_toggled(widget, 'print_status_in_mucs')
+
     def on_show_chatstate_in_tabs_toggled(self, widget):
         self.on_checkbutton_toggled(widget, 'show_chatstate_in_tabs')
 



View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/67318a49e5532392f654b62493922ad4a70e70aa

-- 
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/67318a49e5532392f654b62493922ad4a70e70aa
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/20190104/ddf48bd2/attachment-0001.html>


More information about the Commits mailing list