summaryrefslogtreecommitdiff
path: root/voctogui/lib
diff options
context:
space:
mode:
Diffstat (limited to 'voctogui/lib')
-rw-r--r--voctogui/lib/ui.py50
-rw-r--r--voctogui/lib/uibuilder.py57
2 files changed, 68 insertions, 39 deletions
diff --git a/voctogui/lib/ui.py b/voctogui/lib/ui.py
new file mode 100644
index 0000000..fd40bb8
--- /dev/null
+++ b/voctogui/lib/ui.py
@@ -0,0 +1,50 @@
+#!/usr/bin/python3
+import gi, logging
+from gi.repository import Gtk, Gst
+
+from lib.uibuilder import UiBuilder
+
+class Ui(UiBuilder):
+ def __init__(self, uifile):
+ self.log = logging.getLogger('Ui')
+ super().__init__(uifile)
+
+ def setup(self):
+ # Aquire the Main-Window from the UI-File
+ self.win = self.get_check_widget('window')
+
+ # Connect Close-Handler
+ self.win.connect('delete-event', Gtk.main_quit)
+
+ self.configure_video_previews()
+ self.configure_audio_selector()
+
+ def configure_video_previews(self):
+ sources = ['cam1', 'cam2', 'grabber']
+ box = self.get_check_widget('box_left')
+
+ for source in sources:
+ preview = self.get_check_widget('widget_preview', clone=True)
+ #box.add(preview)
+ box.pack_start(preview, fill=False, expand=False, padding=0)
+
+ # http://stackoverflow.com/questions/3489520/python-gtk-widget-name
+ self.find_widget_recursive(preview, "label").set_label(source)
+
+ def configure_audio_selector(self):
+ combo = self.get_check_widget('combo_audio')
+ combo.set_sensitive(True)
+
+ liststore = self.get_check_widget('liststore_audio')
+ liststore.clear()
+
+ row = liststore.append()
+ liststore.set(row, [0], ['foobar'])
+
+ row = liststore.append('')
+ liststore.set(row, [0], ['moofar'])
+
+ combo.set_active_id('moofar')
+
+ def show(self):
+ self.win.show_all()
diff --git a/voctogui/lib/uibuilder.py b/voctogui/lib/uibuilder.py
index 4084bcf..8ce01ab 100644
--- a/voctogui/lib/uibuilder.py
+++ b/voctogui/lib/uibuilder.py
@@ -4,54 +4,33 @@ from gi.repository import Gtk, Gst
class UiBuilder(object):
def __init__(self, uifile):
- self.log = logging.getLogger('UiBuilder')
+ if not self.log:
+ self.log = logging.getLogger('UiBuilder')
+
self.uifile = uifile
- def setup(self):
self.builder = Gtk.Builder()
self.builder.add_from_file(self.uifile)
- # Aquire the Main-Window from the UI-File
- self.win = self.get_check_widget('window')
-
- # Connect Close-Handler
- self.win.connect('delete-event', Gtk.main_quit)
-
- self.configure_video_previews()
- self.configure_audio_selector()
-
- def configure_video_previews(self):
- sources = ['cam1', 'cam2', 'grabber']
- box = self.get_check_widget('box_left')
-
- for source in sources:
- preview = self.get_check_widget('widget_preview', clone=True)
- #box.add(preview)
- box.pack_start(preview, fill=False, expand=False, padding=0)
-
- # http://stackoverflow.com/questions/3489520/python-gtk-widget-name
- preview.get_children()[0].get_children()[0].get_children()[1].get_children()[0].set_label(source)
-
- def configure_audio_selector(self):
- combo = self.get_check_widget('combo_audio')
- combo.set_sensitive(True)
-
- liststore = self.get_check_widget('liststore_audio')
- liststore.clear()
-
- row = liststore.append()
- liststore.set(row, [0], ['foobar'])
+ def find_widget_recursive(self, widget, name):
+ widget = self._find_widget_recursive(widget, name)
+ if not widget:
+ self.log.error('could find required widget "%s" by name (not ID!) inside the parent %s', name, str(widget))
+ raise Exception('Widget not found in parent')
- row = liststore.append('')
- liststore.set(row, [0], ['moofar'])
+ return widget
- combo.set_active_id('moofar')
+ def _find_widget_recursive(self, widget, name):
+ if widget.get_name() == name:
+ return widget
- def show(self):
- self.win.show_all()
+ if hasattr(widget, 'get_children'):
+ for child in widget.get_children():
+ widget = self._find_widget_recursive(child, name)
+ if widget:
+ return widget
- def find_widget_recursive(self, widget_id, clone=False):
- pass
+ return None
def get_check_widget(self, widget_id, clone=False):
if clone: