aboutsummaryrefslogtreecommitdiff
path: root/voctogui
diff options
context:
space:
mode:
authorMaZderMind <git@mazdermind.de>2015-10-05 23:36:11 +0200
committerMaZderMind <git@mazdermind.de>2015-10-05 23:36:11 +0200
commit83c093175efa46c063335b51f4821396f477ef20 (patch)
tree81738cbf47a54c483b6ba4f3cd5ece82cee857dd /voctogui
parentfa98cb89196ab9dec20a34bc5d139c0a2ff060d9 (diff)
connect composition-toolbar to server
Diffstat (limited to 'voctogui')
-rw-r--r--voctogui/lib/toolbar/composition.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/voctogui/lib/toolbar/composition.py b/voctogui/lib/toolbar/composition.py
index 0185b7d..f473ccf 100644
--- a/voctogui/lib/toolbar/composition.py
+++ b/voctogui/lib/toolbar/composition.py
@@ -1,6 +1,8 @@
import logging
from gi.repository import Gtk
+import lib.connection as Connection
+
class CompositionToolbarController(object):
""" Manages Accelerators and Clicks on the Composition Toolbar-Buttons """
@@ -11,23 +13,38 @@ class CompositionToolbarController(object):
win.add_accel_group(accelerators)
composites = [
- 'composite-fullscreen',
- 'composite-picture-in-picture',
- 'composite-side-by-side-equal',
- 'composite-side-by-side-preview'
+ 'fullscreen',
+ 'picture_in_picture',
+ 'side_by_side_equal',
+ 'side_by_side_preview'
]
+ self.composite_btns = {}
+
for idx, name in enumerate(composites):
key, mod = Gtk.accelerator_parse('F%u' % (idx+1))
- btn = uibuilder.find_widget_recursive(drawing_area, name)
+ 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
- self.log.info("on_btn_toggled: %s", btn.get_name())
+ btn_name = btn.get_name()
+ 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.composite_btns[mode].set_active(True)