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
This commit is contained in:
bjschuma 2009-06-29 03:13:12 +00:00
parent 1314d613e7
commit 920ce35570
19 changed files with 273 additions and 273 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 894 B

After

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 956 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 740 B

After

Width:  |  Height:  |  Size: 505 B

View File

@ -1,2 +1,3 @@
# Used for initializing things in the GuiObjects directory
__all__ = ['menuItem','libView','plistView'] __all__ = ['button','menuItem','libView','plistView']

View File

@ -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()

View File

@ -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()

View File

@ -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

View File

@ -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()

View File

@ -48,7 +48,7 @@ class LibView(gtk.VBox):
tree.set_sort_column_id(0,gtk.SORT_ASCENDING) tree.set_sort_column_id(0,gtk.SORT_ASCENDING)
self.treeview = gtk.TreeView(tree) self.treeview = gtk.TreeView(tree)
self.treeview.connect("button_release_event",self.clicked) 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) self.treeview.append_column(self.col)
cell = gtk.CellRendererText() cell = gtk.CellRendererText()
self.col.pack_start(cell,True) self.col.pack_start(cell,True)

View File

@ -1,3 +1,5 @@
import pygtk
pygtk.require('2.0')
import gtk import gtk
class MenuItem(gtk.MenuItem): class MenuItem(gtk.MenuItem):

View File

@ -1,3 +1,4 @@
import random
import gobject import gobject
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
@ -10,12 +11,15 @@ class PlistView(gtk.ScrolledWindow):
self.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) self.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
self.data = data self.data = data
self.data.song.next = self.next self.data.song.next = self.next
self.controls = None
self.tree = None self.tree = None
self.label = gtk.Label("") self.label = gtk.Label("")
self.makeList() self.makeList()
self.loadSong()
gobject.timeout_add(1000,self.checkUpdate) gobject.timeout_add(1000,self.checkUpdate)
# Check if the playlist has been updated
def checkUpdate(self): def checkUpdate(self):
if self.data.updateList == True: if self.data.updateList == True:
self.data.updateList = False self.data.updateList = False
@ -23,19 +27,20 @@ class PlistView(gtk.ScrolledWindow):
return True return True
# Make the playlist and show it
def makeList(self): 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: if self.tree:
self.remove(self.tree) self.remove(self.tree)
time = 0 time = 0
for index in self.data.curList: for index in self.data.curList:
track = self.data.library.files[index] 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 time+=track.duration
self.tree = gtk.TreeView(trackList) self.tree = gtk.TreeView(self.trackList)
cell = gtk.CellRendererText() cell = gtk.CellRendererText()
cols = ["Id","Title","Length","Artist","Album","#"] 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) lenSaved = len(self.data.colSizes)
for i in range(len(cols)): for i in range(len(cols)):
col = gtk.TreeViewColumn(cols[i],cell) col = gtk.TreeViewColumn(cols[i],cell)
@ -48,7 +53,7 @@ class PlistView(gtk.ScrolledWindow):
if cols[i] != "Id": if cols[i] != "Id":
self.tree.append_column(col) self.tree.append_column(col)
self.tree.set_rules_hint(True) 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.tree.show()
self.resizeCols() self.resizeCols()
self.add(self.tree) self.add(self.tree)
@ -63,26 +68,32 @@ class PlistView(gtk.ScrolledWindow):
self.data.colSizes +=[col.get_width()] self.data.colSizes +=[col.get_width()]
# Uses saved column settings
def resizeCols(self): def resizeCols(self):
cols = self.tree.get_columns() cols = self.tree.get_columns()
for i in range(len(self.data.colSizes)): for i in range(len(self.data.colSizes)):
cols[i].set_fixed_width(self.data.colSizes[i]) cols[i].set_fixed_width(self.data.colSizes[i])
def makeTimeLabel(self,time): # Shows total running time of the playlist
day = time/86500 def makeTimeLabel(self,sec):
time = time-(day*86500) day = 0
hour = time/3600 hour = 0
time = time-(hour*3600) min = 0
min = time/60 day = sec/86500
time = time-(min*60) 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(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.set_text(string)
self.label.show() self.label.show()
# Make a string for the amount of time
def toStr(self,time,label): def toStr(self,time,label):
if time > 0: if time > 0:
string=str(time) + " "+label string=str(time) + " "+label
@ -90,15 +101,48 @@ class PlistView(gtk.ScrolledWindow):
string+="s" string+="s"
string += " " string += " "
return string return string
return ""
# User selected a song with mouse click
def selectSong(self,widgit,iter,path,data,list): 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: if self.data.song:
self.data.song.close() self.data.song.close()
self.data.song.passInfo(self.data.library.files[list[iter][0]]) self.data.song.passInfo(self.data.library.files[self.data.curList[self.data.curSong]])
self.data.song.play(None,None) self.gotoCurSong()
def next(self): def gotoCurSong(self):
self.song.close() 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)

View File

@ -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()

View File

@ -2,7 +2,7 @@ import os
import re import re
import tagpy import tagpy
import cPickle as pickle import cPickle as pickle
from libdata import LibData #from libdata import LibData
from songInfo import SongInfo from songInfo import SongInfo
import thread import thread
@ -98,8 +98,9 @@ class Library:
info.artist = t.artist info.artist = t.artist
a = f.audioProperties() a = f.audioProperties()
info.duration = a.length info.setTime(a.length)
info.fixTime() #info.duration = a.length
#info.fixTime()
artist = info.artist.lower() artist = info.artist.lower()
album = info.album.lower() album = info.album.lower()
@ -117,11 +118,11 @@ class Library:
# Dump to file # Dump to file
def dump(self): #def dump(self):
out = open(self.save,'w') # out = open(self.save,'w')
p = pickle.Pickler(out,2) # p = pickle.Pickler(out,2)
p.dump(self.data) # p.dump(self.data)
out.close() # out.close()
# Return true if file is in the library # Return true if file is in the library
@ -140,17 +141,17 @@ class Library:
return -1 return -1
def nonBanned(self): #def nonBanned(self):
list = [] # list = []
for i in range(len(self.data.files)): # for i in range(len(self.data.files)):
if self.data.files[i].banned == False: # if self.data.files[i].banned == False:
list += [i] # list += [i]
return list # return list
def translate(self,sid): #def translate(self,sid):
#file = self.data.files[sid] # #file = self.data.files[sid]
return self.data.files[sid] # return self.data.files[sid]
#print file.title, file.artist, file.album # #print file.title, file.artist, file.album
return (sid,file.title,file.artist,file.album,file.playCount) # return (sid,file.title,file.artist,file.album,file.playCount)
#return (file.artist,file.album) # #return (file.artist,file.album)

View File

@ -11,11 +11,11 @@ from options import Options
from saveddata import SavedData from saveddata import SavedData
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 operations import Operations
from playlist import Playlist #from playlist import Playlist
from songInfo import SongInfo #from songInfo import SongInfo
from window import Window from window import Window
#gtk.gdk.threads_init() #gtk.gdk.threads_init()
@ -34,43 +34,6 @@ class main:
self.window = Window(self.quit,self.options,self.data) self.window = Window(self.quit,self.options,self.data)
gtk.main() 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 # Eventually replace "delete_event" with this

View File

@ -12,11 +12,13 @@ class SavedData:
self.divider = 150 self.divider = 150
self.library = Library() self.library = Library()
self.curList = [] self.curList = []
self.curSong = 0
self.colSizes = [110,110,110,110,110] self.colSizes = [110,110,110,110,110]
self.sortedCol = 3 self.sortedCol = 3
self.updateList = False self.updateList = False
self.path = path self.path = path
self.song = None self.song = None
self.random = False
if os.path.exists(path): if os.path.exists(path):
try: try:
@ -47,7 +49,10 @@ class SavedData:
p = pickle.Unpickler(open(path)) p = pickle.Unpickler(open(path))
data = p.load() data = p.load()
self.size = data.size self.size = data.size
self.library = data.library
self.divider = data.divider self.divider = data.divider
self.library = data.library
self.curList = data.curList self.curList = data.curList
self.curSong = 0
self.colSizes = data.colSizes self.colSizes = data.colSizes
self.path = data.path
self.random = data.random

View File

@ -10,117 +10,74 @@ class Song():
#def __init__(self,info,exitFunc,prnt): #def __init__(self,info,exitFunc,prnt):
def __init__(self,exitFunc): def __init__(self,exitFunc):
self.quit=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 # initialize player pipeline
self.next = None self.next = None
self.player = gst.Pipeline("player") self.player = gst.Pipeline("player")
self.bin = gst.element_factory_make("playbin",None) self.bin = gst.element_factory_make("playbin",None)
#bin.set_property("uri","file://"+self.info.filename)
self.player.add(self.bin) self.player.add(self.bin)
# initialize bus # initialize bus
bus = self.player.get_bus() bus = self.player.get_bus()
bus.add_signal_watch() bus.add_signal_watch()
bus.connect("message",self.onMessage) bus.connect("message",self.onMessage)
self.playing = False
# Pause song self.hasFile = False
#self.pause()
# Initialize stuff for finding duration # Initialize stuff for finding duration
self.time_format = gst.Format(gst.FORMAT_TIME) self.time_format = gst.Format(gst.FORMAT_TIME)
#self.length = None
#self.taglist = None
# Called on bus messages # Called on bus messages
def onMessage(self,bus,message): def onMessage(self,bus,message):
t = message.type t = message.type
if t == gst.MESSAGE_EOS: if t == gst.MESSAGE_EOS:
#print "End of stream" self.next(None,None)
#self.prnt(["End of stream"]) self.plause()
if self.quit != None:
self.quit("","")
elif t == gst.MESSAGE_ERROR: elif t == gst.MESSAGE_ERROR:
err, debug = message.parse_error() err, debug = message.parse_error()
#if self.prnt != None:
# self.prnt(["Error: "+ str(err) + " " +str(debug)])
self.close() self.close()
print "Error: %s" % err, debug print "Error: %s" % err, debug
print "Trying next song" print "Trying next song"
self.next() self.next(None,None)
#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
# Change state to "playing" # Toggle between play and pause
def play(self,widgit,data): def plause(self):
self.player.set_state(gst.STATE_PLAYING) if self.hasFile == False:
# Start main loop and find duration (if this hasn't been done yet) return
#while self.duration() == False: if self.playing == False:
# time.sleep(0.1) self.player.set_state(gst.STATE_PLAYING)
self.playing = True
else:
# Change state to "paused" self.player.set_state(gst.STATE_PAUSED)
def pause(self,widgit,data): self.playing = False
self.player.set_state(gst.STATE_PAUSED)
# Stop playback # Stop playback
def stop(self): def stop(self):
if self.hasFile == False:
return
self.player.set_state(gst.STATE_PAUSED) self.player.set_state(gst.STATE_PAUSED)
self.playing = False
self.current = 0 self.current = 0
self.player.seek_simple(self.time_format,gst.SEEK_FLAG_FLUSH,self.current) self.player.seek_simple(self.time_format,gst.SEEK_FLAG_FLUSH,self.current)
# Close the song # Close the song
def close(self): def close(self):
self.playing = False
self.player.set_state(gst.STATE_NULL) 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 # Print out current running time
def curTime(self): def curTime(self):
try: if self.playing == False:
length = self.player.query_position(self.time_format,None)[0] return (False,False)
self.current = length return (True, self.player.query_position(self.time_format,None)[0])
dur = Duration()
dur.setTime(length)
return (True,dur)
except:
return (False,None)
# Use to load a file path
def passInfo(self,info): def passInfo(self,info):
self.info = info self.info = info
self.bin.set_property("uri","file://"+self.info.filename) self.bin.set_property("uri","file://"+self.info.filename)
self.hasFile = True

View File

@ -13,25 +13,31 @@ class SongInfo:
self.artist = "" self.artist = ""
def fixTime(self): def setTime(self,time):
time = self.duration self.duration = time
self.length = self.fixTime(time)
def fixTime(self,time):
#time = self.duration
# Find hour # Find hour
length = ""
if time >= 3600: if time >= 3600:
hour = time/3600 hour = time/3600
time = time - (self.hour * 3600) time = time - (self.hour * 3600)
if hour > 0: if hour > 0:
self.length=str(hour)+":" length=str(hour)+":"
# Find minute # Find minute
if time >= 60: if time >= 60:
min = time/60 min = time/60
time = time - (min * 60) time = time - (min * 60)
if min < 10: if min < 10:
self.length+="0" length+="0"
self.length+=str(min)+":" length+=str(min)+":"
else: else:
self.length+="00:" length+="00:"
# Remainder is seconds # Remainder is seconds
sec = time sec = time
if sec < 10: if sec < 10:
self.length+="0" length+="0"
self.length+=str(sec) length+=str(sec)
return length

View File

@ -9,6 +9,7 @@ from kiwi.ui.objectlist import Column, ObjectList
from GuiObjects.menuItem import MenuItem from GuiObjects.menuItem import MenuItem
from GuiObjects.libView import LibView from GuiObjects.libView import LibView
from GuiObjects.plistView import PlistView from GuiObjects.plistView import PlistView
from GuiObjects.controlPanel import ControlPanel
class Window(gtk.Window): class Window(gtk.Window):
@ -29,31 +30,12 @@ class Window(gtk.Window):
self.add(self.mainLayout) self.add(self.mainLayout)
self.makeMenuBar() self.makeMenuBar()
self.makeContentPane() 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.mainLayout.show()
self.show() self.show()
'''
# Make initial info pane # Make initial info pane
def makeInfoPane(self): def makeInfoPane(self):
self.infoFrame = gtk.Frame("Current Song:") self.infoFrame = gtk.Frame("Current Song:")
@ -134,79 +116,7 @@ class Window(gtk.Window):
#self.tree.scroll_to_cell(selrow,None,True,0,0) #self.tree.scroll_to_cell(selrow,None,True,0,0)
#treesel = self.tree.get_selection() #treesel = self.tree.get_selection()
#treesel.select_path(row) #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 # Used to make the top row menu bar
def makeMenuBar(self): def makeMenuBar(self):
@ -224,8 +134,8 @@ class Window(gtk.Window):
bar.append(plist) bar.append(plist)
# Replace first 'None' with after track functions # Replace first 'None' with after track functions
pafter = MenuItem("Pause After Current Track",None,"pafter",self.changeFrameTitle,None) pafter = MenuItem("Pause After Current Track",None,"pafter",None,None)
qafter = MenuItem("Quit After Current Track",None,"qafter",self.changeFrameTitle,None) qafter = MenuItem("Quit After Current Track",None,"qafter",None,None)
playback = MenuItem("Playback",None,None,None,[pafter,qafter]) playback = MenuItem("Playback",None,None,None,[pafter,qafter])
bar.append(playback) bar.append(playback)
@ -236,8 +146,7 @@ class Window(gtk.Window):
def deleteLib(self,widgit,data,other=None): def deleteLib(self,widgit,data,other=None):
self.data.library.reset() self.data.library.reset()
self.libview.update() self.libview.update()
self.data.curList = [] self.clearPlist()
self.data.updateList = True
def clearPlist(self,widgit,data,other=None): def clearPlist(self,widgit,data,other=None):
@ -257,13 +166,8 @@ class Window(gtk.Window):
dirsel.hide() dirsel.hide()
if response != gtk.RESPONSE_OK: if response != gtk.RESPONSE_OK:
return return
#dirsel.destroy()
#dirsel = None
self.libview.updates() self.libview.updates()
thread.start_new_thread(func,(data,file)) thread.start_new_thread(func,(data,file))
#self.libview.updates()
#func(data,file)
#self.libview.update()
def makeContentPane(self): def makeContentPane(self):
@ -293,10 +197,13 @@ class Window(gtk.Window):
def makeBottomRow(self,vbox): def makeBottomRow(self,vbox):
box = gtk.HBox(False,0) 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.pack_end(self.plistview.label)
box.show() box.show()
align = gtk.Alignment(1,0.5,0,0) align = gtk.Alignment(1,1,0,0)
align.add(box) align.add(box)
align.show() align.show()
vbox.pack_start(align,False,False,0) vbox.pack_start(align,False,False,0)