def __init__(self, app): self.app = app combo = Gtk.ComboBox() store = Gtk.ListStore() store.set_column_types((str, str)) for k, v in _FILE_OPEN_OPTIONS: store.append((k, v)) combo.set_model(store) combo.set_active(0) cell = Gtk.CellRendererText() combo.pack_start(cell, True) combo.add_attribute(cell, 'text', 1) combo_label = Gtk.Label( # TRANSLATORS: This is a label for a dropdown menu in the # TRANSLATORS: file chooser dialog when loading .ora files. label=C_("File Load Compat Options", "Compatibility mode:")) hbox = Gtk.HBox() hbox.set_spacing(6) hbox.pack_start(combo_label, False, False, 0) hbox.pack_start(combo, False, False, 0) hbox.show_all() hbox.set_visible(False) self._compat_override = None self._combo = combo combo.connect('changed', self._combo_changed_cb) self._widget = hbox
def __init__(self, parent, target): super(HCYMaskTemplateDialog, self).__init__( title=C_( u"HCY Gamut Mask new-from-template dialog: window title", "New Gamut Mask from Template", ), transient_for=parent, modal=True, destroy_with_parent=True, window_position=Gtk.WindowPosition.MOUSE, ) self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT) target_mgr = target.get_color_manager() prefs_ro = deepcopy(target_mgr.get_prefs()) datapath = target_mgr.get_data_path() mgr = ColorManager(prefs=prefs_ro, datapath=datapath) mgr.set_wheel_type(target_mgr.get_wheel_type()) self.target = target for name, desc, mask_shapes_float in self.__templates: mask = [] for mask_shape_float in mask_shapes_float: shape = [] for h, c, y in mask_shape_float: h = mgr.undistort_hue(h) shape.append(HCYColor(h, c, y)) mask.append(shape) label = Gtk.Label() label.set_markup("<b>%s</b>\n\n%s" % (name, desc)) label.set_size_request(375, -1) label.set_line_wrap(True) label.set_alignment(0, 0.5) preview = HCYMaskPreview() preview.set_color_manager(mgr) preview.set_mask(mask) preview_frame = Gtk.AspectFrame(obey_child=True) preview_frame.add(preview) preview_frame.set_shadow_type(Gtk.ShadowType.NONE) hbox = Gtk.HBox() hbox.set_spacing(6) hbox.pack_start(preview_frame, False, False, 0) hbox.pack_start(label, True, True, 0) button = Gtk.Button() button.add(hbox) button.set_relief(Gtk.ReliefStyle.NONE) button.connect("clicked", self.__button_clicked_cb, mask) self.vbox.pack_start(button, True, True, 0) self.connect("response", self.__response_cb) self.connect("show", self.__show_cb) for w in self.vbox: w.show_all() ref_color = target.get_managed_color() mgr.set_color(ref_color)
def __init__(self, toolstack): """Initialise, with an ancestor ToolStack. :param toolstack: the ancestor ToolStack """ super(ToolStack._Notebook, self).__init__() self._toolstack = toolstack assert self._toolstack is not None self.set_group_name(self.NOTEBOOK_GROUP_NAME) self.connect("create-window", self._create_window_cb) self.connect("page-added", self._page_added_cb) self.connect("page-removed", self._page_removed_cb) self.connect("switch-page", self._switch_page_cb) self.connect_after("drag-begin", self._drag_begin_cb) self.connect_after("drag-end", self._drag_end_cb) self.set_scrollable(True) # Minimum sizing, for the placeholder case self.set_size_request(8, -1) # Action buttons action_hbox = Gtk.HBox() action_hbox.set_homogeneous(True) action_hbox.set_spacing(0) self.set_action_widget(action_hbox, Gtk.PackType.END) self.connect("show", lambda *a: action_hbox.show_all()) # Properties button btn = borderless_button(icon_name="mypaint-tab-options-symbolic", size=self.ACTION_BUTTON_ICON_SIZE) btn.connect("clicked", self._properties_button_clicked_cb) action_hbox.pack_start(btn, False, False, 0) self._properties_button = btn btn.set_sensitive(False) # Sidebar swapper button btn = borderless_button( icon_name="mypaint-tab-sidebar-swap-symbolic", size=self.ACTION_BUTTON_ICON_SIZE, ) btn.connect("clicked", self._sidebar_swap_button_clicked_cb) action_hbox.pack_start(btn, False, False, 0) self._sidebar_swap_button = btn # Close tab button btn = borderless_button(icon_name="mypaint-close-symbolic", size=self.ACTION_BUTTON_ICON_SIZE) btn.connect("clicked", self._close_button_clicked_cb) action_hbox.pack_start(btn, False, False, 0) self._close_button = btn
def ask_for_name(widget, title, default): window = widget.get_toplevel() d = Gtk.Dialog(title, window, Gtk.DialogFlags.MODAL, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) d.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) hbox = Gtk.HBox() hbox.set_property("spacing", widgets.SPACING) hbox.set_border_width(widgets.SPACING) d.vbox.pack_start(hbox, True, True, 0) hbox.pack_start(Gtk.Label(label=_('Name')), False, False, 0) if default is None: default = "" d.e = e = Gtk.Entry() e.set_size_request(250, -1) e.set_text(default) e.select_region(0, len(default)) e.set_input_hints(Gtk.InputHints.UPPERCASE_WORDS) e.set_input_purpose(Gtk.InputPurpose.FREE_FORM) e.connect("activate", _entry_activate_dialog_response_cb, d) hbox.pack_start(e, True, True, 0) d.vbox.show_all() if d.run() == Gtk.ResponseType.ACCEPT: result = d.e.get_text() if isinstance(result, bytes): result = result.decode('utf-8') else: result = None d.destroy() return result
def __init__(self): """Construct, and connect internal signals & callbacks""" SizedVBoxToolWidget.__init__(self) from gui.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, 0) label_hbox.pack_start(self._options_label, True, True, 0) align = Gtk.Alignment.new(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()) # Fallback self._update_ui_with_options_widget( self._no_options_label, self.tool_widget_title, self.tool_widget_icon_name, )
def confirm_rewrite_brush(window, brushname, existing_preview_pixbuf, imported_preview_data): flags = Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT dialog = Gtk.Dialog(_("Overwrite brush?"), window, flags) cancel = Gtk.Button(stock=Gtk.STOCK_CANCEL) cancel.show_all() img_yes = Gtk.Image() img_yes.set_from_stock(Gtk.STOCK_YES, Gtk.IconSize.BUTTON) img_no = Gtk.Image() img_no.set_from_stock(Gtk.STOCK_NO, Gtk.IconSize.BUTTON) overwrite_this = Gtk.Button(label=_("Replace")) overwrite_this.set_image(img_yes) overwrite_this.show_all() skip_this = Gtk.Button(label=_("Rename")) skip_this.set_image(img_no) skip_this.show_all() overwrite_all = Gtk.Button(label=_("Replace all")) overwrite_all.show_all() skip_all = Gtk.Button(label=_("Rename all")) skip_all.show_all() buttons = [ (cancel, CANCEL), (skip_all, DONT_OVERWRITE_ANYTHING), (overwrite_all, OVERWRITE_ALL), (skip_this, DONT_OVERWRITE_THIS), (overwrite_this, OVERWRITE_THIS), ] for button, code in buttons: dialog.add_action_widget(button, code) hbox = Gtk.HBox() vbox_l = Gtk.VBox() vbox_r = Gtk.VBox() try: preview_r = Gtk.image_new_from_pixbuf(existing_preview_pixbuf) except AttributeError: preview_r = Gtk.Image.new_from_pixbuf(existing_preview_pixbuf) label_l = Gtk.Label(label=_("Imported brush")) label_r = Gtk.Label(label=_("Existing brush")) question = Gtk.Label(label=_( u"<b>A brush named “{brush_name}” already exists.</b>\n" u"Do you want to replace it, " u"or should the new brush be renamed?").format(brush_name=brushname, )) question.set_use_markup(True) preview_l = image_new_from_png_data(imported_preview_data) vbox_l.pack_start(preview_l, True, True, 0) vbox_l.pack_start(label_l, False, True, 0) vbox_r.pack_start(preview_r, True, True, 0) vbox_r.pack_start(label_r, False, True, 0) hbox.pack_start(vbox_l, False, True, 0) hbox.pack_start(question, True, True, 0) hbox.pack_start(vbox_r, False, True, 0) hbox.show_all() dialog.vbox.pack_start(hbox, True, True, 0) answer = dialog.run() dialog.destroy() return answer
def __init__(self, parent, target): super(HCYMaskPropertiesDialog, self).__init__( title=C_( "HCY Gamut Mask Editor dialog: window title", u"Gamut Mask Editor", ), transient_for=parent, modal=True, destroy_with_parent=True, window_position=Gtk.WindowPosition.CENTER_ON_PARENT, buttons=( Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT, ), ) self.target = target ed = HCYMaskEditorWheel() target_mgr = target.get_color_manager() prefs_ro = deepcopy(target_mgr.get_prefs()) datapath = target_mgr.get_data_path() ed_mgr = ColorManager(prefs=prefs_ro, datapath=datapath) ed.set_color_manager(ed_mgr) self.editor = ed ed.set_size_request(300, 300) ed.mask_toggle.set_active(True) self.mask_toggle_ctrl = Gtk.CheckButton( C_( "HCY Gamut Mask Editor dialog: mask-is-active checkbox", u"Active", ), use_underline=False, ) self.mask_toggle_ctrl.set_tooltip_text(ed.mask_toggle.get_tooltip()) ed.mask_observers.append(self.__mask_changed_cb) hbox = Gtk.HBox() hbox.set_spacing(3) # Sidebar buttonbox # On the right and packed to the top. This places its secondary # control, a mask toggle button, next to the "OK" button so it's less # likely to be missed. bbox = Gtk.VButtonBox() new_btn = self.__new_button = Gtk.Button(stock=Gtk.STOCK_NEW) load_btn = self.__load_button = Gtk.Button(stock=Gtk.STOCK_OPEN) save_btn = self.__save_button = Gtk.Button(stock=Gtk.STOCK_SAVE) clear_btn = self.__clear_button = Gtk.Button(stock=Gtk.STOCK_CLEAR) help_btn = self.__help_button = Gtk.LinkButton.new_with_label( uri = MASK_EDITOR_HELP_URI, label = C_( "HCY Mask Editor: action button labels", u"Help…", ), ) new_btn.set_tooltip_text(C_( "HCY Mask Editor: action button tooltips", u"Create mask from template."), ) load_btn.set_tooltip_text(C_( "HCY Mask Editor: action button tooltips", u"Load mask from a GIMP palette file."), ) save_btn.set_tooltip_text(C_( "HCY Mask Editor: action button tooltips", u"Save mask to a GIMP palette file."), ) clear_btn.set_tooltip_text(C_( "HCY Mask Editor: action button tooltips", u"Erase the mask."), ) help_btn.set_tooltip_text(C_( "HCY Mask Editor: action button tooltips", u"Open the online help for this dialog in a web browser."), ) new_btn.connect("clicked", self.__new_clicked) save_btn.connect("clicked", self.__save_clicked) load_btn.connect("clicked", self.__load_clicked) clear_btn.connect("clicked", self.__clear_clicked) bbox.pack_start(new_btn, True, True, 0) bbox.pack_start(load_btn, True, True, 0) bbox.pack_start(save_btn, True, True, 0) bbox.pack_start(clear_btn, True, True, 0) action_area = self.get_action_area() if isinstance(action_area, Gtk.ButtonBox): action_area.pack_start(help_btn, True, True, 0) action_area.set_child_secondary(help_btn, True) action_area.set_child_non_homogeneous(help_btn, True) bbox.pack_start(self.mask_toggle_ctrl, True, True, 0) bbox.set_child_secondary(self.mask_toggle_ctrl, True) else: bbox.pack_start(self.mask_toggle_ctrl, True, True, 0) bbox.pack_start(help_btn, True, True, 0) bbox.set_child_secondary(help_btn, True) bbox.set_layout(Gtk.ButtonBoxStyle.START) hbox.pack_start(ed, True, True, 0) hbox.pack_start(bbox, False, False, 0) hbox.set_border_width(9) self.vbox.pack_start(hbox, True, True, 0) self.connect("response", self.__response_cb) self.connect("show", self.__show_cb) for w in self.vbox: w.show_all()