From aea75469a1e71adffdd94138d2b678e8679603f1 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 20 Apr 2012 14:34:24 +0200 Subject: [PATCH] save opened chat controls when quitting and restore them on startup. Fixes #3803 --- src/common/config.py | 1 + src/message_window.py | 12 ++++++++++++ src/roster_window.py | 14 ++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/common/config.py b/src/common/config.py index c226eef8e..b33f1c2ad 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -397,6 +397,7 @@ class Config: 'oauth2_refresh_token': [ opt_str, '', _('Latest token for Oauth2 authentication.')], 'oauth2_client_id': [ opt_str, '0000000044077801', _('client_id for Oauth2 authentication.')], 'oauth2_redirect_url': [ opt_str, 'https%3A%2F%2Fgajim.org%2Fmsnauth%2Findex.cgi', _('redirect_url for Oauth2 authentication.')], + 'opened_chat_controls': [opt_str, '', _('Space separated list of jid for which we want to re-open a chat window on next startup.')], }, {}), 'statusmsg': ({ 'message': [ opt_str, '' ], diff --git a/src/message_window.py b/src/message_window.py index 7537c8f02..8abbd4bf6 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -1244,3 +1244,15 @@ class MessageWindowMgr(gobject.GObject): ctrl.type_id) ctrl.parent_win = mw mw.new_tab(ctrl) + + def save_opened_controls(self): + chat_controls = {} + for acct in gajim.connections: + chat_controls[acct] = [] + for ctrl in self.get_controls(type_=message_control.TYPE_CHAT): + acct = ctrl.account + if ctrl.contact.jid not in chat_controls[acct]: + chat_controls[acct].append(ctrl.contact.jid) + for acct in gajim.connections: + gajim.config.set_per('accounts', acct, 'opened_chat_controls', + ','.join(chat_controls[acct])) diff --git a/src/roster_window.py b/src/roster_window.py index 925e432b8..07243293d 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -2381,6 +2381,8 @@ class RosterWindow: return True # do NOT destroy the window def prepare_quit(self): + if self.save_done: + return msgwin_width_adjust = 0 # in case show_roster_on_start is False and roster is never shown @@ -2403,6 +2405,7 @@ class RosterWindow: msgwin_width_adjust = -1 * width gajim.config.set('last_roster_visible', self.window.get_property('visible')) + gajim.interface.msg_win_mgr.save_opened_controls() gajim.interface.msg_win_mgr.shutdown(msgwin_width_adjust) gajim.config.set('collapsed_rows', '\t'.join(self.collapsed_rows)) @@ -2412,6 +2415,7 @@ class RosterWindow: self.close_all(account) if gajim.interface.systray_enabled: gajim.interface.hide_systray() + self.save_done = True def quit_gtkgui_interface(self): """ @@ -2573,6 +2577,14 @@ class RosterWindow: self.add_account_contacts(obj.conn.name) self.fire_up_unread_messages_events(obj.conn.name) else: + account = obj.conn.name + controls = gajim.config.get_per('accounts', account, + 'opened_chat_controls') + if controls: + for jid in controls.split(','): + contact = gajim.contacts.get_contact_with_highest_priority( + account, jid) + gajim.interface.on_open_chat_window(None, contact, account) gobject.idle_add(self.refilter_shown_roster_items) def _nec_anonymous_auth(self, obj): @@ -6296,6 +6308,8 @@ class RosterWindow: self.filtering = False # Number of renderers plugins added self.nb_ext_renderers = 0 + # When we quit, rememver if we already saved config once + self.save_done = False # [icon, name, type, jid, account, editable, mood_pixbuf, # activity_pixbuf, tune_pixbuf, location_pixbuf, avatar_pixbuf, # padlock_pixbuf]