From 71596ec10b56e40a87b91c1e9dab5de3a0398761 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 18 Apr 2012 23:45:16 +0200 Subject: Add a 'v' keybind on the roster to get the version of the selected resource-s --- src/contact.py | 5 +++++ src/tabs.py | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/contact.py b/src/contact.py index 1874ff59..66f8c453 100644 --- a/src/contact.py +++ b/src/contact.py @@ -78,6 +78,11 @@ class Contact(object): """Groups the contact is in""" return self._groups + @property + def resources(self): + """Resources of the contact""" + return self._resources + @property def bare_jid(self): """The bare_jid or the contact""" diff --git a/src/tabs.py b/src/tabs.py index 88e94e64..403e05f8 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -44,7 +44,7 @@ from sleekxmpp.xmlstream import matcher from sleekxmpp.xmlstream.handler import Callback from config import config from roster import RosterGroup, roster -from contact import Contact +from contact import Contact, Resource from text_buffer import TextBuffer from user import User from os import getenv, path @@ -1710,6 +1710,7 @@ class RosterInfoTab(Tab): self.key_func["M-[1;5B"] = self.move_cursor_to_next_group self.key_func["M-[1;5A"] = self.move_cursor_to_prev_group self.key_func["o"] = self.toggle_offline_show + self.key_func["v"] = self.get_contact_version self.key_func["s"] = self.start_search self.key_func["S"] = self.start_search_slow self.commands['deny'] = (self.command_deny, _("Usage: /deny [jid]\nDeny: Deny your presence to the provided JID (or the selected contact in your roster), who is asking you to be in his/here roster."), self.completion_deny) @@ -2247,6 +2248,16 @@ class RosterInfoTab(Tab): selected_row.toggle_folded() return True + def get_contact_version(self): + selected_row = self.roster_win.get_selected_row() + if isinstance(selected_row, Contact): + for resource in selected_row.resources: + self.core.command_version(str(resource.jid)) + elif isinstance(selected_row, Resource): + self.core.command_version(str(selected_row.jid)) + else: + self.core.information('Nothing to get versions from', 'Info') + def start_search(self): """ Start the search. The input should appear with a short instruction -- cgit v1.2.3