diff options
author | mathieui <mathieui@mathieui.net> | 2012-10-13 15:33:32 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2012-10-13 15:33:32 +0200 |
commit | 4638e7b7b58d39ef1436034deead5d573ca81527 (patch) | |
tree | 79bc7b13acbdc340ee2a0930943b222092f952b1 /src | |
parent | 1621aa9cfdc5249bb287b8df9fd2f227fd28ced3 (diff) | |
download | poezio-4638e7b7b58d39ef1436034deead5d573ca81527.tar.gz poezio-4638e7b7b58d39ef1436034deead5d573ca81527.tar.bz2 poezio-4638e7b7b58d39ef1436034deead5d573ca81527.tar.xz poezio-4638e7b7b58d39ef1436034deead5d573ca81527.zip |
Fixes #2376 (Only open one XMLTab)
- Also make Core.focus_tab_named take an optional type, and return a boolean
Diffstat (limited to 'src')
-rw-r--r-- | src/core.py | 22 | ||||
-rw-r--r-- | src/tabs.py | 2 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/core.py b/src/core.py index c6d7d557..7e21a786 100644 --- a/src/core.py +++ b/src/core.py @@ -128,7 +128,7 @@ class Core(object): self.tab_win = windows.GlobalInfoBar() # Number of xml tabs opened, used to avoid useless memory consumption - self.xml_tabs = 0 + self.xml_tab = False self.xml_buffer = TextBuffer() self.tabs = [] @@ -848,10 +848,14 @@ class Core(object): return return - def focus_tab_named(self, tab_name): + def focus_tab_named(self, tab_name, type_=None): + """Returns True if it found a tab to focus on""" for tab in self.tabs: if tab.get_name() == tab_name: - self.command_win('%s' % (tab.nb,)) + if (type_ and (isinstance(tab, type_))) or not type_: + self.command_win('%s' % (tab.nb,)) + return True + return False @property def current_tab_nb(self): @@ -2258,9 +2262,11 @@ class Core(object): def command_xml_tab(self, arg=''): """/xml_tab""" - self.xml_tabs += 1 - tab = tabs.XMLTab() - self.add_tab(tab, True) + self.xml_tab = True + xml_tab = self.focus_tab_named('XMLTab', tabs.XMLTab) + if not xml_tab: + tab = tabs.XMLTab() + self.add_tab(tab, True) def command_self(self, arg=None): """ @@ -2854,7 +2860,7 @@ class Core(object): """ We are sending a new stanza, write it in the xml buffer if needed. """ - if self.xml_tabs: + if self.xml_tab: self.add_message_to_text_buffer(self.xml_buffer, '\x191}<--\x19o %s' % stanza) if isinstance(self.current_tab(), tabs.XMLTab): self.current_tab().refresh() @@ -2864,7 +2870,7 @@ class Core(object): """ We are receiving a new stanza, write it in the xml buffer if needed. """ - if self.xml_tabs: + if self.xml_tab: self.add_message_to_text_buffer(self.xml_buffer, '\x192}-->\x19o %s' % stanza) if isinstance(self.current_tab(), tabs.XMLTab): self.current_tab().refresh() diff --git a/src/tabs.py b/src/tabs.py index 27f79d9b..da6bceaf 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -3244,7 +3244,7 @@ class XMLTab(Tab): curses.curs_set(0) def on_close(self): - self.core.xml_tabs -= 1 + self.core.xml_tab = False class SimpleTextTab(Tab): """ |