aboutsummaryrefslogtreecommitdiff
path: root/voctogui/lib/toolbar/specialfunctions.py
blob: 61fb6bfdceedf91d07bd951ab3732d3725c751c0 (plain)
  1. import logging
  2. from gi.repository import Gtk
  3. class SpecialFunctionsToolbarController(object):
  4. """ Manages Accelerators and Clicks on the Composition Toolbar-Buttons """
  5. def __init__(self, drawing_area, win, uibuilder, video_display):
  6. self.log = logging.getLogger('SpecialFunctionsToolbarController')
  7. self.video_display = video_display
  8. accelerators = Gtk.AccelGroup()
  9. win.add_accel_group(accelerators)
  10. composites = [
  11. 'preview_fullscreen',
  12. 'preview_freeze',
  13. ]
  14. for idx, name in enumerate(composites):
  15. key, mod = Gtk.accelerator_parse('F%u' % (idx+10))
  16. btn = uibuilder.find_widget_recursive(drawing_area, name)
  17. btn.set_name(name)
  18. # Thanks to http://stackoverflow.com/a/19739855/1659732
  19. childbtn = btn.get_child()
  20. childbtn.add_accelerator('clicked', accelerators, key, mod, Gtk.AccelFlags.VISIBLE)
  21. childbtn.connect('button-press-event', self.on_btn_event)
  22. childbtn.connect('button-release-event', self.on_btn_event)
  23. def on_btn_event(self, btn, event):
  24. self.log.info("on_btn_event: %s @ %s", event.type, btn.get_name())
  25. # do sth. to self.video_display here