ocarina/trunk/src/window.py

129 lines
3.6 KiB
Python

import gobject
import pango
import pygtk
pygtk.require('2.0')
import gtk
import thread
from kiwi.ui.objectlist import Column, ObjectList
from GuiObjects.menuItem import MenuItem
from GuiObjects.libView import LibView
from GuiObjects.plistView import PlistView
from GuiObjects.controlPanel import ControlPanel
from GuiObjects.infoView import InfoView
class Window(gtk.Window):
#def __init__(self,onQuit,ops,song):
def __init__(self,onQuit,options,data):
gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL)
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.set_icon_from_file("images/ocarina.png")
self.mainLayout = gtk.VBox(False,0)
self.add(self.mainLayout)
self.makeMenuBar()
self.makeContentPane()
self.mainLayout.show()
self.show()
# Used to make the top row menu bar
def makeMenuBar(self):
# Make a menu bar
bar = gtk.MenuBar()
# This is the dropdown selections
# Make a new library option
newLib = MenuItem("New Library",self.selectDir,"ScanLib",self.data.library.scan,None)
delete = MenuItem("Delete Library",self.deleteLib,"Delete",None,None)
library = MenuItem("Library",None,None,None,[newLib,delete])
bar.append(library)
clear = MenuItem("Clear Playlist",self.clearPlist,"Clear",None,None)
plist = MenuItem("Playlist",None,None,None,[clear])
bar.append(plist)
# Replace first 'None' with after track functions
pafter = MenuItem("Pause After Current Track",None,"pafter",None,None)
qafter = MenuItem("Quit After Current Track",None,"qafter",None,None)
playback = MenuItem("Playback",None,None,None,[pafter,qafter])
bar.append(playback)
bar.show()
self.mainLayout.pack_start(bar,False,False,0)
def deleteLib(self,widgit,data,other=None):
self.data.library.reset()
self.libview.update()
self.clearPlist()
def clearPlist(self,widgit,data,other=None):
self.data.curList = []
self.data.updateList = True
# Used to select a directory
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 = None
response = dirsel.run()
file = ""
if response == gtk.RESPONSE_OK:
file = dirsel.get_filename()
dirsel.hide()
if response != gtk.RESPONSE_OK:
return
self.libview.updates()
thread.start_new_thread(func,(data,file))
def makeContentPane(self):
self.contentPane = gtk.HBox(False,0)
self.divider = gtk.HPaned()
self.divider.set_position(self.data.divider)
self.contentPane.add(self.divider)
self.divider.show()
self.libview = LibView(self.data)
self.libview.show()
self.divider.add1(self.libview)
rightPane=gtk.VBox(False,0)
infoview = InfoView(self.data)
rightPane.pack_start(infoview,False,False,0)
self.plistview = PlistView(self.data)
rightPane.add(self.plistview)
self.makeBottomRow(rightPane)
rightPane.show()
self.divider.add2(rightPane)
self.contentPane.show()
self.mainLayout.add(self.contentPane)
def makeBottomRow(self,vbox):
box = gtk.HBox(False,0)
#box.pack_end(self.libview.label,False,False,10)
controls = ControlPanel(self.data,self.plistview)
self.plistview.controls = controls
vbox.pack_start(controls,False,False,0)
box.pack_end(self.plistview.label)
box.show()
align = gtk.Alignment(1,1,0,0)
align.add(box)
align.show()
vbox.pack_start(align,False,False,0)