2010-08-13 23:58:19 -04:00
|
|
|
# Bryan Schumaker (8/13/2010)
|
|
|
|
|
|
|
|
import ocarina
|
|
|
|
libsaria = ocarina.libsaria
|
|
|
|
gtk = ocarina.gtk
|
2010-08-15 01:05:37 -04:00
|
|
|
data = None
|
2010-08-13 23:58:19 -04:00
|
|
|
|
2010-08-15 00:25:24 -04:00
|
|
|
TARGET_TYPE_URI_LIST = 80
|
|
|
|
|
2010-08-22 09:20:27 -04:00
|
|
|
window = None
|
|
|
|
add = None
|
|
|
|
resize = None
|
|
|
|
connect = None
|
2010-08-13 23:58:19 -04:00
|
|
|
|
2010-08-15 00:25:24 -04:00
|
|
|
|
2010-08-22 09:20:27 -04:00
|
|
|
def init(size):
|
|
|
|
global window
|
|
|
|
global add
|
|
|
|
global resize
|
|
|
|
global connect
|
2010-08-13 23:58:19 -04:00
|
|
|
|
2010-08-22 09:20:27 -04:00
|
|
|
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
|
|
|
add = window.add
|
|
|
|
resize = window.resize
|
|
|
|
connect = window.connect
|
2010-08-13 23:58:19 -04:00
|
|
|
|
2010-08-22 09:20:27 -04:00
|
|
|
connect("delete-event", ocarina.exit)
|
|
|
|
connect("size-allocate", resized)
|
|
|
|
connect("drag-data-received", dnd_receive)
|
2010-08-13 23:58:19 -04:00
|
|
|
|
2010-08-22 09:20:27 -04:00
|
|
|
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)
|
2010-08-13 23:58:19 -04:00
|
|
|
|
2010-08-22 09:20:27 -04:00
|
|
|
window.resize(size[0], size[1])
|
|
|
|
window.show()
|
2010-08-13 23:58:19 -04:00
|
|
|
|
2010-08-22 09:20:27 -04:00
|
|
|
|
|
|
|
def resized(widget, geom):
|
2010-11-15 21:11:12 -05:00
|
|
|
libsaria.prefs.set_pref("ocarina.window.width", geom.width)
|
|
|
|
libsaria.prefs.set_pref("ocarina.window.height", geom.height)
|
2010-08-22 09:20:27 -04:00
|
|
|
|
|
|
|
|
|
|
|
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)
|