summaryrefslogtreecommitdiff
path: root/voctogui/lib/audioselector.py
diff options
context:
space:
mode:
authorMaZderMind <git@mazdermind.de>2015-08-07 11:32:34 +0200
committerMaZderMind <git@mazdermind.de>2015-08-07 11:32:34 +0200
commit2aa635013174a8c73839d52d678e503eabed2900 (patch)
tree7aab1e6b67cc09a10c2641819d8d7db4bcc9e770 /voctogui/lib/audioselector.py
parent74c0cf9f94ff4ab2a0490eb1819175d3daf0793c (diff)
parent4ba884d3a81d215b341b44626483f1df6f471762 (diff)
Merge branch 'great-refactoring'
Diffstat (limited to 'voctogui/lib/audioselector.py')
-rw-r--r--voctogui/lib/audioselector.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/voctogui/lib/audioselector.py b/voctogui/lib/audioselector.py
new file mode 100644
index 0000000..8ad84e3
--- /dev/null
+++ b/voctogui/lib/audioselector.py
@@ -0,0 +1,63 @@
+import logging
+from gi.repository import Gst, Gdk, GLib
+
+class AudioSelectorController(object):
+ """ Displays a Level-Meter of another VideoDisplay into a GtkWidget """
+
+ def __init__(self, drawing_area, win, uibuilder):
+ self.log = logging.getLogger('AudioSelectorController')
+
+ self.drawing_area = drawing_area
+ self.win = win
+
+ combo = uibuilder.find_widget_recursive(win, 'combo_audio')
+ combo.connect('changed', self.on_changed)
+ #combo.set_sensitive(True)
+ self.combo = combo
+
+ eventbox = uibuilder.find_widget_recursive(win, 'combo_audio_events')
+ eventbox.connect('button_press_event', self.on_button_press_event)
+ eventbox.set_property('above_child', True)
+ self.eventbox = eventbox
+
+ combo.remove_all()
+ combo.append('moobar', 'Moo Bar')
+ combo.append('moofar', 'Moo Far')
+
+ combo.set_active_id('moobar')
+
+ self.timer_iteration = 0
+
+ def on_button_press_event(self, combo, event):
+ if event.type != Gdk.EventType.DOUBLE_BUTTON_PRESS:
+ return
+
+ self.log.debug('double-clicked, unlocking')
+ self.set_enabled(True)
+ GLib.timeout_add_seconds(5, self.on_disabled_timer, self.timer_iteration)
+
+ def on_disabled_timer(self, timer_iteration):
+ if timer_iteration != self.timer_iteration:
+ self.log.debug('lock-timer fired late, ignoring')
+ return
+
+ self.log.debug('lock-timer fired, locking')
+ self.set_enabled(False)
+ return False
+
+ def set_enabled(self, enable):
+ self.combo.set_sensitive(enable)
+ self.eventbox.set_property('above_child', not enable)
+
+ def is_enabled(self):
+ return self.combo.get_sensitive()
+
+ def on_changed(self, combo):
+ if not self.is_enabled():
+ return
+
+ self.timer_iteration += 1
+
+ value = combo.get_active_text()
+ self.log.debug('changed to %s', value)
+ self.set_enabled(False)