[alx] add bookmark button in MUC browser. Fixes #3726

This commit is contained in:
Yann Leboulanger 2009-06-22 18:30:02 +02:00
parent c6214c51b4
commit 3807e5f386
1 changed files with 42 additions and 1 deletions

View File

@ -1553,6 +1553,7 @@ class MucBrowser(AgentBrowser):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
AgentBrowser.__init__(self, *args, **kwargs) AgentBrowser.__init__(self, *args, **kwargs)
self.join_button = None self.join_button = None
self.bookmark_button = None
def _create_treemodel(self): def _create_treemodel(self):
# JID, node, name, users_int, users_str, description, fetched # JID, node, name, users_int, users_str, description, fetched
@ -1618,16 +1619,54 @@ class MucBrowser(AgentBrowser):
AgentBrowser._clean_treemodel(self) AgentBrowser._clean_treemodel(self)
def _add_actions(self): def _add_actions(self):
self.bookmark_button = gtk.Button(label=_('_Bookmark'), use_underline=True)
self.bookmark_button.connect('clicked', self.on_bookmark_button_clicked)
self.window.action_buttonbox.add(self.bookmark_button)
self.bookmark_button.show_all()
self.join_button = gtk.Button(label=_('_Join'), use_underline=True) self.join_button = gtk.Button(label=_('_Join'), use_underline=True)
self.join_button.connect('clicked', self.on_join_button_clicked) self.join_button.connect('clicked', self.on_join_button_clicked)
self.window.action_buttonbox.add(self.join_button) self.window.action_buttonbox.add(self.join_button)
self.join_button.show_all() self.join_button.show_all()
def _clean_actions(self): def _clean_actions(self):
if self.bookmark_button:
self.bookmark_button.destroy()
self.bookmark_button = None
if self.join_button: if self.join_button:
self.join_button.destroy() self.join_button.destroy()
self.join_button = None self.join_button = None
def on_bookmark_button_clicked(self, *args):
model, iter = self.window.services_treeview.get_selection().get_selected()
if not iter:
return
name = gajim.config.get_per('accounts', self.account, 'name')
room_jid = model[iter][0].decode('utf-8')
bm = {
'name': room_jid.split('@')[0],
'jid': room_jid,
'autojoin': '0',
'minimize': '0',
'password': '',
'nick': name
}
for bookmark in gajim.connections[self.account].bookmarks:
if bookmark['jid'] == bm['jid']:
dialogs.ErrorDialog(
_('Bookmark already set'),
_('Group Chat "%s" is already in your bookmarks.') % bm['jid'])
return
gajim.connections[self.account].bookmarks.append(bm)
gajim.connections[self.account].store_bookmarks()
gajim.interface.roster.set_actions_menu_needs_rebuild()
dialogs.InformationDialog(
_('Bookmark has been added successfully'),
_('You can manage your bookmarks via Actions menu in your roster.'))
def on_join_button_clicked(self, *args): def on_join_button_clicked(self, *args):
'''When we want to join a conference: '''When we want to join a conference:
Ask specific informations about the selected agent and close the window''' Ask specific informations about the selected agent and close the window'''
@ -1646,8 +1685,10 @@ class MucBrowser(AgentBrowser):
self.window.destroy(chain = True) self.window.destroy(chain = True)
def update_actions(self): def update_actions(self):
if self.join_button:
sens = self.window.services_treeview.get_selection().count_selected_rows() sens = self.window.services_treeview.get_selection().count_selected_rows()
if self.bookmark_button:
self.bookmark_button.set_sensitive(sens > 0)
if self.join_button:
self.join_button.set_sensitive(sens > 0) self.join_button.set_sensitive(sens > 0)
def default_action(self): def default_action(self):