Add a /remove_bookmark command

This commit is contained in:
mathieui 2011-11-28 16:28:44 +01:00
parent 5abf8ab3ae
commit 0954c12a07
2 changed files with 29 additions and 0 deletions

View file

@ -215,6 +215,9 @@ These commands work in *any* tab.
with this command will be stored locally. They have priority over the ones
stored online.
*/remove_bookmark [room_jid]*:: Remove the bookmark on _room_jid_ or the one on
the current tab, if any.
*/bookmarks*:: Show the current bookmarks.
*/set <option> [value]*:: Set the value to the option in your configuration

View file

@ -141,6 +141,7 @@ class Core(object):
'invite': (self.command_invite, _("Usage: /invite <jid> <room> [reason]\nInvite: Invite jid in room with reason."), self.completion_invite),
'decline': (self.command_decline, _("Usage: /decline <room> [reason]\nDecline: Decline the invitation to room with or without reason."), self.completion_decline),
'bookmarks': (self.command_bookmarks, _("Usage: /bookmarks\nBookmarks: Show the current bookmarks."), None),
'remove_bookmark': (self.command_remove_bookmark, _("Usage: /remove_bookmark [jid]\nRemove Bookmark: Remove the specified bookmark, or the bookmark on the current tab, if any."), self.completion_remove_bookmark),
}
self.key_func = {
@ -1773,6 +1774,31 @@ class Core(object):
self.information(_('Your local bookmarks are: %s') %
[b for b in bookmark.bookmarks if b.method is 'local'], 'Info')
def command_remove_bookmark(self, arg):
"""/remove_bookmark [jid]"""
args = common.shell_split(arg)
if not args:
tab = self.current_tab()
if isinstance(tab, tabs.MucTab) and bookmark.get_by_jid(tab.get_name()):
bookmark.remove(tab.get_name())
bookmark.save(self.xmpp)
if bookmark.save(self.xmpp):
self.core.information('Bookmark deleted', 'Info')
else:
self.information('No bookmark to remove', 'Info')
else:
if bookmark.get_by_jid(args[0]):
bookmark.remove(args[0])
if bookmark.save(self.xmpp):
self.core.information('Bookmark deleted', 'Info')
else:
self.information('No bookmark to remove', 'Info')
def completion_remove_bookmark(self,the_input):
"""Completion for /remove_bookmark"""
return the_input.auto_completion([bm.jid for bm in bookmark.bookmarks], '')
def command_set(self, arg):
"""
/set <option> [value]