Fixes #2376 (Only open one XMLTab)
- Also make Core.focus_tab_named take an optional type, and return a boolean
This commit is contained in:
parent
1621aa9cfd
commit
4638e7b7b5
2 changed files with 15 additions and 9 deletions
16
src/core.py
16
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:
|
||||
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,7 +2262,9 @@ class Core(object):
|
|||
|
||||
def command_xml_tab(self, arg=''):
|
||||
"""/xml_tab"""
|
||||
self.xml_tabs += 1
|
||||
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)
|
||||
|
||||
|
@ -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()
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue