ef78427954
I do as much as I can outside of the init() function to make the code more readable. Doing everything in init() can make things more complicated and annoying.
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
# Bryan Schumaker (8/13/2010)
|
|
|
|
import gtk
|
|
import ocarina
|
|
import libsaria
|
|
files = None
|
|
|
|
TARGET_TYPE_URI_LIST = 80
|
|
DND_MASK = gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP
|
|
DND_LIST = [("text/uri-list", 0, TARGET_TYPE_URI_LIST)]
|
|
|
|
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
|
add = window.add
|
|
resize = window.resize
|
|
connect = window.connect
|
|
set_title = window.set_title
|
|
prefs = libsaria.prefs
|
|
|
|
window.drag_dest_set(DND_MASK, DND_LIST, gtk.gdk.ACTION_COPY)
|
|
|
|
def init():
|
|
from components import entry
|
|
|
|
width = libsaria.init_pref("ocarina.window.width", 800)
|
|
height = libsaria.init_pref("ocarina.window.height", 600)
|
|
|
|
connect("key-press-event", entry.key_press)
|
|
connect("delete-event", ocarina.exit)
|
|
connect("size-allocate", resized)
|
|
connect("drag-data-received", dnd_receive)
|
|
|
|
resize(width, height)
|
|
window.show()
|
|
|
|
def set_icon(path):
|
|
if libsaria.path.exists(path):
|
|
window.set_icon_from_file(path)
|
|
|
|
def resized(widget, geom):
|
|
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)
|
|
|
|
def dnd_receive(widget, context, x, y, selection, type, time):
|
|
global files
|
|
if files == None:
|
|
from libsaria.path import files
|
|
if type == TARGET_TYPE_URI_LIST:
|
|
uri = selection.data.strip('\r\n\x00')
|
|
for file in uri.split():
|
|
file = file[7:]
|
|
files.universal_open(file)
|