More window cleanups
This is looking like a less intimidating file now. It should be more usable going forward.
This commit is contained in:
parent
ef78427954
commit
7caeddf615
|
@ -3,18 +3,13 @@
|
|||
|
||||
import ocarina
|
||||
import libsaria
|
||||
from ocarina import window
|
||||
from ocarina import body
|
||||
from ocarina import library
|
||||
from ocarina import playlist
|
||||
from ocarina import queue
|
||||
from ocarina import menu
|
||||
|
||||
window.init()
|
||||
body.init(window)
|
||||
window.set_title("%s" % ocarina.__vers__)
|
||||
window.set_icon("images/ocarina.png")
|
||||
window.add(body.body)
|
||||
body.init(ocarina.window.window)
|
||||
|
||||
text = "Pause after current song"
|
||||
menu.add_common_menu_item(text, libsaria.controls.do_pause_after)
|
||||
|
|
|
@ -26,3 +26,6 @@ def exit(widget, event):
|
|||
gtk.main_quit()
|
||||
libsaria.shutdown()
|
||||
print "Ocarina ran for: %s" % uptime()
|
||||
|
||||
import window
|
||||
window.init()
|
||||
|
|
|
@ -65,6 +65,7 @@ def init(window):
|
|||
body = gtk.Notebook()
|
||||
body.set_tab_pos(gtk.POS_LEFT)
|
||||
body.show()
|
||||
window.add(body)
|
||||
|
||||
def init_page(page_name):
|
||||
page = prefs.init_pref("ocarina.body.page", page_name)
|
||||
|
|
|
@ -4,7 +4,6 @@ import ocarina
|
|||
gtk = ocarina.gtk
|
||||
LS = ocarina.libsaria
|
||||
|
||||
body = ocarina.body
|
||||
filter = None
|
||||
|
||||
class FilterEntry(gtk.Entry):
|
||||
|
@ -16,7 +15,7 @@ class FilterEntry(gtk.Entry):
|
|||
self.show()
|
||||
|
||||
def filter(self, entry):
|
||||
body.cur_page_filter(entry.get_text())
|
||||
ocarina.body.cur_page_filter(entry.get_text())
|
||||
|
||||
def key_press(widget, event):
|
||||
name = gtk.gdk.keyval_name(event.keyval)
|
||||
|
@ -36,7 +35,7 @@ def key_press(widget, event):
|
|||
elif name == "d":
|
||||
ocarina.footer.down_button()
|
||||
elif name == "g":
|
||||
body.cur_page_goto()
|
||||
ocarina.body.cur_page_goto()
|
||||
elif name == "n":
|
||||
LS.controls.next()
|
||||
elif name == "s":
|
||||
|
|
|
@ -10,26 +10,17 @@ DND_MASK = gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAU
|
|||
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)
|
||||
set_title(ocarina.__vers__)
|
||||
|
||||
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.connect("key-press-event", entry.key_press)
|
||||
window.resize(width, height)
|
||||
window.show()
|
||||
|
||||
def set_icon(path):
|
||||
|
@ -37,9 +28,9 @@ def set_icon(path):
|
|||
window.set_icon_from_file(path)
|
||||
|
||||
def resized(widget, geom):
|
||||
if prefs.get_pref("ocarina.window.width") != geom.width:
|
||||
if libsaria.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:
|
||||
if libsaria.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):
|
||||
|
@ -51,3 +42,8 @@ def dnd_receive(widget, context, x, y, selection, type, time):
|
|||
for file in uri.split():
|
||||
file = file[7:]
|
||||
files.universal_open(file)
|
||||
|
||||
window.connect("delete-event", ocarina.exit)
|
||||
window.connect("size-allocate", resized)
|
||||
window.connect("drag-data-received", dnd_receive)
|
||||
set_icon("images/ocarina.png")
|
||||
|
|
Loading…
Reference in New Issue