summaryrefslogtreecommitdiff
path: root/poezio/tabs
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2018-06-29 21:18:09 +0200
committermathieui <mathieui@mathieui.net>2018-07-21 20:20:13 +0200
commita28b9c4422317c6fed4a430dad4a478f462d3854 (patch)
treea664c2168a4e04e9bf5466868e0e899d0fc799d1 /poezio/tabs
parent7d9afc6ad40348fb21bf54ec55e14e22d023400e (diff)
downloadpoezio-a28b9c4422317c6fed4a430dad4a478f462d3854.tar.gz
poezio-a28b9c4422317c6fed4a430dad4a478f462d3854.tar.bz2
poezio-a28b9c4422317c6fed4a430dad4a478f462d3854.tar.xz
poezio-a28b9c4422317c6fed4a430dad4a478f462d3854.zip
Update poezio for the new tabs module
Diffstat (limited to 'poezio/tabs')
-rw-r--r--poezio/tabs/adhoc_commands_list.py2
-rw-r--r--poezio/tabs/basetabs.py8
-rw-r--r--poezio/tabs/muclisttab.py2
-rw-r--r--poezio/tabs/muctab.py20
-rw-r--r--poezio/tabs/privatetab.py15
-rw-r--r--poezio/tabs/rostertab.py2
-rw-r--r--poezio/tabs/xmltab.py2
7 files changed, 23 insertions, 28 deletions
diff --git a/poezio/tabs/adhoc_commands_list.py b/poezio/tabs/adhoc_commands_list.py
index a1b186be..fecfc9e2 100644
--- a/poezio/tabs/adhoc_commands_list.py
+++ b/poezio/tabs/adhoc_commands_list.py
@@ -58,7 +58,7 @@ class AdhocCommandsListTab(ListTab):
for item in get_items()]
self.listview.set_lines(items)
self.info_header.message = 'Ad-hoc commands of JID %s' % self.name
- if self.core.current_tab() is self:
+ if self.core.tabs.current_tab is self:
self.refresh()
else:
self.state = 'highlight'
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py
index 9ba8e6e5..34945c27 100644
--- a/poezio/tabs/basetabs.py
+++ b/poezio/tabs/basetabs.py
@@ -92,6 +92,7 @@ class Tab:
def __init__(self, core):
self.core = core
+ self.nb = 0
if not hasattr(self, 'name'):
self.name = self.__class__.__name__
self.input = None
@@ -108,13 +109,6 @@ class Tab:
def size(self):
return self.core.size
- @property
- def nb(self):
- for index, tab in enumerate(self.core.tabs):
- if tab == self:
- return index
- return len(self.core.tabs)
-
@staticmethod
def tab_win_height():
"""
diff --git a/poezio/tabs/muclisttab.py b/poezio/tabs/muclisttab.py
index e12d24ee..6ba7816d 100644
--- a/poezio/tabs/muclisttab.py
+++ b/poezio/tabs/muclisttab.py
@@ -59,7 +59,7 @@ class MucListTab(ListTab):
for item in get_items()]
self.listview.set_lines(items)
self.info_header.message = 'Chatroom list on server %s' % self.name
- if self.core.current_tab() is self:
+ if self.core.tabs.current_tab is self:
self.refresh()
else:
self.state = 'highlight'
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py
index 60d5a64b..246606e3 100644
--- a/poezio/tabs/muctab.py
+++ b/poezio/tabs/muctab.py
@@ -429,7 +429,7 @@ class MucTab(ChatTab):
self.handle_presence_joined(presence, status_codes)
except PresenceError:
self.core.room_error(presence, presence['from'].bare)
- if self.core.current_tab() is self:
+ if self.core.tabs.current_tab is self:
self.text_win.refresh()
self.user_win.refresh_if_changed(self.users)
self.info_header.refresh(self, self.text_win, user=self.own_user)
@@ -453,9 +453,9 @@ class MucTab(ChatTab):
# Enable the self ping event, to regularly check if we
# are still in the room.
self.enable_self_ping_event()
- if self.core.current_tab() is not self:
+ if self.core.tabs.current_tab is not self:
self.refresh_tab_win()
- self.core.current_tab().refresh_input()
+ self.core.tabs.current_tab.refresh_input()
self.core.doupdate()
def handle_presence_unjoined(self, presence, deterministic, own=False):
@@ -487,9 +487,9 @@ class MucTab(ChatTab):
if self.name in self.core.initial_joins:
self.core.initial_joins.remove(self.name)
self._state = 'normal'
- elif self != self.core.current_tab():
+ elif self != self.core.tabs.current_tab:
self._state = 'joined'
- if (self.core.current_tab() is self
+ if (self.core.tabs.current_tab is self
and self.core.status.show not in ('xa', 'away')):
self.send_chat_state('active')
new_user.color = get_theme().COLOR_OWN_NICK
@@ -721,7 +721,7 @@ class MucTab(ChatTab):
self.core.disable_private_tabs(self.name, reason=kick_msg)
self.disconnect()
self.refresh_tab_win()
- self.core.current_tab().refresh_input()
+ self.core.tabs.current_tab.refresh_input()
if config.get_by_tabname('autorejoin', self.general_jid):
delay = config.get_by_tabname('autorejoin_delay',
self.general_jid)
@@ -799,7 +799,7 @@ class MucTab(ChatTab):
self.core.disable_private_tabs(self.name, reason=kick_msg)
self.disconnect()
self.refresh_tab_win()
- self.core.current_tab().refresh_input()
+ self.core.tabs.current_tab.refresh_input()
# try to auto-rejoin
if config.get_by_tabname('autorejoin', self.general_jid):
delay = config.get_by_tabname('autorejoin_delay',
@@ -972,7 +972,7 @@ class MucTab(ChatTab):
"""
self.presence_buffer = []
self.users = []
- if self is not self.core.current_tab():
+ if self is not self.core.tabs.current_tab:
self.state = 'disconnected'
self.joined = False
self.disable_self_ping_event()
@@ -1376,7 +1376,7 @@ class MucTab(ChatTab):
"""
message = args[0]
self.leave_room(message)
- if self == self.core.current_tab():
+ if self == self.core.tabs.current_tab:
self.refresh()
self.core.doupdate()
@@ -1406,7 +1406,7 @@ class MucTab(ChatTab):
r = self.core.open_private_window(self.name, user.nick)
if r and len(args) == 2:
msg = args[1]
- self.core.current_tab().command_say(
+ self.core.tabs.current_tab.command_say(
xhtml.convert_simple_to_full_colors(msg))
if not r:
self.core.information("Cannot find user: %s" % nick, 'Error')
diff --git a/poezio/tabs/privatetab.py b/poezio/tabs/privatetab.py
index d2d2f5ac..bc7f31c7 100644
--- a/poezio/tabs/privatetab.py
+++ b/poezio/tabs/privatetab.py
@@ -60,7 +60,8 @@ class PrivateTab(OneToOneTab):
'Get the software version of the current interlocutor (usually its XMPP client and Operating System).',
shortdesc='Get the software version of a jid.')
self.resize()
- self.parent_muc = self.core.get_tab_by_name(safeJID(name).bare, MucTab)
+ self.parent_muc = self.core.tabs.by_name_and_class(
+ safeJID(name).bare, MucTab)
self.on = True
self.update_commands()
self.update_keys()
@@ -275,7 +276,7 @@ class PrivateTab(OneToOneTab):
empty_after = self.input.get_text() == '' or (
self.input.get_text().startswith('/')
and not self.input.get_text().startswith('//'))
- tab = self.core.get_tab_by_name(safeJID(self.name).bare, MucTab)
+ tab = self.core.tabs.by_name_and_class(safeJID(self.name).bare, MucTab)
if tab and tab.joined:
self.send_composing_chat_state(empty_after)
return False
@@ -288,7 +289,7 @@ class PrivateTab(OneToOneTab):
self.text_win.remove_line_separator()
self.text_win.add_line_separator(self._text_buffer)
- tab = self.core.get_tab_by_name(safeJID(self.name).bare, MucTab)
+ tab = self.core.tabs.by_name_and_class(safeJID(self.name).bare, MucTab)
if tab and tab.joined and config.get_by_tabname(
'send_chat_states', self.general_jid) and self.on:
self.send_chat_state('inactive')
@@ -297,7 +298,7 @@ class PrivateTab(OneToOneTab):
def on_gain_focus(self):
self.state = 'current'
curses.curs_set(1)
- tab = self.core.get_tab_by_name(safeJID(self.name).bare, MucTab)
+ tab = self.core.tabs.by_name_and_class(safeJID(self.name).bare, MucTab)
if tab and tab.joined and config.get_by_tabname(
'send_chat_states',
self.general_jid,
@@ -334,7 +335,7 @@ class PrivateTab(OneToOneTab):
typ=2)
new_jid = safeJID(self.name).bare + '/' + user.nick
self.name = new_jid
- return self.core.current_tab() is self
+ return self.core.tabs.current_tab is self
@refresh_wrapper.conditional
def user_left(self, status_message, user):
@@ -372,7 +373,7 @@ class PrivateTab(OneToOneTab):
'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
},
typ=2)
- return self.core.current_tab() is self
+ return self.core.tabs.current_tab is self
@refresh_wrapper.conditional
def user_rejoined(self, nick):
@@ -398,7 +399,7 @@ class PrivateTab(OneToOneTab):
'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
},
typ=2)
- return self.core.current_tab() is self
+ return self.core.tabs.current_tab is self
def activate(self, reason=None):
self.on = True
diff --git a/poezio/tabs/rostertab.py b/poezio/tabs/rostertab.py
index 6aba2c15..2941159c 100644
--- a/poezio/tabs/rostertab.py
+++ b/poezio/tabs/rostertab.py
@@ -1150,7 +1150,7 @@ class RosterInfoTab(Tab):
def reset_help_message(self, _=None):
self.input = self.default_help_message
- if self.core.current_tab() is self:
+ if self.core.tabs.current_tab is self:
curses.curs_set(0)
self.input.refresh()
self.core.doupdate()
diff --git a/poezio/tabs/xmltab.py b/poezio/tabs/xmltab.py
index fc04f778..c4a50df8 100644
--- a/poezio/tabs/xmltab.py
+++ b/poezio/tabs/xmltab.py
@@ -286,7 +286,7 @@ class XMLTab(Tab):
def reset_help_message(self, _=None):
if self.closed:
return True
- if self.core.current_tab() is self:
+ if self.core.tabs.current_tab is self:
curses.curs_set(0)
self.input = self.default_help_message
return True