Skip to content
Snippets Groups Projects
Commit 7d9d47ac authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

we now save and restore some variables in tabbed chat window (gpg_enabled)...

we now save and restore some variables in tabbed chat window (gpg_enabled) when we split / merge windows
parent 11ef5a07
No related branches found
No related tags found
No related merge requests found
......@@ -178,59 +178,65 @@ class Preferences_window:
gajim.config.get_default('userfont'))
self.plugin.roster.draw_roster()
self.plugin.save_config()
def merge_windows(self, kind):
for acct in gajim.connections:
#save buffers and close windows
buf1 = {}
buf2 = {}
saved_var = {}
jids = self.plugin.windows[acct][kind].keys()
for jid in jids:
buf1[jid] = self.plugin.windows[acct][kind][jid].\
xmls[jid].get_widget('conversation_textview').get_buffer()
buf2[jid] = self.plugin.windows[acct][kind][jid].\
xmls[jid].get_widget('message_textview').get_buffer()
saved_var[jid] = self.plugin.windows[acct][kind][jid].save_var(jid)
self.plugin.windows[acct][kind][jid].window.destroy()
#open new tabbed chat windows
for jid in jids:
user = self.plugin.roster.contacts[acct][jid][0]
self.plugin.roster.new_chat(user, acct)
self.plugin.windows[acct][kind][jid].xmls[jid].\
get_widget('conversation_textview').set_buffer(buf1[jid])
self.plugin.windows[acct][kind][jid].xmls[jid].\
get_widget('message_textview').set_buffer(buf2[jid])
self.plugin.windows[acct][kind][jid].load_var(jid, saved_var[jid])
def split_windows(self, kind):
for acct in gajim.connections:
#save buffers and close tabbed chat windows
buf1 = {}
buf2 = {}
saved_var = {}
jids = self.plugin.windows[acct][kind].keys()
if not 'tabbed' in jids:
continue
jids.remove('tabbed')
for jid in jids:
buf1[jid] = self.plugin.windows[acct][kind][jid].\
xmls[jid].get_widget('conversation_textview').get_buffer()
buf2[jid] = self.plugin.windows[acct][kind][jid].\
xmls[jid].get_widget('message_textview').get_buffer()
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
for jid in jids:
user = self.plugin.roster.contacts[acct][jid][0]
self.plugin.roster.new_chat(user, acct)
self.plugin.windows[acct][kind][jid].xmls[jid].\
get_widget('conversation_textview').set_buffer(buf1[jid])
self.plugin.windows[acct][kind][jid].xmls[jid].\
get_widget('message_textview').set_buffer(buf2[jid])
self.plugin.windows[acct][kind][jid].load_var(jid, saved_var[jid])
def on_use_tabbed_chat_window_checkbutton_toggled(self, widget):
buf1 = {}
buf2 = {}
jids = {}
if widget.get_active():
#save buffers and close windows
for acct in gajim.connections:
buf1[acct] = {}
buf2[acct] = {}
jids[acct] = self.plugin.windows[acct]['chats'].keys()
for jid in jids[acct]:
buf1[acct][jid] = self.plugin.windows[acct]['chats'][jid].\
xmls[jid].get_widget('conversation_textview').get_buffer()
buf2[acct][jid] = self.plugin.windows[acct]['chats'][jid].\
xmls[jid].get_widget('message_textview').get_buffer()
self.plugin.windows[acct]['chats'][jid].window.destroy()
gajim.config.set('usetabbedchat', True)
#open new tabbed chat windows
for acct in gajim.connections:
for jid in jids[acct]:
user = self.plugin.roster.contacts[acct][jid][0]
self.plugin.roster.new_chat(user, acct)
self.plugin.windows[acct]['chats'][jid].xmls[jid].\
get_widget('conversation_textview').set_buffer(\
buf1[acct][jid])
self.plugin.windows[acct]['chats'][jid].xmls[jid].\
get_widget('message_textview').set_buffer(buf2[acct][jid])
self.merge_windows('chats')
else:
#save buffers and close tabbed chat windows
for acct in gajim.connections:
buf1[acct] = {}
buf2[acct] = {}
jids[acct] = self.plugin.windows[acct]['chats'].keys()
if 'tabbed' in jids[acct]:
jids[acct].remove('tabbed')
for jid in jids[acct]:
buf1[acct][jid] = self.plugin.windows[acct]['chats'][jid].\
xmls[jid].get_widget('conversation_textview').get_buffer()
buf2[acct][jid] = self.plugin.windows[acct]['chats'][jid].\
xmls[jid].get_widget('message_textview').get_buffer()
self.plugin.windows[acct]['chats']['tabbed'].window.destroy()
gajim.config.set('usetabbedchat', False)
#open new tabbed chat windows
for acct in gajim.connections:
for jid in jids[acct]:
user = self.plugin.roster.contacts[acct][jid][0]
self.plugin.roster.new_chat(user, acct)
self.plugin.windows[acct]['chats'][jid].xmls[jid].\
get_widget('conversation_textview').set_buffer(\
buf1[acct][jid])
self.plugin.windows[acct]['chats'][jid].xmls[jid].\
get_widget('message_textview').set_buffer(buf2[acct][jid])
self.split_windows('chats')
self.plugin.save_config()
def update_print_time(self):
......
......@@ -55,6 +55,18 @@ class Tabbed_chat_window(chat.Chat):
self.xml.signal_connect('on_chat_notebook_switch_page', \
self.on_chat_notebook_switch_page)
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):
"""draw the widgets in a tab (status_image, contact_button ...)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment