79 lines
2.3 KiB
Python
79 lines
2.3 KiB
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
import gi
|
||
|
gi.require_version('Gtk', '3.0')
|
||
|
from gi.repository import Gtk, GObject
|
||
|
|
||
|
from .image_button import ImageButton
|
||
|
|
||
|
class CtrlBox(Gtk.Box):
|
||
|
|
||
|
__gsignals__ = {
|
||
|
'clicked': (GObject.SIGNAL_RUN_FIRST, None, (str,))
|
||
|
}
|
||
|
|
||
|
def __init__(self, spacing = 6):
|
||
|
Gtk.Box.__init__(self, spacing = spacing)
|
||
|
|
||
|
self.modes = ['./usr/share/sonist/all.png','./usr/share/sonist/rand.png','./usr/share/sonist/single.png']
|
||
|
self.curr_mode = 0
|
||
|
|
||
|
self.mode_btn = ImageButton('./usr/share/sonist/all.png')
|
||
|
self.prev_btn = ImageButton('./usr/share/sonist/prev.png')
|
||
|
self.play_btn = ImageButton('./usr/share/sonist/pause.png', 48, 48)
|
||
|
self.next_btn = ImageButton('./usr/share/sonist/next.png')
|
||
|
self.vol_btn = ImageButton('./usr/share/sonist/volume.png')
|
||
|
|
||
|
self.pack_start(self.mode_btn, False, False, 0)
|
||
|
self.pack_start(self.prev_btn, False, False, 0)
|
||
|
self.pack_start(self.play_btn, False, False, 0)
|
||
|
self.pack_start(self.next_btn, False, False, 0)
|
||
|
self.pack_start(self.vol_btn, False, False, 0)
|
||
|
|
||
|
|
||
|
self.mode_btn.connect('clicked', self.on_btn_clicked)
|
||
|
self.prev_btn.connect('clicked', self.on_btn_clicked)
|
||
|
self.play_btn.connect('clicked', self.on_btn_clicked)
|
||
|
self.next_btn.connect('clicked', self.on_btn_clicked)
|
||
|
self.vol_btn.connect('clicked', self.on_btn_clicked)
|
||
|
|
||
|
|
||
|
def on_btn_clicked(self, btn):
|
||
|
|
||
|
if btn == self.play_btn:
|
||
|
self.emit('clicked', 'play_btn')
|
||
|
|
||
|
elif btn == self.mode_btn:
|
||
|
self.curr_mode += 1
|
||
|
if self.curr_mode > 2:
|
||
|
self.curr_mode = 0
|
||
|
self.mode_btn.set_image(self.modes[self.curr_mode])
|
||
|
self.emit('clicked', 'mode_btn')
|
||
|
|
||
|
elif btn == self.prev_btn:
|
||
|
self.emit('clicked', 'prev_btn')
|
||
|
|
||
|
elif btn == self.next_btn:
|
||
|
self.emit('clicked', 'next_btn')
|
||
|
|
||
|
elif btn == self.vol_btn:
|
||
|
self.emit('clicked','vol_btn')
|
||
|
|
||
|
|
||
|
def toggle_play_btn(self, on = True):
|
||
|
if on:
|
||
|
self.play_btn.set_image('./usr/share/sonist/play_a.png')
|
||
|
else:
|
||
|
self.play_btn.set_image('./usr/share/sonist/pause.png')
|
||
|
|
||
|
|
||
|
def toggle_mode_btn(self, mode = 'single'):
|
||
|
if mode == 'single':
|
||
|
self.curr_mode = 2
|
||
|
elif mode == 'random':
|
||
|
self.curr_mode = 1
|
||
|
else:
|
||
|
self.curr_mode = 0
|
||
|
|
||
|
self.mode_btn.set_image(self.modes[self.curr_mode])
|