summaryrefslogtreecommitdiff
path: root/voctogui/lib/toolbar
diff options
context:
space:
mode:
authorMaZderMind <git@mazdermind.de>2015-08-07 11:32:34 +0200
committerMaZderMind <git@mazdermind.de>2015-08-07 11:32:34 +0200
commit2aa635013174a8c73839d52d678e503eabed2900 (patch)
tree7aab1e6b67cc09a10c2641819d8d7db4bcc9e770 /voctogui/lib/toolbar
parent74c0cf9f94ff4ab2a0490eb1819175d3daf0793c (diff)
parent4ba884d3a81d215b341b44626483f1df6f471762 (diff)
Merge branch 'great-refactoring'
Diffstat (limited to 'voctogui/lib/toolbar')
-rw-r--r--voctogui/lib/toolbar/composition.py33
-rw-r--r--voctogui/lib/toolbar/specialfunctions.py33
-rw-r--r--voctogui/lib/toolbar/streamblank.py45
3 files changed, 111 insertions, 0 deletions
diff --git a/voctogui/lib/toolbar/composition.py b/voctogui/lib/toolbar/composition.py
new file mode 100644
index 0000000..0185b7d
--- /dev/null
+++ b/voctogui/lib/toolbar/composition.py
@@ -0,0 +1,33 @@
+import logging
+from gi.repository import Gtk
+
+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 = [
+ 'composite-fullscreen',
+ 'composite-picture-in-picture',
+ 'composite-side-by-side-equal',
+ 'composite-side-by-side-preview'
+ ]
+
+ for idx, name in enumerate(composites):
+ key, mod = Gtk.accelerator_parse('F%u' % (idx+1))
+ btn = uibuilder.find_widget_recursive(drawing_area, name)
+ 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)
+
+ def on_btn_toggled(self, btn):
+ if not btn.get_active():
+ return
+
+ self.log.info("on_btn_toggled: %s", btn.get_name())
diff --git a/voctogui/lib/toolbar/specialfunctions.py b/voctogui/lib/toolbar/specialfunctions.py
new file mode 100644
index 0000000..61fb6bf
--- /dev/null
+++ b/voctogui/lib/toolbar/specialfunctions.py
@@ -0,0 +1,33 @@
+import logging
+from gi.repository import Gtk
+
+class SpecialFunctionsToolbarController(object):
+ """ Manages Accelerators and Clicks on the Composition Toolbar-Buttons """
+
+ def __init__(self, drawing_area, win, uibuilder, video_display):
+ self.log = logging.getLogger('SpecialFunctionsToolbarController')
+
+ self.video_display = video_display
+
+ accelerators = Gtk.AccelGroup()
+ win.add_accel_group(accelerators)
+
+ composites = [
+ 'preview_fullscreen',
+ 'preview_freeze',
+ ]
+
+ for idx, name in enumerate(composites):
+ key, mod = Gtk.accelerator_parse('F%u' % (idx+10))
+ btn = uibuilder.find_widget_recursive(drawing_area, name)
+ btn.set_name(name)
+
+ # Thanks to http://stackoverflow.com/a/19739855/1659732
+ childbtn = btn.get_child()
+ childbtn.add_accelerator('clicked', accelerators, key, mod, Gtk.AccelFlags.VISIBLE)
+ childbtn.connect('button-press-event', self.on_btn_event)
+ childbtn.connect('button-release-event', self.on_btn_event)
+
+ def on_btn_event(self, btn, event):
+ self.log.info("on_btn_event: %s @ %s", event.type, btn.get_name())
+ # do sth. to self.video_display here
diff --git a/voctogui/lib/toolbar/streamblank.py b/voctogui/lib/toolbar/streamblank.py
new file mode 100644
index 0000000..074fb80
--- /dev/null
+++ b/voctogui/lib/toolbar/streamblank.py
@@ -0,0 +1,45 @@
+import logging
+from gi.repository import Gtk
+
+class StreamblankToolbarController(object):
+ """ Manages Accelerators and Clicks on the Composition Toolbar-Buttons """
+
+ def __init__(self, drawing_area, win, uibuilder, warning_overlay):
+ self.log = logging.getLogger('StreamblankToolbarController')
+
+ self.warning_overlay = warning_overlay
+
+ blank_sources = ['pause', 'nostream']
+
+
+ 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)
+
+ livebtn.connect('toggled', self.on_btn_toggled)
+ livebtn.set_name('live')
+
+ 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)
+
+ def on_btn_toggled(self, btn):
+ if not btn.get_active():
+ return
+
+ self.log.info("on_btn_toggled: %s", btn.get_name())
+ if btn.get_name() == 'live':
+ self.warning_overlay.disable()
+
+ else:
+ self.warning_overlay.enable(btn.get_name())