def __init__(self, *args, filefilter): GenericOption.__init__(self, *args) button = Gtk.FileChooserButton(self.label, Gtk.FileChooserAction.OPEN) button.set_halign(Gtk.Align.END) # GTK Bug: The FileChooserButton expands without limit # get the label and use set_max_wide_chars() label = button.get_children()[0].get_children()[0].get_children()[1] label.set_max_width_chars(20) if filefilter: name, pattern = filefilter filter_ = Gtk.FileFilter() filter_.set_name(name) filter_.add_pattern(pattern) button.add_filter(filter_) button.set_filter(filter_) filter_ = Gtk.FileFilter() filter_.set_name(_('All files')) filter_.add_pattern('*') button.add_filter(filter_) if self.option_value: button.set_filename(self.option_value) button.connect('selection-changed', self.on_select) clear_button = gtkgui_helpers.get_image_button( 'edit-clear-all-symbolic', _('Clear File')) clear_button.connect('clicked', lambda *args: button.unselect_all()) self.option_box.pack_start(button, True, True, 0) self.option_box.pack_start(clear_button, False, False, 0) self.show_all()
def __init__(self, account, parent): Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=12) self.account = account if account == app.ZEROCONF_ACC_NAME: self.options = ZeroConfPage(account) else: self.options = AccountPage(account) self.parent = parent switch = Gtk.Switch() switch.set_active(app.config.get_per('accounts', account, 'active')) switch.set_vexpand(False) switch.set_valign(Gtk.Align.CENTER) switch.set_halign(Gtk.Align.START) if account == app.ZEROCONF_ACC_NAME and not app.HAVE_ZEROCONF: switch.set_sensitive(False) switch.set_active(False) switch.connect('notify::active', self.on_switch, self.account) account_label = app.config.get_per('accounts', account, 'account_label') self.label = Gtk.Label(label=account_label or account) self.label.set_halign(Gtk.Align.START) self.label.set_hexpand(True) self.add(switch) self.add(self.label) if account != app.ZEROCONF_ACC_NAME: button = get_image_button('list-remove-symbolic', _('Remove')) button.connect('clicked', parent.on_remove_account, account) self.add(button)
def __init__(self, account, parent, options): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=12) self.account = account self.parent = parent self.toggle = get_image_button('document-edit-symbolic', _('Rename account label'), toggle=True) self.toggle.connect('toggled', self.set_entry_text) self.entry = Gtk.Entry() self.entry.set_sensitive(False) self.entry.set_name('AccountNameEntry') self.set_entry_text(self.toggle, update=True) box = Gtk.Box() if isinstance(self, AccountPage): box.pack_start(self.toggle, False, True, 0) box.pack_start(self.entry, True, True, 0) self.listbox = OptionsBox(account) self.listbox.set_selection_mode(Gtk.SelectionMode.NONE) for option in options: self.listbox.add_option(option) self.listbox.update_states() self.pack_start(box, False, False, 0) self.pack_start(self.listbox, True, True, 0) self.listbox.connect('row-activated', self.on_row_activated)
def __init__(self, *args): GenericOption.__init__(self, *args) self.combo = Gtk.ComboBoxText() self.update_values() self.combo.connect('changed', self.on_value_change) self.combo.set_valign(Gtk.Align.CENTER) button = gtkgui_helpers.get_image_button('preferences-system-symbolic', _('Manage Proxies')) button.set_action_name('app.manage-proxies') button.set_valign(Gtk.Align.CENTER) self.option_box.pack_start(self.combo, True, True, 0) self.option_box.pack_start(button, False, True, 0) self.show_all()
def __init__(self): Gtk.ApplicationWindow.__init__(self) self.set_application(app.app) self.set_position(Gtk.WindowPosition.CENTER) self.set_show_menubar(False) self.set_name('AccountsWindow') self.set_size_request(500, -1) self.set_resizable(False) self.need_relogin = {} glade_objects = [ 'stack', 'box', 'actionbar', 'headerbar', 'back_button', 'menu_button', 'account_page', 'account_list' ] self.builder = gtkgui_helpers.get_gtk_builder('accounts_window.ui') for obj in glade_objects: setattr(self, obj, self.builder.get_object(obj)) self.set_titlebar(self.headerbar) menu = Gio.Menu() menu.append(_('Merge Accounts'), 'app.merge') menu.append(_('Use PGP Agent'), 'app.agent') self.menu_button.set_menu_model(menu) button = get_image_button('list-add-symbolic', _('Add')) button.set_action_name('app.add-account') self.actionbar.pack_start(button) accounts = app.config.get_per('accounts') accounts.sort() for account in accounts: self.need_relogin[account] = self.get_relogin_options(account) account_item = Account(account, self) self.account_list.add(account_item) account_item.set_activatable() self.add(self.box) self.builder.connect_signals(self) self.connect('destroy', self.on_destroy) self.connect('key-press-event', self.on_key_press) self.show_all()