ocarina/remote/gui/buttons.py

76 lines
1.6 KiB
Python

# Bryan Schumaker (11/13/2010)
import remote
gtk = remote.gtk
play_button = None
pause_button = None
def set_state_playing():
play_button.hide()
pause_button.show()
def set_state_paused():
play_button.show()
pause_button.hide()
from remote import procs
class Button(gtk.Button):
def __init__(self, stock, size=gtk.ICON_SIZE_LARGE_TOOLBAR, func=None, show=True):
gtk.Button.__init__(self)
self.func = func
img = gtk.image_new_from_stock(stock, size)
img.show()
self.add(img)
self.set_relief(gtk.RELIEF_NONE)
self.click_id = self.connect("clicked", self.clicked)
if show == True:
Button.show(self)
self.set_alignment(0,0)
def clicked(self, button):
self.func()
def show(self, *args):
gtk.Button.show(self)
def hide(self, *args):
gtk.Button.hide(self)
class PlayButton(Button):
def __init__(self):
global play_button
Button.__init__(self, gtk.STOCK_MEDIA_PLAY)
play_button = self
def clicked(self, button):
procs.play()
def hide(self):
Button.hide(self)
def show(self):
Button.show(self)
class PauseButton(Button):
def __init__(self):
global pause_button
Button.__init__(self, gtk.STOCK_MEDIA_PAUSE, show=False)
pause_button = self
def clicked(self, button):
procs.pause()
def hide(self):
Button.hide(self)
def show(self):
Button.show(self)
class StopButton(Button):
def __init__(self):
Button.__init__(self, gtk.STOCK_MEDIA_STOP)
def clicked(self, button):
procs.stop()
class NextButton(Button):
def __init__(self):
Button.__init__(self, gtk.STOCK_MEDIA_NEXT)
def clicked(self, button):
procs.next()