def on_app_options_changed(self, plugin_name): app = get_app() if plugin_name == app.name: data = app.get_data(app.name) if 'realtime_mode' in data: proxy = proxy_for(self.checkbutton_realtime_mode) proxy.set_widget_value(data['realtime_mode'])
def run(self): # Empty plugin form vbox # Get list of app option forms self.forms = emit_signal('get_app_form_class') self.form_views = {} self.clear_form() app = get_app() self.no_gui_names = set() for name, form in self.forms.iteritems(): # For each form, generate a pygtkhelpers formview and append the # view onto the end of the plugin vbox if form is None: schema_entries = [] else: # Only include fields that do not have show_in_gui set to False # in 'properties' dictionary schema_entries = [ f for f in form.field_schema if f.properties.get('show_in_gui', True) ] if not schema_entries: self.no_gui_names.add(name) continue gui_form = Form.of(*schema_entries) FormView.schema_type = gui_form self.form_views[name] = FormView() if name in app.core_plugins: self.core_plugins_vbox.pack_start(self.form_views[name].widget) self.frame_core_plugins.show() else: expander = gtk.Expander() expander.set_label(name) expander.set_expanded(True) expander.add(self.form_views[name].widget) self.plugin_form_vbox.pack_start(expander) for form_name, form in self.forms.iteritems(): if form_name in self.no_gui_names: continue form_view = self.form_views[form_name] values = self._get_app_values(form_name) fields = set(values.keys()).intersection(form_view.form.fields) for field in fields: value = values[field] proxy = proxy_for(getattr(form_view, field)) proxy.set_widget_value(value) form_field = form_view.form.fields[field] form_field.label_widget.set_text( re.sub(r'_', ' ', field).title()) self.dialog.show_all() response = self.dialog.run() if response == gtk.RESPONSE_OK: self.apply() elif response == gtk.RESPONSE_CANCEL: pass self.dialog.hide() return response
def __init__(self, element, widget, label_widget=None): self.element = element self.widget = widget self.proxy = proxy_for(widget) self.label_event_box = gtk.EventBox() self.label_widget = gtk.Label() self.label_event_box.add(self.label_widget) self.widget.set_data('pygtkhelpers::label_widget', self.label_widget)
def run(self): # Empty plugin form vbox # Get list of app option forms self.forms = emit_signal('get_app_form_class') self.form_views = {} self.clear_form() app = get_app() self.no_gui_names = set() for name, form in self.forms.iteritems(): # For each form, generate a pygtkhelpers formview and append the view # onto the end of the plugin vbox if form is None: schema_entries = [] else: # Only include fields that do not have show_in_gui set to False in # 'properties' dictionary schema_entries = [f for f in form.field_schema\ if f.properties.get('show_in_gui', True)] if not schema_entries: self.no_gui_names.add(name) continue gui_form = Form.of(*schema_entries) FormView.schema_type = gui_form self.form_views[name] = FormView() if name in app.core_plugins: self.core_plugins_vbox.pack_start(self.form_views[name].widget) self.frame_core_plugins.show() else: expander = gtk.Expander() expander.set_label(name) expander.set_expanded(True) expander.add(self.form_views[name].widget) self.plugin_form_vbox.pack_start(expander) for form_name, form in self.forms.iteritems(): if form_name in self.no_gui_names: continue form_view = self.form_views[form_name] values = self._get_app_values(form_name) fields = set(values.keys()).intersection(form_view.form.fields) for field in fields: value = values[field] proxy = proxy_for(getattr(form_view, field)) proxy.set_widget_value(value) form_field = form_view.form.fields[field] form_field.label_widget.set_text( re.sub(r'_', ' ', field).title()) self.dialog.show_all() response = self.dialog.run() if response == gtk.RESPONSE_OK: self.apply() elif response == gtk.RESPONSE_CANCEL: pass self.dialog.hide() return response
def on_app_options_changed(self, plugin_name): ''' .. versionchanged:: 2.11.2 Schedule label update asynchronously to occur in the main GTK loop. ''' app = get_app() if plugin_name == app.name: data = app.get_data(app.name) if 'realtime_mode' in data: proxy = proxy_for(self.checkbutton_realtime_mode) gobject.idle_add(proxy.set_widget_value, data['realtime_mode'])
def run(self, forms, initial_values=None): # Empty plugin form vbox # Get list of app option forms self.forms = forms self.form_views = {} self.clear_form() app = get_app() core_plugins_count = 0 for name, form in self.forms.iteritems(): # For each form, generate a pygtkhelpers formview and append the view # onto the end of the plugin vbox if len(form.field_schema) == 0: continue # Only include fields that do not have show_in_gui set to False in # 'properties' dictionary schema_entries = [f for f in form.field_schema\ if f.properties.get('show_in_gui', True)] gui_form = Form.of(*[Boolean.named(s.name).using(default=True, optional=True) for s in schema_entries]) FormView.schema_type = gui_form if not schema_entries: continue self.form_views[name] = FormView() if name in app.core_plugins: self.core_plugins_vbox.pack_start(self.form_views[name].widget) core_plugins_count += 1 else: expander = gtk.Expander() expander.set_label(name) expander.set_expanded(True) expander.add(self.form_views[name].widget) self.plugin_form_vbox.pack_start(expander) if core_plugins_count == 0: self.frame_core_plugins.hide() self.plugin_form_vbox.remove(self.frame_core_plugins) else: if not self.frame_core_plugins in self.plugin_form_vbox.children(): self.plugin_form_vbox.pack_start(self.frame_core_plugins) self.frame_core_plugins.show() if not initial_values: initial_values = {} for form_name, form in self.forms.iteritems(): if not form.field_schema: continue form_view = self.form_views[form_name] values = initial_values.get(form_name, {}) for name, field in form_view.form.fields.items(): if name in values or not initial_values: value = True else: value = False logger.debug('set %s to %s' % (name, value)) proxy = proxy_for(getattr(form_view, name)) proxy.set_widget_value(value) field.label_widget.set_text( re.sub(r'_', ' ', name).title()) self.dialog.show_all() response = self.dialog.run() if response == gtk.RESPONSE_OK: self.apply() elif response == gtk.RESPONSE_CANCEL: pass self.dialog.hide() return response
def create_ui(self): self.paste_location.set_choices(self.svc.get_pastebin_types(), None) self.paste_proxy = proxy_for(self.paste_location) self.syntax_proxy = proxy_for(self.paste_syntax)
def run(self, forms, initial_values=None): # Empty plugin form vbox # Get list of app option forms self.forms = forms self.form_views = {} self.clear_form() app = get_app() core_plugins_count = 0 for name, form in self.forms.iteritems(): # For each form, generate a pygtkhelpers formview and append the view # onto the end of the plugin vbox if len(form.field_schema) == 0: continue # Only include fields that do not have show_in_gui set to False in # 'properties' dictionary schema_entries = [f for f in form.field_schema\ if f.properties.get('show_in_gui', True)] gui_form = Form.of(*[ Boolean.named(s.name).using(default=True, optional=True) for s in schema_entries ]) FormView.schema_type = gui_form if not schema_entries: continue self.form_views[name] = FormView() if name in app.core_plugins: self.core_plugins_vbox.pack_start(self.form_views[name].widget) core_plugins_count += 1 else: expander = gtk.Expander() expander.set_label(name) expander.set_expanded(True) expander.add(self.form_views[name].widget) self.plugin_form_vbox.pack_start(expander) if core_plugins_count == 0: self.frame_core_plugins.hide() self.plugin_form_vbox.remove(self.frame_core_plugins) else: if not self.frame_core_plugins in self.plugin_form_vbox.children(): self.plugin_form_vbox.pack_start(self.frame_core_plugins) self.frame_core_plugins.show() if not initial_values: initial_values = {} for form_name, form in self.forms.iteritems(): if not form.field_schema: continue form_view = self.form_views[form_name] values = initial_values.get(form_name, {}) for name, field in form_view.form.fields.items(): if name in values or not initial_values: value = True else: value = False logger.debug('set %s to %s' % (name, value)) proxy = proxy_for(getattr(form_view, name)) proxy.set_widget_value(value) field.label_widget.set_text(re.sub(r'_', ' ', name).title()) self.dialog.show_all() response = self.dialog.run() if response == gtk.RESPONSE_OK: self.apply() elif response == gtk.RESPONSE_CANCEL: pass self.dialog.hide() return response