54 lines
1.2 KiB
Python
54 lines
1.2 KiB
Python
#! /usr/bin/python
|
|
|
|
# To change this template, choose Tools | Templates
|
|
# and open the template in the editor.
|
|
|
|
__author__="bjschuma"
|
|
__date__ ="$Mar 15, 2010 11:47:24 PM$"
|
|
|
|
|
|
import guibuilder
|
|
import ocarina
|
|
import gtk
|
|
from ct import cmd
|
|
|
|
class PlayButton(gtk.HBox):
|
|
def __init__(self,attrs):
|
|
gtk.HBox.__init__(self,False,0)
|
|
size = gtk.ICON_SIZE_BUTTON
|
|
for a in attrs:
|
|
if a=="size":
|
|
if attrs[a] == "large":
|
|
size = gtk.ICON_SIZE_DIALOG
|
|
|
|
self.play = self.getButton(gtk.STOCK_MEDIA_PLAY, size)
|
|
self.pause = self.getButton(gtk.STOCK_MEDIA_PAUSE, size)
|
|
|
|
self.play.show()
|
|
self.show()
|
|
|
|
ocarina.events.invite("ocarina-play", self.play.hide)
|
|
ocarina.events.invite("ocarina-play", self.pause.show)
|
|
ocarina.events.invite("ocarina-pause",self.play.show)
|
|
ocarina.events.invite("ocarina-pause",self.pause.hide)
|
|
|
|
|
|
def getButton(self,stock,size):
|
|
img = gtk.image_new_from_stock(stock,size)
|
|
button = gtk.Button()
|
|
button.add(img)
|
|
img.show()
|
|
button.connect("clicked",self.onclick)
|
|
self.pack_start(button, False)
|
|
return button
|
|
|
|
|
|
def onclick(self,button):
|
|
if button == self.play:
|
|
cmd.run("play")
|
|
else:
|
|
cmd.run("pause")
|
|
|
|
|
|
def make_playbutton(attrs=None):return PlayButton(attrs)
|
|
guibuilder.parts["playbutton"] = make_playbutton |