53 lines
1.1 KiB
Python
53 lines
1.1 KiB
Python
# Bryan Schumaker (8/13/2010)
|
|
|
|
import ocarina
|
|
libsaria = ocarina.libsaria
|
|
gtk = ocarina.gtk
|
|
data = None
|
|
|
|
TARGET_TYPE_URI_LIST = 80
|
|
|
|
window = None
|
|
add = None
|
|
resize = None
|
|
connect = None
|
|
|
|
|
|
def init(size):
|
|
global window
|
|
global add
|
|
global resize
|
|
global connect
|
|
|
|
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
|
add = window.add
|
|
resize = window.resize
|
|
connect = window.connect
|
|
|
|
connect("delete-event", ocarina.exit)
|
|
connect("size-allocate", resized)
|
|
connect("drag-data-received", dnd_receive)
|
|
|
|
mask = gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP
|
|
dnd_list = [("text/uri-list", 0, TARGET_TYPE_URI_LIST)]
|
|
window.drag_dest_set(mask, dnd_list, gtk.gdk.ACTION_COPY)
|
|
|
|
window.resize(size[0], size[1])
|
|
window.show()
|
|
|
|
|
|
def resized(widget, geom):
|
|
libsaria.prefs["window_size"] = (geom.width, geom.height)
|
|
|
|
|
|
def dnd_receive(widget, context, x, y, selection, type, time):
|
|
global data
|
|
if data == None:
|
|
from libsaria import data
|
|
if type == TARGET_TYPE_URI_LIST:
|
|
uri = selection.data.strip('\r\n\x00')
|
|
import os
|
|
for file in uri.split():
|
|
file = file[7:]
|
|
data.universal_open(file)
|