Made menuItem class and GuiObjects module

git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@29 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
bjschuma 2009-06-27 05:31:07 +00:00
parent 84710dbd20
commit 972d0ccd77
7 changed files with 43 additions and 55 deletions

View File

@ -5,6 +5,10 @@ open:
clean:
rm -rf src/*.pyc
rm -rf src/*~
rm -rf src/GuiObjects/*.pyc
rm -rf src/GuiObjects/*~
rm *~
install:
rsync src/ ~/bin/ocarina-bin/

View File

@ -0,0 +1,2 @@
__all__ = ['menuItem']

View File

@ -0,0 +1,18 @@
import gtk
class MenuItem(gtk.MenuItem):
def __init__(self,lbl,func,text,func2,subs):
gtk.MenuItem.__init__(self,label=lbl)
if func != None:
self.connect("activate",func,text,func2)
# If there are any submenus, add them
if subs != None:
menu = gtk.Menu()
for sub in subs:
menu.append(sub)
self.set_submenu(menu)
# Show the menu
self.show()

View File

@ -13,15 +13,15 @@ class Library():
self.data = LibData()
self.goodTypes = ["ogg","mp3"]#,"wma"]
# Build up directory if library save
self.save = os.path.expanduser("~")
self.save = os.path.join(self.save,".ocarina")
self.save = os.path.join(self.save,"library.pickle")
#self.save = os.path.expanduser("~")
#self.save = os.path.join(self.save,".ocarina")
#self.save = os.path.join(self.save,"library.pickle")
# Load existing library
if os.path.exists(self.save):
#if os.path.exists(self.save):
#self.prnt(["Library found, loading..."])
print "Library found, loading..."
p = pickle.Unpickler(open(self.save))
self.data = p.load()
# print "Library found, loading..."
# p = pickle.Unpickler(open(self.save))
# self.data = p.load()
# Begin a scan on dir

View File

@ -1,7 +0,0 @@
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

@ -1,5 +1,6 @@
import os
import cPickle as pickle
from library import Library
class SavedData:
@ -7,7 +8,7 @@ class SavedData:
path = os.path.join(options.user,".ocarina")
path = os.path.join(path,"ocarina-data.data")
self.size = (800,600)
self.library = None
self.library = Library()
self.path = path
if os.path.exists(path):

View File

@ -6,7 +6,7 @@ import gtk
import thread
from kiwi.ui.objectlist import Column, ObjectList
import GuiObjects.*
from GuiObjects.menuItem import MenuItem
class Window(gtk.Window):
@ -23,6 +23,7 @@ class Window(gtk.Window):
self.mainLayout = gtk.VBox(False,0)
self.mainLayout.show()
self.add(self.mainLayout)
self.makeMenuBar()
'''
self.song = song
@ -266,52 +267,21 @@ class Window(gtk.Window):
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
bar = gtk.MenuBar()
# This is the dropdown selections
# Make a new library option
library = gtk.MenuItem("Library")
lib = gtk.Menu()
newLib = gtk.MenuItem(label="New Library")
newLib.connect_object("activate",self.selectDir,self.ops.scanLib)
newLib.show()
lib.append(newLib)
# This shows in the toolbar
library.set_submenu(lib)
library.show()
newLib = MenuItem("New Library",self.selectDir,None,self.data.library.scan,None)
library = MenuItem("Library",None,None,None,[newLib])
bar.append(library)
# Make playback option
playback = gtk.MenuItem("Playback")
pback = gtk.Menu()
# Pause after current track
pafter = gtk.MenuItem(label="Pause After Current Track")
pafter.connect("activate",self.ops.afterTrack,"pafter",self.changeFrameTitle)
pafter.show()
pback.append(pafter)
# Quit after current track
qafter = gtk.MenuItem(label="Quit After Current Track")
qafter.connect("activate",self.ops.afterTrack,"qafter",self.changeFrameTitle)
qafter.show()
pback.append(qafter)
playback.set_submenu(pback)
playback.show()
# Replace first 'None' with after track functions
pafter = MenuItem("Pause After Current Track",None,"pafter",self.changeFrameTitle,None)
qafter = MenuItem("Quit After Current Track",None,"qafter",self.changeFrameTitle,None)
playback = MenuItem("Playback",None,None,None,[pafter,qafter])
bar.append(playback)
# Add to main layout
bar.show()
self.mainLayout.pack_start(bar,False,False,0)
'''
def selectDir(self,func):
def selectDir(self,widgit,data,func):
dirsel = gtk.FileChooserDialog(None,action=gtk.FILE_CHOOSER_ACTION_OPEN,buttons =(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
dirsel.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
response = dirsel.run()