aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--voctogui/lib/toolbar/specialfunctions.py33
-rw-r--r--voctogui/lib/ui.py8
-rw-r--r--voctogui/ui/voctogui.ui1
3 files changed, 39 insertions, 3 deletions
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/ui.py b/voctogui/lib/ui.py
index f264284..0343c86 100644
--- a/voctogui/lib/ui.py
+++ b/voctogui/lib/ui.py
@@ -14,7 +14,7 @@ from lib.audioselector import AudioSelectorController
from lib.toolbar.composition import CompositionToolbarController
from lib.toolbar.streamblank import StreamblankToolbarController
-# from lib.toolbar.specialfunctions import SpecialFunctionsToolbarController
+from lib.toolbar.specialfunctions import SpecialFunctionsToolbarController
class Ui(UiBuilder):
def __init__(self, uifile):
@@ -72,8 +72,10 @@ class Ui(UiBuilder):
uibuilder=self,
warning_overlay=self.video_warning_overlay)
- # self.special_functions_toolbar_controller = SpecialFunctionsToolbarController(toolbar,
- # video_display=self.main_video_display)
+ self.special_functions_toolbar_controller = SpecialFunctionsToolbarController(toolbar,
+ win=self.win,
+ uibuilder=self,
+ video_display=self.main_video_display)
def show(self):
diff --git a/voctogui/ui/voctogui.ui b/voctogui/ui/voctogui.ui
index eac6794..1eb64cc 100644
--- a/voctogui/ui/voctogui.ui
+++ b/voctogui/ui/voctogui.ui
@@ -167,6 +167,7 @@
<object class="GtkToolButton" id="preview_freeze">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
<property name="label" translatable="yes">Freeze Preview</property>
<property name="use_underline">True</property>
</object>