diff --git a/trunk/ocarina.py b/trunk/ocarina.py index f8fb87da..5779c4fb 100644 --- a/trunk/ocarina.py +++ b/trunk/ocarina.py @@ -10,14 +10,17 @@ import gtk from song import Song from duration import Duration from library import Library +from operations import Operations from playlist import Playlist from songInfo import SongInfo #gtk.gdk.threads_init() gobject.threads_init() + class main: def __init__(self,argv): + self.ops = Operations() self.makeWindow() self.library = Library() @@ -40,6 +43,7 @@ class main: info.filename = file self.song = Song(info,self.next)#,self.commands.printLines) self.next("","") + self.ops.song = self.song #gobject.idle_add(self.markProgress,self.pbar,"progress") @@ -57,27 +61,36 @@ class main: self.window.set_border_width(0) self.window.set_icon_from_file("images/ocarina.png") # Make a control box for buttons - self.control = gtk.HBox(False,0) + self.control = gtk.VBox(False,0) + self.inside = gtk.HBox(False,0) self.window.add(self.control) # Make buttons - self.playButton = self.makeButton("playButton","images/play.png",None,self.play) - self.pauseButton = self.makeButton("pauseButton","images/pause.png",None,self.pause) + self.playButton = self.makeButton("playButton","images/play.png",None,self.ops.play) + self.pauseButton = self.makeButton("pauseButton","images/pause.png",None,self.ops.pause) self.nextButton = self.makeButton("nextButton","images/next.png",None,self.next) self.thisButton = self.makeButton("thisButton",None,"This",self.this) self.infoButton = self.makeButton("infoButton",None,"Info",self.info) # Add buttons to window - self.control.pack_start(self.playButton,False,False,3) - self.control.pack_start(self.pauseButton,False,False,3) - self.control.pack_start(self.nextButton,False,False,3) - self.control.pack_start(self.thisButton,False,False,3) - self.control.pack_start(self.infoButton,False,False,3) - + self.inside.pack_start(self.playButton,False,False,0) + self.inside.pack_start(self.pauseButton,False,False,0) + self.inside.pack_start(self.nextButton,False,False,0) + self.inside.pack_start(self.thisButton,False,False,0) + self.inside.pack_start(self.infoButton,False,False,0) + self.inside.show() + # Top row + self.control.pack_start(self.inside,False,False,0) self.pbar = gtk.ProgressBar() self.pbar.set_fraction(0) self.pbar.show() # Update the progress bar every 100 ms gobject.timeout_add(100,self.markProgress,self.pbar,"progress") - self.control.pack_start(self.pbar,False,False,3) + self.control.pack_start(self.pbar,False,False,0) + + # Tray + self.statusIcon = gtk.StatusIcon() + self.statusIcon.set_from_file("images/ocarina.png") + self.statusIcon.set_tooltip("Ocarina") + #self.statusIcon.show() self.control.show() self.window.show() @@ -95,7 +108,7 @@ class main: def makeButton(self,name,path,text,func): button = gtk.Button() box = gtk.HBox(False,0) - box.set_border_width(1) + box.set_border_width(0) if path != None: image = gtk.Image() image.set_from_file(path) @@ -113,16 +126,16 @@ class main: # Begin playback - def play(self,widget,data): - if self.song == None: - return - self.song.play() + #def play(self,widget,data): + # if self.song == None: + # return + # self.song.play() # Pause music - def pause(self,widget,data): - if self.song == None: - return - self.song.pause() + #def pause(self,widget,data): + # if self.song == None: + # return + # self.song.pause() # Show running time info def time(self,unused): @@ -178,6 +191,7 @@ class main: self.song = Song(info,self.next)#self.commands.printLines) if index > -2: self.song.play() + self.ops.song = self.song def random(self,unused): diff --git a/trunk/operations.py b/trunk/operations.py new file mode 100644 index 00000000..0cad09ef --- /dev/null +++ b/trunk/operations.py @@ -0,0 +1,20 @@ +from song import Song + +# Use to define various operations +class Operations: + def __init__(self): + self.song = None + + + # Begin playback + def play(self,widget,data): + if self.song == None: + return + self.song.play() + + + # Pause playback + def pause(self,widget,data): + if self.song == None: + return + self.song.pause() diff --git a/trunk/playlist.py b/trunk/playlist.py index 2ce67f8a..4f18e2b9 100644 --- a/trunk/playlist.py +++ b/trunk/playlist.py @@ -1,6 +1,7 @@ import Queue import random + class Playlist: #def __init__(self,prnt): def __init__(self):