def __init__(self, label=''): """ Create a new BoolSearchFilter object. :param label: label of the search filter """ self._block_updates = False SearchFilter.__init__(self, label=label) self.button = ProxyCheckButton(label=label) self.button.connect('content-changed', self._on_button__content_changed) self.pack_start(self.button, False, False, 6) self.button.show() self.combo = False
def setup_slaves(self): settings = {} for setting in self.model.profile_settings: settings[setting.app_dir_name] = setting apps = get_utility(IApplicationDescriptions) for name, full_name, icon_name, description in apps.get_descriptions(): # Virtual apps should not be selected here if name in ProfileSettings.virtual_apps: continue # Create the user interface for each application which is # a HBox, a CheckButton and an Image box = Gtk.HBox() box.show() button = ProxyCheckButton() button.set_label(full_name) button.data_type = bool button.model_attribute = 'has_permission' button.show() box.pack_start(button, True, True, 6) image = Gtk.Image.new_from_stock(icon_name, Gtk.IconSize.MENU) box.pack_start(image, False, False, 0) image.show() self.applications_vbox.pack_start(box, False, True, 0) model = settings.get(name) if model is None: model = ProfileSettings(store=self.store, has_permission=False, app_dir_name=name, user_profile=self.model) setattr(self, name, button) self.add_proxy(model, [name]) # Scroll to the bottom of the scrolled window vadj = self.scrolled_window.get_vadjustment() vadj.set_value(vadj.get_upper())
def get_widget_for_type(rtype): if rtype is types.boolean: return ProxyCheckButton() elif rtype is types.file: w = ProxyFileChooserButton('Select File') #w.set_action(gtk.FILE_CHOOSER_ACTION_SAVE) return w elif rtype is types.readonlyfile: w = ProxyFileChooserButton('Select File') w.set_sensitive(False) #w.set_action(gtk.FILE_CHOOSER_ACTION_SAVE) return w elif rtype in [types.directory]: w = ProxyFileChooserButton(title='Select Directory') w.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER) return w elif rtype is types.font: return ProxyFontButton() elif rtype is types.color: return CleverProxyColorButton() elif rtype is types.integer: w = ProxySpinButton() return w elif rtype.__name__ is 'intrange': adjvals = rtype.lower, rtype.upper, rtype.step adj = gtk.Adjustment(0, *adjvals) w = ProxySpinButton() w.set_adjustment(adj) return w elif rtype is types.readonly: return FormattedLabel(VC_NAME_MU) elif rtype.__name__ is 'stringlist': w = ProxyComboBox() w.set_property('data-type', str) w.prefill(rtype.choices) return w else: w = ProxyEntry(data_type=str) w.set_width_chars(18) return w
def setup_slaves(self): settings = {} for setting in self.model.profile_settings: settings[setting.app_dir_name] = setting apps = get_utility(IApplicationDescriptions) for name, full_name, icon_name, description in apps.get_descriptions(): # Virtual apps should not be selected here if name in ProfileSettings.virtual_apps: continue # Create the user interface for each application which is # a HBox, a CheckButton and an Image box = gtk.HBox() box.show() button = ProxyCheckButton() button.set_label(full_name) button.data_type = bool button.model_attribute = 'has_permission' button.show() box.pack_start(button, padding=6) image = gtk.image_new_from_stock(icon_name, gtk.ICON_SIZE_MENU) box.pack_start(image, False, False) image.show() self.applications_vbox.pack_start(box, False) model = settings.get(name) if model is None: model = ProfileSettings(store=self.store, has_permission=False, app_dir_name=name, user_profile=self.model) setattr(self, name, button) self.add_proxy(model, [name]) # Scroll to the bottom of the scrolled window vadj = self.scrolled_window.get_vadjustment() vadj.set_value(vadj.upper)
class BoolSearchFilter(SearchFilter): """ - a checkbutton - a label """ __gtype_name__ = 'BoolSearchFilter' def __init__(self, label=''): """ Create a new BoolSearchFilter object. :param label: label of the search filter """ self._block_updates = False SearchFilter.__init__(self, label=label) self.button = ProxyCheckButton(label=label) self.button.connect('content-changed', self._on_button__content_changed) self.pack_start(self.button, False, False, 6) self.button.show() self.combo = False # # SearchFilter # def get_state(self): return BoolQueryState(filter=self, value=self.button.read()) def set_state(self, value): if isinstance(value, bool): self.button.set_active(value) elif value is None or value is ValueUnset: self.button.set_active(False) else: self.button.set_active(True) def get_title_label(self): return self.button.get_label() def get_description(self): return '%s: %s' % (self.get_label(), str(self.get_state())) def get_mode_combo(self): return None # # Public API # def check(self, data): self.button.set_active(True) def uncheck(self, data): self.button.set_active(False) # # Callbacks # def _on_button__content_changed(self, mode): if not self._block_updates: self.emit('changed')
def testForBool(self): myChkBtn = ProxyCheckButton() assert isinstance(myChkBtn, gtk.CheckButton)
def build_widget(self): widget = ProxyCheckButton(self.label) return widget
def testForBool(self): myChkBtn = ProxyCheckButton() self.assertEqual(myChkBtn.get_property("data-type"), 'bool')