def test_apply_model_whitelist(self): combo = Gtk.ComboBox() self.modeler.apply_model(combo, list(mock_domains_info.keys())) self.assertEqual(7, len(combo.get_model())) names = [entry['api_name'] for entry in self.modeler._entries.values()] self.modeler.apply_model(combo, [names[0]]) self.assertEqual(1, len(combo.get_model())) self.modeler.apply_model(combo, [names[0], names[1]]) self.assertEqual(2, len(combo.get_model()))
def __init__(self, dbstate, uistate, clicked): self.clicked_func = clicked self.filter_id = widgets.BasicEntry() self.filter_title = widgets.BasicEntry() self.filter_name = widgets.BasicEntry() self.filter_place = Place() self.filter_place.set_type((PlaceType.CUSTOM, '')) self.ptype = Gtk.ComboBox(has_entry=True) self.place_menu = widgets.MonitoredDataType( self.ptype, self.filter_place.set_type, self.filter_place.get_type) self.filter_code = widgets.BasicEntry() self.filter_note = widgets.BasicEntry() self.filter_regex = Gtk.CheckButton(label=_('Use regular expressions')) self.tag = Gtk.ComboBox() self.generic = Gtk.ComboBox() SidebarFilter.__init__(self, dbstate, uistate, "Place")
def __init__(self): super(ReleaseEventComboBox, self).__init__() self.model = Gtk.ListStore(object, str) self.combo = Gtk.ComboBox(model=self.model) render = Gtk.CellRendererText() self.combo.pack_start(render, True) self.combo.add_attribute(render, "markup", 1) self.combo.set_sensitive(False) self.label = Gtk.Label(label="_Release:", use_underline=True) self.label.set_use_underline(True) self.label.set_mnemonic_widget(self.combo) self.pack_start(self.label, False, True, 0) self.pack_start(self.combo, True, True, 0)
def __init__(self, id_proj=0): Gtk.Window.__init__(self, title='Cadastro de Projetos') self.set_border_width(10) self.set_default_size(400, 200) self.layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.layout.set_spacing(10) proj_list_store = Gtk.ListStore(int, str) self.pdao = ProjectDAO(make_connection()) for projeto in self.pdao.todos_projetos(): proj_list_store.append([projeto.id, projeto.nome]) self.projeto_combo = Gtk.ComboBox.new_with_model_and_entry( proj_list_store) self.projeto_combo.set_entry_text_column(1) self.projeto_combo.set_active(id_proj - 1) if id_proj: self.projeto_combo.set_sensitive(False) self.layout.add(self.projeto_combo) type_source_ls = Gtk.ListStore(int, str) type_source_ls.append([0, 'book']) type_source_ls.append([1, 'article']) type_source_ls.append([2, 'site']) self.type_source_combo = Gtk.ComboBox.new_with_model_and_entry( type_source_ls) self.type_source_combo.set_entry_text_column(1) self.type_source_combo.connect("changed", self.select_type_source) self.layout.add(self.type_source_combo) self.source_combo = Gtk.ComboBox() self.source_combo.set_sensitive(False) self.source_combo.set_entry_text_column(1) self.source_box = Gtk.Box() self.source_box.add(self.source_combo) self.layout.add(self.source_box) self.ent_ini = Gtk.Entry() self.ent_ini.set_placeholder_text("página inicio") self.ent_fim = Gtk.Entry() self.ent_fim.set_placeholder_text("página fim") box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) box.set_spacing(5) box.pack_start(self.ent_ini, True, True, 0) box.pack_start(self.ent_fim, True, True, 0) self.layout.add(box) self.btn_save = Gtk.Button("Salvar") self.btn_save.connect("clicked", self.save) self.layout.add(self.btn_save) self.add(self.layout)
def __init__(self): GObject.GObject.__init__(self) self.widgets = widgets = uistuff.GladeWidgets("taskers.glade") tasker = widgets["newGameTasker"] tasker.unparent() self.add(tasker) startButton = self.widgets["startButton"] startButton.set_name("startButton") combo = Gtk.ComboBox() uistuff.createCombo(combo, [(get_pixbuf("glade/white.png"), _("White")), (get_pixbuf("glade/black.png"), _("Black")), (get_pixbuf("glade/random.png"), _("Random"))]) widgets["colorDock"].add(combo) if combo.get_active() < 0: combo.set_active(0) uistuff.keep(combo, "newgametasker_colorcombo") widgets['yourColorLabel'].set_mnemonic_widget(combo) # We need to wait until after engines have been discovered, to init the # playerCombos. We use connect_after to make sure, that newGameDialog # has also had time to init the constants we share with them. self.playerCombo = Gtk.ComboBox() widgets["opponentDock"].add(self.playerCombo) discoverer.connect_after("all_engines_discovered", self.__initPlayerCombo, widgets) widgets['opponentLabel'].set_mnemonic_widget(self.playerCombo) def on_skill_changed(scale): pix = newGameDialog.skillToIconLarge[int(scale.get_value())] widgets["skillImage"].set_from_pixbuf(pix) widgets["skillSlider"].connect("value-changed", on_skill_changed) on_skill_changed(widgets["skillSlider"]) widgets["startButton"].connect("clicked", self.startClicked) self.widgets["opendialog1"].connect("clicked", self.openDialogClicked)
def build_options_combo(group_id, active_index=0, include_empty_option=True): list_store = UIUtils.build_options_liststore(group_id, include_empty_option) combobox = gtk.ComboBox(model=list_store) renderer = gtk.CellRendererText() combobox.pack_start(renderer, True) combobox.add_attribute(renderer, 'text', 0) combobox.set_active(active_index) return combobox
def __init__(self): """ creates the combobox to be used in footer """ self.liststore = Gtk.ListStore(str) lang_ids = GtkSource.LanguageManager().get_language_ids() lang_ids.sort() for lang in lang_ids: self.liststore.append([lang]) self.combobox = Gtk.ComboBox() self.combobox.set_model(self.liststore) crt = Gtk.CellRendererText() self.combobox.pack_start(crt, True) self.combobox.add_attribute(crt, "text", 0)
def test_valid_qube_name_whitelist(self): list_exc = ["@dispvm:test-disp6", "test-red2"] whitelist = [name for name in mock_whitelist if name not in list_exc] self.modeler.apply_model(Gtk.ComboBox(), whitelist) for name in list_exc: mock = MockComboEntry(name) self.assertIsNone( self.modeler._get_valid_qube_name(mock, mock, whitelist)) self.assertIsNone( self.modeler._get_valid_qube_name(None, mock, whitelist)) self.assertIsNone( self.modeler._get_valid_qube_name(mock, None, whitelist))
def PluginPreferences(self, *args): current = config.gettext("settings", "language") if not current: current = None combo = Gtk.ComboBox() model = ObjectStore() combo.set_model(model) for lang_id in ([None] + sorted(get_available_languages("quodlibet"))): iter_ = model.append(row=[lang_id]) if lang_id == current: combo.set_active_iter(iter_) def cell_func(combo, render, model, iter_, *args): value = model.get_value(iter_) if value is None: text = escape(_("System Default")) else: if value == u"C": value = u"en" text = "%s <span weight='light'>(%s)</span>" % ( escape(value), escape(iso639.translate(value.split("_", 1)[0]))) render.set_property("markup", text) render = Gtk.CellRendererText() render.props.ellipsize = Pango.EllipsizeMode.END combo.pack_start(render, True) combo.set_cell_data_func(render, cell_func) def on_combo_changed(combo): new_language = model.get_value(combo.get_active_iter()) if new_language is None: new_language = u"" config.settext("settings", "language", new_language) combo.connect("changed", on_combo_changed) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12) box.pack_start(combo, False, False, 0) box.pack_start( Gtk.Label( label=_( "A restart is required for any changes to take effect"), wrap=True, xalign=0), False, False, 0) return box
def __run_load_dialog(self): """Display a dialog for loading a filter.""" oLoadDialog = SutekhDialog( "Load Filter", self.__oParent, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT) oLoadDialog.set_keep_above(True) oLoadDialog.add_button("_OK", Gtk.ResponseType.OK) oLoadDialog.add_button("_Cancel", Gtk.ResponseType.CANCEL) # default (True or False), filter name (str), query string (str) oFilterStore = Gtk.ListStore(GObject.TYPE_BOOLEAN, GObject.TYPE_STRING, GObject.TYPE_STRING) def iter_to_text(_oLayout, oCell, oModel, oIter): """Convert the model entry at oIter into the correct text""" bDefault = oModel.get_value(oIter, 0) sName = oModel.get_value(oIter, 1) if bDefault: oCell.set_property('text', sName + " (built-in)") else: oCell.set_property('text', sName) for bDefault in (True, False): for sName, sFilter in self.__fetch_filters(bDefault): oIter = oFilterStore.append(None) oFilterStore.set(oIter, 0, bDefault, 1, sName, 2, sFilter) oFilterSelector = Gtk.ComboBox() oFilterSelector.set_model(oFilterStore) oCell = Gtk.CellRendererText() oFilterSelector.pack_start(oCell, True) oFilterSelector.set_cell_data_func(oCell, iter_to_text) oLoadDialog.vbox.pack_start(oFilterSelector, True, True, 0) oLoadDialog.show_all() try: iResponse = oLoadDialog.run() oIter = oFilterSelector.get_active_iter() if iResponse == Gtk.ResponseType.OK and oIter: sName = oFilterStore.get_value(oIter, 1) sFilter = oFilterStore.get_value(oIter, 2) oAST = self.__oParser.apply(sFilter) self.__load_filter(sName, oAST) finally: oLoadDialog.destroy()
def __init__(self, dbstate, uistate, clicked): self.clicked_func = clicked self.filter_id = widgets.BasicEntry() self.filter_desc = widgets.BasicEntry() self.filter_event = Event() self.filter_event.set_type((EventType.CUSTOM, '')) self.etype = Gtk.ComboBox(has_entry=True) self.event_menu = widgets.MonitoredDataType(self.etype, self.filter_event.set_type, self.filter_event.get_type) self.filter_mainparts = widgets.BasicEntry() self.filter_date = widgets.DateEntry(uistate, []) self.filter_place = widgets.BasicEntry() self.filter_note = widgets.BasicEntry() self.filter_regex = Gtk.CheckButton(label=_('Use regular expressions')) self.tag = Gtk.ComboBox() self.generic = Gtk.ComboBox() SidebarFilter.__init__(self, dbstate, uistate, "Event")
def make_combo(expand=True): label2 = Gtk.Label() label2.set_text_with_mnemonic('Mode of _Transportation') cb = Gtk.ComboBox() label2.set_mnemonic_widget(cb) set_model_from_list( cb, ['Planes', 'Trains', 'Automobiles', 'Spacecraft', 'Bicycles'], expand=expand) setup_typeahead(cb) hb2 = Gtk.HBox() hb2.add(label2) hb2.add(cb) hb2.show_all() return hb2
def __init__(self, installer): BasePage.__init__(self) self.installer = installer self.install_grub = False self.hostname = None content = Gtk.VBox() content.set_border_width(30) self.add(content) # hostname section host = Gtk.Frame() host.set_label(_("What name should this computer use on the network?")) content.pack_start(host, False, False, 10) self.host_entry = Gtk.Entry() self.host_entry.set_placeholder_text(_("Type the hostname here")) self.host_regex = re.compile(ValidHostnameRegex) self.host_entry.connect("changed", self.host_validate) host_wrap = Gtk.VBox() host_wrap.set_border_width(5) host_wrap.add(self.host_entry) host.add(host_wrap) # grub grub_frame = Gtk.Frame() grub_check = Gtk.CheckButton(_("Should we install a boot loader (GRUB) on this computer?")) grub_frame.set_label_widget(grub_check) self.grub_combo = Gtk.ComboBox() renderer = Gtk.CellRendererText () self.grub_combo.pack_start (renderer, True) self.grub_combo.add_attribute (renderer, "text", 0) grub_wrap = Gtk.VBox() grub_wrap.set_border_width(5) grub_wrap.add(self.grub_combo) grub_frame.add(grub_wrap) # Hook up the checkbutton grub_check.connect("clicked", lambda x: self.grub_combo.set_sensitive(x.get_active())) self.grub_combo.set_sensitive(False) content.pack_start(grub_frame, False, False, 10) self.installer.can_go_forward(False) self.grub_model = None
def test_valid_qube_name(self): self.apply_model(Gtk.ComboBox(), list(mock_domains_info.keys())) for name in ["test-red1", "test-red2", "test-red3", "test-target", "Disposable VM (test-disp6)"]: mock = MockComboEntry(name) self.assertEquals(name, self._get_valid_qube_name(mock, mock, mock_whitelist)) self.assertEquals(name, self._get_valid_qube_name(None, mock, mock_whitelist)) self.assertEquals(name, self._get_valid_qube_name(mock, None, mock_whitelist)) self.assertIsNone( self._get_valid_qube_name(None, None, mock_whitelist))
def make_liststore_state(self): liststore = Gtk.ListStore(int, str) self.states = ['Nation'] liststore.append([0, "Nation Wide"]) for i, state in enumerate(self.data['state_name'].unique()): liststore.append([i + 1, state]) self.states.append(state) combo = Gtk.ComboBox() combo.set_model(liststore) cell = Gtk.CellRendererText() combo.pack_start(cell, False) combo.add_attribute(cell, 'text', 1) combo.connect("changed", self.state_select) combo.set_active(0) return combo
def __init__(self, text): Gtk.HBox.__init__(self) self.combo = Gtk.ComboBox() self.combo.set_size_request(200, -1) self.label = LeftAlignedLabel() self.label.set_text(text) self.label.set_size_request(170, -1) cell = Gtk.CellRendererText() self.combo.pack_start(cell, True) self.combo.add_attribute(cell, 'text', 0) self.pack_start(self.label, True, True, 0) self.pack_start(self.combo, False, False, 0) self.label.show() self.combo.show() self.show()
def _setup_group_switch_option(self): """Adds the controls for changing the group switch option of keyboard """ separator_group_option = Gtk.HSeparator() self._vbox.pack_start(separator_group_option, False, True, 0) separator_group_option.show_all() label_group_option = Gtk.Label(label=_('Key(s) to change layout')) label_group_option.set_alignment(0, 0) self._vbox.pack_start(label_group_option, False, True, 0) label_group_option.show_all() box_group_option = Gtk.VBox() box_group_option.set_border_width(style.DEFAULT_SPACING * 2) box_group_option.set_spacing(style.DEFAULT_SPACING) group_option_store = Gtk.ListStore(GObject.TYPE_STRING, \ GObject.TYPE_STRING) for description, name in self._keyboard_manager.get_options_group(): group_option_store.append([name, description]) group_option_combo = Gtk.ComboBox(model=group_option_store) cell = Gtk.CellRendererText() cell.props.ellipsize = Pango.EllipsizeMode.MIDDLE cell.props.ellipsize_set = True group_option_combo.pack_start(cell, True) group_option_combo.add_attribute(cell, 'text', 1) self._group_switch_option = \ self._keyboard_manager.get_current_option_group() if not self._group_switch_option: group_option_combo.set_active(0) else: found = False for row in group_option_store: if self._group_switch_option in row[0]: group_option_combo.set_active_iter(row.iter) found = True break if not found: group_option_combo.set_active(0) box_group_option.pack_start(group_option_combo, False, True, 0) self._vbox.pack_start(box_group_option, False, True, 0) box_group_option.show_all() group_option_combo.connect('changed', \ self.__group_switch_changed_cb)
def __init__(self, text, controls, filename, all_icons=temp_list): Gtk.HBox.__init__(self, False, 0) self.controls = controls self.combobox = Gtk.ComboBox() self.entry = Gtk.Entry() self.entry.set_size_request(300, -1) self.entry.set_property("margin", 0) if filename: self.entry.set_text(filename) else: filename = "" self.all_icons = all_icons self.modconst = ModelConstructor(all_icons) self.combobox.set_model(self.modconst.model) if filename in self.all_icons: self.combobox.set_active(self.all_icons.index(filename)) else: self.combobox.set_active(0) self.on_change_icon() logging.warning("Icon " + filename + " is absent in list of icons") pix_render = Gtk.CellRendererPixbuf() self.combobox.pack_start(pix_render, 0) self.combobox.add_attribute(pix_render, 'pixbuf', 0) button = Gtk.Button("Choose", Gtk.STOCK_OPEN) button.connect("clicked", self.on_file_choose) button_2 = Gtk.Button("Delete", Gtk.STOCK_DELETE) button_2.connect("clicked", self.on_delete) label = Gtk.Label(text) if text: # if iconblock without label label.set_size_request(80, -1) self.pack_start(label, False, False, 0) self.pack_start(self.combobox, False, False, 0) self.pack_start(self.entry, True, True, 0) self.pack_start(button, False, False, 0) self.pack_start(button_2, False, False, 0) self.combobox.connect("changed", self.on_change_icon)
def __init__(self, dbstate, uistate, on_apply, apply_done=None): self.on_apply_callback = on_apply self.apply_done_callback = apply_done self.dbstate = dbstate self.uistate = uistate self.apply_text = '' self.visible = False self.filterbar = Gtk.Box() self.filter_text = Gtk.Entry() self.filter_button = Gtk.Button(stock=Gtk.STOCK_FIND) self.clear_button = Gtk.Button(stock=Gtk.STOCK_CLEAR) self.filter_list = Gtk.ComboBox() self.filter_model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_INT, GObject.TYPE_BOOLEAN)
def __init__(self, dbstate, uistate, on_apply, apply_done=None): self.on_apply_callback = on_apply self.apply_done_callback = apply_done self.dbstate = dbstate self.uistate = uistate self.apply_text = '' self.visible = False self.filterbar = Gtk.Box() self.filter_text = Gtk.Entry() self.filter_button = Gtk.Button.new_with_mnemonic(_('_Find')) self.clear_button = Gtk.Button.new_with_mnemonic(_('_Clear')) self.filter_list = Gtk.ComboBox() self.filter_model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_INT, GObject.TYPE_BOOLEAN)
def __init__(self, oParent, oConfig, sType): super().__init__( "Edit Per-Deck Profiles", oParent, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT) self.__oParent = oParent self.__oConfig = oConfig self._sType = sType self.__dUnsavedChanges = {} self.__sActiveProfile = None # Model for selector drop-down (profile key, profile name) oModel = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING) oCell = Gtk.CellRendererText() self.__oSelectorCombo = Gtk.ComboBox() self.__oSelectorCombo.set_model(oModel) self.__oSelectorCombo.pack_start(oCell, True) self.__oSelectorCombo.add_attribute(oCell, 'text', 1) self.__oSelectorCombo.set_wrap_width(1) self.__oSelectorCombo.connect("changed", self._selector_changed) self.__oSelectorCombo.connect("notify::popup-shown", self._selector_opened) self.vbox.pack_start(self.__oSelectorCombo, False, True, 0) aOptions = [] for sKey in self.__oConfig.profile_options(self._sType): bInherit = sKey != "name" aOptions.append( (sKey, self.__oConfig.get_option_spec(self._sType, sKey), bInherit)) self.__oOptionsTable = PreferenceTable(aOptions, oConfig.get_validator()) self.vbox.pack_start(AutoScrolledWindow(self.__oOptionsTable), True, True, 0) self.set_default_size(700, 550) self.connect("response", self._button_response) self.add_button("Cancel", self.RESPONSE_CANCEL) self.add_button("Save and Close", self.RESPONSE_SAVE_AND_CLOSE) self._repopulate_selector() self.show_all() # should be last to allow PreferenceTable to show / hide inheritance # widgets correctly. self.__oSelectorCombo.set_active(0)
def __init__(self, items): self.items = items liststore = Gtk.ListStore(str) for item in items: liststore.append([item]) combobox = Gtk.ComboBox() combobox.set_model(liststore) combobox.set_active(0) combobox.connect("changed", self.on_combobox_changed) cellrenderertext = Gtk.CellRendererText() combobox.pack_start(cellrenderertext, True) combobox.add_attribute(cellrenderertext, "text", 0) combobox.show() self.widget = combobox
def initiate_station_selector_box(self, hbox): listmodel = Gtk.ListStore(str) listmodel.append(["Custom"]) for i in self.Stations: listmodel.append([i]) self.stationSelector = Gtk.ComboBox(model=listmodel) cell = Gtk.CellRendererText() self.stationSelector.pack_start(cell, False) self.stationSelector.add_attribute(cell, "text", 0) self.stationSelector.set_active(0) self.stationSelector.connect("changed", self.on_changed_station_selector) hbox.pack_start(self.stationSelector, True, True, 0)
def _build_target_widget(self): self.treestore = Gtk.TreeStore(str) iter_db = {} self.tree_list = {} for item in self._label(): iter = iter_db[item[2]] if item[2] != 0 else None iter_db[item[0]] = self.treestore.append(iter, [item[1]]) self.tree_list[str(item[1])] = iter_db[item[0]] self.target_widget = Gtk.ComboBox(model=self.treestore) self.target_widget.set_active(0) self._set_target_sensitive(_("_Tag:"), True) cell = Gtk.CellRendererText() self.target_widget.pack_start(cell, True) self.target_widget.add_attribute(cell, 'text', 0)
def __init__(self, adapter_name=None, orientation=Gtk.Orientation.VERTICAL, **kwargs): super().__init__(orientation=orientation, spacing=1, vexpand=True, width_request=360, height_request=340, name="DeviceSelectorWidget", **kwargs) self.List = DeviceSelectorList(adapter_name) if self.List.Adapter is not None: self.List.display_known_devices() self.List.Adapter.start_discovery() sw = Gtk.ScrolledWindow(hscrollbar_policy=Gtk.PolicyType.NEVER, vscrollbar_policy=Gtk.PolicyType.AUTOMATIC, shadow_type=Gtk.ShadowType.IN) sw.add(self.List) self.pack_start(sw, True, True, 0) # Disable overlay scrolling if Gtk.get_minor_version() >= 16: sw.props.overlay_scrolling = False model = Gtk.ListStore(str, str) cell = Gtk.CellRendererText() self.cb_adapters = Gtk.ComboBox(model=model, visible=True) self.cb_adapters.set_tooltip_text(_("Adapter selection")) self.cb_adapters.pack_start(cell, True) self.cb_adapters.add_attribute(cell, 'text', 0) spinner_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6, height_request=8) self.spinner = Gtk.Spinner(halign=Gtk.Align.START, hexpand=True, has_tooltip=True, tooltip_text="Discovering…", margin=6) spinner_box.add(self.cb_adapters) spinner_box.add(self.spinner) self.add(spinner_box) self.cb_adapters.connect("changed", self.on_adapter_selected) self.List.connect("adapter-changed", self.on_adapter_changed) self.List.connect("adapter-added", self.on_adapter_added) self.List.connect("adapter-removed", self.on_adapter_removed) self.List.connect("adapter-property-changed", self.on_adapter_prop_changed) self.update_adapters_list() self.show_all()
def __get_combobox(self, store, iter): """ @description: get the combobox of the toolbar @return: a Gtk.Combobox """ # the data in the model, of type string listmodel = Gtk.ListStore(str) # append the data in the model self.dic = {} self.dic[0] = _('time') listmodel.append([_('time')]) self.dic[1] = _('power') listmodel.append([_('power')]) self.dic[2] = _('clipboard') listmodel.append([_('clipboard')]) self.dic[3] = _('dictation mode') listmodel.append([_('dictation mode')]) self.dic[4] = _('exit dictation mode') listmodel.append([_('exit dictation mode')]) selected = 0 if iter is not None: for i in range(len(self.dic)): if self.dic[i] == store[iter][1]: selected = i # a combobox to see the data stored in the model combobox = Gtk.ComboBox(model=listmodel) combobox.set_tooltip_text(_("Which internal command to choose") + '?') # a cellrenderer to render the text cell = Gtk.CellRendererText() # pack the cell into the beginning of the combobox, allocating # no more space than needed combobox.pack_start(cell, False) # associate a property ("text") of the cellrenderer (cell) to a column (column 0) # in the model used by the combobox combobox.add_attribute(cell, "text", 0) # the first row is the active one by default at the beginning combobox.set_active(selected) return combobox
def __init__(self, size_group): super(ColorsWidget, self).__init__(dep_key=None) #gsettings self.settings = Gio.Settings("org.cinnamon.desktop.background") # settings widgets combo = Gtk.ComboBox() key = 'color-shading-type' value = self.settings.get_string(key) renderer_text = Gtk.CellRendererText() combo.pack_start(renderer_text, True) combo.add_attribute(renderer_text, "text", 1) model = Gtk.ListStore(str, str) combo.set_model(model) combo.set_id_column(0) for option in BACKGROUND_COLOR_SHADING_TYPES: iter = model.append([option[0], option[1]]) if value == option[0]: combo.set_active_iter(iter) combo.connect('changed', self.on_combo_changed, key) self.content_widget = Gtk.Box(valign=Gtk.Align.CENTER) self.content_widget.pack_start(combo, False, False, 2) # Primary color for key in ['primary-color', 'secondary-color']: color_button = Gtk.ColorButton() color_button.set_use_alpha(True) rgba = Gdk.RGBA() rgba.parse(self.settings.get_string(key)) color_button.set_rgba(rgba) color_button.connect('color-set', self.on_color_changed, key) self.content_widget.pack_start(color_button, False, False, 2) # Keep a ref on the second color button (so we can hide/show it when appropriate) self.color2_button = color_button self.color2_button.set_no_show_all(True) self.show_or_hide_color2(value) self.add_to_size_group(size_group) self.label = SettingsLabel(_("Background color")) self.pack_start(self.label, False, False, 0) self.pack_end(self.content_widget, False, False, 0)
def __init__(self, controller): super(ProfileSelector, self).__init__() self.controller = controller self.model = Gtk.ListStore(str, str) self.combo = Gtk.ComboBox() self.combo.set_model(self.model) render = Gtk.CellRendererText() self.combo.pack_start(render, True) self.combo.add_attribute(render, "text", 1) self.combo.set_id_column(0) self.pack_start(Gtk.Label(_("Output profile")), False, False, 0) button = Gtk.Button.new_with_label(_("Test sound")) self.pack_end(button, False, False, 0) self.pack_end(self.combo, False, False, 0) button.connect("clicked", self.testSpeakers) self.combo.connect("changed", self.onProfileSelect)
def __init__(self): super(Lpane_frameserial, self).__init__() self.set_label("Conexión Serial") self._grid = Gtk.Grid() self.add(self._grid) self._cbox_ports = Gtk.ComboBox() renderer_text = Gtk.CellRendererText() self._cbox_ports.pack_start(renderer_text, True) self._cbox_ports.add_attribute(renderer_text, "text", 0) self._cbox_ports.connect("changed", self._on_cbox_ports_changed) self._grid.attach(self._cbox_ports, 0, 0, 2, 1) self._btn_refresh = Gtk.Button() refresh_icon = Gio.ThemedIcon(name="view-refresh-symbolic") refresh_image = Gtk.Image.new_from_gicon(refresh_icon, Gtk.IconSize.BUTTON) self._btn_refresh.set_image(refresh_image) self._btn_refresh.connect("clicked", self._on_btn_refresh_clicked) self._grid.attach_next_to(self._btn_refresh, self._cbox_ports, Gtk.PositionType.RIGHT, 1, 1) self._switch_serial = Gtk.Switch() self._switch_serial.connect("notify::active", self._on_switch_serial_toggled) # self._switch_serial.set_halign(Gtk.Align.FILL) # self._switch_serial.set_hexpand(True) self._grid.attach(self._switch_serial, 0, 1, 3, 1) # self._grid.attach_next_to(self._switch_serial, self._cbox_ports, Gtk.PositionType.BOTTOM, 1, 1) # TODO: Serial connection configuration # self._btn_config = Gtk.Button() # config_icon = Gio.ThemedIcon(name="emblem-system-symbolic") # config_image = Gtk.Image.new_from_gicon(config_icon, # Gtk.IconSize.BUTTON) # self._btn_config.set_image(config_image) # self._grid.attach(self._btn_config, 2, 1, 1, 1) self._progress_bar = Gtk.ProgressBar(show_text=True) s = "T1: 0, T2: 0\nTOTAL: 0 \u2714" self._progress_bar.set_text(s) self._grid.attach(self._progress_bar, 0, 2, 3, 1)
def standard_combo(model, active_item=None, column=0, active_item_lookup=None, lookup_column=None, width=None): cb = Gtk.ComboBox(model=model) if active_item_lookup is not None: if lookup_column is None: lookup_column = column active_item = ls_index(model, active_item_lookup, lookup_column) if active_item is not None: cb.set_active(active_item) cell = Gtk.CellRendererText() if width is not None: cb.set_size_request(width, -1) cb.pack_start(cell, True) cb.add_attribute(cell, 'text', column) return cb