diff options
author | MaZderMind <git@mazdermind.de> | 2015-10-05 23:48:37 +0200 |
---|---|---|
committer | MaZderMind <git@mazdermind.de> | 2015-10-05 23:48:37 +0200 |
commit | a9a3798af63247500ce8e01cac419a78ebe4e596 (patch) | |
tree | 62458a8e5066246e3c94613dfb9357f5af15e960 /voctogui/lib | |
parent | 83c093175efa46c063335b51f4821396f477ef20 (diff) |
connect stream-blanker buttons so server
Diffstat (limited to 'voctogui/lib')
-rw-r--r-- | voctogui/lib/toolbar/streamblank.py | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/voctogui/lib/toolbar/streamblank.py b/voctogui/lib/toolbar/streamblank.py index 074fb80..e1963c2 100644 --- a/voctogui/lib/toolbar/streamblank.py +++ b/voctogui/lib/toolbar/streamblank.py @@ -1,6 +1,8 @@ import logging from gi.repository import Gtk +import lib.connection as Connection + class StreamblankToolbarController(object): """ Manages Accelerators and Clicks on the Composition Toolbar-Buttons """ @@ -10,7 +12,7 @@ class StreamblankToolbarController(object): self.warning_overlay = warning_overlay blank_sources = ['pause', 'nostream'] - + self.status_btns = {} livebtn = uibuilder.find_widget_recursive(drawing_area, 'stream_live') blankbtn = uibuilder.find_widget_recursive(drawing_area, 'stream_blank') @@ -20,6 +22,9 @@ class StreamblankToolbarController(object): livebtn.connect('toggled', self.on_btn_toggled) livebtn.set_name('live') + self.livebtn = livebtn + self.blank_btns = {} + for idx, name in enumerate(blank_sources): if idx == 0: new_btn = blankbtn @@ -33,13 +38,33 @@ class StreamblankToolbarController(object): new_btn.connect('toggled', self.on_btn_toggled) new_btn.set_name(name) + self.blank_btns[name] = new_btn + + # connect event-handler and request initial state + Connection.on('stream_status', self.on_stream_status) + Connection.send('get_stream_status') + 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': + btn_name = btn.get_name() + self.log.info('stream-status activated: %s', btn_name) + if btn_name == 'live': self.warning_overlay.disable() else: - self.warning_overlay.enable(btn.get_name()) + self.warning_overlay.enable(btn_name) + + if btn_name == 'live': + Connection.send('set_stream_live') + else: + Connection.send('set_stream_blank', btn_name) + + def on_stream_status(self, status, source = None): + self.log.info('on_stream_status callback w/ status %s and source %s', status, source) + + if status == 'live': + self.livebtn.set_active(True) + else: + self.blank_btns[source].set_active(True) |