ocarina: enable window drag-n-drop
This calls universal_open() to open whatever file is dropped onto the window
This commit is contained in:
parent
2c5d873cd0
commit
34f2ffe227
|
@ -5,11 +5,11 @@ import ocarina
|
|||
import libsaria
|
||||
import body
|
||||
import shortcuts
|
||||
#files = None
|
||||
from libsaria.path import files
|
||||
|
||||
#TARGET_TYPE_URI_LIST = 80
|
||||
#DND_MASK = gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP
|
||||
#DND_LIST = [("text/uri-list", 0, TARGET_TYPE_URI_LIST)]
|
||||
TARGET_TYPE_URI_LIST = 80
|
||||
DND_MASK = gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP
|
||||
DND_LIST = [("text/uri-list", 0, TARGET_TYPE_URI_LIST)]
|
||||
|
||||
width = libsaria.init_pref("ocarina.window.width", 800)
|
||||
height = libsaria.init_pref("ocarina.window.height", 600)
|
||||
|
@ -42,16 +42,11 @@ def resized(widget, geom):
|
|||
libsaria.prefs.set_pref("ocarina.window.height", geom.height)
|
||||
window.connect("size-allocate", resized)
|
||||
|
||||
#window.drag_dest_set(DND_MASK, DND_LIST, gtk.gdk.ACTION_COPY)
|
||||
|
||||
#def dnd_receive(widget, context, x, y, selection, type, time):
|
||||
#global files
|
||||
#if files == None:
|
||||
#from libsaria.path import files
|
||||
#if type == TARGET_TYPE_URI_LIST:
|
||||
#uri = selection.data.strip('\r\n\x00')
|
||||
#for file in uri.split():
|
||||
#file = file[7:]
|
||||
#files.universal_open(file)
|
||||
|
||||
#window.connect("drag-data-received", dnd_receive)
|
||||
def dnd_receive(widget, context, x, y, selection, type, time):
|
||||
if type == TARGET_TYPE_URI_LIST:
|
||||
uri = selection.data.strip('\r\n\x00')
|
||||
for file in uri.split():
|
||||
file = file[7:]
|
||||
files.universal_open(file)
|
||||
window.connect("drag-data-received", dnd_receive)
|
||||
window.drag_dest_set(DND_MASK, DND_LIST, gtk.gdk.ACTION_COPY)
|
||||
|
|
Loading…
Reference in New Issue