Drag and drop working for creating favorites, still problem with reordering
This commit is contained in:
parent
28d89a7297
commit
fffebe8897
@ -215,7 +215,8 @@ class TargetEntry(Structure):
|
|||||||
|
|
||||||
class pluginclass( object ):
|
class pluginclass( object ):
|
||||||
TARGET_TYPE_TEXT = 80
|
TARGET_TYPE_TEXT = 80
|
||||||
toButton = TargetEntry( "text/uri-list", 0, TARGET_TYPE_TEXT )
|
array2 = TargetEntry * 2
|
||||||
|
toButton = array2( ("text/uri-list", 0, TARGET_TYPE_TEXT), ("text/uri-list", 0, TARGET_TYPE_TEXT) )
|
||||||
TARGET_TYPE_FAV = 81
|
TARGET_TYPE_FAV = 81
|
||||||
array = TargetEntry * 3
|
array = TargetEntry * 3
|
||||||
toFav = array( ( "FAVORITES", Gtk.TargetFlags.SAME_APP, 81 ), ( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ) )
|
toFav = array( ( "FAVORITES", Gtk.TargetFlags.SAME_APP, 81 ), ( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ) )
|
||||||
@ -278,9 +279,9 @@ class pluginclass( object ):
|
|||||||
|
|
||||||
self.favoritesBox.connect( "drag-data-received", self.ReceiveCallback )
|
self.favoritesBox.connect( "drag-data-received", self.ReceiveCallback )
|
||||||
|
|
||||||
gtk.gtk_drag_dest_set ( hash(self.favoritesBox), Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toButton, Gdk.DragAction.COPY )
|
gtk.gtk_drag_dest_set ( hash(self.favoritesBox), Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toButton, 2, Gdk.DragAction.COPY )
|
||||||
self.showFavoritesButton.connect( "drag-data-received", self.ReceiveCallback )
|
self.showFavoritesButton.connect( "drag-data-received", self.ReceiveCallback )
|
||||||
gtk.gtk_drag_dest_set ( hash(self.showFavoritesButton), Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toButton, Gdk.DragAction.COPY )
|
gtk.gtk_drag_dest_set ( hash(self.showFavoritesButton), Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toButton, 2, Gdk.DragAction.COPY )
|
||||||
|
|
||||||
# self.searchButton.connect( "button_release_event", self.SearchWithButton )
|
# self.searchButton.connect( "button_release_event", self.SearchWithButton )
|
||||||
try:
|
try:
|
||||||
@ -1432,9 +1433,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.onFavButtonDragReorder )
|
||||||
gtk.gtk_drag_dest_set( hash(favButton), Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.fromFav, Gdk.DragAction.COPY )
|
gtk.gtk_drag_dest_set( hash(favButton), Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.fromFav, 2, Gdk.DragAction.COPY )
|
||||||
favButton.connect( "drag-data-get", self.onFavButtonDragReorderGet )
|
favButton.connect( "drag-data-get", self.onFavButtonDragReorderGet )
|
||||||
gtk.gtk_drag_source_set( hash(favButton), Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY )
|
gtk.gtk_drag_source_set( hash(favButton), Gdk.ModifierType.BUTTON1_MASK, self.toFav, 3, Gdk.DragAction.COPY )
|
||||||
position += 1
|
position += 1
|
||||||
|
|
||||||
self.favoritesSave()
|
self.favoritesSave()
|
||||||
@ -1482,9 +1483,10 @@ class pluginclass( object ):
|
|||||||
self.favoritesBox.attach( favorite, col, col + 1, row, row + 1, yoptions = 0 )
|
self.favoritesBox.attach( favorite, col, col + 1, row, row + 1, yoptions = 0 )
|
||||||
|
|
||||||
def favoritesReorder( self, oldposition, newposition ):
|
def favoritesReorder( self, oldposition, newposition ):
|
||||||
|
print oldposition, "old"
|
||||||
|
print newposition, "new"
|
||||||
if oldposition == newposition:
|
if oldposition == newposition:
|
||||||
return
|
return
|
||||||
|
|
||||||
tmp = self.favorites[ oldposition ]
|
tmp = self.favorites[ oldposition ]
|
||||||
if newposition > oldposition:
|
if newposition > oldposition:
|
||||||
if ( self.favorites[ newposition - 1 ].type == "space" or self.favorites[ newposition - 1 ].type == "separator" ) and self.favCols > 1:
|
if ( self.favorites[ newposition - 1 ].type == "space" or self.favorites[ newposition - 1 ].type == "separator" ) and self.favCols > 1:
|
||||||
@ -1513,9 +1515,9 @@ class pluginclass( object ):
|
|||||||
self.favoritesPositionOnGrid( favButton )
|
self.favoritesPositionOnGrid( favButton )
|
||||||
|
|
||||||
favButton.connect( "drag-data-received", self.onFavButtonDragReorder )
|
favButton.connect( "drag-data-received", self.onFavButtonDragReorder )
|
||||||
gtk.gtk_drag_dest_set( hash(favButton), Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toFav, Gdk.DragAction.COPY )
|
gtk.gtk_drag_dest_set( hash(favButton), Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toFav, 3, Gdk.DragAction.COPY )
|
||||||
favButton.connect( "drag-data-get", self.onFavButtonDragReorderGet )
|
favButton.connect( "drag-data-get", self.onFavButtonDragReorderGet )
|
||||||
gtk.gtk_drag_source_set ( hash(favButton), Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY )
|
gtk.gtk_drag_source_set ( hash(favButton), Gdk.ModifierType.BUTTON1_MASK, self.toFav, 3, Gdk.DragAction.COPY )
|
||||||
|
|
||||||
if position >= 0:
|
if position >= 0:
|
||||||
self.favoritesReorder( favButton.position, position )
|
self.favoritesReorder( favButton.position, position )
|
||||||
@ -1564,12 +1566,10 @@ class pluginclass( object ):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def onFavButtonDragReorderGet( self, widget, context, selection, targetType, eventTime ):
|
def onFavButtonDragReorderGet( self, widget, context, selection, targetType, eventTime ):
|
||||||
print "get"
|
|
||||||
if targetType == self.TARGET_TYPE_FAV:
|
if targetType == self.TARGET_TYPE_FAV:
|
||||||
selection.set( selection.target, 8, str(widget.position))
|
selection.set( selection.target, 8, str(widget.position))
|
||||||
|
|
||||||
def onFavButtonDragReorder( self, widget, context, x, y, selection, targetType, time ):
|
def onFavButtonDragReorder( self, widget, context, x, y, selection, targetType, time ):
|
||||||
print "reordeR"
|
|
||||||
if targetType == self.TARGET_TYPE_FAV:
|
if targetType == self.TARGET_TYPE_FAV:
|
||||||
self.favoritesReorder( int(selection.data), widget.position )
|
self.favoritesReorder( int(selection.data), widget.position )
|
||||||
|
|
||||||
|
@ -274,12 +274,12 @@ class ApplicationLauncher( easyButton ):
|
|||||||
|
|
||||||
array = TargetEntry * 2
|
array = TargetEntry * 2
|
||||||
targets = array(( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ))
|
targets = array(( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ))
|
||||||
gtk.gtk_drag_source_set(hash(self), Gdk.ModifierType.BUTTON1_MASK, targets, Gdk.DragAction.COPY)
|
gtk.gtk_drag_source_set(hash(self), Gdk.ModifierType.BUTTON1_MASK, targets, 2, Gdk.DragAction.COPY)
|
||||||
|
|
||||||
icon = self.getIcon( Gtk.IconSize.DND )
|
icon = self.getIcon( Gtk.IconSize.DND )
|
||||||
if icon:
|
if icon:
|
||||||
gtk.gtk_drag_source_set_icon_pixbuf( hash(self), hash(icon) )
|
gtk.gtk_drag_source_set_icon_pixbuf( hash(self), hash(icon) )
|
||||||
# del icon
|
del icon
|
||||||
|
|
||||||
self.connectSelf( "focus-in-event", self.onFocusIn )
|
self.connectSelf( "focus-in-event", self.onFocusIn )
|
||||||
self.connectSelf( "focus-out-event", self.onFocusOut )
|
self.connectSelf( "focus-out-event", self.onFocusOut )
|
||||||
|
Loading…
Reference in New Issue
Block a user