From 79501461056f82e92453d52bc1e5356683c66e1e Mon Sep 17 00:00:00 2001 From: tmolitor Date: Mon, 5 Sep 2016 19:02:43 +0200 Subject: [PATCH] Minimize groupchats by default, fixes #8369 --- src/chat_control.py | 22 +++++++++++----------- src/common/config.py | 2 +- src/common/optparser.py | 3 +++ src/groupchat_control.py | 8 ++++---- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index 71f34d4fb..bf3556234 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -1112,19 +1112,19 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): """ When a grouchat is minimized, unparent the tab, put it in roster etc """ - old_value = False - minimized_gc = gajim.config.get_per('accounts', self.account, - 'minimized_gc').split() - if self.contact.jid in minimized_gc: - old_value = True + old_value = True + non_minimized_gc = gajim.config.get_per('accounts', self.account, + 'non_minimized_gc').split() + if self.contact.jid in non_minimized_gc: + old_value = False minimize = widget.get_active() - if minimize and not self.contact.jid in minimized_gc: - minimized_gc.append(self.contact.jid) - if not minimize and self.contact.jid in minimized_gc: - minimized_gc.remove(self.contact.jid) + if not minimize and not self.contact.jid in non_minimized_gc: + non_minimized_gc.append(self.contact.jid) + if minimize and self.contact.jid in non_minimized_gc: + non_minimized_gc.remove(self.contact.jid) if old_value != minimize: - gajim.config.set_per('accounts', self.account, 'minimized_gc', - ' '.join(minimized_gc)) + gajim.config.set_per('accounts', self.account, 'non_minimized_gc', + ' '.join(non_minimized_gc)) def set_control_active(self, state): if state: diff --git a/src/common/config.py b/src/common/config.py index 9c5fd8b51..109113461 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -368,7 +368,7 @@ class Config: 'no_log_for': [ opt_str, '', _('Space separated list of JIDs for which you do not want to store logs. You can also add account name to log nothing for this account.')], 'sync_logs_with_server': [ opt_bool, True, _('Download logs stored on server on Gajim startup if server supports XEP-0136 or XEP-0313')], 'allow_no_log_for': [ opt_str, '', _('Space separated list of JIDs for which you accept to not log conversations if he does not want to.')], - 'minimized_gc': [ opt_str, '' ], + 'non_minimized_gc': [ opt_str, '' ], 'attached_gpg_keys': [ opt_str, '' ], 'keep_alives_enabled': [ opt_bool, True, _('Whitespace sent after inactivity')], 'ping_alives_enabled': [ opt_bool, True, _('XMPP ping sent after inactivity')], diff --git a/src/common/optparser.py b/src/common/optparser.py index a9bcf3f15..d907c8928 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -946,6 +946,9 @@ class OptionsParser: if self.old_values['video_input_device'] == 'videotestsrc is-live=true ! video/x-raw-yuv,framerate=10/1': gajim.config.set('video_input_device', 'videotestsrc is-live=true ! video/x-raw,framerate=10/1') + for account in self.old_values['accounts'].keys(): + gajim.config.del_per('accounts', account, 'minimized_gc') + back = os.getcwd() os.chdir(logger.LOG_DB_FOLDER) con = sqlite.connect(logger.LOG_DB_FILE) diff --git a/src/groupchat_control.py b/src/groupchat_control.py index b8b33146a..f2fa58ce0 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -865,8 +865,8 @@ class GroupchatControl(ChatControlBase): history_menuitem.add_accelerator('activate', ag, Gdk.KEY_h, Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE) - if self.contact.jid in gajim.config.get_per('accounts', self.account, - 'minimized_gc').split(' '): + if self.contact.jid not in gajim.config.get_per('accounts', self.account, + 'non_minimized_gc').split(' '): minimize_menuitem.set_active(True) conn = gajim.connections[self.account] if not conn.private_storage_supported and (not conn.pubsub_supported or \ @@ -2038,8 +2038,8 @@ class GroupchatControl(ChatControlBase): return 'visitor' def minimizable(self): - if self.contact.jid in gajim.config.get_per('accounts', self.account, - 'minimized_gc').split(' '): + if self.contact.jid not in gajim.config.get_per('accounts', self.account, + 'non_minimized_gc').split(' '): return True return False