diff --git a/src/config.py b/src/config.py index 9728577f7..3ad5b01eb 100644 --- a/src/config.py +++ b/src/config.py @@ -534,69 +534,12 @@ class PreferencesWindow: gajim.interface.roster.change_roster_style(None) gajim.interface.save_config() - # FIXME: Remove or implement for new window code - def merge_windows(self, kind): - for acct in gajim.connections: - # save buffers and close windows - buf1 = {} - buf2 = {} - saved_var = {} - windows = gajim.interface.instances[acct][kind] - jids = windows.keys() - for jid in jids: - window = windows[jid] - buf1[jid] = window.conversation_textviews[jid].get_buffer() - buf2[jid] = window.message_textviews[jid].get_buffer() - saved_var[jid] = window.save_var(jid) - window.window.destroy() - # open new tabbed chat windows - for jid in jids: - if kind == 'chats': - c = gajim.contacts.get_contact_with_highest_priority(acct, jid) - gajim.interface.roster.new_chat(c, acct) - if kind == 'gc': - gajim.interface.roster.new_room(jid, saved_var[jid]['nick'], acct) - window = windows[jid] - window.conversation_textviews[jid].set_buffer(buf1[jid]) - window.message_textviews[jid].set_buffer(buf2[jid]) - window.load_var(jid, saved_var[jid]) - - # FIXME: Remove or implement for new window code - def split_windows(self, kind): - for acct in gajim.connections: - # save buffers and close tabbed chat windows - buf1 = {} - buf2 = {} - saved_var = {} - windows = gajim.interface.instances[acct][kind] - jids = windows.keys() - if not 'tabbed' in jids: - continue - jids.remove('tabbed') - for jid in jids: - window = windows[jid] - buf1[jid] = window.conversation_textviews[jid].get_buffer() - buf2[jid] = window.message_textviews[jid].get_buffer() - saved_var[jid] = window.save_var(jid) - windows['tabbed'].window.destroy() - # open new tabbed chat windows - for jid in jids: - if kind == 'chats': - c = gajim.contacts.get_contact_with_highest_priority(acct, jid) - gajim.interface.roster.new_chat(c, acct) - if kind == 'gc': - gajim.interface.roster.new_room(jid, saved_var[jid]['nick'], acct) - window = windows[jid] - window.conversation_textviews[jid].set_buffer(buf1[jid]) - window.message_textviews[jid].set_buffer(buf2[jid]) - window.load_var(jid, saved_var[jid]) - def on_one_window_type_combo_changed(self, widget): active = widget.get_active() config_type = common.config.opt_one_window_types[active] gajim.config.set('one_message_window', config_type) gajim.interface.save_config() - # FIXME: Update current windows? Meh + gajim.interface.msg_win_mgr.reconfig() def apply_speller(self, kind): for acct in gajim.connections: diff --git a/src/message_window.py b/src/message_window.py index 432a585b4..d075562a5 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -409,8 +409,9 @@ class MessageWindow: def _on_notebook_switch_page(self, notebook, page, page_num): old_no = notebook.get_current_page() - old_ctrl = self._widget_to_control(notebook.get_nth_page(old_no)) - old_ctrl.set_control_active(False) + if old_no >= 0: + old_ctrl = self._widget_to_control(notebook.get_nth_page(old_no)) + old_ctrl.set_control_active(False) new_ctrl = self._widget_to_control(notebook.get_nth_page(page_num)) new_ctrl.set_control_active(True) @@ -706,6 +707,7 @@ class MessageWindowMgr: for w in self.windows(): self.save_state(w) w.window.hide() + w.window.destroy() def save_state(self, msg_win): if not gajim.config.get('saveposition'): @@ -746,3 +748,35 @@ class MessageWindowMgr: gajim.config.set(pos_y_key, y) gajim.config.set(size_width_key, width) gajim.config.set(size_height_key, height) + + def reconfig(self): + for w in self._windows.values(): + self.save_state(w) + # Map the mode to a int constant for frequent compares + mode = gajim.config.get('one_message_window') + if self.mode == common.config.opt_one_window_types.index(mode): + # No change + return + self.mode = common.config.opt_one_window_types.index(mode) + + controls = [] + for w in self._windows.values(): + w.window.hide() + while w.notebook.get_n_pages(): + page = w.notebook.get_nth_page(0) + ctrl = w._widget_to_control(page) + w.notebook.remove_page(0) + page.unparent() + controls.append(ctrl) + w.window.destroy() + + for k in self._windows.keys(): + del self._windows[k] + self._windows = {} + + for ctrl in controls: + mw = self.get_window(ctrl.contact.jid) + if not mw: + mw = self.create_window(ctrl.contact, ctrl.account, ctrl.type_id) + ctrl.parent_win = mw + mw.new_tab(ctrl)