コード例 #1
0
    def get_suiting_target(self, widget, context, x, y, data=None):
        """
        find a suiting target within the registered drop_targets
        that allows to drop
        """

        for target in self.drop_targets:
            if target.atom in context.list_targets():
                same_app = gtk.drag_get_source_widget(context) is not None
                if target.app & gtk.TARGET_SAME_APP != 0 and not same_app:
                    continue
                if target.app & gtk.TARGET_OTHER_APP != 0 and same_app:
                    continue

                same_widget = gtk.drag_get_source_widget(context) is widget
                if target.widget & gtk.TARGET_SAME_WIDGET != 0 and not same_widget:
                    continue
                if target.widget & gtk.TARGET_OTHER_WIDGET != 0 and same_widget:
                    continue

                if data is None and target.preview_required:
                    # we can potentially drop here, however need a data preview first
                    return target

                if target.can_drop(widget, context, x, y, data):
                    return target
        # no suitable target found
        return None
コード例 #2
0
ファイル: pixbuflist.py プロジェクト: gwojcik/mypaint
 def drag_motion_cb(self, widget, context, x, y, time):
     if not self.dragging_allowed:
         return False
     action = None
     source_widget = gtk.drag_get_source_widget(context)
     if self is source_widget:
         # Only moves are possible
         action = gdk.ACTION_MOVE
     else:
         # Dragging from another widget, default action is copy
         action = gdk.ACTION_COPY
         # However, if the item already exists here, it's a move
         sel = source_widget.selected
         if sel in self.itemlist:
             action = gdk.ACTION_MOVE
         else:
             # the user can force a move by pressing shift
             tup = self.get_window().get_pointer()
             kbmods = tup[-1]
             if kbmods & gdk.SHIFT_MASK:
                 action = gdk.ACTION_MOVE
     gdk.drag_status(context, action, time)
     if not self.drag_highlighted:
         #self.drag_highlight()   # XXX nonfunctional
         self.drag_highlighted = True
         self.queue_draw()
     if self.drag_highlighted:
         i = self.index(x, y)
         if i != self.drag_insertion_index:
             self.queue_draw()
             self.drag_insertion_index = i
コード例 #3
0
 def drag_motion_cb(self, widget, context, x, y, time):
     if not self.dragging_allowed:
         return False
     action = None
     source_widget = gtk.drag_get_source_widget(context)
     if self is source_widget:
         # Only moves are possible
         action = gdk.ACTION_MOVE
     else:
         # Dragging from another widget, default action is copy
         action = gdk.ACTION_COPY
         # However, if the item already exists here, it's a move
         sel = source_widget.selected
         if sel in self.itemlist:
             action = gdk.ACTION_MOVE
         else:
             # the user can force a move by pressing shift
             tup = self.get_window().get_pointer()
             kbmods = tup[-1]
             if kbmods & gdk.SHIFT_MASK:
                 action = gdk.ACTION_MOVE
     gdk.drag_status(context, action, time)
     if not self.drag_highlighted:
         #self.drag_highlight()   # XXX nonfunctional
         self.drag_highlighted = True
         self.queue_draw()
     if self.drag_highlighted:
         i = self.index(x, y)
         if i != self.drag_insertion_index:
             self.queue_draw()
             self.drag_insertion_index = i
コード例 #4
0
ファイル: JAMediaTube.py プロジェクト: i5o/JAMediaSuite
    def __drag_drop(self, destino, drag_context, x, y, n):
        """
        Ejecuta drop sobre un destino.
        """

        videoitem = gtk.drag_get_source_widget(drag_context)

        if videoitem.get_parent() == destino:
            return

        else:
            # E try siguiente es para evitar problemas cuando:
            # El drag termina luego de que el origen se ha
            # comenzado a descargar y por lo tanto, no tiene padre.
            try:
                videoitem.get_parent().remove(videoitem)
                destino.pack_start(videoitem, False, False, 1)

            except:
                return

            if destino == self.paneltube.descargar:
                text = TipDescargas

            elif destino == self.paneltube.encontrados:
                text = TipEncontrados

            videoitem.set_tooltip_text(text)
コード例 #5
0
ファイル: pixbuflist.py プロジェクト: Griatch/dopey
 def drag_data_received_cb(self, widget, context, x, y, selection,
                           info, time):
     if info != DRAG_ITEM_ID:
         return False
     data = selection.get_text()
     data_type = selection.get_data_type()
     fmt = selection.get_format()
     logger.debug("drag-data-received: got type=%r", data_type)
     logger.debug("drag-data-received: got fmt=%r", fmt)
     logger.debug("drag-data-received: got data=%r len=%r", data, len(data))
     target_item_idx = self.index(x, y) # idx always valid, we reject
                                        # drops at invalid idx
     src_widget = gtk.drag_get_source_widget(context)
     is_copy = context.get_selected_action() == gdk.ACTION_COPY
     success = self.on_drag_data(is_copy, src_widget, data, target_item_idx)
     context.finish(success, False, time)
     return True
コード例 #6
0
ファイル: pixbuflist.py プロジェクト: thorsummoner/mypaint
    def drag_data_received_cb(self, widget, context, x, y, selection, info,
                              time):
        if info != DRAG_ITEM_ID:
            return False
        data = selection.get_text()
        data_type = selection.get_data_type()
        fmt = selection.get_format()
        logger.debug("drag-data-received: got type=%r", data_type)
        logger.debug("drag-data-received: got fmt=%r", fmt)
        logger.debug("drag-data-received: got data=%r len=%r", data, len(data))

        # isc always valid, we reject drops at invalid idx
        target_item_idx = self.index(x, y)

        src_widget = gtk.drag_get_source_widget(context)
        is_copy = context.get_selected_action() == gdk.ACTION_COPY
        success = self.on_drag_data(is_copy, src_widget, data, target_item_idx)
        context.finish(success, False, time)
        return True
コード例 #7
0
ファイル: pixbuflist.py プロジェクト: thorsummoner/mypaint
 def drag_motion_cb(self, widget, context, x, y, time):
     if not self.dragging_allowed:
         return False
     action = None
     source_widget = gtk.drag_get_source_widget(context)
     if self is source_widget:
         # Only moves are possible
         action = gdk.ACTION_MOVE
     else:
         # Dragging from another widget, is always a copy
         action = gdk.ACTION_COPY
     gdk.drag_status(context, action, time)
     if not self.drag_highlighted:
         self.drag_highlighted = True
         self.queue_draw()
     if self.drag_highlighted:
         i = self.index(x, y)
         if i != self.drag_insertion_index:
             self.queue_draw()
             self.drag_insertion_index = i
コード例 #8
0
ファイル: pixbuflist.py プロジェクト: psmorelle72/mypaint
 def drag_motion_cb(self, widget, context, x, y, time):
     if not self.dragging_allowed:
         return False
     action = None
     source_widget = gtk.drag_get_source_widget(context)
     if self is source_widget:
         # Only moves are possible
         action = gdk.ACTION_MOVE
     else:
         # Dragging from another widget, is always a copy
         action = gdk.ACTION_COPY
     gdk.drag_status(context, action, time)
     if not self.drag_highlighted:
         self.drag_highlighted = True
         self.queue_draw()
     if self.drag_highlighted:
         i = self.index(x, y)
         if i != self.drag_insertion_index:
             self.queue_draw()
             self.drag_insertion_index = i
コード例 #9
0
 def __drag_drop(self, destino, drag_context, x, y, n):
     """
     Ejecuta drop sobre un destino.
     """
     videoitem = gtk.drag_get_source_widget(drag_context)
     if videoitem.get_parent() == destino:
         return
     else:
         # E try siguiente es para evitar problemas cuando:
         # El drag termina luego de que el origen se ha
         # comenzado a descargar y por lo tanto, no tiene padre.
         try:
             videoitem.get_parent().remove(videoitem)
             destino.pack_start(videoitem, False, False, 1)
         except:
             return
         if destino == self.paneltube.descargar:
             text = TipDescargas
         elif destino == self.paneltube.encontrados:
             text = TipEncontrados
         videoitem.set_tooltip_text(text)