From 8634b5ea66cd8fb305d41a2680c66a7d4fcde73c Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 22 Jul 2016 19:56:07 +0200 Subject: Fix a bug with the _close_tab shortcut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit on_close wasn’t used correctly everywhere. Also make the "close" commands for each tab specific to themselves, rather than taking the current tab for closure. --- poezio/core/core.py | 2 +- poezio/tabs/bookmarkstab.py | 4 ++-- poezio/tabs/conversationtab.py | 2 +- poezio/tabs/listtab.py | 1 - poezio/tabs/muctab.py | 6 +++++- poezio/tabs/privatetab.py | 3 ++- poezio/tabs/xmltab.py | 3 ++- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/poezio/core/core.py b/poezio/core/core.py index 3cc02979..d4a5c060 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -1346,9 +1346,9 @@ class Core(object): tab = self.current_tab() if isinstance(tab, tabs.RosterInfoTab): return # The tab 0 should NEVER be closed + tab.on_close() del tab.key_func # Remove self references del tab.commands # and make the object collectable - tab.on_close() nb = tab.nb if was_current: if self.previous_tab_nb != nb: diff --git a/poezio/tabs/bookmarkstab.py b/poezio/tabs/bookmarkstab.py index 053e45dd..5416712b 100644 --- a/poezio/tabs/bookmarkstab.py +++ b/poezio/tabs/bookmarkstab.py @@ -58,7 +58,7 @@ class BookmarksTab(Tab): self.removed_bookmarks.append(current) def on_cancel(self): - self.core.close_tab() + self.core.close_tab(self) return True def on_save(self): @@ -85,7 +85,7 @@ class BookmarksTab(Tab): self.core.information('Remote bookmarks not saved.', 'Error') log.debug('alerte %s', str(stanza_storage(self.bookmarks.bookmarks))) self.bookmarks.save(self.core.xmpp, callback=send_cb) - self.core.close_tab() + self.core.close_tab(self) return True def on_input(self, key, raw=False): diff --git a/poezio/tabs/conversationtab.py b/poezio/tabs/conversationtab.py index 99c4b122..469ef28a 100644 --- a/poezio/tabs/conversationtab.py +++ b/poezio/tabs/conversationtab.py @@ -207,7 +207,7 @@ class ConversationTab(OneToOneTab): @command_args_parser.ignored def command_unquery(self): - self.core.close_tab() + self.core.close_tab(self) @command_args_parser.quoted(0, 1) def command_version(self, args): diff --git a/poezio/tabs/listtab.py b/poezio/tabs/listtab.py index c99bd3bd..18ee1da4 100644 --- a/poezio/tabs/listtab.py +++ b/poezio/tabs/listtab.py @@ -111,7 +111,6 @@ class ListTab(Tab): self.input.do_command("/") # we add the slash def close(self, arg=None): - self.input.on_delete() self.core.close_tab(self) def set_error(self, msg, code, body): diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py index e0f3b6e2..281237ad 100644 --- a/poezio/tabs/muctab.py +++ b/poezio/tabs/muctab.py @@ -624,7 +624,11 @@ class MucTab(ChatTab): /close [msg] """ self.command_part(msg) - self.core.close_tab() + self.core.close_tab(self) + + def on_close(self): + super().on_close() + self.command_part('') @command_args_parser.quoted(1, 1) def command_query(self, args): diff --git a/poezio/tabs/privatetab.py b/poezio/tabs/privatetab.py index c8c80f19..7a132167 100644 --- a/poezio/tabs/privatetab.py +++ b/poezio/tabs/privatetab.py @@ -96,6 +96,7 @@ class PrivateTab(OneToOneTab): self.core.information('Unable to write in the log file', 'Error') def on_close(self): + super().on_close() self.parent_muc.privates.remove(self) def completion(self): @@ -188,7 +189,7 @@ class PrivateTab(OneToOneTab): """ /unquery """ - self.core.close_tab() + self.core.close_tab(self) @command_args_parser.quoted(0, 1) def command_version(self, args): diff --git a/poezio/tabs/xmltab.py b/poezio/tabs/xmltab.py index 937ab0f9..3fdaffc7 100644 --- a/poezio/tabs/xmltab.py +++ b/poezio/tabs/xmltab.py @@ -303,7 +303,7 @@ class XMLTab(Tab): return self.key_func[key]() def close(self, arg=None): - self.core.close_tab() + self.core.close_tab(self) def resize(self): self.need_resize = False @@ -348,6 +348,7 @@ class XMLTab(Tab): curses.curs_set(0) def on_close(self): + super().on_close() self.command_clear('') self.core.xml_tab = False -- cgit v1.2.3