2009-05-26 23:07:46 -04:00
|
|
|
import sys
|
2009-08-05 23:57:35 -04:00
|
|
|
import os
|
2009-06-03 00:10:00 -04:00
|
|
|
import gtk
|
2009-07-04 16:18:53 -04:00
|
|
|
import gobject
|
2009-06-03 00:10:00 -04:00
|
|
|
|
2009-06-27 00:32:43 -04:00
|
|
|
from options import Options
|
2009-07-13 23:17:53 -04:00
|
|
|
from data import Data
|
2009-08-05 23:57:35 -04:00
|
|
|
from library import Library
|
2009-06-27 00:32:43 -04:00
|
|
|
|
2009-06-05 12:51:18 -04:00
|
|
|
from window import Window
|
2009-06-03 00:10:00 -04:00
|
|
|
|
|
|
|
gobject.threads_init()
|
2009-05-26 23:07:46 -04:00
|
|
|
|
2009-06-03 23:48:44 -04:00
|
|
|
|
2009-05-27 19:16:56 -04:00
|
|
|
class main:
|
|
|
|
def __init__(self,argv):
|
2009-06-27 00:32:43 -04:00
|
|
|
# Parse options
|
|
|
|
self.options = Options()
|
|
|
|
if ("-v" in argv) == True:
|
|
|
|
self.options.verbose = True
|
2009-08-05 23:57:35 -04:00
|
|
|
|
2009-07-13 23:17:53 -04:00
|
|
|
self.data = Data(self.options)
|
2009-08-05 23:57:35 -04:00
|
|
|
|
|
|
|
if ("-l" in argv) == True:
|
|
|
|
self.buildLib()
|
|
|
|
return
|
|
|
|
# Load saved data (or create new data)
|
2009-07-01 09:41:33 -04:00
|
|
|
#self.data.song = Song(self.quit)
|
|
|
|
self.data.quit = None
|
2009-06-27 00:32:43 -04:00
|
|
|
|
|
|
|
self.window = Window(self.quit,self.options,self.data)
|
|
|
|
gtk.main()
|
2009-06-03 00:10:00 -04:00
|
|
|
|
|
|
|
|
2009-06-05 12:51:18 -04:00
|
|
|
# Eventually replace "delete_event" with this
|
2009-06-27 00:32:43 -04:00
|
|
|
def quit(self,widgit,data):
|
|
|
|
if self.options.verbose == True:
|
|
|
|
print "Quitting..."
|
2009-08-02 16:04:33 -04:00
|
|
|
if self.data.song:
|
|
|
|
self.data.song.close()
|
2009-06-27 00:32:43 -04:00
|
|
|
self.data.size = self.window.get_size()
|
2009-08-02 18:24:54 -04:00
|
|
|
#self.data.divider = self.window.contentPane.divider.get_position()
|
2009-08-02 15:46:57 -04:00
|
|
|
self.window.contentPane.storeCols()
|
2009-06-27 00:32:43 -04:00
|
|
|
self.data.dump()
|
2009-06-03 00:10:00 -04:00
|
|
|
gtk.main_quit()
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2009-08-05 23:57:35 -04:00
|
|
|
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"
|
|
|
|
|
2009-05-31 21:13:30 -04:00
|
|
|
|
2009-05-26 23:07:46 -04:00
|
|
|
if __name__=='__main__':main(sys.argv[1:])
|