From 8383f773413cee8529ad4fdc05f092286d6dd377 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 30 Jun 2016 23:57:12 +0200 Subject: Use a "core" parameter for each tab object instead of a singleton fixes the circular import issue --- poezio/core/commands.py | 8 ++++---- poezio/core/core.py | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'poezio/core') diff --git a/poezio/core/commands.py b/poezio/core/commands.py index 40f0182b..c36afc90 100644 --- a/poezio/core/commands.py +++ b/poezio/core/commands.py @@ -276,7 +276,7 @@ class CommandCore: if not isinstance(self.core.current_tab(), tabs.MucTab): return self.core.information('Please provide a server', 'Error') jid = safeJID(self.core.current_tab().name).server - list_tab = tabs.MucListTab(jid) + list_tab = tabs.MucListTab(self.core, jid) self.core.add_tab(list_tab, True) cb = list_tab.on_muc_list_item_received self.core.xmpp.plugin['xep_0030'].get_items(jid=jid, @@ -491,7 +491,7 @@ class CommandCore: if tab: self.core.current_tab_nb = tab.nb else: - tab = tabs.BookmarksTab(self.core.bookmarks) + tab = tabs.BookmarksTab(self.core, self.core.bookmarks) self.core.tabs.append(tab) self.core.current_tab_nb = tab.nb old_tab.on_lose_focus() @@ -959,7 +959,7 @@ class CommandCore: """/xml_tab""" xml_tab = self.core.focus_tab_named('XMLTab', tabs.XMLTab) if not xml_tab: - tab = tabs.XMLTab() + tab = tabs.XMLTab(self.core) self.core.add_tab(tab, True) self.core.xml_tab = tab @@ -968,7 +968,7 @@ class CommandCore: if not args: return self.help('ad-hoc') jid = safeJID(args[0]) - list_tab = tabs.AdhocCommandsListTab(jid) + list_tab = tabs.AdhocCommandsListTab(self.core, jid) self.core.add_tab(list_tab, True) cb = list_tab.on_list_received self.core.xmpp.plugin['xep_0050'].get_commands(jid=jid, local=False, diff --git a/poezio/core/core.py b/poezio/core/core.py index b8c4f5cf..c6d83ad5 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -531,7 +531,7 @@ class Core(object): self.stdscr = curses.initscr() self._init_curses(self.stdscr) self.call_for_resize() - default_tab = tabs.RosterInfoTab() + default_tab = tabs.RosterInfoTab(self) default_tab.on_gain_focus() self.tabs.append(default_tab) self.information('Welcome to poezio!', 'Info') @@ -1056,16 +1056,16 @@ class Core(object): if not target: if new_pos < len(self.tabs): old_tab = self.tabs[old_pos] - self.tabs[new_pos], self.tabs[old_pos] = old_tab, tabs.GapTab() + self.tabs[new_pos], self.tabs[old_pos] = old_tab, tabs.GapTab(self) else: self.tabs.append(self.tabs[old_pos]) - self.tabs[old_pos] = tabs.GapTab() + self.tabs[old_pos] = tabs.GapTab(self) else: if new_pos > old_pos: self.tabs.insert(new_pos, tab) - self.tabs[old_pos] = tabs.GapTab() + self.tabs[old_pos] = tabs.GapTab(self) elif new_pos < old_pos: - self.tabs[old_pos] = tabs.GapTab() + self.tabs[old_pos] = tabs.GapTab(self) self.tabs.insert(new_pos, tab) else: return False @@ -1230,9 +1230,9 @@ class Core(object): DynamicConversationTab """ if safeJID(jid).resource: - new_tab = tabs.StaticConversationTab(jid) + new_tab = tabs.StaticConversationTab(self, jid) else: - new_tab = tabs.DynamicConversationTab(jid) + new_tab = tabs.DynamicConversationTab(self, jid) if not focus: new_tab.state = "private" self.add_tab(new_tab, focus) @@ -1253,7 +1253,7 @@ class Core(object): tab = self.get_tab_by_name(room_name, tabs.MucTab) if not tab: return None - new_tab = tabs.PrivateTab(complete_jid, tab.own_nick) + new_tab = tabs.PrivateTab(self, complete_jid, tab.own_nick) if hasattr(tab, 'directed_presence'): new_tab.directed_presence = tab.directed_presence if not focus: @@ -1268,7 +1268,7 @@ class Core(object): """ Open a new tab.MucTab containing a muc Room, using the specified nick """ - new_tab = tabs.MucTab(room, nick, password=password) + new_tab = tabs.MucTab(self, room, nick, password=password) self.add_tab(new_tab, focus) self.refresh_window() return new_tab @@ -1279,7 +1279,7 @@ class Core(object): The callback are called with the completed form as parameter in addition with kwargs """ - form_tab = tabs.DataFormsTab(form, on_cancel, on_send, kwargs) + form_tab = tabs.DataFormsTab(self, form, on_cancel, on_send, kwargs) self.add_tab(form_tab, True) ### Modifying actions ### @@ -1363,7 +1363,7 @@ class Core(object): self.tabs.pop() nb -= 1 else: - self.tabs[nb] = tabs.GapTab() + self.tabs[nb] = tabs.GapTab(self) else: self.tabs.remove(tab) logger.close(tab.name) -- cgit v1.2.3