ocarina/trunk/src/ocarina.py

73 lines
1.6 KiB
Python

import sys
import os
import gtk
import gobject
from options import Options
from data import Data
from library import Library
from window import Window
gobject.threads_init()
class main:
def __init__(self,argv):
# Parse options
self.options = Options()
if ("-v" in argv) == True:
self.options.verbose = True
self.data = Data(self.options)
if ("-l" in argv) == True:
self.buildLib()
return
# Load saved data (or create new data)
#self.data.song = Song(self.quit)
self.data.quit = None
self.window = Window(self.quit,self.options,self.data)
gtk.main()
# Eventually replace "delete_event" with this
def quit(self,widgit,data):
if self.options.verbose == True:
print "Quitting..."
if self.data.song:
self.data.song.close()
self.data.size = self.window.get_size()
#self.data.divider = self.window.contentPane.divider.get_position()
self.window.contentPane.storeCols()
self.data.dump(True)
gtk.main_quit()
return False
def buildLib(self):
path = ""
validPath= False
self.data.options.verbose = True
self.data.library.data = self.data
while validPath == False:
path = raw_input("Input path to library: ")
path = os.path.expanduser(path)
if os.path.exists(path) == True:
validPath = True
else:
print "Invalid path entered:",path
actual = ""
actual = raw_input("Input recorded library path (or none to use scan path): ")
print actual
print "Scanning: ",path
self.data.library.scan(None,path)
if actual != "":
self.data.library.path = actual
self.data.dump(False)
print "Library saved to ~/.ocarina/library"
if __name__=='__main__':main(sys.argv[1:])