Ejemplo n.º 1
0
    def __init__(self, plugin, parent, expander=True, onlyclear=False):

        # Alias.
        self.plugin = plugin

        # Force to make dir if not exists.
        main.presets.get_plugin_path(plugin.name)

        # Interface display.
        self.box = gtk.HBox()
        if expander:
            self.expander = gtk.Expander(_('Presets'))
            self.expander.add(self.box)
            gutils.separator(parent)
            parent.pack_start(self.expander, False)
        else:
            gutils.separator(parent)
            parent.pack_start(self.box, False)

        # Restore defaults button.
        default = gtk.Button()
        default.set_image(gtk.image_new_from_icon_name('gtk-clear', 1))
        default.set_relief(gtk.RELIEF_NONE)
        default.set_tooltip_text(_('Restore default values'))
        default.connect('clicked', lambda x: self.load_default())
        self.box.pack_end(default, False)

        if onlyclear: return

        # Manage presets button.
        manage = gtk.Button()
        manage.set_image(gtk.image_new_from_icon_name('gtk-edit', 1))
        manage.set_relief(gtk.RELIEF_NONE)
        manage.set_tooltip_text(_('Manage presets'))
        manager = main.plugins.childs['preset-manager']
        manage.connect('clicked',lambda x: manager.callback(plugin.name))
        self.box.pack_end(manage, False)

        # Save preset button.
        save = gtk.Button()
        save.set_image(gtk.image_new_from_icon_name('gtk-save', 1))
        save.set_relief(gtk.RELIEF_NONE)
        save.set_tooltip_text(_('Save the current values as a new preset'))
        save.connect('clicked', lambda x: self.save())
        self.box.pack_end(save, False)

        # Available presets menu-button.
        load = gtk.Button()
        load.set_image(gtk.image_new_from_icon_name('gtk-index', 1))
        load.set_relief(gtk.RELIEF_NONE)
        load.set_tooltip_text(_('Show available presets'))
        self.box.pack_end(load, False)
        load.connect(
            'clicked',
            lambda x: self.popup())
Ejemplo n.º 2
0
    def __init__(self):

        # Allow debug tracking.
        main.log.allow_tracking(self)

        # Parent box for the following widgets.
        self.box = gtk.VBox(False, 0)
        self.box.set_border_width(10)

        # Layers tree.
        self.treeview = gtk.TreeView()
        self.treeview.set_headers_visible(False)
        self.treeview.set_reorderable(True)
        self.box.pack_start(self.treeview, True, True)
        render_txt = gtk.CellRendererText()
        render_txt.set_property('editable', True)
        render_txt.connect('edited', lambda x,y,z: self.edited(y, z))
        render_pix = gtk.CellRendererPixbuf()
        column_txt = gtk.TreeViewColumn(
            None,
            render_txt,
            text=0)
        column_pix = gtk.TreeViewColumn(
            None,
            render_pix,
            stock_id=1,
            stock_size=2)
        self.treeview.append_column(column_pix)
        self.treeview.append_column(column_txt)

        # Break.
        gutils.separator(self.box)

        # Bottom buttons.
        grid = gtk.HBox(True, 0)
        self.box.pack_start(grid, False, False)

        # Set buttons properties.
        buttons = []
        layers = lambda: main.documents.active.layers
        buttons.append(['gtk-new', lambda x=layers: x().append_blank_tracked()])
        buttons.append(['gtk-copy', lambda x=layers: x().duplicate_active()])
        buttons.append(['gtk-go-up', lambda x=layers: x().swap_up_active()])
        buttons.append(['gtk-go-down', lambda x=layers: x().swap_down_active()])
        buttons.append(['gtk-delete', lambda x=layers: x().remove_active()])

        # Create buttons.
        for icon, callback in buttons:
            image = gtk.image_new_from_stock(icon, 1)
            button = gtk.Button()
            button.set_image(image)
            button.set_relief(gtk.RELIEF_NONE)
            button.connect('clicked', lambda x,y=callback: y())
            grid.pack_start(button, True, True)
Ejemplo n.º 3
0
    def gui(self):

        self.box = gtk.VBox(False, 0)

        self.gui_shape = MultiWidgetToggle(
            self.box,
            _('Shape'),
            ['square', 'circle'],
            self.shape,
            lambda x: self.set_then_new('shape', x))

        gutils.separator(self.box)

        self.gui_size = MultiWidgetSpin(
            self.box,
            _('Size'),
            True,
            1,
            100,
            self.size,
            self.updateSize)

        self.gui_soft = MultiWidgetSpin(
            self.box,
            _('Smoothing'),
            True,
            0,
            100,
            self.soft,
            self.updateSoftness)

        self.gui_opacity = MultiWidgetSpin(
            self.box,
            _('Opacity'),
            True,
            1,
            100,
            self.opacity,
            self.updateOpacity)

        gutils.separator(self.box)

        self.gui_spacing = MultiWidgetCombo(
            self.box,
            _('Spacing'),
            ['not ported'],
            self.spacing,
            lambda x: None)

        return self.box
Ejemplo n.º 4
0
    def __init__(self):
        """Create the sidebar color object at program start, including the
        interface controllers."""

        # Configure box.
        self.box = gtk.VBox(False, 0)
        self.box.set_border_width(10)

        # Append callback to color update stack.
        main.color.updated_todo.append(self.update)

        # Red controller.
        self.color_r = MultiWidgetSpin(
            self.box,
            _('Red') + ' (R)',
            True,
            0,
            255,
            main.color.rgb[0],
            lambda x: main.color.set_rgb_component(x, 0))

        # Green controller.
        self.color_g = MultiWidgetSpin(
            self.box,
            _('Green') + ' (G)',
            True,
            0,
            255,
            main.color.rgb[1],
            lambda x: main.color.set_rgb_component(x, 1))

        # Blue controller.
        self.color_b = MultiWidgetSpin(
            self.box,
            _('Blue') + ' (B)',
            True,
            0,
            255,
            main.color.rgb[2],
            lambda x: main.color.set_rgb_component(x, 2))

        # Separator between rgb and hsv.
        gutils.separator(self.box)

        # Hue controller.
        self.color_h = MultiWidgetSpin(
            self.box,
            _('Hue') + ' (H)',
            True,
            0,
            359,
            main.color.hsv[0],
            lambda x: main.color.set_hsv_component(x, 0))

        # Saturation controller.
        self.color_s = MultiWidgetSpin(
            self.box,
            _('Saturation') + ' (S)',
            True,
            0,
            100,
            main.color.hsv[1],
            lambda x: main.color.set_hsv_component(x, 1))

        # Value controller.
        self.color_v = MultiWidgetSpin(
            self.box,
            _('Value') + ' (V)',
            True,
            0,
            100,
            main.color.hsv[2],
            lambda x: main.color.set_hsv_component(x, 2))

        # Separator between hsv and hexadecimal.
        gutils.separator(self.box)

        self.color_hex = MultiWidgetEntry(
            self.box,
            _('Hexadecimal'),
            6,
            main.color.hex,
            main.color.set_hex)

        # Gap to the box bottom.
        gutils.expander(self.box)
        gutils.separator(self.box)

        # Clear button.
        self.clear = MultiWidgetClear(
            self.box,
            1,
            main.color.clear)