Ocarina GUI
I have begun creating the Ocarina 4.1 gui. So far, I can create and resize a window. After a resize, the new size is saved and used again when Ocarina is next started. I am also investigating drag and drop for use with plugin loading.
This commit is contained in:
parent
d8cadb83e9
commit
7ce3da1a2a
|
@ -16,5 +16,11 @@ def startup():
|
||||||
global vars
|
global vars
|
||||||
global prefs
|
global prefs
|
||||||
vars = Map()
|
vars = Map()
|
||||||
prefs = Map()
|
prefs = Map("preferences")
|
||||||
event.start("POSTINIT")
|
event.start("POSTINIT")
|
||||||
|
|
||||||
|
|
||||||
|
def init_pref(key, value):
|
||||||
|
global prefs
|
||||||
|
if prefs.get(key) == None:
|
||||||
|
prefs[key] = value
|
||||||
|
|
|
@ -2,19 +2,27 @@
|
||||||
|
|
||||||
get = dict.get
|
get = dict.get
|
||||||
|
|
||||||
class TagNode:
|
class TagNode(dict):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
dict.__init__(self)
|
||||||
|
|
||||||
def insert(self, tag_list, tags, audio, filepath):
|
def insert(self, tag_list, tags, audio, filepath):
|
||||||
self.artist = tags.artist
|
self["artist"] = tags.artist
|
||||||
self.album = tags.album
|
self["album"] = tags.album
|
||||||
self.title = tags.title
|
self["title"] = tags.title
|
||||||
self.year = tags.year
|
self["year"] = tags.year
|
||||||
|
|
||||||
self.filepath = filepath
|
self["filepath"] = filepath
|
||||||
self.playcount = 0
|
self["playcount"] = 0
|
||||||
self.length = audio.length
|
self["length"] = audio.length
|
||||||
|
#self.artist = tags.artist
|
||||||
|
#self.album = tags.album
|
||||||
|
#self.title = tags.title
|
||||||
|
#self.year = tags.year
|
||||||
|
|
||||||
|
#self.filepath = filepath
|
||||||
|
#self.playcount = 0
|
||||||
|
#self.length = audio.length
|
||||||
|
|
||||||
def sort(self, level):
|
def sort(self, level):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -6,7 +6,7 @@ import cPickle as pickle
|
||||||
PROTO = pickle.HIGHEST_PROTOCOL
|
PROTO = pickle.HIGHEST_PROTOCOL
|
||||||
|
|
||||||
def save(item, file, ext="pickle"):
|
def save(item, file, ext="pickle"):
|
||||||
file = "%s%s" % (path.join(path.sariadir(),file), ext)
|
file = "%s.%s" % (path.join(path.sariadir(),file), ext)
|
||||||
savefile(item, file)
|
savefile(item, file)
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ def savefile(item, file):
|
||||||
|
|
||||||
|
|
||||||
def load(file, ext="pickle"):
|
def load(file, ext="pickle"):
|
||||||
file = "%s%s" % (path.join(path.sariadir(),file),ext)
|
file = "%s.%s" % (path.join(path.sariadir(),file),ext)
|
||||||
return loadfile(file)
|
return loadfile(file)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# Bryan Schumaker (8/13/2010)
|
||||||
|
|
||||||
|
import libsaria
|
||||||
|
import ocarina
|
||||||
|
|
||||||
|
libsaria.startup()
|
||||||
|
libsaria.init_pref("window_size", (800,600))
|
||||||
|
|
||||||
|
prefs = libsaria.prefs
|
||||||
|
|
||||||
|
win = ocarina.get_window(prefs["window_size"])
|
||||||
|
|
||||||
|
ocarina.startup()
|
|
@ -0,0 +1,56 @@
|
||||||
|
# Bryan Schumaker (8/13/2010)
|
||||||
|
|
||||||
|
import gtk
|
||||||
|
import libsaria
|
||||||
|
|
||||||
|
# Lazy loaded modules
|
||||||
|
window = None
|
||||||
|
tabs = None
|
||||||
|
|
||||||
|
|
||||||
|
# Global variables for some objects
|
||||||
|
main_window = None
|
||||||
|
main_tabs = None
|
||||||
|
|
||||||
|
|
||||||
|
def startup():
|
||||||
|
global gtk
|
||||||
|
import gtk
|
||||||
|
gtk.main()
|
||||||
|
|
||||||
|
|
||||||
|
def exit(widget, event):
|
||||||
|
gtk.main_quit()
|
||||||
|
|
||||||
|
|
||||||
|
def get_main_tabs_init():
|
||||||
|
global tabs
|
||||||
|
import tabs
|
||||||
|
global get_main_tabs
|
||||||
|
get_main_tabs = get_main_tabs_always
|
||||||
|
return get_main_tabs_always()
|
||||||
|
def get_main_tabs_always():
|
||||||
|
global tabs
|
||||||
|
global main_tabs
|
||||||
|
if main_tabs == None:
|
||||||
|
main_tabs = tabs.Tabs()
|
||||||
|
return main_tabs
|
||||||
|
get_main_tabs = get_main_tabs_init
|
||||||
|
|
||||||
|
|
||||||
|
def get_window_init(size):
|
||||||
|
global window
|
||||||
|
import window
|
||||||
|
global get_window
|
||||||
|
get_window = get_window_always
|
||||||
|
return get_window_always(size)
|
||||||
|
def get_window_always(size=None):
|
||||||
|
global window
|
||||||
|
global main_window
|
||||||
|
if main_window == None:
|
||||||
|
main_window = window.Window()
|
||||||
|
main_window.add(get_main_tabs())
|
||||||
|
if size != None:
|
||||||
|
main_window.resize(size[0], size[1])
|
||||||
|
return main_window
|
||||||
|
get_window = get_window_init
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Bryan Schumaker (8/13/2010)
|
||||||
|
|
||||||
|
import ocarina
|
||||||
|
|
||||||
|
libsaria = ocarina.libsaria
|
||||||
|
gtk = ocarina.gtk
|
||||||
|
|
||||||
|
class Tabs(gtk.Notebook):
|
||||||
|
def __init__(self):
|
||||||
|
gtk.Notebook.__init__(self)
|
||||||
|
self.show()
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Bryan Schumaker (8/13/2010)
|
||||||
|
|
||||||
|
import ocarina
|
||||||
|
libsaria = ocarina.libsaria
|
||||||
|
gtk = ocarina.gtk
|
||||||
|
|
||||||
|
|
||||||
|
class Window(gtk.Window):
|
||||||
|
def __init__(self):
|
||||||
|
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
|
||||||
|
connect = self.connect
|
||||||
|
connect("delete-event", ocarina.exit)
|
||||||
|
connect("size-allocate", self.resized)
|
||||||
|
connect("drag_motion", self.dnd)
|
||||||
|
connect("drag_drop", self.dnd)
|
||||||
|
|
||||||
|
self.drag_dest_set(0, [], 0)
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
|
||||||
|
def resized(self, widget, geom):
|
||||||
|
libsaria.prefs["window_size"] = (geom.width, geom.height)
|
||||||
|
|
||||||
|
|
||||||
|
def dnd(self, widget, *args):
|
||||||
|
print widget, args
|
|
@ -15,7 +15,10 @@ after = now()
|
||||||
print "libsaria loaded (", after-before, ")"
|
print "libsaria loaded (", after-before, ")"
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
|
before = now()
|
||||||
libsaria.startup()
|
libsaria.startup()
|
||||||
|
after = now()
|
||||||
|
print "startup took", after-before
|
||||||
print
|
print
|
||||||
print "Available tests:"
|
print "Available tests:"
|
||||||
for file in os.listdir("tests"):
|
for file in os.listdir("tests"):
|
||||||
|
|
Loading…
Reference in New Issue