Began reworking most code

git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@28 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
bjschuma 2009-06-27 04:32:43 +00:00
parent c8dd47719e
commit 84710dbd20
7 changed files with 104 additions and 10 deletions

View File

@ -1,6 +1,7 @@
open: open:
geany src/*.py & geany src/*.py &
geany src/GuiObjects/*.py &
clean: clean:
rm -rf src/*.pyc rm -rf src/*.pyc

7
trunk/src/menuItem.py Normal file
View File

@ -0,0 +1,7 @@
import gtk
class MenuItem(gtk.MenuItem)
def __init__(self,label,func,text,func2):
gtk.MenuItem.__init__(self,label)
self.connect("activate",func,text,func2)
self.show()

View File

@ -7,6 +7,9 @@ import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gtk import gtk
from options import Options
from saveddata import SavedData
from song import Song from song import Song
from duration import Duration from duration import Duration
from library import Library from library import Library
@ -21,8 +24,17 @@ gobject.threads_init()
class main: class main:
def __init__(self,argv): def __init__(self,argv):
# Parse options
self.options = Options()
if ("-v" in argv) == True:
self.options.verbose = True
# Load saved data (or create new data)
self.data = SavedData(self.options)
self.window = Window(self.quit,self.options,self.data)
gtk.main()
'''
self.ops = Operations(self.quit) self.ops = Operations(self.quit)
self.library = Library() self.library = Library()
self.plist = Playlist() self.plist = Playlist()
self.plist.insert(self.library.nonBanned()) self.plist.insert(self.library.nonBanned())
@ -53,15 +65,21 @@ class main:
song = Song(info,self.next)#,self.commands.printLines) song = Song(info,self.next)#,self.commands.printLines)
self.ops.song = song self.ops.song = song
self.ops.next("","") self.ops.next("","")
window.song = self.ops.song
# Call gtk main # Call gtk main
gtk.main() gtk.main()
'''
# Eventually replace "delete_event" with this # Eventually replace "delete_event" with this
def quit(self,widget,event,data=None): def quit(self,widgit,data):
print "Quitting..." if self.options.verbose == True:
self.library.dump() print "Quitting..."
#print self.window.get_size()
self.data.size = self.window.get_size()
self.data.dump()
#self.library.dump()
gtk.main_quit() gtk.main_quit()
return False return False

6
trunk/src/options.py Normal file
View File

@ -0,0 +1,6 @@
import os
class Options:
def __init__(self):
self.verbose = False
self.user = os.path.expanduser("~")

30
trunk/src/saveddata.py Normal file
View File

@ -0,0 +1,30 @@
import os
import cPickle as pickle
class SavedData:
def __init__(self,options):
path = os.path.join(options.user,".ocarina")
path = os.path.join(path,"ocarina-data.data")
self.size = (800,600)
self.library = None
self.path = path
if os.path.exists(path):
self.load(path)
# Dump user data to a file
def dump(self):
out = open(self.path,'w')
p = pickle.Pickler(out,1)
p.dump(self)
out.close()
# Read user data from the file
def load(self,path):
print "User data found, loading..."
p = pickle.Unpickler(open(path))
data = p.load()
self.size = data.size

View File

@ -70,7 +70,7 @@ class Song():
# Change state to "playing" # Change state to "playing"
def play(self): def play(self,widgit,data):
self.player.set_state(gst.STATE_PLAYING) self.player.set_state(gst.STATE_PLAYING)
# Start main loop and find duration (if this hasn't been done yet) # Start main loop and find duration (if this hasn't been done yet)
while self.duration() == False: while self.duration() == False:
@ -78,7 +78,7 @@ class Song():
# Change state to "paused" # Change state to "paused"
def pause(self): def pause(self,widgit,data):
self.player.set_state(gst.STATE_PAUSED) self.player.set_state(gst.STATE_PAUSED)

View File

@ -6,11 +6,26 @@ import gtk
import thread import thread
from kiwi.ui.objectlist import Column, ObjectList from kiwi.ui.objectlist import Column, ObjectList
import GuiObjects.*
class Window(gtk.Window): class Window(gtk.Window):
def __init__(self,onQuit,ops): #def __init__(self,onQuit,ops,song):
def __init__(self,onQuit,options,data):
gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL) gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL)
print "Making window!" self.data = data
self.options = options
if self.options.verbose == True:
print "Making window!"
self.resize(self.data.size[0],self.data.size[1])
self.set_title("Ocarina")
self.connect("delete_event",onQuit)
self.mainLayout = gtk.VBox(False,0)
self.mainLayout.show()
self.makeMenuBar()
'''
self.song = song
self.ops = ops self.ops = ops
self.tree = None self.tree = None
self.tooltip = gtk.Tooltips() self.tooltip = gtk.Tooltips()
@ -29,6 +44,7 @@ class Window(gtk.Window):
self.makeList() self.makeList()
self.makeControls() self.makeControls()
self.maximize() self.maximize()
'''
self.show() self.show()
@ -179,8 +195,12 @@ class Window(gtk.Window):
row = gtk.HBox(False,0) row = gtk.HBox(False,0)
topRow = gtk.HBox(False,0) topRow = gtk.HBox(False,0)
# Make top row buttons # Make top row buttons
self.makeButton("play","images/play.png",None,self.ops.play,topRow) #self.makeButton("play","images/play.png",None,self.ops.play,topRow)
self.makeButton("pause","images/pause.png",None,self.ops.pause,topRow) self.makeButton("play","images/play.png",None,self.song.play,topRow)
#self.makeButton("pause","images/pause.png",None,self.ops.pause,topRow)
self.makeButton("pause","images/pause.png",None,self.song.pause,topRow)
self.makeButton("stop","images/stop.png",None,self.ops.stop,topRow) self.makeButton("stop","images/stop.png",None,self.ops.stop,topRow)
self.makeButton("next","images/next.png",None,self.ops.next,topRow) self.makeButton("next","images/next.png",None,self.ops.next,topRow)
self.makeButton("info",None,"Info",self.ops.info,topRow) self.makeButton("info",None,"Info",self.ops.info,topRow)
@ -242,6 +262,17 @@ class Window(gtk.Window):
def makeMenuBar(self): def makeMenuBar(self):
# Make a menu bar
bar = gtk.MenuBar()
# This is the dropdown selections
# Make a new library option
library = MenuItem("Library",None,None,None)
bar.append(library)
bar.show()
self.mainLayout.pack_start(bar,False,False,0)
'''
# Make menu bar # Make menu bar
bar = gtk.MenuBar() bar = gtk.MenuBar()
# This is the dropdown selections # This is the dropdown selections
@ -277,6 +308,7 @@ class Window(gtk.Window):
# Add to main layout # Add to main layout
bar.show() bar.show()
self.mainLayout.pack_start(bar,False,False,0) self.mainLayout.pack_start(bar,False,False,0)
'''
def selectDir(self,func): def selectDir(self,func):