From 384f6939cb09268ebbb3072490b3b0c87bff82ba Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 15:54:52 +0200 Subject: Add a get_nick method to the tabs --- src/tabs.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/tabs.py b/src/tabs.py index fce2bade..66af43b5 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -269,6 +269,12 @@ class Tab(object): """ return self.__class__.__name__ + def get_nick(self): + """ + Get the nick of the tab (defaults to its name) + """ + return self.get_name() + def get_text_window(self): """ Returns the principal TextWin window, if there's one @@ -1086,6 +1092,11 @@ class MucTab(ChatTab): def get_name(self): return self.name + def get_nick(self): + if config.getl('show_muc_jid', 'true') == 'false': + return JID(self.name).user + return self.name + def get_text_window(self): return self.text_win @@ -1585,6 +1596,9 @@ class PrivateTab(ChatTab): def get_name(self): return self.name + def get_nick(self): + return JID(self.name).resource + def on_input(self, key, raw): if not raw and key in self.key_func: self.key_func[key]() @@ -2350,6 +2364,10 @@ class ConversationTab(ChatTab): def get_name(self): return self.name + def get_nick(self): + jid = JID(self.name) + return roster.get_contact_by_jid(jid.bare).name or jid.user + def on_input(self, key, raw): if not raw and key in self.key_func: self.key_func[key]() -- cgit v1.2.3