Fix DND in favorites

This commit is contained in:
Clement Lefebvre 2017-04-28 15:50:25 +01:00
parent ccf9573581
commit 916ad7b731

View File

@ -1407,10 +1407,10 @@ class pluginclass( object ):
favButton.position = position favButton.position = position
self.favorites.append( favButton ) self.favorites.append( favButton )
self.favoritesPositionOnGrid( favButton ) self.favoritesPositionOnGrid( favButton )
favButton.connect( "drag-data-received", self.onFavButtonDragReorder )
favButton.drag_dest_set( Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toFav, Gdk.DragAction.COPY )
favButton.connect( "drag-data-get", self.onFavButtonDragReorderGet )
favButton.drag_source_set (Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY) favButton.drag_source_set (Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY)
favButton.drag_dest_set(Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toFav, Gdk.DragAction.COPY)
favButton.connect("drag-data-get", self.on_drag_data_get)
favButton.connect("drag-data-received", self.on_drag_data_received)
position += 1 position += 1
self.favoritesSave() self.favoritesSave()
@ -1469,9 +1469,9 @@ class pluginclass( object ):
self.favorites.append( favButton ) self.favorites.append( favButton )
self.favoritesPositionOnGrid( favButton ) self.favoritesPositionOnGrid( favButton )
favButton.connect( "drag-data-received", self.onFavButtonDragReorder ) favButton.connect("drag-data-received", self.on_drag_data_received)
favButton.drag_dest_set(Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toFav, Gdk.DragAction.COPY) favButton.drag_dest_set(Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toFav, Gdk.DragAction.COPY)
favButton.connect( "drag-data-get", self.onFavButtonDragReorderGet ) favButton.connect("drag-data-get", self.on_drag_data_get)
favButton.drag_source_set (Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY) favButton.drag_source_set (Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY)
if position >= 0: if position >= 0:
@ -1519,15 +1519,14 @@ class pluginclass( object ):
return False return False
def onFavButtonDragReorderGet( self, widget, context, selection, targetType, eventTime ): def on_drag_data_get(self, widget, context, selection, info, time):
if targetType == self.TARGET_TYPE_FAV: if info == self.TARGET_TYPE_FAV:
self.drag_origin = widget.position self.drag_origin = widget.position
selection.set( selection.target, 8, str(widget.position)) selection.set(selection.get_target(), 8, str(widget.position))
def onFavButtonDragReorder( self, widget, context, x, y, selection, targetType, time ): def on_drag_data_received( self, widget, context, x, y, selection, info, time):
if targetType == self.TARGET_TYPE_FAV: if info == self.TARGET_TYPE_FAV:
#self.favoritesReorder( int(selection.data), widget.position ) self.favoritesReorder( int(selection.get_data()), widget.position )
self.favoritesReorder( self.drag_origin, widget.position )
def on_icon_theme_changed(self, theme): def on_icon_theme_changed(self, theme):
print "on_icon_theme_changed" print "on_icon_theme_changed"