ocarina/ocarina/window.py

37 lines
972 B
Python

# Bryan Schumaker (8/13/2010)
import ocarina
libsaria = ocarina.libsaria
gtk = ocarina.gtk
TARGET_TYPE_URI_LIST = 80
class Window(gtk.Window):
def __init__(self, size):
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
connect = self.connect
connect("delete-event", ocarina.exit)
connect("size-allocate", self.resized)
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)
self.resize(size[0], size[1])
self.show()
def resized(self, widget, geom):
libsaria.prefs["window_size"] = (geom.width, geom.height)
def dnd_receive(self, widget, context, x, y, selection, type, time):
if type == TARGET_TYPE_URI_LIST:
uri = selection.data.strip('\r\n\x00')
import os
for file in uri.split():
file = file[7:]
print file, os.path.isfile(file)