def get_bookmarks_menu(account, rebuild=False): con = app.connections[account] boomarks = con.get_module('Bookmarks').bookmarks if not boomarks: return None menu = Gio.Menu() # Build Join Groupchat action = 'app.{}-join-groupchat'.format(account) menuitem = Gio.MenuItem.new(_('Join Group Chat'), action) variant = GLib.Variant('s', account) menuitem.set_action_and_target_value(action, variant) menu.append_item(menuitem) # Build Bookmarks section = Gio.Menu() for jid, bookmark in boomarks.items(): name = bookmark['name'] if not name: # No name was given for this bookmark. # Use the first part of JID instead... name = jid.split("@")[0] # Shorten long names name = (name[:42] + '..') if len(name) > 42 else name action = 'app.{}-activate-bookmark'.format(account) menuitem = Gio.MenuItem.new(name, action) # Create Variant Dict dict_ = { 'account': GLib.Variant('s', account), 'jid': GLib.Variant('s', jid) } if bookmark['nick']: dict_['nick'] = GLib.Variant('s', bookmark['nick']) if bookmark['password']: dict_['password'] = GLib.Variant('s', bookmark['password']) variant_dict = GLib.Variant('a{sv}', dict_) menuitem.set_action_and_target_value(action, variant_dict) section.append_item(menuitem) menu.append_section(None, section) if not rebuild: get_action(account + '-activate-bookmark').set_enabled(True) return menu
def __init__(self, *args, action_args): GenericOption.__init__(self, *args) self.action = gtkgui_helpers.get_action(self.option_value) self.variant = GLib.Variant.new_string(action_args) self.on_enable() self.show_all() self.action.connect('notify::enabled', self.on_enable)
def __init__(self, *args, account): GenericSetting.__init__(self, *args) action_name = '%s%s' % (account, self.value) self.action = gtkgui_helpers.get_action(action_name) self.variant = GLib.Variant.new_string(account) self.on_enable() self.show_all() self.action.connect('notify::enabled', self.on_enable)
def _open_update(is_checked): if is_checked: self.config['auto_update'] = True get_action('plugins').activate() page = self.notebook.page_num(self._ui.available_plugins_box) self.notebook.set_current_page(page)