buttons, images, checkboxes, scrolling to current track,toggling random
git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@36 1daee41c-8060-4895-b1f0-2197c00d777a
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 894 B After Width: | Height: | Size: 667 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 956 B |
Before Width: | Height: | Size: 740 B After Width: | Height: | Size: 505 B |
|
@ -1,2 +1,3 @@
|
|||
# Used for initializing things in the GuiObjects directory
|
||||
|
||||
__all__ = ['menuItem','libView','plistView']
|
||||
__all__ = ['button','menuItem','libView','plistView']
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
|
||||
from image import Image
|
||||
|
||||
class Button(gtk.Button):
|
||||
def __init__(self,name,image,text,func):
|
||||
gtk.Button.__init__(self)
|
||||
box = gtk.HBox(True,0)
|
||||
if image!= None:
|
||||
box.pack_start(image,True,True,0)
|
||||
#box.add(image)
|
||||
if text != None:
|
||||
label = gtk.Label(text)
|
||||
label.show()
|
||||
box.pack_start(label,False,False,0)
|
||||
box.show()
|
||||
self.add(box)
|
||||
self.connect("clicked",func,name)
|
||||
self.show()
|
|
@ -0,0 +1,12 @@
|
|||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
|
||||
|
||||
class CheckButton(gtk.CheckButton):
|
||||
def __init__(self,label,func,active):
|
||||
gtk.CheckButton.__init__(self,label)
|
||||
if active==True:
|
||||
self.set_active(1)
|
||||
self.connect("toggled",func)
|
||||
self.show()
|
|
@ -0,0 +1,80 @@
|
|||
import os
|
||||
import gobject
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
|
||||
from button import Button
|
||||
from image import Image
|
||||
from check import CheckButton
|
||||
|
||||
class ControlPanel(gtk.HBox):
|
||||
def __init__(self,data,plist):
|
||||
gtk.HBox.__init__(self,False,0)
|
||||
self.pauseImg = Image(os.path.join("images","pause.png"))
|
||||
self.data = data
|
||||
self.next = plist.next
|
||||
self.pack_start(CheckButton("Random",self.toggleRand,self.data.random),False,False,0)
|
||||
self.makeProgressBar()
|
||||
(self.nextImg,self.nextBtn) = self.makeButton("next","next.png",None,self.next)
|
||||
(self.stopImg,self.stopBtn) = self.makeButton("stop","stop.png",None,self.stop)
|
||||
(self.playImg,self.plauseBtn) = self.makeButton("plause","play.png",None,self.plause)
|
||||
self.show()
|
||||
|
||||
|
||||
# Everything for making and adding a button
|
||||
def makeButton(self,name,img,text,func):
|
||||
image = None
|
||||
if img:
|
||||
image = Image(os.path.join("images",img))
|
||||
button = Button(name,image,text,func)
|
||||
self.pack_end(button,False,False,0)
|
||||
return (image,button)
|
||||
|
||||
|
||||
# Make the progress bar, and set updates
|
||||
def makeProgressBar(self):
|
||||
vbox = gtk.VBox()
|
||||
pbar = gtk.ProgressBar()
|
||||
pbar.set_fraction(0)
|
||||
vbox.pack_start(pbar,True,False,0)
|
||||
self.pack_start(vbox,True,True,0)
|
||||
vbox.show()
|
||||
pbar.show()
|
||||
gobject.timeout_add(1000,self.updatePBar,pbar)
|
||||
|
||||
|
||||
# Play/Pause function
|
||||
def plause(self,widgit,data):
|
||||
self.data.song.plause()
|
||||
self.changeImg()
|
||||
|
||||
|
||||
# Stop function
|
||||
def stop(self,widgit,data):
|
||||
self.data.song.stop()
|
||||
self.changeImg()
|
||||
|
||||
|
||||
# Change the image on the play button
|
||||
def changeImg(self):
|
||||
self.plauseBtn.set_image(self.playImg)
|
||||
if self.data.song.playing == True:
|
||||
self.plauseBtn.set_image(self.pauseImg)
|
||||
|
||||
|
||||
# Update time/progress of the progress bar
|
||||
def updatePBar(self,pbar):
|
||||
try:
|
||||
(success,time) = self.data.song.curTime()
|
||||
except:
|
||||
success = False
|
||||
if success == True:
|
||||
time = time/1000000000
|
||||
pbar.set_fraction(float(time)/self.data.song.info.duration)
|
||||
pbar.set_text(self.data.song.info.fixTime(time) + " / " + self.data.song.info.length)
|
||||
return True
|
||||
|
||||
|
||||
def toggleRand(self,widgit):
|
||||
self.data.random = not self.data.random
|
|
@ -0,0 +1,9 @@
|
|||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
|
||||
class Image(gtk.Image):
|
||||
def __init__(self,path):
|
||||
gtk.Image.__init__(self)
|
||||
self.set_from_file(path)
|
||||
self.show()
|
|
@ -48,7 +48,7 @@ class LibView(gtk.VBox):
|
|||
tree.set_sort_column_id(0,gtk.SORT_ASCENDING)
|
||||
self.treeview = gtk.TreeView(tree)
|
||||
self.treeview.connect("button_release_event",self.clicked)
|
||||
self.col = gtk.TreeViewColumn('Library')
|
||||
self.col = gtk.TreeViewColumn('Library ('+str(self.data.library.count)+')')
|
||||
self.treeview.append_column(self.col)
|
||||
cell = gtk.CellRendererText()
|
||||
self.col.pack_start(cell,True)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
|
||||
class MenuItem(gtk.MenuItem):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import random
|
||||
import gobject
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
|
@ -10,12 +11,15 @@ class PlistView(gtk.ScrolledWindow):
|
|||
self.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
|
||||
self.data = data
|
||||
self.data.song.next = self.next
|
||||
self.controls = None
|
||||
self.tree = None
|
||||
self.label = gtk.Label("")
|
||||
self.makeList()
|
||||
self.loadSong()
|
||||
gobject.timeout_add(1000,self.checkUpdate)
|
||||
|
||||
|
||||
|
||||
|
||||
# Check if the playlist has been updated
|
||||
def checkUpdate(self):
|
||||
if self.data.updateList == True:
|
||||
self.data.updateList = False
|
||||
|
@ -23,19 +27,20 @@ class PlistView(gtk.ScrolledWindow):
|
|||
return True
|
||||
|
||||
|
||||
# Make the playlist and show it
|
||||
def makeList(self):
|
||||
trackList= gtk.ListStore(int,str,str,str,str,int)
|
||||
self.trackList= gtk.ListStore(int,str,str,str,str,int)
|
||||
if self.tree:
|
||||
self.remove(self.tree)
|
||||
time = 0
|
||||
for index in self.data.curList:
|
||||
track = self.data.library.files[index]
|
||||
trackList.append([track.id,track.title,track.length,track.artist,track.album,track.count])
|
||||
self.trackList.append([track.id,track.title,track.length,track.artist,track.album,track.count])
|
||||
time+=track.duration
|
||||
self.tree = gtk.TreeView(trackList)
|
||||
self.tree = gtk.TreeView(self.trackList)
|
||||
cell = gtk.CellRendererText()
|
||||
cols = ["Id","Title","Length","Artist","Album","#"]
|
||||
trackList.set_sort_column_id(self.data.sortedCol,gtk.SORT_ASCENDING)
|
||||
self.trackList.set_sort_column_id(self.data.sortedCol,gtk.SORT_ASCENDING)
|
||||
lenSaved = len(self.data.colSizes)
|
||||
for i in range(len(cols)):
|
||||
col = gtk.TreeViewColumn(cols[i],cell)
|
||||
|
@ -48,7 +53,7 @@ class PlistView(gtk.ScrolledWindow):
|
|||
if cols[i] != "Id":
|
||||
self.tree.append_column(col)
|
||||
self.tree.set_rules_hint(True)
|
||||
self.tree.connect("row-activated",self.selectSong,"clicked",trackList)
|
||||
self.tree.connect("row-activated",self.selectSong,"clicked",self.trackList)
|
||||
self.tree.show()
|
||||
self.resizeCols()
|
||||
self.add(self.tree)
|
||||
|
@ -63,26 +68,32 @@ class PlistView(gtk.ScrolledWindow):
|
|||
self.data.colSizes +=[col.get_width()]
|
||||
|
||||
|
||||
# Uses saved column settings
|
||||
def resizeCols(self):
|
||||
cols = self.tree.get_columns()
|
||||
for i in range(len(self.data.colSizes)):
|
||||
cols[i].set_fixed_width(self.data.colSizes[i])
|
||||
|
||||
|
||||
def makeTimeLabel(self,time):
|
||||
day = time/86500
|
||||
time = time-(day*86500)
|
||||
hour = time/3600
|
||||
time = time-(hour*3600)
|
||||
min = time/60
|
||||
time = time-(min*60)
|
||||
|
||||
# Shows total running time of the playlist
|
||||
def makeTimeLabel(self,sec):
|
||||
day = 0
|
||||
hour = 0
|
||||
min = 0
|
||||
day = sec/86500
|
||||
sec = sec-(day*86500)
|
||||
hour = sec/3600
|
||||
sec = sec-(hour*3600)
|
||||
min = sec/60
|
||||
sec = sec-(min*60)
|
||||
string = ""
|
||||
string = self.toStr(day,"day")+self.toStr(hour,"hour")
|
||||
string += self.toStr(min,"minute")+self.toStr(time,"second")
|
||||
string += self.toStr(min,"minute")+self.toStr(sec,"second")
|
||||
self.label.set_text(string)
|
||||
self.label.show()
|
||||
|
||||
|
||||
# Make a string for the amount of time
|
||||
def toStr(self,time,label):
|
||||
if time > 0:
|
||||
string=str(time) + " "+label
|
||||
|
@ -90,15 +101,48 @@ class PlistView(gtk.ScrolledWindow):
|
|||
string+="s"
|
||||
string += " "
|
||||
return string
|
||||
return ""
|
||||
|
||||
|
||||
# User selected a song with mouse click
|
||||
def selectSong(self,widgit,iter,path,data,list):
|
||||
print list[iter][0]
|
||||
self.data.curSong = self.data.curList.index(list[iter][0])
|
||||
self.loadSong()
|
||||
self.controls.plause(None,None)
|
||||
|
||||
|
||||
# Go to the next song in the list
|
||||
def next(self,widgit,data):
|
||||
if self.data.random == True:
|
||||
self.data.curSong = random.randint(0,len(self.data.curList))
|
||||
else:
|
||||
self.data.curSong+=1
|
||||
if self.data.curSong >= len(self.data.curList):
|
||||
self.data.curSong = 0
|
||||
self.loadSong()
|
||||
self.controls.plause(None,None)
|
||||
|
||||
|
||||
# Load a song and begin playback
|
||||
def loadSong(self):
|
||||
if len(self.data.curList) == 0:
|
||||
return
|
||||
if self.data.song:
|
||||
self.data.song.close()
|
||||
self.data.song.passInfo(self.data.library.files[list[iter][0]])
|
||||
self.data.song.play(None,None)
|
||||
self.data.song.passInfo(self.data.library.files[self.data.curList[self.data.curSong]])
|
||||
self.gotoCurSong()
|
||||
|
||||
|
||||
def next(self):
|
||||
self.song.close()
|
||||
def gotoCurSong(self):
|
||||
if len(self.data.curList) == 0:
|
||||
return
|
||||
selrow = 0
|
||||
row = 0
|
||||
for i in range(len(self.trackList)):
|
||||
if self.trackList[i] == self.data.curSong:
|
||||
if i > 10:
|
||||
selrow = i - 10
|
||||
row = i
|
||||
break
|
||||
#self.tree.scroll_to_cell(selrow,None,True,0,0)
|
||||
self.tree.set_cursor(self.data.curSong,None,False)
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
from songInfo import SongInfo
|
||||
|
||||
# This class is used to store all library data
|
||||
class LibData:
|
||||
def __init__(self):
|
||||
self.path = ""
|
||||
self.files = []
|
||||
self.map = dict()
|
|
@ -2,7 +2,7 @@ import os
|
|||
import re
|
||||
import tagpy
|
||||
import cPickle as pickle
|
||||
from libdata import LibData
|
||||
#from libdata import LibData
|
||||
from songInfo import SongInfo
|
||||
import thread
|
||||
|
||||
|
@ -98,8 +98,9 @@ class Library:
|
|||
info.artist = t.artist
|
||||
|
||||
a = f.audioProperties()
|
||||
info.duration = a.length
|
||||
info.fixTime()
|
||||
info.setTime(a.length)
|
||||
#info.duration = a.length
|
||||
#info.fixTime()
|
||||
|
||||
artist = info.artist.lower()
|
||||
album = info.album.lower()
|
||||
|
@ -117,11 +118,11 @@ class Library:
|
|||
|
||||
|
||||
# Dump to file
|
||||
def dump(self):
|
||||
out = open(self.save,'w')
|
||||
p = pickle.Pickler(out,2)
|
||||
p.dump(self.data)
|
||||
out.close()
|
||||
#def dump(self):
|
||||
# out = open(self.save,'w')
|
||||
# p = pickle.Pickler(out,2)
|
||||
# p.dump(self.data)
|
||||
# out.close()
|
||||
|
||||
|
||||
# Return true if file is in the library
|
||||
|
@ -140,17 +141,17 @@ class Library:
|
|||
return -1
|
||||
|
||||
|
||||
def nonBanned(self):
|
||||
list = []
|
||||
for i in range(len(self.data.files)):
|
||||
if self.data.files[i].banned == False:
|
||||
list += [i]
|
||||
return list
|
||||
#def nonBanned(self):
|
||||
# list = []
|
||||
# for i in range(len(self.data.files)):
|
||||
# if self.data.files[i].banned == False:
|
||||
# list += [i]
|
||||
# return list
|
||||
|
||||
|
||||
def translate(self,sid):
|
||||
#file = self.data.files[sid]
|
||||
return self.data.files[sid]
|
||||
#print file.title, file.artist, file.album
|
||||
return (sid,file.title,file.artist,file.album,file.playCount)
|
||||
#return (file.artist,file.album)
|
||||
#def translate(self,sid):
|
||||
# #file = self.data.files[sid]
|
||||
# return self.data.files[sid]
|
||||
# #print file.title, file.artist, file.album
|
||||
# return (sid,file.title,file.artist,file.album,file.playCount)
|
||||
# #return (file.artist,file.album)
|
||||
|
|
|
@ -11,11 +11,11 @@ from options import Options
|
|||
from saveddata import SavedData
|
||||
|
||||
from song import Song
|
||||
from duration import Duration
|
||||
from library import Library
|
||||
from operations import Operations
|
||||
from playlist import Playlist
|
||||
from songInfo import SongInfo
|
||||
#from duration import Duration
|
||||
#from library import Library
|
||||
#from operations import Operations
|
||||
#from playlist import Playlist
|
||||
#from songInfo import SongInfo
|
||||
from window import Window
|
||||
|
||||
#gtk.gdk.threads_init()
|
||||
|
@ -34,43 +34,6 @@ class main:
|
|||
|
||||
self.window = Window(self.quit,self.options,self.data)
|
||||
gtk.main()
|
||||
'''
|
||||
self.ops = Operations(self.quit)
|
||||
self.library = Library()
|
||||
self.plist = Playlist()
|
||||
self.plist.insert(self.library.nonBanned())
|
||||
self.plist.translate = self.library.translate
|
||||
self.plist.opsNext = self.ops.next
|
||||
self.ops.plist = self.plist
|
||||
self.ops.library = self.library
|
||||
|
||||
window = Window(self.quit,self.ops)
|
||||
self.ops.setInfo = window.changeInfo
|
||||
self.ops.resetInfo = window.resetInfo
|
||||
self.ops.scrollSong = window.gotoCurSong
|
||||
|
||||
song = None
|
||||
# If we were given a song as input, check that it exists and begin playback
|
||||
if len(argv) > 0:
|
||||
split = argv[0].split(self.library.data.path)
|
||||
if len(split) > 0:
|
||||
index = self.library.has(split[len(split)-1])
|
||||
#if index != -1:
|
||||
#info = self.library.data.files[index]
|
||||
self.plist.queueSong(index)
|
||||
if index==-1:
|
||||
file = os.path.expanduser(argv[0])
|
||||
if os.path.exists(file):
|
||||
info = SongInfo()
|
||||
info.filename = file
|
||||
song = Song(info,self.next)#,self.commands.printLines)
|
||||
self.ops.song = song
|
||||
self.ops.next("","")
|
||||
window.song = self.ops.song
|
||||
|
||||
# Call gtk main
|
||||
gtk.main()
|
||||
'''
|
||||
|
||||
|
||||
# Eventually replace "delete_event" with this
|
||||
|
|
|
@ -12,11 +12,13 @@ class SavedData:
|
|||
self.divider = 150
|
||||
self.library = Library()
|
||||
self.curList = []
|
||||
self.curSong = 0
|
||||
self.colSizes = [110,110,110,110,110]
|
||||
self.sortedCol = 3
|
||||
self.updateList = False
|
||||
self.path = path
|
||||
self.song = None
|
||||
self.random = False
|
||||
|
||||
if os.path.exists(path):
|
||||
try:
|
||||
|
@ -47,7 +49,10 @@ class SavedData:
|
|||
p = pickle.Unpickler(open(path))
|
||||
data = p.load()
|
||||
self.size = data.size
|
||||
self.library = data.library
|
||||
self.divider = data.divider
|
||||
self.library = data.library
|
||||
self.curList = data.curList
|
||||
self.curSong = 0
|
||||
self.colSizes = data.colSizes
|
||||
self.path = data.path
|
||||
self.random = data.random
|
||||
|
|
|
@ -10,117 +10,74 @@ class Song():
|
|||
#def __init__(self,info,exitFunc,prnt):
|
||||
def __init__(self,exitFunc):
|
||||
self.quit=exitFunc
|
||||
#self.prnt=prnt
|
||||
#self.info = info
|
||||
#self.info.tags = dict()
|
||||
#self.setInfo = None
|
||||
#self.getNext = None
|
||||
#self.current = 0
|
||||
# initialize player pipeline
|
||||
self.next = None
|
||||
self.player = gst.Pipeline("player")
|
||||
self.bin = gst.element_factory_make("playbin",None)
|
||||
#bin.set_property("uri","file://"+self.info.filename)
|
||||
self.player.add(self.bin)
|
||||
|
||||
# initialize bus
|
||||
bus = self.player.get_bus()
|
||||
bus.add_signal_watch()
|
||||
bus.connect("message",self.onMessage)
|
||||
|
||||
# Pause song
|
||||
#self.pause()
|
||||
self.playing = False
|
||||
self.hasFile = False
|
||||
|
||||
# Initialize stuff for finding duration
|
||||
self.time_format = gst.Format(gst.FORMAT_TIME)
|
||||
#self.length = None
|
||||
#self.taglist = None
|
||||
|
||||
|
||||
# Called on bus messages
|
||||
def onMessage(self,bus,message):
|
||||
t = message.type
|
||||
if t == gst.MESSAGE_EOS:
|
||||
#print "End of stream"
|
||||
#self.prnt(["End of stream"])
|
||||
if self.quit != None:
|
||||
self.quit("","")
|
||||
self.next(None,None)
|
||||
self.plause()
|
||||
elif t == gst.MESSAGE_ERROR:
|
||||
err, debug = message.parse_error()
|
||||
#if self.prnt != None:
|
||||
# self.prnt(["Error: "+ str(err) + " " +str(debug)])
|
||||
self.close()
|
||||
print "Error: %s" % err, debug
|
||||
print "Trying next song"
|
||||
self.next()
|
||||
#self.getNext(None,None)
|
||||
#if self.quit != None:
|
||||
# self.quit("")
|
||||
#elif t == gst.MESSAGE_TAG:
|
||||
# tags = message.parse_tag()
|
||||
# for tag in tags.keys():
|
||||
# self.info.tags[tag] = tags[tag]
|
||||
# if tag=="title":
|
||||
# self.info.title = tags[tag]
|
||||
# elif tag=="album":
|
||||
# self.info.album = tags[tag]
|
||||
# elif tag=="artist":
|
||||
# self.info.artist = tags[tag]
|
||||
# self.setInfo(tags)
|
||||
#self.taglist = message.parse_tag()
|
||||
# return
|
||||
self.next(None,None)
|
||||
|
||||
|
||||
# Change state to "playing"
|
||||
def play(self,widgit,data):
|
||||
self.player.set_state(gst.STATE_PLAYING)
|
||||
# Start main loop and find duration (if this hasn't been done yet)
|
||||
#while self.duration() == False:
|
||||
# time.sleep(0.1)
|
||||
|
||||
|
||||
# Change state to "paused"
|
||||
def pause(self,widgit,data):
|
||||
self.player.set_state(gst.STATE_PAUSED)
|
||||
# Toggle between play and pause
|
||||
def plause(self):
|
||||
if self.hasFile == False:
|
||||
return
|
||||
if self.playing == False:
|
||||
self.player.set_state(gst.STATE_PLAYING)
|
||||
self.playing = True
|
||||
else:
|
||||
self.player.set_state(gst.STATE_PAUSED)
|
||||
self.playing = False
|
||||
|
||||
|
||||
# Stop playback
|
||||
def stop(self):
|
||||
if self.hasFile == False:
|
||||
return
|
||||
self.player.set_state(gst.STATE_PAUSED)
|
||||
self.playing = False
|
||||
self.current = 0
|
||||
self.player.seek_simple(self.time_format,gst.SEEK_FLAG_FLUSH,self.current)
|
||||
|
||||
|
||||
# Close the song
|
||||
def close(self):
|
||||
self.playing = False
|
||||
self.player.set_state(gst.STATE_NULL)
|
||||
|
||||
|
||||
# Find the duration of the pipeline
|
||||
#def duration(self):
|
||||
# try:
|
||||
# self.info.length = Duration()
|
||||
# length = self.player.query_duration(self.time_format,None)[0]
|
||||
# self.total = length
|
||||
# self.info.length.setTime(length)
|
||||
# return True
|
||||
#except:
|
||||
# return False
|
||||
#self.length.disp(self.prnt)
|
||||
|
||||
|
||||
# Print out current running time
|
||||
def curTime(self):
|
||||
try:
|
||||
length = self.player.query_position(self.time_format,None)[0]
|
||||
self.current = length
|
||||
dur = Duration()
|
||||
dur.setTime(length)
|
||||
return (True,dur)
|
||||
except:
|
||||
return (False,None)
|
||||
if self.playing == False:
|
||||
return (False,False)
|
||||
return (True, self.player.query_position(self.time_format,None)[0])
|
||||
|
||||
|
||||
# Use to load a file path
|
||||
def passInfo(self,info):
|
||||
self.info = info
|
||||
self.bin.set_property("uri","file://"+self.info.filename)
|
||||
self.hasFile = True
|
||||
|
|
|
@ -13,25 +13,31 @@ class SongInfo:
|
|||
self.artist = ""
|
||||
|
||||
|
||||
def fixTime(self):
|
||||
time = self.duration
|
||||
def setTime(self,time):
|
||||
self.duration = time
|
||||
self.length = self.fixTime(time)
|
||||
|
||||
def fixTime(self,time):
|
||||
#time = self.duration
|
||||
# Find hour
|
||||
length = ""
|
||||
if time >= 3600:
|
||||
hour = time/3600
|
||||
time = time - (self.hour * 3600)
|
||||
if hour > 0:
|
||||
self.length=str(hour)+":"
|
||||
length=str(hour)+":"
|
||||
# Find minute
|
||||
if time >= 60:
|
||||
min = time/60
|
||||
time = time - (min * 60)
|
||||
if min < 10:
|
||||
self.length+="0"
|
||||
self.length+=str(min)+":"
|
||||
length+="0"
|
||||
length+=str(min)+":"
|
||||
else:
|
||||
self.length+="00:"
|
||||
length+="00:"
|
||||
# Remainder is seconds
|
||||
sec = time
|
||||
if sec < 10:
|
||||
self.length+="0"
|
||||
self.length+=str(sec)
|
||||
length+="0"
|
||||
length+=str(sec)
|
||||
return length
|
||||
|
|
|
@ -9,6 +9,7 @@ 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
|
||||
|
||||
|
||||
class Window(gtk.Window):
|
||||
|
@ -29,31 +30,12 @@ class Window(gtk.Window):
|
|||
self.add(self.mainLayout)
|
||||
self.makeMenuBar()
|
||||
self.makeContentPane()
|
||||
'''
|
||||
self.song = song
|
||||
self.ops = ops
|
||||
self.tree = None
|
||||
self.tooltip = gtk.Tooltips()
|
||||
self.tagLabels = dict()
|
||||
self.set_title("Ocarina")
|
||||
# Call quit function when closed
|
||||
self.connect("delete_event",onQuit)
|
||||
self.set_icon_from_file("images/ocarina.png")
|
||||
|
||||
self.mainLayout = gtk.VBox(False,0)
|
||||
self.add(self.mainLayout)
|
||||
self.mainLayout.show()
|
||||
|
||||
self.makeMenuBar()
|
||||
self.makeInfoPane()
|
||||
self.makeList()
|
||||
self.makeControls()
|
||||
self.maximize()
|
||||
'''
|
||||
self.mainLayout.show()
|
||||
self.show()
|
||||
|
||||
|
||||
'''
|
||||
# Make initial info pane
|
||||
def makeInfoPane(self):
|
||||
self.infoFrame = gtk.Frame("Current Song:")
|
||||
|
@ -134,79 +116,7 @@ class Window(gtk.Window):
|
|||
#self.tree.scroll_to_cell(selrow,None,True,0,0)
|
||||
#treesel = self.tree.get_selection()
|
||||
#treesel.select_path(row)
|
||||
|
||||
|
||||
# Use to make play/pause/next/etc buttons
|
||||
def makeControls(self):
|
||||
#controls = gtk.VBox(False,0)
|
||||
row = gtk.HBox(False,0)
|
||||
topRow = gtk.HBox(False,0)
|
||||
# Make top row buttons
|
||||
#self.makeButton("play","images/play.png",None,self.ops.play,topRow)
|
||||
self.makeButton("play","images/play.png",None,self.song.play,topRow)
|
||||
|
||||
#self.makeButton("pause","images/pause.png",None,self.ops.pause,topRow)
|
||||
self.makeButton("pause","images/pause.png",None,self.song.pause,topRow)
|
||||
|
||||
self.makeButton("stop","images/stop.png",None,self.ops.stop,topRow)
|
||||
self.makeButton("next","images/next.png",None,self.ops.next,topRow)
|
||||
self.makeButton("info",None,"Info",self.ops.info,topRow)
|
||||
#self.makeButton("plist",None,"Plist",self.ops.plist.showWindow,topRow)
|
||||
|
||||
test = gtk.VBox(False,0)
|
||||
self.makeCheck("Random",self.ops.random,self.ops.plist.random,True,topRow)
|
||||
topRow.show()
|
||||
row.pack_end(topRow,False,False,0)
|
||||
row.show()
|
||||
#self.mainLayout.pack_start(topRow,False,False,0)
|
||||
self.mainLayout.pack_start(row,False,False,0)
|
||||
# Make progress bar, add below top row
|
||||
pbar = gtk.ProgressBar()
|
||||
pbar.set_fraction(0)
|
||||
gobject.timeout_add(1000,self.ops.markProgress,pbar,"progress")
|
||||
pbar.show()
|
||||
self.mainLayout.pack_start(pbar,False,False,0)
|
||||
# Show completed controls
|
||||
#controls.show()
|
||||
#self.add(controls)
|
||||
|
||||
|
||||
# Make buttons and add to container
|
||||
# Path is to an image
|
||||
# Text is label text
|
||||
# Func is callback function
|
||||
def makeButton(self,name,path,text,func,container):
|
||||
button = gtk.Button()
|
||||
box = gtk.HBox(False,0)
|
||||
box.set_border_width(0)
|
||||
if path != None:
|
||||
image = gtk.Image()
|
||||
image.set_from_file(path)
|
||||
image.show()
|
||||
box.pack_start(image,False,False,0)
|
||||
if text != None:
|
||||
label = gtk.Label(text)
|
||||
label.show()
|
||||
box.pack_start(label,False,False,0)
|
||||
box.show()
|
||||
button.add(box)
|
||||
button.connect("clicked",func,name)
|
||||
button.show()
|
||||
container.pack_start(button,False,False,0)
|
||||
return button
|
||||
|
||||
|
||||
# Make a checkbox and add to container
|
||||
# Active is variable to check, status is value it has to mark as active
|
||||
def makeCheck(self,name,func,active,status,container):
|
||||
check = gtk.CheckButton(label=name)
|
||||
if active == status:
|
||||
check.set_active(1)
|
||||
check.connect("toggled",func,name)
|
||||
check.show()
|
||||
container.pack_start(check,False,False,0)
|
||||
return check
|
||||
|
||||
'''
|
||||
|
||||
# Used to make the top row menu bar
|
||||
def makeMenuBar(self):
|
||||
|
@ -224,8 +134,8 @@ class Window(gtk.Window):
|
|||
bar.append(plist)
|
||||
|
||||
# Replace first 'None' with after track functions
|
||||
pafter = MenuItem("Pause After Current Track",None,"pafter",self.changeFrameTitle,None)
|
||||
qafter = MenuItem("Quit After Current Track",None,"qafter",self.changeFrameTitle,None)
|
||||
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)
|
||||
|
||||
|
@ -236,8 +146,7 @@ class Window(gtk.Window):
|
|||
def deleteLib(self,widgit,data,other=None):
|
||||
self.data.library.reset()
|
||||
self.libview.update()
|
||||
self.data.curList = []
|
||||
self.data.updateList = True
|
||||
self.clearPlist()
|
||||
|
||||
|
||||
def clearPlist(self,widgit,data,other=None):
|
||||
|
@ -257,13 +166,8 @@ class Window(gtk.Window):
|
|||
dirsel.hide()
|
||||
if response != gtk.RESPONSE_OK:
|
||||
return
|
||||
#dirsel.destroy()
|
||||
#dirsel = None
|
||||
self.libview.updates()
|
||||
thread.start_new_thread(func,(data,file))
|
||||
#self.libview.updates()
|
||||
#func(data,file)
|
||||
#self.libview.update()
|
||||
|
||||
|
||||
def makeContentPane(self):
|
||||
|
@ -293,10 +197,13 @@ class Window(gtk.Window):
|
|||
|
||||
def makeBottomRow(self,vbox):
|
||||
box = gtk.HBox(False,0)
|
||||
box.pack_end(self.libview.label,False,False,10)
|
||||
#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,0.5,0,0)
|
||||
align = gtk.Alignment(1,1,0,0)
|
||||
align.add(box)
|
||||
align.show()
|
||||
vbox.pack_start(align,False,False,0)
|
||||
|
|