Exemplo n.º 1
0
    def addBlock(self, data, name, block):
        # tooltip
        invoker = WidgetInvoker(block)
        invoker._position_hint = WidgetInvoker.AT_CURSOR
        invoker.set_palette(Palette(name))

        block.add_events(
            Gdk.EventMask.BUTTON_PRESS_MASK
            | Gdk.EventMask.BUTTON_RELEASE_MASK
            | Gdk.EventMask.ENTER_NOTIFY_MASK
            | Gdk.EventMask.LEAVE_NOTIFY_MASK
            | Gdk.EventMask.POINTER_MOTION_MASK
            | Gdk.EventMask.POINTER_MOTION_HINT_MASK
        )
        block.connect("button-press-event", self.on_button_press)
        block.connect("button-release-event", self.on_button_release)
        block.connect("motion-notify-event", self.on_motion_notify)
        block.data = data

        self.blocks.append(block)

        if self._testAgainstFilter(block):
            self.pickerBox.pack_start(block, False, False, 3)

        block.show_all()

        return block
Exemplo n.º 2
0
    def addBlock(self, data, name, block):
        # tooltip
        invoker = WidgetInvoker(block)
        invoker._position_hint = WidgetInvoker.AT_CURSOR
        invoker.set_palette(Palette(name))

        block.add_events(Gdk.EventMask.BUTTON_PRESS_MASK
                         | Gdk.EventMask.BUTTON_RELEASE_MASK
                         | Gdk.EventMask.ENTER_NOTIFY_MASK
                         | Gdk.EventMask.LEAVE_NOTIFY_MASK
                         | Gdk.EventMask.POINTER_MOTION_MASK
                         | Gdk.EventMask.POINTER_MOTION_HINT_MASK)
        block.connect("button-press-event", self.on_button_press)
        block.connect("button-release-event", self.on_button_release)
        block.connect("motion-notify-event", self.on_motion_notify)
        block.data = data

        self.blocks.append(block)

        if self._testAgainstFilter(block):
            self.pickerBox.pack_start(block, False, False, 3)

        block.show_all()

        return block
Exemplo n.º 3
0
    def __init__(self, **kwargs):
        self._title = _('Choose a color')
        self._color = Gdk.Color(0, 0, 0)
        self._has_palette = True
        self._has_invoker = True
        self._palette = None
        self._accept_drag = True

        self._preview = Icon(icon_name='color-preview',
                             pixel_size=style.STANDARD_ICON_SIZE)

        GObject.GObject.__init__(self, **kwargs)

        # FIXME Drag and drop is not working, SL #3796
        if self._accept_drag:
            self.drag_dest_set(Gtk.DestDefaults.MOTION |
                               Gtk.DestDefaults.HIGHLIGHT |
                               Gtk.DestDefaults.DROP,
                               [Gtk.TargetEntry.new(
                                'application/x-color', 0, 0)],
                               Gdk.DragAction.COPY)
        self.drag_source_set(Gdk.ModifierType.BUTTON1_MASK |
                             Gdk.ModifierType.BUTTON3_MASK,
                             [Gtk.TargetEntry.new(
                                 'application/x-color', 0, 0)],
                             Gdk.DragAction.COPY)
        self.connect('drag-data-received', self.__drag_data_received_cb)
        self.connect('drag-data-get', self.__drag_data_get_cb)

        self._preview.fill_color = get_svg_color_string(self._color)
        self._preview.stroke_color = self._get_fg_style_color_str()
        self.set_image(self._preview)

        if self._has_palette and self._has_invoker:
            self._invoker = WidgetInvoker(self)
            # FIXME: This is a hack.
            self._invoker.has_rectangle_gap = lambda: False
            self._invoker.palette = self._palette
Exemplo n.º 4
0
 def _add_palette(self, widget, palette):
     widget._palette = palette
     widget._palette.props.invoker = WidgetInvoker(widget)
Exemplo n.º 5
0
    def __init__(self, widget):
        WidgetInvoker.__init__(self, widget, widget.get_child())

        self._position_hint = self.ANCHORED
        self._screen_area = _get_screen_area()
Exemplo n.º 6
0
    def __init__(self, widget):
        WidgetInvoker.__init__(self, widget, widget.get_child())

        self._position_hint = self.ANCHORED
        self._screen_area = _get_screen_area()
Exemplo n.º 7
0
 def __init__(self, textview):
     WidgetInvoker.__init__(self, textview)
     self._textview = textview