2010-08-13 23:58:19 -04:00
|
|
|
# Bryan Schumaker (8/13/2010)
|
|
|
|
|
2011-04-17 09:19:19 -04:00
|
|
|
import gtk
|
2010-08-13 23:58:19 -04:00
|
|
|
import ocarina
|
2011-04-17 09:19:19 -04:00
|
|
|
import libsaria
|
2010-11-20 10:01:25 -05:00
|
|
|
files = None
|
2010-08-13 23:58:19 -04:00
|
|
|
|
2010-08-15 00:25:24 -04:00
|
|
|
TARGET_TYPE_URI_LIST = 80
|
2011-04-17 09:19:19 -04:00
|
|
|
DND_MASK = gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP
|
|
|
|
DND_LIST = [("text/uri-list", 0, TARGET_TYPE_URI_LIST)]
|
2010-08-15 00:25:24 -04:00
|
|
|
|
2011-04-17 09:19:19 -04:00
|
|
|
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
|
|
|
add = window.add
|
|
|
|
resize = window.resize
|
|
|
|
connect = window.connect
|
|
|
|
set_title = window.set_title
|
|
|
|
prefs = libsaria.prefs
|
2010-08-15 00:25:24 -04:00
|
|
|
|
2011-04-17 09:19:19 -04:00
|
|
|
window.drag_dest_set(DND_MASK, DND_LIST, gtk.gdk.ACTION_COPY)
|
2010-08-13 23:58:19 -04:00
|
|
|
|
2011-04-17 09:19:19 -04:00
|
|
|
def init():
|
2010-12-16 22:02:34 -05:00
|
|
|
from components import entry
|
|
|
|
|
2011-04-17 09:19:19 -04:00
|
|
|
width = libsaria.init_pref("ocarina.window.width", 800)
|
|
|
|
height = libsaria.init_pref("ocarina.window.height", 600)
|
2010-08-13 23:58:19 -04:00
|
|
|
|
2010-12-16 22:02:34 -05:00
|
|
|
connect("key-press-event", entry.key_press)
|
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-11-23 20:05:37 -05:00
|
|
|
resize(width, height)
|
2010-08-22 09:20:27 -04:00
|
|
|
window.show()
|
2010-08-13 23:58:19 -04:00
|
|
|
|
2010-11-23 20:05:37 -05:00
|
|
|
def set_icon(path):
|
|
|
|
if libsaria.path.exists(path):
|
|
|
|
window.set_icon_from_file(path)
|
|
|
|
|
2010-08-22 09:20:27 -04:00
|
|
|
def resized(widget, geom):
|
2010-12-16 11:03:09 -05:00
|
|
|
if prefs.get_pref("ocarina.window.width") != geom.width:
|
|
|
|
libsaria.prefs.set_pref("ocarina.window.width", geom.width)
|
|
|
|
if prefs.get_pref("ocarina.window.height") != geom.height:
|
|
|
|
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):
|
2010-11-20 10:01:25 -05:00
|
|
|
global files
|
|
|
|
if files == None:
|
|
|
|
from libsaria.path import files
|
2010-08-22 09:20:27 -04:00
|
|
|
if type == TARGET_TYPE_URI_LIST:
|
|
|
|
uri = selection.data.strip('\r\n\x00')
|
|
|
|
for file in uri.split():
|
|
|
|
file = file[7:]
|
2010-11-20 10:01:25 -05:00
|
|
|
files.universal_open(file)
|