we now save and restore some variables in tabbed chat window (gpg_enabled) when we split / merge windows

This commit is contained in:
Yann Leboulanger 2005-04-28 14:38:36 +00:00
parent 11ef5a0787
commit 7d9d47ac9b
2 changed files with 67 additions and 49 deletions

View file

@ -179,58 +179,64 @@ class Preferences_window:
self.plugin.roster.draw_roster() self.plugin.roster.draw_roster()
self.plugin.save_config() self.plugin.save_config()
def on_use_tabbed_chat_window_checkbutton_toggled(self, widget): def merge_windows(self, kind):
buf1 = {} for acct in gajim.connections:
buf2 = {}
jids = {}
if widget.get_active():
#save buffers and close windows #save buffers and close windows
for acct in gajim.connections: buf1 = {}
buf1[acct] = {} buf2 = {}
buf2[acct] = {} saved_var = {}
jids[acct] = self.plugin.windows[acct]['chats'].keys() jids = self.plugin.windows[acct][kind].keys()
for jid in jids[acct]: for jid in jids:
buf1[acct][jid] = self.plugin.windows[acct]['chats'][jid].\ buf1[jid] = self.plugin.windows[acct][kind][jid].\
xmls[jid].get_widget('conversation_textview').get_buffer() xmls[jid].get_widget('conversation_textview').get_buffer()
buf2[acct][jid] = self.plugin.windows[acct]['chats'][jid].\ buf2[jid] = self.plugin.windows[acct][kind][jid].\
xmls[jid].get_widget('message_textview').get_buffer() xmls[jid].get_widget('message_textview').get_buffer()
self.plugin.windows[acct]['chats'][jid].window.destroy() saved_var[jid] = self.plugin.windows[acct][kind][jid].save_var(jid)
gajim.config.set('usetabbedchat', True) self.plugin.windows[acct][kind][jid].window.destroy()
#open new tabbed chat windows #open new tabbed chat windows
for acct in gajim.connections: for jid in jids:
for jid in jids[acct]: user = self.plugin.roster.contacts[acct][jid][0]
user = self.plugin.roster.contacts[acct][jid][0] self.plugin.roster.new_chat(user, acct)
self.plugin.roster.new_chat(user, acct) self.plugin.windows[acct][kind][jid].xmls[jid].\
self.plugin.windows[acct]['chats'][jid].xmls[jid].\ get_widget('conversation_textview').set_buffer(buf1[jid])
get_widget('conversation_textview').set_buffer(\ self.plugin.windows[acct][kind][jid].xmls[jid].\
buf1[acct][jid]) get_widget('message_textview').set_buffer(buf2[jid])
self.plugin.windows[acct]['chats'][jid].xmls[jid].\ self.plugin.windows[acct][kind][jid].load_var(jid, saved_var[jid])
get_widget('message_textview').set_buffer(buf2[acct][jid])
else: def split_windows(self, kind):
for acct in gajim.connections:
#save buffers and close tabbed chat windows #save buffers and close tabbed chat windows
for acct in gajim.connections: buf1 = {}
buf1[acct] = {} buf2 = {}
buf2[acct] = {} saved_var = {}
jids[acct] = self.plugin.windows[acct]['chats'].keys() jids = self.plugin.windows[acct][kind].keys()
if 'tabbed' in jids[acct]: if not 'tabbed' in jids:
jids[acct].remove('tabbed') continue
for jid in jids[acct]: jids.remove('tabbed')
buf1[acct][jid] = self.plugin.windows[acct]['chats'][jid].\ for jid in jids:
xmls[jid].get_widget('conversation_textview').get_buffer() buf1[jid] = self.plugin.windows[acct][kind][jid].\
buf2[acct][jid] = self.plugin.windows[acct]['chats'][jid].\ xmls[jid].get_widget('conversation_textview').get_buffer()
xmls[jid].get_widget('message_textview').get_buffer() buf2[jid] = self.plugin.windows[acct][kind][jid].\
self.plugin.windows[acct]['chats']['tabbed'].window.destroy() xmls[jid].get_widget('message_textview').get_buffer()
gajim.config.set('usetabbedchat', False) saved_var[jid] = self.plugin.windows[acct][kind][jid].save_var(jid)
self.plugin.windows[acct][kind]['tabbed'].window.destroy()
#open new tabbed chat windows #open new tabbed chat windows
for acct in gajim.connections: for jid in jids:
for jid in jids[acct]: user = self.plugin.roster.contacts[acct][jid][0]
user = self.plugin.roster.contacts[acct][jid][0] self.plugin.roster.new_chat(user, acct)
self.plugin.roster.new_chat(user, acct) self.plugin.windows[acct][kind][jid].xmls[jid].\
self.plugin.windows[acct]['chats'][jid].xmls[jid].\ get_widget('conversation_textview').set_buffer(buf1[jid])
get_widget('conversation_textview').set_buffer(\ self.plugin.windows[acct][kind][jid].xmls[jid].\
buf1[acct][jid]) get_widget('message_textview').set_buffer(buf2[jid])
self.plugin.windows[acct]['chats'][jid].xmls[jid].\ self.plugin.windows[acct][kind][jid].load_var(jid, saved_var[jid])
get_widget('message_textview').set_buffer(buf2[acct][jid])
def on_use_tabbed_chat_window_checkbutton_toggled(self, widget):
if widget.get_active():
gajim.config.set('usetabbedchat', True)
self.merge_windows('chats')
else:
gajim.config.set('usetabbedchat', False)
self.split_windows('chats')
self.plugin.save_config() self.plugin.save_config()
def update_print_time(self): def update_print_time(self):

View file

@ -56,6 +56,18 @@ class Tabbed_chat_window(chat.Chat):
self.on_chat_notebook_switch_page) self.on_chat_notebook_switch_page)
self.window.show_all() self.window.show_all()
def save_var(self, jid):
'''return the specific variable of a jid, like gpg_enabled
the return value have to be compatible with wthe one given to load_var'''
gpg_enabled = self.xmls[jid].get_widget('gpg_togglebutton').get_active()
return {'gpg_enabled': gpg_enabled}
def load_var(self, jid, var):
if not self.xmls.has_key(jid):
return
self.xmls[jid].get_widget('gpg_togglebutton').set_active(\
var['gpg_enabled'])
def draw_widgets(self, user): def draw_widgets(self, user):
"""draw the widgets in a tab (status_image, contact_button ...) """draw the widgets in a tab (status_image, contact_button ...)
according to the the information in the user variable""" according to the the information in the user variable"""