コード例 #1
0
ファイル: adjbases.py プロジェクト: mypaint/mypaint
 def drag_begin_cb(self, widget, context):
     color = self.get_managed_color()
     preview = GdkPixbuf.Pixbuf.new(
         GdkPixbuf.Colorspace.RGB, False, 8, 32, 32)
     pixel = color.to_fill_pixel()
     preview.fill(pixel)
     Gtk.drag_set_icon_pixbuf(context, preview, 0, 0)
コード例 #2
0
ファイル: common.py プロジェクト: exaile/exaile
    def on_drag_begin(self, widget, context):
        """
            Sets the cover of dragged tracks as drag icon
        """
        self.drag_context = context
        Gdk.drag_abort(context, Gtk.get_current_event_time())

        self.reset_selection_status()

        # Load covers
        drag_cover_icon = None
        get_tracks_for_path = getattr(self, 'get_tracks_for_path', None)
        if get_tracks_for_path:
            model, paths = self.get_selection().get_selected_rows()
            drag_cover_icon = icons.MANAGER.get_drag_cover_icon(
                imap(get_tracks_for_path, paths)
            )

        if drag_cover_icon is None:
            # Set default icon
            icon_name = (
                'gtk-dnd-multiple'
                if self.get_selection().count_selected_rows() > 1
                else 'gtk-dnd'
            )
            Gtk.drag_set_icon_name(context, icon_name, 0, 0)
        else:
            Gtk.drag_set_icon_pixbuf(context, drag_cover_icon, 0, 0)
コード例 #3
0
ファイル: gui.py プロジェクト: johncheetham/samuel
    def drag_begin(self, widget, drag_context, data):
        self.dnd_data_received = False
        # get x,y co-ords of source square
        x, y = data

        # convert the x, y co-ords into the gui checkers representation
        gc_loc = self.board.get_gc_loc(x, y)
        self.src = gc_loc
        # set the icon for the drag and drop to the piece that is being dragged
        pce = self.board.get_piece_at_square(x, y)
        self.dnd_pce = pce

        #   0 is unoccupied
        #   1 is a red piece
        #   2 is a white piece
        #   5 is a red king
        #   6 is a white king
        if pce == 1:
            scaled_pixbuf = self.rcheckdnd.scale_simple(self.width, self.height, GdkPixbuf.InterpType.HYPER)
        elif pce == 2:
            scaled_pixbuf = self.wcheckdnd.scale_simple(self.width, self.height, GdkPixbuf.InterpType.HYPER)
        elif pce == 5:
            scaled_pixbuf = self.rkingdnd.scale_simple(self.width, self.height, GdkPixbuf.InterpType.HYPER)
        elif pce == 6:
            scaled_pixbuf = self.wkingdnd.scale_simple(self.width, self.height, GdkPixbuf.InterpType.HYPER)
        else:
            return

        hot_x = scaled_pixbuf.get_width() / 2
        hot_y = scaled_pixbuf.get_height() / 2
        Gtk.drag_set_icon_pixbuf(drag_context, scaled_pixbuf, hot_x, hot_y)

        # Set piece at source square as unoccupied (0)
        self.board.set_piece_at_square(gc_loc, 0)
        self.eb[x][y].queue_draw()
コード例 #4
0
    def on_drag_begin(self, widget, context):
        """
        Sets the cover of dragged tracks as drag icon
        """
        self.drag_context = context
        Gdk.drag_abort(context, Gtk.get_current_event_time())

        self.reset_selection_status()

        # Load covers
        drag_cover_icon = None
        get_tracks_for_path = getattr(self, 'get_tracks_for_path', None)
        if get_tracks_for_path:
            model, paths = self.get_selection().get_selected_rows()
            drag_cover_icon = icons.MANAGER.get_drag_cover_icon(
                map(get_tracks_for_path, paths))

        if drag_cover_icon is None:
            # Set default icon
            icon_name = ('gtk-dnd-multiple'
                         if self.get_selection().count_selected_rows() > 1 else
                         'gtk-dnd')
            Gtk.drag_set_icon_name(context, icon_name, 0, 0)
        else:
            Gtk.drag_set_icon_pixbuf(context, drag_cover_icon, 0, 0)
コード例 #5
0
 def drag_begin_cb(self, widget, context):
     preview = self.bm.selected_brush.preview
     preview = preview.scale_simple(
         preview.get_width()//2, preview.get_height()//2,
         GdkPixbuf.InterpType.BILINEAR)
     Gtk.drag_set_icon_pixbuf(context, preview, 0, 0)
     super(BrushList, self).drag_begin_cb(widget, context)
コード例 #6
0
 def _drag_begin_cb(self, widget, context):
     # TODO: We should get the pixbuf from the icon, with colors, etc.
     icon_theme = Gtk.IconTheme.get_default()
     pixbuf = icon_theme.load_icon(self._icon.props.icon_name,
                                   style.STANDARD_ICON_SIZE, 0)
     Gtk.drag_set_icon_pixbuf(context, pixbuf, hot_x=pixbuf.props.width / 2,
                              hot_y=pixbuf.props.height / 2)
コード例 #7
0
 def drag_begin_cb(self, widget, context):
     color = self.get_managed_color()
     preview = GdkPixbuf.Pixbuf.new(
         GdkPixbuf.Colorspace.RGB, False, 8, 32, 32)
     pixel = color.to_fill_pixel()
     preview.fill(pixel)
     Gtk.drag_set_icon_pixbuf(context, preview, 0, 0)
コード例 #8
0
 def drag_begin_cb(self, widget, context):
     preview = self.bm.selected_brush.preview
     preview = preview.scale_simple(
         preview.get_width() // 2,
         preview.get_height() // 2,
         GdkPixbuf.InterpType.BILINEAR,
     )
     Gtk.drag_set_icon_pixbuf(context, preview, 0, 0)
     super(BrushList, self).drag_begin_cb(widget, context)
コード例 #9
0
    def __drag_begin_cb(self, widget, context):
        if not self._dragging_mode:
            return False

        pixbuf = GdkPixbuf.Pixbuf.new_from_file(widget.props.file_name)

        self._hot_x = pixbuf.props.width / 2
        self._hot_y = pixbuf.props.height / 2
        Gtk.drag_set_icon_pixbuf(context, pixbuf, self._hot_x, self._hot_y)
コード例 #10
0
ファイル: favoritesview.py プロジェクト: salil93/sugar
    def __drag_begin_cb(self, widget, context):
        if not self._dragging_mode:
            return False

        pixbuf = GdkPixbuf.Pixbuf.new_from_file(widget.props.file_name)

        self._hot_x = pixbuf.props.width / 2
        self._hot_y = pixbuf.props.height / 2
        Gtk.drag_set_icon_pixbuf(context, pixbuf, self._hot_x, self._hot_y)
コード例 #11
0
ファイル: medialibrary.py プロジェクト: lubosz/pitivi
    def _dndDragBeginCb(self, unused_view, context):
        self.info("Drag operation begun")
        self.dragged = True
        paths = self.getSelectedPaths()

        if not paths:
            context.drag_abort(int(time.time()))
        else:
            row = self.modelFilter[paths[0]]
            Gtk.drag_set_icon_pixbuf(context, row[COL_ICON_64], 0, 0)
コード例 #12
0
    def on_drag_begin(self, _, drag_context):
        """ Triggered when dragging starts """

        logger.info("Drag has begun")

        # (120, 90) refers to where the cursor relative to the drag icon
        Gtk.drag_set_icon_pixbuf(drag_context, self.pixbuf, 100, 20)
        self.eventbox.remove(self.image)
        self.eventbox.add(self.bg_image)
        self.eventbox.show_all()
コード例 #13
0
 def _drag_begin(self, iconview, context):
     """We hook up on drag_begin events so that we can set the hotspot
     for the cursor at the top left corner of the thumbnail (so that we
     might actually see where we are dropping!).
     """
     path = iconview.get_cursor()[0]
     surface = treeview.create_row_drag_icon(path)
     width, height = surface.get_width(), surface.get_height()
     pixbuf = Gdk.pixbuf_get_from_surface(surface, 0, 0, width, height)
     Gtk.drag_set_icon_pixbuf(context, pixbuf, -5, -5)
コード例 #14
0
ファイル: medialibrary.py プロジェクト: palango/pitivi
    def _dndDragBeginCb(self, view, context):
        self.info("tree drag_begin")
        self.dragged = True
        paths = self.getSelectedPaths()

        if len(paths) < 1:
            context.drag_abort(int(time.time()))
        else:
            row = self.modelFilter[paths[0]]
            Gtk.drag_set_icon_pixbuf(context, row[COL_ICON], 0, 0)
コード例 #15
0
ファイル: medialibrary.py プロジェクト: davlem/pitivi
    def _dndDragBeginCb(self, unused_view, context):
        self.info("Drag operation begun")
        self.dragged = True
        paths = self.getSelectedPaths()

        if not paths:
            context.drag_abort(int(time.time()))
        else:
            row = self.modelFilter[paths[0]]
            Gtk.drag_set_icon_pixbuf(context, row[COL_ICON_64], 0, 0)
コード例 #16
0
 def _drag_begin(self, treeview, context):
     '''Create a cursor image for drag-n-drop of collections. We use the
     default one (i.e. the row with text), but put the hotspot in the
     top left corner so that one can actually see where one is dropping,
     which unfortunately isn't the default case.
     '''
     path = treeview.get_cursor()[0]
     surface = treeview.create_row_drag_icon(path)
     width, height = surface.get_width(), surface.get_height()
     pixbuf = Gdk.pixbuf_get_from_surface(surface, 0, 0, width, height)
     Gtk.drag_set_icon_pixbuf(context, pixbuf, -5, -5)
コード例 #17
0
    def _dndDragBeginCb(self, unused_view, context):
        self.info("Drag operation begun")
        model, paths = self.view.get_selection().get_selected_rows()

        if not paths:
            context.drag_abort(int(time.time()))
            return

        path = paths[0]
        pixbuf = model.get_value(model.get_iter(path), COL_ICON)
        if pixbuf:
            Gtk.drag_set_icon_pixbuf(context, pixbuf, 0, 0)
コード例 #18
0
ファイル: effects.py プロジェクト: luisbg/PiTiVi
    def _dndDragBeginCb(self, unused_view, context):
        self.info("Drag operation begun")
        model, paths = self.view.get_selection().get_selected_rows()

        if not paths:
            context.drag_abort(int(time.time()))
            return

        path = paths[0]
        pixbuf = model.get_value(model.get_iter(path), COL_ICON)
        if pixbuf:
            Gtk.drag_set_icon_pixbuf(context, pixbuf, 0, 0)
コード例 #19
0
    def on_drag_begin(self, _, drag_context):
        """ Triggered when dragging starts """

        logger.info("Drag has begun")

        # (120, 90) refers to where the cursor relative to the drag icon
        Gtk.drag_set_icon_pixbuf(drag_context, self.pixbuf, 50, 50)
        self.remove(self.image)

        for element in self.hidden_elements:
            element.hide()

        self.show_all()
コード例 #20
0
    def on_drag_begin(self, _, drag_context):
        """ Triggered when dragging starts """

        logger.info("Drag has begun")

        # (120, 90) refers to where the cursor relative to the drag icon
        Gtk.drag_set_icon_pixbuf(drag_context, self.pixbuf, 50, 50)
        self.remove(self.image)

        for element in self.hidden_elements:
            element.hide()

        self.show_all()
コード例 #21
0
 def _drag_begin(self, treeview, context):
     """We hook up on drag_begin events so that we can set the hotspot
     for the cursor at the top left corner of the thumbnail (so that we
     might actually see where we are dropping!).
     """
     path = treeview.get_cursor()[0]
     surface = treeview.create_row_drag_icon(path)
     # Because of course a cairo.Win32Surface does not have
     # get_width/get_height, that would be to easy...
     cr = cairo.Context(surface)
     x1, y1, x2, y2 = cr.clip_extents()
     width, height = x2 - x1, y2 - y1
     pixbuf = Gdk.pixbuf_get_from_surface(surface, 0, 0, width, height)
     Gtk.drag_set_icon_pixbuf(context, pixbuf, -5, -5)
コード例 #22
0
  def _do_drag_motion_check(self, widget, event):

    if not self.DRAG_BUTTON_MASK & event.get_state():
      return False

    if self._drag_event:

      x = int(event.x)
      y = int(event.y)

      log.debug("%s Do motion check at b(%d, %d)", self, x, y)

      if widget.drag_check_threshold(
          int(self._drag_event.x), int(self._drag_event.y), x, y):

        log.debug("%s Drag threshold reached", self)

        targets = widget.drag_source_get_target_list()
        if targets:
          context = widget.drag_begin(targets, self.ACTIONS_MASK,
              self._drag_event.button.button, event)

          log.debug("%s Drag icon function: %s", self, self.icon_func)

          if self.icon_func:

            try:
              Gtk.drag_set_icon_pixbuf(
                context,
                *self.icon_func(
                  widget,
                  int(self._drag_event.x),
                  int(self._drag_event.y),
                )
              )

            except:
              log.exception("%s Drag icon function failed", self)

      log.debug("%s Do motion check ended", self)
コード例 #23
0
    def drag_begin(self, widget, drag_context, data):
        self.dnd_data_received = False
        # get x,y co-ords of source square
        x, y = data

        # convert the x, y co-ords into the gui checkers representation
        gc_loc = self.board.get_gc_loc(x, y)
        self.src = gc_loc
        # set the icon for the drag and drop to the piece that is being dragged
        pce = self.board.get_piece_at_square(x, y)
        self.dnd_pce = pce

        #   0 is unoccupied
        #   1 is a red piece
        #   2 is a white piece
        #   5 is a red king
        #   6 is a white king
        if pce == 1:
            scaled_pixbuf = self.rcheckdnd.scale_simple(
                self.width, self.height, GdkPixbuf.InterpType.HYPER)
        elif pce == 2:
            scaled_pixbuf = self.wcheckdnd.scale_simple(
                self.width, self.height, GdkPixbuf.InterpType.HYPER)
        elif pce == 5:
            scaled_pixbuf = self.rkingdnd.scale_simple(
                self.width, self.height, GdkPixbuf.InterpType.HYPER)
        elif pce == 6:
            scaled_pixbuf = self.wkingdnd.scale_simple(
                self.width, self.height, GdkPixbuf.InterpType.HYPER)
        else:
            return

        hot_x = scaled_pixbuf.get_width() / 2
        hot_y = scaled_pixbuf.get_height() / 2
        Gtk.drag_set_icon_pixbuf(drag_context, scaled_pixbuf, hot_x, hot_y)

        # Set piece at source square as unoccupied (0)
        self.board.set_piece_at_square(gc_loc, 0)
        self.eb[x][y].queue_draw()
コード例 #24
0
ファイル: common.py プロジェクト: BlubberHarpoonist/exaile
 def _set_drag_cover(self, context, pixbuf):
     """
         Completes drag icon setup
     """
     Gtk.drag_set_icon_pixbuf(context, pixbuf, 0, 0)
コード例 #25
0
ファイル: clipboard.py プロジェクト: dieterv/pygobject
 def drag_begin(self, widget, context, data):
     pixbuf = self.get_image_pixbuf(data)
     Gtk.drag_set_icon_pixbuf(context, pixbuf, -2, -2)
コード例 #26
0
    def _drag_begin(self, iconview, context):
        '''Create a cursor image for drag-n-drop from the library.

        This method relies on implementation details regarding PIL's
        drawing functions and default font to produce good looking results.
        If those are changed in a future release of PIL, this method might
        produce bad looking output (e.g. non-centered text).

        It's also used with connect_after() to overwrite the cursor
        automatically created when using enable_model_drag_source(), so in
        essence it's a hack, but at least it works.
        '''
        icon_path = iconview.get_cursor()[1]
        num_books = len(iconview.get_selected_items())
        book = self.get_book_at_path(icon_path)

        cover = self._library.backend.get_book_cover(book)
        if cover is None:
            cover = image_tools.MISSING_IMAGE_ICON

        cover = cover.scale_simple(max(0,
                                       cover.get_width() // 2),
                                   max(0,
                                       cover.get_height() // 2),
                                   prefs['scaling quality'])
        cover = image_tools.add_border(cover, 1, 0xFFFFFFFF)
        cover = image_tools.add_border(cover, 1)

        if num_books > 1:
            cover_width = cover.get_width()
            cover_height = cover.get_height()
            pointer = GdkPixbuf.Pixbuf.new(colorspace=GdkPixbuf.Colorspace.RGB,
                                           has_alpha=True,
                                           bits_per_sample=8,
                                           width=max(30, cover_width + 15),
                                           height=max(30, cover_height + 10))
            pointer.fill(0x00000000)
            cover.composite(pointer, 0, 0, cover_width, cover_height, 0, 0, 1,
                            1, prefs['scaling quality'], 255)
            im = Image.new('RGBA', (30, 30), 0x00000000)
            draw = ImageDraw.Draw(im)
            draw.polygon(
                (8, 0, 20, 0, 28, 8, 28, 20, 20, 28, 8, 28, 0, 20, 0, 8),
                fill=(0, 0, 0),
                outline=(0, 0, 0))
            draw.polygon(
                (8, 1, 20, 1, 27, 8, 27, 20, 20, 27, 8, 27, 1, 20, 1, 8),
                fill=(128, 0, 0),
                outline=(255, 255, 255))
            text = str(num_books)
            draw.text((15 - (6 * len(text) // 2), 9),
                      text,
                      fill=(255, 255, 255))
            circle = image_tools.pil_to_pixbuf(im)
            circle.composite(pointer, max(0, cover_width - 15),
                             max(0, cover_height - 20), 30, 30,
                             max(0,
                                 cover_width - 15), max(0, cover_height - 20),
                             1, 1, prefs['scaling quality'], 255)
        else:
            pointer = cover

        Gtk.drag_set_icon_pixbuf(context, pointer, -5, -5)
コード例 #27
0
ファイル: clipboard.py プロジェクト: kurt-cb/pygobject
 def drag_begin(self, widget, context, data):
     pixbuf = self.get_image_pixbuf(data)
     Gtk.drag_set_icon_pixbuf(context, pixbuf, -2, -2)
コード例 #28
0
ファイル: drag_and_drop.py プロジェクト: gbtami/gshogi
    def drag_begin(self, widget, drag_context, data):

        self.dnd_data_received = False

        # get x,y co-ords of source square
        x, y = data

        if gv.verbose:
            print "in drag begin"
            print "data=", data
            print "widget_name=", widget.get_name()
            print "source sq=", x, y

        stm = gv.gshogi.get_side_to_move()

        # print "proto=",drag_context.protocol
        # drag source is a capture square not a board square
        if widget.get_name() == "bcap_eb" or widget.get_name() == "wcap_eb":
            self.src_x = x
            self.src_y = y
            self.piece = gv.board.get_cap_piece(y, stm)

            self.src = self.piece + "*"

            pb = gv.board.get_cap_pixbuf(y, stm)

            hot_x = pb.get_width() / 2
            hot_y = pb.get_height() / 2
            Gtk.drag_set_icon_pixbuf(drag_context,
                                     pb,
                                     hot_x, hot_y)

            # save the pixbuf for use in the drop (receivecallback) routines
            self.dnd_pixbuf = pb

            # clear the square where the piece is being moved from
            gv.board.set_cap_as_unoccupied(y, self.piece, stm)
            gv.board.refresh_screen()
        else:

            # convert the x, y co-ords into the shogi representation
            # (e.g. 8, 6 is 1g)
            sq = gv.board.get_square_posn(x, y)

            self.src = sq
            if gv.verbose:
                print "source square: (x, y) = (", x, ",",  y, ") ", sq
            self.src_x = x
            self.src_y = y

            # set the icon for the drag and drop to the piece that is being
            # dragged
            self.piece = gv.board.get_piece(x, y)
            pb = gv.board.get_piece_pixbuf(x, y)

            hot_x = pb.get_width() / 2
            hot_y = pb.get_height() / 2

            Gtk.drag_set_icon_pixbuf(drag_context,
                                     gv.board.get_piece_pixbuf(x, y),
                                     hot_x, hot_y)

            # save the pixbuf for use in the drop (receivecallback) routines
            self.dnd_pixbuf = pb

            # clear the square where the piece is being moved from
            gv.board.set_square_as_unoccupied(x, y)
コード例 #29
0
 def _set_drag_cover(self, context, pixbuf):
     """
         Completes drag icon setup
     """
     Gtk.drag_set_icon_pixbuf(context, pixbuf, 0, 0)