def update_filter_page(self, index): name = str(self.cb_filter_group.itemText(index)) fr = engine.get_component("filter_rack") page = fr.get_page(name) layout = self.filter_rack_contents.layout() try: if get_app().user_options["filter_group"] is not None: cur_page = fr.get_page(get_app().user_options["filter_group"]) length = len(cur_page) # Clear the Layout while length > 0: i = layout.takeAt(1).widget() i.setParent(None) i.deleteLater() length -= 1 except: log.error("Error when cleaning the Rack UI", exc_info=True) get_app().user_options["filter_group"] = name # Add the filters contained in the filter page for f in page: self.add_filter_gui(f.fid, engine.get_plugin(f.fid)) self.update_filter_uis() self.lbl_page_in.setText(page.in_color) self.lbl_page_out.setText(page.out_color)
def add_filter_gui(self, pid, plugin): app = get_app() name = plugin.plugin_name info = [i[3] for i in engine.list_plugins() if i[1] == name][0] # Create the widget ui = FilterUI(pid, name, info["Title"], get_app().user_options["filter_group"]) layout = self.filter_rack_contents.layout() layout.insertWidget(layout.count() - 2, ui) self.update_filter_uis()
def actngroup_language_triggered(self, action): try: locale_str = str(action.property("locale_str").toString()) get_app().set_language(locale_str) except: log.exception("") QMessageBox.warning(None, tr("MainWindow", "Language Error"), tr("MainWindow", "Could not set the language to '%1', missing language file." ).arg(locale_str))
def __init__(self): app = None if __name__ != '__main__': from application import get_app app = get_app() self._brush = app.brush bm = app.brushmanager bm.brush_selected += self.brush_selected_cb else: self._brush = lib.brush.BrushInfo() self._brush.load_defaults() SubWindow.__init__(self, app, key_input=True) # Adjusters: may be shared those of the app self._base_adj = {} #: setting cname => base value adj self._input_y_adj = {} #: input name => scale y range (+-) adj self._input_xmin_adj = {} #: input name => scale x min adj self._input_xmax_adj = {} #: input name => scale x min adj self._disable_input_adj_changed_cb = False self._init_adjustments() self.set_title(C_( "brush settings editor: subwindow title", "Brush Settings Editor", )) self._setting = None self._builder = Gtk.Builder() self._build_ui() self.connect_after("show", self._post_show_cb) editor = self._builder.get_object("brush_editor") self.add(editor) self._brush.observers.append(self.brush_modified_cb) self._live_update_idle_cb_id = None self._updating_metadata_ui = False
def _init_from_accel_map(self): """Initializes from the app UIManager and the global AccelMap""" if self.ui_manager is None: import application app = application.get_app() self.ui_manager = app.ui_manager assert self.ui_manager is not None self._action_labels.clear() self._store.clear() accel_labels = {} for path, key, mods, changed in self._get_accel_map_entries(): accel_labels[path] = Gtk.accelerator_get_label(key, mods) for group in self.ui_manager.get_action_groups(): group_name = group.get_name() for action in group.list_actions(): action_name = action.get_name() path = "<Actions>/%s/%s" % (group_name, action_name) action_label = action.get_label() if not action_label: continue self._action_labels[path] = action_label accel_label = accel_labels.get(path) row = [None for t in self._COLUMN_TYPES] row[self._PATH_COLUMN] = path row[self._ACTION_LABEL_COLUMN] = action_label row[self._ACCEL_LABEL_COLUMN] = accel_label self._store.append(row)
def get_db(): global db if db == None: from application import get_app app = get_app() db = init_db(app) return db
def __init__(self): super(DrawWindow, self).__init__() import application app = application.get_app() self.app = app self.app.kbm.add_window(self) # Window handling self._updating_toggled_item = False self.is_fullscreen = False # Enable drag & drop if not gtk2compat.USE_GTK3: self.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, [("text/uri-list", 0, 1), ("application/x-color", 0, 2)], gtk.gdk.ACTION_DEFAULT|gtk.gdk.ACTION_COPY) # Connect events self.connect('delete-event', self.quit_cb) self.connect('key-press-event', self.key_press_event_cb) self.connect('key-release-event', self.key_release_event_cb) self.connect("drag-data-received", self.drag_data_received) self.connect("window-state-event", self.window_state_event_cb) # Deferred setup self._done_realize = False self.connect("realize", self._realize_cb) self.app.filehandler.current_file_observers.append(self.update_title)
def __init__(self): app = None if __name__ != '__main__': from application import get_app app = get_app() self._brush = app.brush bm = app.brushmanager bm.brush_selected += self.brush_selected_cb else: self._brush = lib.brush.BrushInfo() self._brush.load_defaults() SubWindow.__init__(self, app, key_input=False) # Adjusters: may be shared those of the app self._base_adj = {} #: setting cname => base value adj self._input_y_adj = {} #: input name => scale y range (+-) adj self._input_xmin_adj = {} #: input name => scale x min adj self._input_xmax_adj = {} #: input name => scale x min adj self._disable_input_adj_changed_cb = False self._init_adjustments() self.set_title("Brush Settings Editor") self._setting = None self._builder = Gtk.Builder() self._build_ui() self.connect_after("show", self._post_show_cb) editor = self._builder.get_object("brush_editor") self.add(editor) self._brush.observers.append(self.brush_modified_cb) self._live_update_idle_cb_id = None GObject.idle_add(self._update_brush_header)
def __init__(self): """Initialize, called by the LayerMode FactoryAction making a menu""" Gtk.ImageMenuItem.__init__(self) menu = Gtk.Menu() self._menu_items = [] prev_item = None spec_separator = (None,) modes_menu_spec = ( lib.layer.STACK_MODES + spec_separator + lib.layer.STANDARD_MODES) for mode in modes_menu_spec: if mode is None: menu.append(Gtk.SeparatorMenuItem()) continue label, tooltip = lib.layer.MODE_STRINGS.get(mode) if prev_item is None: item = Gtk.RadioMenuItem() else: item = Gtk.RadioMenuItem(group=prev_item) item.set_label(label) item.set_tooltip_text(tooltip) item.connect("activate", self._item_activated_cb, mode) menu.append(item) self._menu_items.append((mode, item)) prev_item = item self._submenu = menu self.set_submenu(self._submenu) self._submenu.show_all() from application import get_app app = get_app() self._model = app.doc.model rootstack = self._model.layer_stack rootstack.layer_properties_changed += self._update_actions rootstack.current_path_updated += self._update_actions self._updating = False self._update_actions()
def __init__(self): """Initialize, called by the LayerMode FactoryAction making a menu""" Gtk.ImageMenuItem.__init__(self) menu = Gtk.Menu() self._menu_items = [] prev_item = None for mode in range(NUM_COMBINE_MODES): label, tooltip = COMBINE_MODE_STRINGS.get(mode) if prev_item is None: item = Gtk.RadioMenuItem() else: item = Gtk.RadioMenuItem(group=prev_item) item.set_label(label) item.set_tooltip_text(tooltip) item.connect("activate", self._item_activated_cb, mode) menu.append(item) self._menu_items.append((mode, item)) prev_item = item self._submenu = menu self.set_submenu(self._submenu) self._submenu.show_all() from application import get_app app = get_app() self._model = app.doc.model rootstack = self._model.layer_stack rootstack.layer_properties_changed += self._update_actions rootstack.current_path_updated += self._update_actions self._updating = False self._update_actions()
def __init__(self): super(SymmetryEditOptionsWidget, self).__init__( xalign=0.5, yalign=0.5, xscale=1.0, yscale=1.0, ) self._axis_pos_dialog = None self._axis_pos_button = None from application import get_app self.app = get_app() rootstack = self.app.doc.model.layer_stack self._axis_pos_adj = Gtk.Adjustment( rootstack.symmetry_axis, upper=32000, lower=-32000, step_incr=1, page_incr=100, ) self._axis_pos_adj.connect( 'value-changed', self._axis_pos_adj_changed, ) self._init_ui() rootstack.symmetry_state_changed += self._symmetry_state_changed_cb self._update_axis_pos_button_label(rootstack.symmetry_axis)
def __init__(self): super(DrawWindow, self).__init__() import application app = application.get_app() self.app = app self.app.kbm.add_window(self) # Window handling self._updating_toggled_item = False self.is_fullscreen = False # Enable drag & drop if not gtk2compat.USE_GTK3: self.drag_dest_set( gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, [("text/uri-list", 0, 1), ("application/x-color", 0, 2)], gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_COPY) # Connect events self.connect('delete-event', self.quit_cb) self.connect('key-press-event', self.key_press_event_cb) self.connect('key-release-event', self.key_release_event_cb) self.connect("drag-data-received", self.drag_data_received) self.connect("window-state-event", self.window_state_event_cb) # Deferred setup self._done_realize = False self.connect("realize", self._realize_cb) self.app.filehandler.current_file_observers.append(self.update_title)
def _update_gui(self, pos=0): mw = get_app().get_ui("main_window") vs = engine.get_component("video_source") mw.frm_playback.setEnabled(True) mw.scb_pos.setRange(0, vs.get_length() - 1) mw.lbl_total.setText(self._format_pos(mw.scb_pos.maximum(), vs.get_fps()))
def __init__(self): Gtk.Alignment.__init__(self, 0.5, 0.5, 1.0, 1.0) from application import get_app self.app = get_app() self.callbacks_active = False docmodel = self.app.doc.model x, y, w, h = docmodel.get_frame() dpi = docmodel.get_resolution() self.width_adj = UnitAdjustment(w, upper=32000, lower=1, step_incr=1, page_incr=128, dpi=dpi) self.height_adj = UnitAdjustment(h, upper=32000, lower=1, step_incr=1, page_incr=128, dpi=dpi) self.dpi_adj = Gtk.Adjustment(dpi, upper=9600, lower=1, step_incr=76, page_incr=dpi) # hack: 3 clicks 72->300 docmodel.frame_updated += self._frame_updated_cb self._init_ui() self.width_adj.connect("value-changed", self.on_size_adjustment_changed) self.height_adj.connect("value-changed", self.on_size_adjustment_changed) self.dpi_adj.connect("value-changed", self.on_dpi_adjustment_changed) self._update_size_button()
def __init__(self): from application import get_app self.app = get_app() CurveWidget.__init__(self, npoints=4, ylockgroups=((1, 2),), changed_cb=self._changed_cb) self.app.line_mode_settings.observers.append(self._adjs_changed_cb) self._update()
def __init__(self): super(DrawWindow, self).__init__() import application app = application.get_app() self.app = app self.app.kbm.add_window(self) # Window handling self._updating_toggled_item = False self.is_fullscreen = False # Enable drag & drop drag_targets = [ Gtk.TargetEntry.new("text/uri-list", 0, 1), Gtk.TargetEntry.new("application/x-color", 0, 2), ] drag_flags = (Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP) drag_actions = Gdk.DragAction.DEFAULT | Gdk.DragAction.COPY self.drag_dest_set(drag_flags, drag_targets, drag_actions) # Connect events self.connect('delete-event', self.quit_cb) self.connect('key-press-event', self.key_press_event_cb) self.connect('key-release-event', self.key_release_event_cb) self.connect("drag-data-received", self._drag_data_received_cb) self.connect("window-state-event", self.window_state_event_cb) # Deferred setup self._done_realize = False self.connect("realize", self._realize_cb) self.app.filehandler.current_file_observers.append(self.update_title)
def __init__(self): """Construct a tool widget with subwidgets from self.PAGE_CLASS.""" # Superclass setup Gtk.VBox.__init__(self) self.set_spacing(3) self.set_border_width(3) # Fields for Workspace's use self.tool_widget_icon_name = self.PAGE_CLASS.get_page_icon_name() self.tool_widget_title = self.PAGE_CLASS.get_page_title() self.tool_widget_description = self.PAGE_CLASS.get_page_description() # Main adjuster widget page = self.PAGE_CLASS() page_widget = page.get_page_widget() self.pack_start(page_widget, True, True, 0) self._adjusters = [] self._adjusters.append(page) # Properties button properties_desc = self.PAGE_CLASS.get_properties_description() if properties_desc is not None: show_props = lambda *a: page.show_properties() self.tool_widget_properties = show_props # Adjuster setup from application import get_app self._app = get_app() self.set_color_manager(self._app.brush_color_manager) # Sizing. size = workspace.TOOL_WIDGET_MIN_WIDTH self.set_size_request(size, size * 0.9)
def _new_color_adjusters_menu(): from application import get_app app = get_app() menu = Gtk.Menu() action_names = [ "HCYWheelTool", "HSVWheelTool", "PaletteTool", "HSVSquareTool", "HSVCubeTool", "ComponentSlidersTool", None, "CrossedBowlColorChangerTool", "WashColorChangerTool", "RingsColorChangerTool", ] for an in action_names: if an is None: item = Gtk.SeparatorMenuItem() else: action = app.find_action(an) item = Gtk.MenuItem() item.set_use_action_appearance(True) item.set_related_action(action) menu.append(item) return menu
def __init__(self): """Construct a tool widget with subwidgets from self.PAGE_CLASS.""" # Superclass setup Gtk.VBox.__init__(self) self.set_spacing(3) self.set_border_width(3) # Fields for Workspace's use self.tool_widget_icon_name = self.PAGE_CLASS.get_page_icon_name() self.tool_widget_title = self.PAGE_CLASS.get_page_title() self.tool_widget_description = self.PAGE_CLASS.get_page_description() # Main adjuster widget page = self.PAGE_CLASS() page_widget = page.get_page_widget() self.pack_start(page_widget, True, True) self._adjusters = [] self._adjusters.append(page) # Properties button properties_desc = self.PAGE_CLASS.get_properties_description() if properties_desc is not None: show_props = lambda *a: page.show_properties() self.tool_widget_properties = show_props # Adjuster setup from application import get_app self._app = get_app() self.set_color_manager(self._app.brush_color_manager) # Sizing. size = workspace.TOOL_WIDGET_MIN_WIDTH self.set_size_request(size, size*0.9)
def __init__(self): """Construct, and connect internal signals & callbacks""" workspace.SizedVBoxToolWidget.__init__(self) from application import get_app self._app = get_app() self._app.doc.modes.changed += self._modestack_changed_cb self.set_border_width(3) self.set_spacing(6) # Placeholder in case a mode has no options label = Gtk.Label() label.set_markup(self.NO_OPTIONS_MARKUP) self._no_options_label = label # Container for an options widget exposed by the current mode self._mode_icon = Gtk.Image() label = Gtk.Label() label.set_text("<options-label>") self._options_label = label label.set_alignment(0.0, 0.5) label_hbox = Gtk.HBox() label_hbox.set_spacing(3) label_hbox.set_border_width(3) label_hbox.pack_start(self._mode_icon, False, False) label_hbox.pack_start(self._options_label, True, True) align = Gtk.Alignment(0.5, 0.5, 1.0, 1.0) align.set_padding(0, 0, 0, 0) align.set_border_width(3) self._options_bin = align self.pack_start(label_hbox, False, False, 0) self.pack_start(align, True, True, 0) self.connect("show", lambda *a: self._update_ui())
def __init__(self): gtk.Alignment.__init__(self, 0.5, 0.5, 1.0, 1.0) from application import get_app self.app = get_app() self.callbacks_active = False x, y, w, h = self.app.doc.model.get_frame() dpi = self.app.doc.model.get_resolution() self.width_adj = UnitAdjustment(w, upper=32000, lower=1, step_incr=1, page_incr=128, dpi=dpi) self.height_adj = UnitAdjustment(h, upper=32000, lower=1, step_incr=1, page_incr=128, dpi=dpi) self.dpi_adj = gtk.Adjustment(dpi, upper=9600, lower=1, step_incr=76, # hack: 3 clicks 72->300 page_incr=dpi) self.unit_label = gtk.Label(_('px')) self.unit_label.set_alignment(0, 0.5) self.app.doc.model.frame_observers.append(self.on_frame_changed) self._init_ui() self.width_adj.connect('value-changed', self.on_size_adjustment_changed) self.height_adj.connect('value-changed', self.on_size_adjustment_changed) self.dpi_adj.connect('value-changed', self.on_dpi_adjustment_changed) self._update_size_button()
def __init__(self): """Construct, and connect internal signals & observers""" workspace.SizedVBoxToolWidget.__init__(self) from application import get_app self._app = get_app() self._app.doc.modes.observers.append(self._mode_changed_cb) self.set_border_width(3) self.set_spacing(6) # Placeholder in case a mode has no options label = Gtk.Label() label.set_markup(self.NO_OPTIONS_MARKUP) self._no_options_label = label # Container for an options widget exposed by the current mode self._mode_icon = Gtk.Image() label = Gtk.Label() label.set_text("<options-label>") self._options_label = label label.set_alignment(0.0, 0.5) label_hbox = Gtk.HBox() label_hbox.set_spacing(3) label_hbox.set_border_width(3) label_hbox.pack_start(self._mode_icon, False, False) label_hbox.pack_start(self._options_label, True, True) align = Gtk.Alignment(0.5, 0.5, 1.0, 1.0) align.set_padding(0, 0, 0, 0) align.set_border_width(3) self._options_bin = align self.pack_start(label_hbox, False, False, 0) self.pack_start(align, True, True, 0) self.connect("show", lambda *a: self._update_ui())
def __init__(self): widgets.MenuButtonToolItem.__init__(self) from application import get_app app = get_app() menu = Gtk.Menu() action_names = [ "HCYWheelTool", "HSVWheelTool", "PaletteTool", "HSVTriangleTool", "HSVSquareTool", "HSVCubeTool", "ComponentSlidersTool", None, "CrossedBowlColorChangerTool", "WashColorChangerTool", "RingsColorChangerTool", ] for an in action_names: if an is None: item = Gtk.SeparatorMenuItem() else: action = app.find_action(an) item = Gtk.MenuItem() item.set_use_action_appearance(True) item.set_related_action(action) menu.append(item) self.menu = menu
def __init__(self): super(DrawWindow, self).__init__() import application app = application.get_app() self.app = app self.app.kbm.add_window(self) # Window handling self._updating_toggled_item = False self.is_fullscreen = False # Enable drag & drop drag_targets = [ Gtk.TargetEntry.new("text/uri-list", 0, 1), Gtk.TargetEntry.new("application/x-color", 0, 2) ] drag_flags = (Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP) drag_actions = Gdk.DragAction.DEFAULT | Gdk.DragAction.COPY self.drag_dest_set(drag_flags, drag_targets, drag_actions) # Connect events self.connect('delete-event', self.quit_cb) self.connect("drag-data-received", self._drag_data_received_cb) self.connect("window-state-event", self.window_state_event_cb) # Deferred setup self._done_realize = False self.connect("realize", self._realize_cb) self.app.filehandler.current_file_observers.append(self.update_title) # Named quick chooser instances self._quick_choosers = {}
def __init__(self): import application app = application.get_app() assert app is not None super(PreferencesWindow, self).__init__( app=app, title=_('Preferences'), transient_for=app.drawWindow, destroy_with_parent=True, ) self.add_buttons( Gtk.STOCK_REVERT_TO_SAVED, RESPONSE_REVERT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT, ) self.connect('response', self.on_response) self.in_update_ui = False # Set up widgets builder = Gtk.Builder() builder.set_translation_domain("mypaint") ui_dir = os.path.dirname(os.path.abspath(__file__)) xml_path = os.path.join(ui_dir, 'preferenceswindow.glade') builder.add_from_file(xml_path) self._builder = builder getobj = builder.get_object # Notebook nb = getobj("prefs_notebook") self.nb = nb self.vbox.pack_start(nb, True, True, 0) # Curve init curve = getobj("mapping_curve") curve.changed_cb = self.pressure_curve_changed_cb curve.magnetic = False self._pressure_curve = curve # Button mappings editor assert "input.button_mapping" in app.preferences reg = gui.mode.ModeRegistry actions_possible = [n for n in reg.get_action_names() if issubclass(reg.get_mode_class(n), gui.mode.DragMode)] actions_possible += gui.mode.BUTTON_BINDING_ACTIONS bm_ed = getobj("button_mapping_editor") bm_ed.set_bindings(app.preferences["input.button_mapping"]) bm_ed.set_actions(actions_possible) bm_ed.bindings_observers.append(self.button_mapping_edited_cb) # Autosave controls autosave_interval_spinbut = getobj("autosave_interval_spinbutton") self._autosave_interval_spinbutton = autosave_interval_spinbut # Signal hookup now everything is in the right initial state self._builder.connect_signals(self)
def __init__(self): Gtk.VBox.__init__(self) from application import get_app app = get_app() color_hist_view = ColorHistoryView(app) self.pack_start(color_hist_view, True, False, 0) brush_hist_view = BrushHistoryView(app) self.pack_start(brush_hist_view, True, False, 0)
def __init__(self): super(_SimpleAdjusterAdapter, self).__init__() adjuster = self.ADJUSTER_CLASS() from application import get_app self._app = get_app() adjuster.set_color_manager(self._app.brush_color_manager) self.pack_start(adjuster, True, True) self._adjuster = adjuster
def actngroup_preview_source_triggered(self, action): app = get_app() if action is self.actn_raw: app.user_options["preview_source"] = app.OPT_PREVIEW_RAW elif action is self.actn_post_analysis: app.user_options["preview_source"] = app.OPT_PREVIEW_POST_ANALYSIS elif action is self.actn_filter_page: app.user_options["preview_source"] = app.OPT_PREVIEW_FILTER_PAGE
def __init__(self): gtk.VBox.__init__(self) app = get_app() self.app = app self.bm = app.brushmanager self.group_widgets = {} self.update() self.bm.groups_observers.append(self.groups_modified_cb)
def _get_icon_size(): from application import get_app app = get_app() size = str(app.preferences.get("ui.toolbar_icon_size", "large")).lower() if size == 'small': return widgets.ICON_SIZE_SMALL else: return widgets.ICON_SIZE_LARGE
def __init__(self): super(_SimpleAdjusterAdapter, self).__init__() adjuster = self.ADJUSTER_CLASS() from application import get_app self._app = get_app() adjuster.set_color_manager(self._app.brush_color_manager) self.pack_start(adjuster, True, True, 0) self._adjuster = adjuster
def prompt_filter_plugin(self, checked): ret, selected = PluginDialog.select_type(engine.PLUGIN_TYPE_FILTER) app = get_app() vs = engine.get_component("video_source") fs = engine.get_component("frame_stream") if ret: try: pid, plugin = engine.load_plugin(selected) engine.get_component("filter_rack").get_page(get_app().user_options["filter_group"]).add(pid) # Create the GUI self.add_filter_gui(pid, plugin) except: log.exception("") QMessageBox.warning(None, tr("MainWindow", "Plugin Load Error"), tr("MainWindow", "Got an error when trying to load the filter plugin")) return
def __init__(self): gtk.ToolItem.__init__(self) self.history_images = [] self.main_image = ManagedBrushPreview() self.dropdown_button = dropdownpanel.DropdownPanelButton(self.main_image) self.app = None self.image_size = ToolbarManager.icon_size self.connect("toolbar-reconfigured", self.on_toolbar_reconf) self.connect("create-menu-proxy", lambda *a: True) self.set_tooltip_text(_("Brush history etc.")) self.add(self.dropdown_button) from application import get_app app = get_app() self.app = app bm = self.app.brushmanager bm.brush_selected += self.on_brush_selected self.app.doc.input_stroke_ended_observers\ .append(self.doc_input_stroke_ended_cb) self.update_history_images() panel_frame = gtk.Frame() panel_frame.set_shadow_type(gtk.SHADOW_OUT) self.dropdown_button.set_property("panel-widget", panel_frame) panel_vbox = gtk.VBox() panel_vbox.set_spacing(widgets.SPACING_TIGHT) panel_vbox.set_border_width(widgets.SPACING) panel_frame.add(panel_vbox) # Quick brush changer section_frame = widgets.section_frame(_("Change Brush")) panel_vbox.pack_start(section_frame, True, True) section_vbox = gtk.VBox() section_vbox.set_border_width(widgets.SPACING) section_vbox.set_spacing(widgets.SPACING_TIGHT) section_frame.add(section_vbox) quick_changer = dialogs.QuickBrushChooser(app, self.on_quick_change_select) evbox = gtk.EventBox() evbox.add(quick_changer) section_vbox.pack_start(evbox, True, True) # List editor button # FIXME: perhaps list out the brush groups now? # Brush history section_frame = widgets.section_frame(_("Recently Used")) panel_vbox.pack_start(section_frame, True, True) history_hbox = gtk.HBox() history_hbox.set_border_width(widgets.SPACING) section_frame.add(history_hbox) for i, image in enumerate(self.history_images): button = widgets.borderless_button() button.add(image) button.connect("clicked", self.on_history_button_clicked, i) history_hbox.pack_end(button, True, True)
def show_parameters(self): """Make sure that the widget_parameters is visible. """ mainwindow = get_app().get_ui("main_window") # If the widget_parameters is not in the tools tab, add it i = mainwindow.toolstab.indexOf(self._widget_parameters) if i == -1: mainwindow.toolstab.addTab(self._widget_parameters, "Parameters")
def remove_main_tab(self, name): app = get_app() pid = self._plugin_id mainwindow = app.get_ui("main_window") ui = app.get_plugin_ui(pid, name) self.maintab_names.discard(name) mainwindow.maintab.removeTab(mainwindow.maintab.indexOf(ui))
def __init__(self): from application import get_app app = get_app() self._app = app windowing.SubWindow.__init__(self, app) self._editor = BrushIconEditor() self._editor.mode_changed += self._editor_mode_changed self.add(self._editor) self.set_title(self._TITLE_PREVIEWING)
def __init__(self): from application import get_app app = get_app() super(InputTestWindow, self).__init__(app) self.last_selected_brush = None self.set_title(_('Input Device Test')) self.set_role('Test') self.connect('map', self.map_cb) self.connect('unmap', self.unmap_cb) self._timer_id = 0 self.motion_reports = [] self.motion_event_counter = 0 self.motion_dtime_sample = [] self.last_device = None self.last_motion_time = 0 #main container vbox = Gtk.VBox() self.add(vbox) table = Gtk.Table(2, 4) vbox.pack_start(table, False, True, 0) def add(row, name, value_widget): l1 = Gtk.Label(name) l1.set_justify(Gtk.Justification.LEFT) l1.set_alignment(0.0, 0.5) l2 = value_widget l2.set_alignment(0.0, 0.5) table.attach(l1, 0, 1, row, row + 1, Gtk.AttachOptions.FILL, 0, 5, 0) table.attach(l2, 1, 2, row, row + 1, Gtk.AttachOptions.FILL, 0, 5, 0) l = self.pressure_label = Gtk.Label(_('(no pressure)')) add(0, _('Pressure:'), l) l = self.tilt_label = Gtk.Label(_('(no tilt)')) add(1, _('Tilt:'), l) l = self.motion_event_counter_label = Gtk.Label() add(2, 'Motion:', l) l = self.device_label = Gtk.Label(_('(no device)')) add(3, _('Device:'), l) vbox.pack_start(Gtk.HSeparator(), False, False, 0) tv = self.tv = Gtk.TextView() tv.set_editable(False) tv.modify_font(Pango.FontDescription("Monospace")) tv.set_cursor_visible(False) vbox.pack_start(tv, True, True, 0) self.log = []
def add_main_tab(self, name, title): app = get_app() pid = self._plugin_id mainwindow = app.get_ui("main_window") if name not in self.maintab_names: ui = app.get_plugin_ui(pid, name) mainwindow.maintab.addTab(ui, title) self.maintab_names.add(name)
def __init__(self): gtk.ToolItem.__init__(self) self.set_homogeneous(False) self.button_image = gtk.Image() self.button_image.set_from_icon_name('mypaint-line-mode', ToolbarManager.icon_size) self.line_mode_panel = dropdownpanel.DropdownPanelButton( self.button_image) self.vbox = gtk.VBox() self.vbox.set_border_width(widgets.SPACING_TIGHT) self.vbox.set_spacing(widgets.SPACING_TIGHT) frame = gtk.Frame() frame.add(self.vbox) frame.set_shadow_type(gtk.SHADOW_OUT) self.line_mode_panel.set_property("panel-widget", frame) self.add(self.line_mode_panel) self.connect("create-menu-proxy", lambda *a: True) from application import get_app app = get_app() self.app = app # Action switcher buttons bbox = gtk.HButtonBox() frame = widgets.section_frame(_("Line Mode")) frame.add(bbox) bbox.set_border_width(widgets.SPACING) for action_name in self.action_names: action = app.find_action(action_name) if action.get_active(): self.update_icon_from_action(action) action.connect("changed", self.linemode_action_changed_cb) button = gtk.ToggleButton() button.set_related_action(action) button.connect("clicked", self.linemode_button_clicked_cb) button.set_can_focus(False) button.set_can_default(False) button.set_image_position(gtk.POS_TOP) button.set_relief(gtk.RELIEF_HALF) image = action.create_icon(gtk.ICON_SIZE_LARGE_TOOLBAR) image.set_padding(widgets.SPACING_TIGHT, widgets.SPACING_TIGHT) button.set_image(image) bbox.pack_start(button) self.vbox.pack_start(frame, False, False) bbox.show() # Pressure settings. frame = widgets.section_frame(_("Line Pressure")) self.vbox.pack_start(frame, True, True) curve = LineModeCurveWidget() curve_align = gtk.Alignment(0, 0, 1, 1) curve_align.add(curve) curve_align.set_padding(widgets.SPACING, widgets.SPACING, widgets.SPACING, widgets.SPACING) frame.add(curve_align) curve_align.show()
def __init__(self): gtk.Grid.__init__(self) self.set_row_spacing(6) self.set_column_spacing(6) from application import get_app self.app = get_app() self.adjustable_settings = set() #: What the reset button resets row = self.init_common_widgets(0) row = self.init_specialized_widgets(row) row = self.init_reset_widgets(row)
def __init__(self): import application app = application.get_app() assert app is not None flags = gtk.DIALOG_DESTROY_WITH_PARENT buttons = (gtk.STOCK_REVERT_TO_SAVED, RESPONSE_REVERT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT) windowing.Dialog.__init__(self, app=app, title=_('Preferences'), parent=app.drawWindow, flags=flags, buttons=buttons) self.connect('response', self.on_response) self.in_update_ui = False # Set up widgets builder = gtk.Builder() xml_path = os.path.join(app.datapath, 'gui/preferenceswindow.glade') builder.add_from_file(xml_path) self._builder = builder getobj = builder.get_object # Notebook nb = getobj("prefs_notebook") self.nb = nb self.vbox.pack_start(nb, expand=True, padding=0) # Curve init curve = getobj("mapping_curve") curve.changed_cb = self.pressure_curve_changed_cb curve.magnetic = False self._pressure_curve = curve # Button mappings editor assert "input.button_mapping" in app.preferences reg = gui.mode.ModeRegistry actions_possible = [ n for n in reg.get_action_names() if issubclass(reg.get_mode_class(n), gui.mode.DragMode) ] actions_possible += gui.mode.BUTTON_BINDING_ACTIONS bm_ed = getobj("button_mapping_editor") bm_ed.set_bindings(app.preferences["input.button_mapping"]) bm_ed.set_actions(actions_possible) bm_ed.bindings_observers.append(self.button_mapping_edited_cb) # Autosave controls autosave_interval_spinbut = getobj("autosave_interval_spinbutton") self._autosave_interval_spinbutton = autosave_interval_spinbut # Signal hookup now everything is in the right initial state self._builder.connect_signals(self)
def __init__(self): import application app = application.get_app() assert app is not None flags = Gtk.DialogFlags.DESTROY_WITH_PARENT buttons = [ _('Save as Default'), RESPONSE_SAVE_AS_DEFAULT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT, ] windowing.Dialog.__init__( self, app=app, title=_('Background'), parent=app.drawWindow, flags=flags, buttons=buttons, ) #set up window self.connect('response', self._response_cb) notebook = self.nb = Gtk.Notebook() self.vbox.pack_start(notebook) #set up patterns tab patterns_scroll = Gtk.ScrolledWindow() patterns_scroll.set_policy( Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC, ) notebook.append_page(patterns_scroll, Gtk.Label(_('Pattern'))) self.bgl = BackgroundList(self) patterns_scroll.add_with_viewport(self.bgl) def lazy_init(*ignored): if not self.bgl.initialized: self.bgl.initialize() self.connect("realize", lazy_init) #set up colors tab color_vbox = Gtk.VBox() notebook.append_page(color_vbox, Gtk.Label(_('Color'))) self.cs = Gtk.ColorSelection() self.cs.connect('color-changed', self._color_changed_cb) color_vbox.pack_start(self.cs, expand=True) b = Gtk.Button(_('Add color to Patterns')) b.connect('clicked', self._add_color_to_patterns_cb) color_vbox.pack_start(b, expand=False)
def __init__(self): super(SymmetryEditOptionsWidget, self).__init__( xalign=0.5, yalign=0.5, xscale=1.0, yscale=1.0, ) self._axis_pos_x_dialog = None self._axis_pos_x_button = None self._axis_pos_y_dialog = None self._axis_pos_y_button = None self._symmetry_type_combo = None self._axis_rot_sym_lines_entry = None from application import get_app self.app = get_app() rootstack = self.app.doc.model.layer_stack self._axis_pos_adj_x = Gtk.Adjustment( rootstack.symmetry_x, upper=32000, lower=-32000, step_incr=1, page_incr=100, ) self._axis_pos_adj_x.connect( 'value-changed', self._axis_pos_adj_x_changed, ) self._axis_pos_adj_y = Gtk.Adjustment( rootstack.symmetry_y, upper=32000, lower=-32000, step_incr=1, page_incr=100, ) self._axis_pos_adj_y.connect( 'value-changed', self._axis_pos_adj_y_changed, ) self._axis_rot_symmetry_lines = Gtk.Adjustment( rootstack.rot_symmetry_lines, upper=50, lower=2, step_incr=1, page_incr=3, ) self._axis_rot_symmetry_lines.connect( 'value-changed', self._axis_rot_symmetry_lines_changed, ) self._init_ui() rootstack.symmetry_state_changed += self._symmetry_state_changed_cb self._update_axis_pos_x_button_label(rootstack.symmetry_x) self._update_axis_pos_y_button_label(rootstack.symmetry_y)
def __init__(self): gtk.ToolItem.__init__(self) self.history_images = [] self.main_image = ManagedBrushPreview() self.dropdown_button = dropdownpanel.DropdownPanelButton( self.main_image) self.app = None self.image_size = ToolbarManager.icon_size self.connect("toolbar-reconfigured", self._toolbar_reconf_cb) self.connect("create-menu-proxy", lambda *a: True) self.set_tooltip_text(_("Brush history etc.")) self.add(self.dropdown_button) from application import get_app app = get_app() self.app = app bm = self.app.brushmanager bm.brush_selected += self._brush_selected_cb panel_frame = gtk.Frame() panel_frame.set_shadow_type(gtk.SHADOW_OUT) self.dropdown_button.set_property("panel-widget", panel_frame) panel_vbox = gtk.VBox() panel_vbox.set_spacing(widgets.SPACING_TIGHT) panel_vbox.set_border_width(widgets.SPACING) panel_frame.add(panel_vbox) # Quick brush changer section_frame = widgets.section_frame(_("Change Brush")) panel_vbox.pack_start(section_frame, True, True) section_vbox = gtk.VBox() section_vbox.set_border_width(widgets.SPACING) section_vbox.set_spacing(widgets.SPACING_TIGHT) section_frame.add(section_vbox) quick_changer = dialogs.QuickBrushChooser(app, self._quick_change_select_cb) evbox = gtk.EventBox() evbox.add(quick_changer) section_vbox.pack_start(evbox, True, True) # List editor button # FIXME: perhaps list out the brush groups now? # Brush history section_frame = widgets.section_frame(_("Recently Used")) panel_vbox.pack_start(section_frame, True, True) history = BrushHistoryView(app) history.set_border_width(widgets.SPACING) history.button_clicked += self._history_button_clicked_cb section_frame.add(history)
def __init__(self): from application import get_app app = get_app() windowing.SubWindow.__init__(self, app) self.last_selected_brush = None self.set_title(_('Input Device Test')) self.set_role('Test') self.connect('map-event', self.map_cb) self.initialized = False self.motion_reports = [] self.motion_event_counter = 0 self.motion_dtime_sample = [] self.last_device = None self.last_motion_time = 0 #main container vbox = gtk.VBox() self.add(vbox) table = gtk.Table(2, 4) vbox.pack_start(table, expand=False, fill=True) def add(row, name, value_widget): l1 = gtk.Label(name) l1.set_justify(gtk.JUSTIFY_LEFT) l1.set_alignment(0.0, 0.5) l2 = value_widget l2.set_alignment(0.0, 0.5) table.attach(l1, 0, 1, row, row+1, gtk.FILL, 0, 5, 0) table.attach(l2, 1, 2, row, row+1, gtk.FILL, 0, 5, 0) l = self.pressure_label = gtk.Label(_('(no pressure)')) add(0, _('Pressure:'), l) l = self.tilt_label = gtk.Label(_('(no tilt)')) add(1, _('Tilt:'), l) l = self.motion_event_counter_label = gtk.Label() add(2, 'Motion:', l) l = self.device_label = gtk.Label(_('(no device)')) add(3, _('Device:'), l) vbox.pack_start(gtk.HSeparator(), expand=False, fill=False) tv = self.tv = gtk.TextView() tv.set_editable(False) tv.modify_font(pango.FontDescription("Monospace")) tv.set_cursor_visible(False) vbox.pack_start(tv, expand=True, fill=True) self.log = []
def __init__(self, idle_redraw_priority=None): """Instantiate a TiledDrawWidget. """ gtk.EventBox.__init__(self) if __name__ == '__main__': app = None else: import application app = application.get_app() self.app = app self.doc = None self.add_events( gdk.POINTER_MOTION_MASK # Workaround for https://gna.org/bugs/index.php?16253 # Mypaint doesn't use proximity-*-event for anything # yet, but this seems to be needed for scrollwheels # etc. to keep working. | gdk.PROXIMITY_OUT_MASK | gdk.PROXIMITY_IN_MASK # For some reason we also need to specify events # handled in drawwindow.py: | gdk.BUTTON_PRESS_MASK | gdk.BUTTON_RELEASE_MASK ) # Support smooth scrolling unless configured not to if app and app.preferences.get("ui.support_smooth_scrolling", True): self.add_events(gdk.SMOOTH_SCROLL_MASK) self.last_painting_pos = None self.renderer = CanvasRenderer( self, idle_redraw_priority = idle_redraw_priority, ) self.add(self.renderer) self.renderer.update_cursor() # get the initial cursor right self.add_events(gdk.ENTER_NOTIFY_MASK) self.connect("enter-notify-event", self.enter_notify_cb) self.__tdw_refs.insert(0, weakref.ref(self)) self._last_alloc_pos = (0, 0) self.connect("size-allocate", self._size_allocate_cb) #: Scroll to match appearing/disappearing sidebars and toolbars. self.scroll_on_allocate = True forwarder = lambda *a: self.transformation_updated() self.renderer.transformation_updated += forwarder
def __init__(self, group): """Construct, to show a named group""" SizedVBoxToolWidget.__init__(self) self._group = group self._scrolls = Gtk.ScrolledWindow() self._dialog = None self._brush_list = None from application import get_app self._app = get_app() if group not in self._app.brushmanager.groups: raise ValueError("No group named %r" % group) self.pack_start(self._scrolls, True, True, 0) self._update_brush_list()
def test_factorial_endpoint_with_simple_input(): app = application.get_app() assert app is not None with app.test_client() as client: response = client.get("/factorial?input=3") assert response.status_code == 200 expected = "3! = 6" assert expected in response.get_data(as_text=True)
def __init__(self, **kwds): """Initialize.""" super(SymmetryEditMode, self).__init__(**kwds) from application import get_app app = get_app() self.app = app statusbar_cid = app.statusbar.get_context_id(self._STATUSBAR_CONTEXT) self._statusbar_context_id = statusbar_cid self._drag_start_axis = None self._drag_start_model_x = None self.zone = _EditZone.UNKNOWN self._last_msg_zone = None self._click_info = None self.button_pos = None
def __init__(self): gtk.VBox.__init__(self) from application import get_app app = get_app() self.app = app #self.set_size_request(200, 250) self.is_updating = False # Common controls load_button = self.load_button = stock_button(gtk.STOCK_OPEN) load_button.set_tooltip_text(_("Load Scratchpad")) save_as_button = self.save_as_button = stock_button(gtk.STOCK_SAVE_AS) save_as_button.set_tooltip_text(_("Save Scratchpad as...")) revert_button = self.revert_button = stock_button(gtk.STOCK_UNDO) revert_button.set_tooltip_text(_("Revert Scratchpad")) new_button = self.delete_button = stock_button(gtk.STOCK_NEW) new_button.set_tooltip_text(_("New Scratchpad")) load_button.connect('clicked', self.load_cb) save_as_button.connect('clicked', self.save_as_cb) revert_button.connect('clicked', self.revert_cb) new_button.connect('clicked', self.new_cb) buttons_hbox = gtk.HBox() buttons_hbox.pack_start(new_button) buttons_hbox.pack_start(load_button) buttons_hbox.pack_start(save_as_button) buttons_hbox.pack_start(revert_button) scratchpad_view = app.scratchpad_doc.tdw scratchpad_view.set_size_request(64, 64) self.connect("destroy-event", self.save_cb) self.connect("delete-event", self.save_cb) scratchpad_box = gtk.EventBox() scratchpad_box.add(scratchpad_view) self.pack_start(scratchpad_box) self.pack_start(buttons_hbox, expand=False) # Updates doc = app.scratchpad_doc.model doc.doc_observers.append(self.update) # FIXME pull the scratchpad filename from preferences instead of this # self.app.scratchpad_filename = self.scratchpad_filename = os.path.join(self.app.filehandler.get_scratchpad_prefix(), "scratchpad_default.ora") self.update(app.scratchpad_doc)