summaryrefslogtreecommitdiff
path: root/voctogui/lib/toolbar
diff options
context:
space:
mode:
Diffstat (limited to 'voctogui/lib/toolbar')
-rw-r--r--voctogui/lib/toolbar/composition.py104
-rw-r--r--voctogui/lib/toolbar/misc.py41
-rw-r--r--voctogui/lib/toolbar/streamblank.py120
3 files changed, 138 insertions, 127 deletions
diff --git a/voctogui/lib/toolbar/composition.py b/voctogui/lib/toolbar/composition.py
index a2b1f29..2674260 100644
--- a/voctogui/lib/toolbar/composition.py
+++ b/voctogui/lib/toolbar/composition.py
@@ -3,54 +3,58 @@ from gi.repository import Gtk
import lib.connection as Connection
-class CompositionToolbarController(object):
- """ Manages Accelerators and Clicks on the Composition Toolbar-Buttons """
-
- def __init__(self, drawing_area, win, uibuilder):
- self.log = logging.getLogger('CompositionToolbarController')
-
- accelerators = Gtk.AccelGroup()
- win.add_accel_group(accelerators)
-
- composites = [
- 'fullscreen',
- 'picture_in_picture',
- 'side_by_side_equal',
- 'side_by_side_preview'
- ]
-
- self.composite_btns = {}
- self.current_composition = None
-
- for idx, name in enumerate(composites):
- key, mod = Gtk.accelerator_parse('F%u' % (idx+1))
- btn = uibuilder.find_widget_recursive(drawing_area, 'composite-'+name.replace('_', '-'))
- btn.set_name(name)
-
- # Thanks to http://stackoverflow.com/a/19739855/1659732
- btn.get_child().add_accelerator('clicked', accelerators, key, mod, Gtk.AccelFlags.VISIBLE)
- btn.connect('toggled', self.on_btn_toggled)
- self.composite_btns[name] = btn
-
- # connect event-handler and request initial state
- Connection.on('composite_mode', self.on_composite_mode)
- Connection.send('get_composite_mode')
-
-
- def on_btn_toggled(self, btn):
- if not btn.get_active():
- return
-
- btn_name = btn.get_name()
- if self.current_composition == btn_name:
- self.log.info('composition-mode already active: %s', btn_name)
- return
-
- self.log.info('composition-mode activated: %s', btn_name)
- Connection.send('set_composite_mode', btn_name)
-
- def on_composite_mode(self, mode):
- self.log.info('on_composite_mode callback w/ mode %s', mode)
- self.current_composition = mode
- self.composite_btns[mode].set_active(True)
+class CompositionToolbarController(object):
+ """Manages Accelerators and Clicks on the Composition Toolbar-Buttons"""
+
+ def __init__(self, drawing_area, win, uibuilder):
+ self.log = logging.getLogger('CompositionToolbarController')
+
+ accelerators = Gtk.AccelGroup()
+ win.add_accel_group(accelerators)
+
+ composites = [
+ 'fullscreen',
+ 'picture_in_picture',
+ 'side_by_side_equal',
+ 'side_by_side_preview'
+ ]
+
+ self.composite_btns = {}
+ self.current_composition = None
+
+ for idx, name in enumerate(composites):
+ key, mod = Gtk.accelerator_parse('F%u' % (idx + 1))
+ btn = uibuilder.find_widget_recursive(
+ drawing_area,
+ 'composite-' + name.replace('_', '-')
+ )
+ btn.set_name(name)
+
+ # Thanks to http://stackoverflow.com/a/19739855/1659732
+ btn.get_child().add_accelerator('clicked', accelerators,
+ key, mod, Gtk.AccelFlags.VISIBLE)
+ btn.connect('toggled', self.on_btn_toggled)
+
+ self.composite_btns[name] = btn
+
+ # connect event-handler and request initial state
+ Connection.on('composite_mode', self.on_composite_mode)
+ Connection.send('get_composite_mode')
+
+ def on_btn_toggled(self, btn):
+ if not btn.get_active():
+ return
+
+ btn_name = btn.get_name()
+ if self.current_composition == btn_name:
+ self.log.info('composition-mode already active: %s', btn_name)
+ return
+
+ self.log.info('composition-mode activated: %s', btn_name)
+ Connection.send('set_composite_mode', btn_name)
+
+ def on_composite_mode(self, mode):
+ self.log.info('on_composite_mode callback w/ mode %s', mode)
+ self.current_composition = mode
+ self.composite_btns[mode].set_active(True)
diff --git a/voctogui/lib/toolbar/misc.py b/voctogui/lib/toolbar/misc.py
index 9528b67..530bbad 100644
--- a/voctogui/lib/toolbar/misc.py
+++ b/voctogui/lib/toolbar/misc.py
@@ -6,30 +6,31 @@ import lib.connection as Connection
class MiscToolbarController(object):
- """ Manages Accelerators and Clicks Misc buttons """
+ """Manages Accelerators and Clicks Misc buttons"""
- def __init__(self, drawing_area, win, uibuilder):
- self.log = logging.getLogger('MiscToolbarController')
+ def __init__(self, drawing_area, win, uibuilder):
+ self.log = logging.getLogger('MiscToolbarController')
- # Accelerators
- accelerators = Gtk.AccelGroup()
- win.add_accel_group(accelerators)
+ # Accelerators
+ accelerators = Gtk.AccelGroup()
+ win.add_accel_group(accelerators)
- closebtn = uibuilder.find_widget_recursive(drawing_area, 'close')
- closebtn.set_visible( Config.getboolean('misc', 'close') )
- closebtn.connect('clicked', self.on_closebtn_clicked)
+ closebtn = uibuilder.find_widget_recursive(drawing_area, 'close')
+ closebtn.set_visible(Config.getboolean('misc', 'close'))
+ closebtn.connect('clicked', self.on_closebtn_clicked)
- cutbtn = uibuilder.find_widget_recursive(drawing_area, 'cut')
- cutbtn.set_visible( Config.getboolean('misc', 'cut') )
- cutbtn.connect('clicked', self.on_cutbtn_clicked)
+ cutbtn = uibuilder.find_widget_recursive(drawing_area, 'cut')
+ cutbtn.set_visible(Config.getboolean('misc', 'cut'))
+ cutbtn.connect('clicked', self.on_cutbtn_clicked)
- key, mod = Gtk.accelerator_parse('t')
- cutbtn.add_accelerator('clicked', accelerators, key, mod, Gtk.AccelFlags.VISIBLE)
+ key, mod = Gtk.accelerator_parse('t')
+ cutbtn.add_accelerator('clicked', accelerators,
+ key, mod, Gtk.AccelFlags.VISIBLE)
- def on_closebtn_clicked(self, btn):
- self.log.info('close-button clicked')
- Gtk.main_quit()
+ def on_closebtn_clicked(self, btn):
+ self.log.info('close-button clicked')
+ Gtk.main_quit()
- def on_cutbtn_clicked(self, btn):
- self.log.info('cut-button clicked')
- Connection.send('message', 'cut')
+ def on_cutbtn_clicked(self, btn):
+ self.log.info('cut-button clicked')
+ Connection.send('message', 'cut')
diff --git a/voctogui/lib/toolbar/streamblank.py b/voctogui/lib/toolbar/streamblank.py
index 717fadd..e627237 100644
--- a/voctogui/lib/toolbar/streamblank.py
+++ b/voctogui/lib/toolbar/streamblank.py
@@ -4,82 +4,88 @@ from gi.repository import Gtk
from lib.config import Config
import lib.connection as Connection
+
class StreamblankToolbarController(object):
- """ Manages Accelerators and Clicks on the Composition Toolbar-Buttons """
+ """Manages Accelerators and Clicks on the Composition Toolbar-Buttons"""
- def __init__(self, drawing_area, win, uibuilder, warning_overlay):
- self.log = logging.getLogger('StreamblankToolbarController')
+ def __init__(self, drawing_area, win, uibuilder, warning_overlay):
+ self.log = logging.getLogger('StreamblankToolbarController')
- self.warning_overlay = warning_overlay
+ self.warning_overlay = warning_overlay
- livebtn = uibuilder.find_widget_recursive(drawing_area, 'stream_live')
- blankbtn = uibuilder.find_widget_recursive(drawing_area, 'stream_blank')
+ livebtn = uibuilder.find_widget_recursive(drawing_area, 'stream_live')
+ blankbtn = uibuilder.find_widget_recursive(drawing_area,
+ 'stream_blank')
- blankbtn_pos = drawing_area.get_item_index(blankbtn)
+ blankbtn_pos = drawing_area.get_item_index(blankbtn)
- if not Config.getboolean('stream-blanker', 'enabled'):
- self.log.info('disabling stream-blanker features because the server does not support them: %s', Config.getboolean('stream-blanker', 'enabled'))
+ if not Config.getboolean('stream-blanker', 'enabled'):
+ self.log.info('disabling stream-blanker features '
+ 'because the server does not support them: %s',
+ Config.getboolean('stream-blanker', 'enabled'))
- drawing_area.remove(livebtn)
- drawing_area.remove(blankbtn)
- return
+ drawing_area.remove(livebtn)
+ drawing_area.remove(blankbtn)
+ return
- blank_sources = Config.getlist('stream-blanker', 'sources')
- self.status_btns = {}
+ blank_sources = Config.getlist('stream-blanker', 'sources')
+ self.status_btns = {}
- self.current_status = None
+ self.current_status = None
- livebtn.connect('toggled', self.on_btn_toggled)
- livebtn.set_name('live')
+ livebtn.connect('toggled', self.on_btn_toggled)
+ livebtn.set_name('live')
- self.livebtn = livebtn
- self.blank_btns = {}
+ self.livebtn = livebtn
+ self.blank_btns = {}
- for idx, name in enumerate(blank_sources):
- if idx == 0:
- new_btn = blankbtn
- else:
- new_icon = Gtk.Image.new_from_pixbuf(blankbtn.get_icon_widget().get_pixbuf())
- new_btn = Gtk.RadioToolButton(group=livebtn)
- new_btn.set_icon_widget(new_icon)
- drawing_area.insert(new_btn, blankbtn_pos+1)
+ for idx, name in enumerate(blank_sources):
+ if idx == 0:
+ new_btn = blankbtn
+ else:
+ new_icon = Gtk.Image.new_from_pixbuf(blankbtn.get_icon_widget()
+ .get_pixbuf())
+ new_btn = Gtk.RadioToolButton(group=livebtn)
+ new_btn.set_icon_widget(new_icon)
+ drawing_area.insert(new_btn, blankbtn_pos + 1)
- new_btn.set_label("Stream %s" % name)
- new_btn.connect('toggled', self.on_btn_toggled)
- new_btn.set_name(name)
+ new_btn.set_label("Stream %s" % name)
+ new_btn.connect('toggled', self.on_btn_toggled)
+ new_btn.set_name(name)
- self.blank_btns[name] = new_btn
+ self.blank_btns[name] = new_btn
- # connect event-handler and request initial state
- Connection.on('stream_status', self.on_stream_status)
- Connection.send('get_stream_status')
+ # connect event-handler and request initial state
+ Connection.on('stream_status', self.on_stream_status)
+ Connection.send('get_stream_status')
- def on_btn_toggled(self, btn):
- if not btn.get_active():
- return
+ def on_btn_toggled(self, btn):
+ if not btn.get_active():
+ return
- btn_name = btn.get_name()
- if btn_name == 'live':
- self.warning_overlay.disable()
+ btn_name = btn.get_name()
+ if btn_name == 'live':
+ self.warning_overlay.disable()
- else:
- self.warning_overlay.enable(btn_name)
+ else:
+ self.warning_overlay.enable(btn_name)
- if self.current_status == btn_name:
- self.log.info('stream-status already activate: %s', btn_name)
- return
+ if self.current_status == btn_name:
+ self.log.info('stream-status already activate: %s', btn_name)
+ return
- self.log.info('stream-status activated: %s', btn_name)
- if btn_name == 'live':
- Connection.send('set_stream_live')
- else:
- Connection.send('set_stream_blank', btn_name)
+ self.log.info('stream-status activated: %s', btn_name)
+ if btn_name == 'live':
+ Connection.send('set_stream_live')
+ else:
+ Connection.send('set_stream_blank', btn_name)
- def on_stream_status(self, status, source = None):
- self.log.info('on_stream_status callback w/ status %s and source %s', status, source)
+ def on_stream_status(self, status, source=None):
+ self.log.info('on_stream_status callback w/ status %s and source %s',
+ status, source)
- self.current_status = source if source is not None else status
- if status == 'live':
- self.livebtn.set_active(True)
- else:
- self.blank_btns[source].set_active(True)
+ self.current_status = source if source is not None else status
+ if status == 'live':
+ self.livebtn.set_active(True)
+ else:
+ self.blank_btns[source].set_active(True)