Made operations.py, began moving functions from main.py to operations.py
git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@12 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
parent
cca44a7e98
commit
378a2a7185
|
@ -10,14 +10,17 @@ import gtk
|
||||||
from song import Song
|
from song import Song
|
||||||
from duration import Duration
|
from duration import Duration
|
||||||
from library import Library
|
from library import Library
|
||||||
|
from operations import Operations
|
||||||
from playlist import Playlist
|
from playlist import Playlist
|
||||||
from songInfo import SongInfo
|
from songInfo import SongInfo
|
||||||
|
|
||||||
#gtk.gdk.threads_init()
|
#gtk.gdk.threads_init()
|
||||||
gobject.threads_init()
|
gobject.threads_init()
|
||||||
|
|
||||||
|
|
||||||
class main:
|
class main:
|
||||||
def __init__(self,argv):
|
def __init__(self,argv):
|
||||||
|
self.ops = Operations()
|
||||||
self.makeWindow()
|
self.makeWindow()
|
||||||
|
|
||||||
self.library = Library()
|
self.library = Library()
|
||||||
|
@ -40,6 +43,7 @@ class main:
|
||||||
info.filename = file
|
info.filename = file
|
||||||
self.song = Song(info,self.next)#,self.commands.printLines)
|
self.song = Song(info,self.next)#,self.commands.printLines)
|
||||||
self.next("","")
|
self.next("","")
|
||||||
|
self.ops.song = self.song
|
||||||
|
|
||||||
#gobject.idle_add(self.markProgress,self.pbar,"progress")
|
#gobject.idle_add(self.markProgress,self.pbar,"progress")
|
||||||
|
|
||||||
|
@ -57,27 +61,36 @@ class main:
|
||||||
self.window.set_border_width(0)
|
self.window.set_border_width(0)
|
||||||
self.window.set_icon_from_file("images/ocarina.png")
|
self.window.set_icon_from_file("images/ocarina.png")
|
||||||
# Make a control box for buttons
|
# 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)
|
self.window.add(self.control)
|
||||||
# Make buttons
|
# Make buttons
|
||||||
self.playButton = self.makeButton("playButton","images/play.png",None,self.play)
|
self.playButton = self.makeButton("playButton","images/play.png",None,self.ops.play)
|
||||||
self.pauseButton = self.makeButton("pauseButton","images/pause.png",None,self.pause)
|
self.pauseButton = self.makeButton("pauseButton","images/pause.png",None,self.ops.pause)
|
||||||
self.nextButton = self.makeButton("nextButton","images/next.png",None,self.next)
|
self.nextButton = self.makeButton("nextButton","images/next.png",None,self.next)
|
||||||
self.thisButton = self.makeButton("thisButton",None,"This",self.this)
|
self.thisButton = self.makeButton("thisButton",None,"This",self.this)
|
||||||
self.infoButton = self.makeButton("infoButton",None,"Info",self.info)
|
self.infoButton = self.makeButton("infoButton",None,"Info",self.info)
|
||||||
# Add buttons to window
|
# Add buttons to window
|
||||||
self.control.pack_start(self.playButton,False,False,3)
|
self.inside.pack_start(self.playButton,False,False,0)
|
||||||
self.control.pack_start(self.pauseButton,False,False,3)
|
self.inside.pack_start(self.pauseButton,False,False,0)
|
||||||
self.control.pack_start(self.nextButton,False,False,3)
|
self.inside.pack_start(self.nextButton,False,False,0)
|
||||||
self.control.pack_start(self.thisButton,False,False,3)
|
self.inside.pack_start(self.thisButton,False,False,0)
|
||||||
self.control.pack_start(self.infoButton,False,False,3)
|
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 = gtk.ProgressBar()
|
||||||
self.pbar.set_fraction(0)
|
self.pbar.set_fraction(0)
|
||||||
self.pbar.show()
|
self.pbar.show()
|
||||||
# Update the progress bar every 100 ms
|
# Update the progress bar every 100 ms
|
||||||
gobject.timeout_add(100,self.markProgress,self.pbar,"progress")
|
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.control.show()
|
||||||
self.window.show()
|
self.window.show()
|
||||||
|
@ -95,7 +108,7 @@ class main:
|
||||||
def makeButton(self,name,path,text,func):
|
def makeButton(self,name,path,text,func):
|
||||||
button = gtk.Button()
|
button = gtk.Button()
|
||||||
box = gtk.HBox(False,0)
|
box = gtk.HBox(False,0)
|
||||||
box.set_border_width(1)
|
box.set_border_width(0)
|
||||||
if path != None:
|
if path != None:
|
||||||
image = gtk.Image()
|
image = gtk.Image()
|
||||||
image.set_from_file(path)
|
image.set_from_file(path)
|
||||||
|
@ -113,16 +126,16 @@ class main:
|
||||||
|
|
||||||
|
|
||||||
# Begin playback
|
# Begin playback
|
||||||
def play(self,widget,data):
|
#def play(self,widget,data):
|
||||||
if self.song == None:
|
# if self.song == None:
|
||||||
return
|
# return
|
||||||
self.song.play()
|
# self.song.play()
|
||||||
|
|
||||||
# Pause music
|
# Pause music
|
||||||
def pause(self,widget,data):
|
#def pause(self,widget,data):
|
||||||
if self.song == None:
|
# if self.song == None:
|
||||||
return
|
# return
|
||||||
self.song.pause()
|
# self.song.pause()
|
||||||
|
|
||||||
# Show running time info
|
# Show running time info
|
||||||
def time(self,unused):
|
def time(self,unused):
|
||||||
|
@ -178,6 +191,7 @@ class main:
|
||||||
self.song = Song(info,self.next)#self.commands.printLines)
|
self.song = Song(info,self.next)#self.commands.printLines)
|
||||||
if index > -2:
|
if index > -2:
|
||||||
self.song.play()
|
self.song.play()
|
||||||
|
self.ops.song = self.song
|
||||||
|
|
||||||
|
|
||||||
def random(self,unused):
|
def random(self,unused):
|
||||||
|
|
|
@ -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()
|
|
@ -1,6 +1,7 @@
|
||||||
import Queue
|
import Queue
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
class Playlist:
|
class Playlist:
|
||||||
#def __init__(self,prnt):
|
#def __init__(self,prnt):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
Loading…
Reference in New Issue