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-13 23:58:19 -04:00
|
|
|
|
|
|
|
class Window(gtk.Window):
|
2010-08-15 00:25:24 -04:00
|
|
|
def __init__(self, size):
|
2010-08-13 23:58:19 -04:00
|
|
|
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
|
|
|
|
connect = self.connect
|
|
|
|
connect("delete-event", ocarina.exit)
|
|
|
|
connect("size-allocate", self.resized)
|
2010-08-15 00:25:24 -04:00
|
|
|
connect("drag-data-received", self.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)]
|
|
|
|
self.drag_dest_set(mask, dnd_list, gtk.gdk.ACTION_COPY)
|
2010-08-13 23:58:19 -04:00
|
|
|
|
2010-08-15 00:25:24 -04:00
|
|
|
self.resize(size[0], size[1])
|
2010-08-13 23:58:19 -04:00
|
|
|
self.show()
|
|
|
|
|
|
|
|
|
|
|
|
def resized(self, widget, geom):
|
|
|
|
libsaria.prefs["window_size"] = (geom.width, geom.height)
|
|
|
|
|
|
|
|
|
2010-08-15 00:25:24 -04:00
|
|
|
def dnd_receive(self, widget, context, x, y, selection, type, time):
|
2010-08-15 01:05:37 -04:00
|
|
|
global data
|
|
|
|
if data == None:
|
|
|
|
from libsaria import data
|
2010-08-15 00:25:24 -04:00
|
|
|
if type == TARGET_TYPE_URI_LIST:
|
|
|
|
uri = selection.data.strip('\r\n\x00')
|
|
|
|
import os
|
|
|
|
for file in uri.split():
|
|
|
|
file = file[7:]
|
2010-08-15 01:05:37 -04:00
|
|
|
data.universal_open(file)
|