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: clean:
rm -rf src/*.pyc rm -rf src/*.pyc
rm -rf src/*~
rm -rf src/GuiObjects/*.pyc
rm -rf src/GuiObjects/*~
rm *~
install: install:
rsync src/ ~/bin/ocarina-bin/ 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.data = LibData()
self.goodTypes = ["ogg","mp3"]#,"wma"] self.goodTypes = ["ogg","mp3"]#,"wma"]
# Build up directory if library save # Build up directory if library save
self.save = os.path.expanduser("~") #self.save = os.path.expanduser("~")
self.save = os.path.join(self.save,".ocarina") #self.save = os.path.join(self.save,".ocarina")
self.save = os.path.join(self.save,"library.pickle") #self.save = os.path.join(self.save,"library.pickle")
# Load existing library # Load existing library
if os.path.exists(self.save): #if os.path.exists(self.save):
#self.prnt(["Library found, loading..."]) #self.prnt(["Library found, loading..."])
print "Library found, loading..." # print "Library found, loading..."
p = pickle.Unpickler(open(self.save)) # p = pickle.Unpickler(open(self.save))
self.data = p.load() # self.data = p.load()
# Begin a scan on dir # 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 os
import cPickle as pickle import cPickle as pickle
from library import Library
class SavedData: class SavedData:
@ -7,7 +8,7 @@ class SavedData:
path = os.path.join(options.user,".ocarina") path = os.path.join(options.user,".ocarina")
path = os.path.join(path,"ocarina-data.data") path = os.path.join(path,"ocarina-data.data")
self.size = (800,600) self.size = (800,600)
self.library = None self.library = Library()
self.path = path self.path = path
if os.path.exists(path): if os.path.exists(path):

View File

@ -6,7 +6,7 @@ import gtk
import thread import thread
from kiwi.ui.objectlist import Column, ObjectList from kiwi.ui.objectlist import Column, ObjectList
import GuiObjects.* from GuiObjects.menuItem import MenuItem
class Window(gtk.Window): class Window(gtk.Window):
@ -23,6 +23,7 @@ class Window(gtk.Window):
self.mainLayout = gtk.VBox(False,0) self.mainLayout = gtk.VBox(False,0)
self.mainLayout.show() self.mainLayout.show()
self.add(self.mainLayout)
self.makeMenuBar() self.makeMenuBar()
''' '''
self.song = song self.song = song
@ -266,52 +267,21 @@ class Window(gtk.Window):
bar = gtk.MenuBar() bar = gtk.MenuBar()
# This is the dropdown selections # This is the dropdown selections
# Make a new library option # Make a new library option
library = MenuItem("Library",None,None,None) newLib = MenuItem("New Library",self.selectDir,None,self.data.library.scan,None)
bar.append(library) library = MenuItem("Library",None,None,None,[newLib])
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()
bar.append(library) bar.append(library)
# Make playback option # Replace first 'None' with after track functions
playback = gtk.MenuItem("Playback") pafter = MenuItem("Pause After Current Track",None,"pafter",self.changeFrameTitle,None)
pback = gtk.Menu() qafter = MenuItem("Quit After Current Track",None,"qafter",self.changeFrameTitle,None)
# Pause after current track playback = MenuItem("Playback",None,None,None,[pafter,qafter])
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()
bar.append(playback) bar.append(playback)
# 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,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 = 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) dirsel.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
response = dirsel.run() response = dirsel.run()