diff options
author | MaZderMind <git@mazdermind.de> | 2015-08-07 11:31:36 +0200 |
---|---|---|
committer | MaZderMind <git@mazdermind.de> | 2015-08-07 11:31:36 +0200 |
commit | 4ba884d3a81d215b341b44626483f1df6f471762 (patch) | |
tree | 7aab1e6b67cc09a10c2641819d8d7db4bcc9e770 /voctogui | |
parent | d200e609432591c1f1b2422c96616b3bfd1ea0f4 (diff) |
mockup specialfunctions controller
Diffstat (limited to 'voctogui')
-rw-r--r-- | voctogui/lib/toolbar/specialfunctions.py | 33 | ||||
-rw-r--r-- | voctogui/lib/ui.py | 8 | ||||
-rw-r--r-- | voctogui/ui/voctogui.ui | 1 |
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> |