From 67318a49e5532392f654b62493922ad4a70e70aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 4 Jan 2019 09:00:12 +0100 Subject: [PATCH] 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 --- gajim/common/config.py | 7 ++ gajim/data/gui/preferences_window.ui | 106 ++++++++++++++++++++++++++- gajim/groupchat_control.py | 8 +- gajim/gtk/preferences.py | 30 ++++++++ 4 files changed, 147 insertions(+), 4 deletions(-) diff --git a/gajim/common/config.py b/gajim/common/config.py index 5081eaf6b..24150bae5 100644 --- a/gajim/common/config.py +++ b/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] diff --git a/gajim/data/gui/preferences_window.ui b/gajim/data/gui/preferences_window.ui index f6c82c63b..30908d824 100644 --- a/gajim/data/gui/preferences_window.ui +++ b/gajim/data/gui/preferences_window.ui @@ -179,6 +179,14 @@ + + + + + + + + @@ -702,10 +710,104 @@ 6 12 - + + True + False + Group Chat Settings + True + 0 + + + + 0 + 0 + - + + Show join/leave (Default) + True + True + False + If join/leave status messages are shown in the group chat. This setting can be overridden in the groupchat menu. + True + + + + 0 + 2 + + + + + True + False + start + 12 + + + True + False + The default sync threshold for new public group chats. This setting can be overridden in the groupchat menu. + start + Default Sync Threshold + True + right + outgoing_chat_states_combobox + + + + False + True + 0 + + + + + 200 + True + False + start + sync_threshold_liststore + + + + + 1 + + + + + False + True + 1 + + + + + 0 + 1 + + + + + Show status changes (Default) + True + True + False + If status change messages are shown in the group chat. This setting can be overridden in the groupchat menu. + True + + + + 0 + 3 + diff --git a/gajim/groupchat_control.py b/gajim/groupchat_control.py index a67c8c978..ac6d515b1 100644 --- a/gajim/groupchat_control.py +++ b/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, diff --git a/gajim/gtk/preferences.py b/gajim/gtk/preferences.py index 7849ffdd8..3c07373cc 100644 --- a/gajim/gtk/preferences.py +++ b/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')