More drag and drop work
This commit is contained in:
parent
edbfda1764
commit
28d89a7297
@ -219,7 +219,8 @@ class pluginclass( object ):
|
||||
TARGET_TYPE_FAV = 81
|
||||
array = TargetEntry * 3
|
||||
toFav = array( ( "FAVORITES", Gtk.TargetFlags.SAME_APP, 81 ), ( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ) )
|
||||
fromFav = TargetEntry( "FAVORITES", Gtk.TargetFlags.SAME_APP, 81 )
|
||||
array1 = TargetEntry * 2
|
||||
fromFav = array1( ("FAVORITES", Gtk.TargetFlags.SAME_APP, 81), ("FAVORITES", Gtk.TargetFlags.SAME_APP, 81) )
|
||||
|
||||
@print_timing
|
||||
def __init__( self, mintMenuWin, toggleButton, de ):
|
||||
@ -275,10 +276,10 @@ class pluginclass( object ):
|
||||
# Hookup for text input
|
||||
self.content_holder.connect( "key-press-event", self.keyPress )
|
||||
|
||||
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 )
|
||||
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 )
|
||||
|
||||
# self.searchButton.connect( "button_release_event", self.SearchWithButton )
|
||||
@ -1430,9 +1431,9 @@ class pluginclass( object ):
|
||||
favButton.position = position
|
||||
self.favorites.append( favButton )
|
||||
self.favoritesPositionOnGrid( favButton )
|
||||
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 )
|
||||
favButton.connect( "drag_data_get", self.onFavButtonDragReorderGet )
|
||||
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 )
|
||||
favButton.connect( "drag-data-get", self.onFavButtonDragReorderGet )
|
||||
gtk.gtk_drag_source_set( hash(favButton), Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY )
|
||||
position += 1
|
||||
|
||||
@ -1511,9 +1512,9 @@ class pluginclass( object ):
|
||||
self.favorites.append( 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 )
|
||||
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 )
|
||||
|
||||
if position >= 0:
|
||||
@ -1563,10 +1564,12 @@ class pluginclass( object ):
|
||||
return False
|
||||
|
||||
def onFavButtonDragReorderGet( self, widget, context, selection, targetType, eventTime ):
|
||||
print "get"
|
||||
if targetType == self.TARGET_TYPE_FAV:
|
||||
selection.set( selection.target, 8, str(widget.position) )
|
||||
|
||||
def onFavButtonDragReorder( self, widget, context, x, y, selection, targetType, time ):
|
||||
print "reordeR"
|
||||
if targetType == self.TARGET_TYPE_FAV:
|
||||
self.favoritesReorder( int(selection.data), widget.position )
|
||||
|
||||
|
@ -12,7 +12,10 @@ import xdg.DesktopEntry
|
||||
import xdg.Menu
|
||||
from filemonitor import monitor as filemonitor
|
||||
import glib
|
||||
import ctypes
|
||||
from ctypes import *
|
||||
|
||||
gtk = CDLL("libgtk-x11-2.0.so.0")
|
||||
|
||||
class IconManager(GObject.GObject):
|
||||
|
||||
@ -231,6 +234,11 @@ class easyButton( Gtk.Button ):
|
||||
#[ iW, iH ] = iconManager.getIconSize( self.iconSize )
|
||||
self.buttonImage.set_size_request( self.iconSize, self.iconSize )
|
||||
|
||||
class TargetEntry(Structure):
|
||||
_fields_ = [("target", c_char_p),
|
||||
("flags", c_int),
|
||||
("info", c_int)]
|
||||
|
||||
class ApplicationLauncher( easyButton ):
|
||||
|
||||
def __init__( self, desktopFile, iconSize):
|
||||
@ -262,13 +270,16 @@ class ApplicationLauncher( easyButton ):
|
||||
self.setupLabels()
|
||||
|
||||
# Drag and Drop
|
||||
self.connectSelf( "drag_data_get", self.dragDataGet )
|
||||
#FIX self.drag_source_set( Gdk.ModifierType.BUTTON1_MASK , [ ( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ) ], Gdk.DragAction.COPY )
|
||||
self.connectSelf( "drag-data-get", self.dragDataGet )
|
||||
|
||||
array = TargetEntry * 2
|
||||
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)
|
||||
|
||||
icon = self.getIcon( Gtk.IconSize.DND )
|
||||
if icon:
|
||||
#FIX # self.drag_source_set_icon_pixbuf( icon )
|
||||
del icon
|
||||
gtk.gtk_drag_source_set_icon_pixbuf( hash(self), hash(icon) )
|
||||
# del icon
|
||||
|
||||
self.connectSelf( "focus-in-event", self.onFocusIn )
|
||||
self.connectSelf( "focus-out-event", self.onFocusOut )
|
||||
@ -356,6 +367,7 @@ class ApplicationLauncher( easyButton ):
|
||||
|
||||
|
||||
def dragDataGet( self, widget, context, selection, targetType, eventTime ):
|
||||
print "drag data get"
|
||||
if targetType == 100: # text/plain
|
||||
selection.set_text( "'" + self.desktopFile + "'", -1 )
|
||||
elif targetType == 101: # text/uri-list
|
||||
|
Loading…
Reference in New Issue
Block a user