diff options
Diffstat (limited to 'voctogui/lib')
-rw-r--r-- | voctogui/lib/args.py | 20 | ||||
-rw-r--r-- | voctogui/lib/config.py | 24 | ||||
-rw-r--r-- | voctogui/lib/uibuilder.py | 27 |
3 files changed, 71 insertions, 0 deletions
diff --git a/voctogui/lib/args.py b/voctogui/lib/args.py new file mode 100644 index 0000000..3a9032f --- /dev/null +++ b/voctogui/lib/args.py @@ -0,0 +1,20 @@ +#!/usr/bin/python3 +import argparse + +__all__ = ['Args'] + +parser = argparse.ArgumentParser(description='Voctogui') +parser.add_argument('-v', '--verbose', action='count', + help="Also print INFO and DEBUG messages.") + +parser.add_argument('-c', '--color', action='store', choices=['auto', 'always', 'never'], default='auto', + help="Control the use of colors in the Log-Output") + +parser.add_argument('-i', '--ini-file', action='store', + help="Load a custom config.ini-File") + +parser.add_argument('-u', '--ui-file', action='store', + help="Load a custom .ui-File") + + +Args = parser.parse_args() diff --git a/voctogui/lib/config.py b/voctogui/lib/config.py new file mode 100644 index 0000000..b06075c --- /dev/null +++ b/voctogui/lib/config.py @@ -0,0 +1,24 @@ +#!/usr/bin/python3 +import os.path +from configparser import SafeConfigParser +from lib.args import Args + +__all__ = ['Config'] + +def getlist(self, section, option): + return [x.strip() for x in self.get(section, option).split(',')] + +SafeConfigParser.getlist = getlist + +files = [ + os.path.join(os.path.dirname(os.path.realpath(__file__)), '../default-config.ini'), + os.path.join(os.path.dirname(os.path.realpath(__file__)), '../config.ini'), + '/etc/voctogui.ini', + os.path.expanduser('~/.voctogui.ini'), +] + +if Args.ini_file is not None: + files.append(Args.ini_file) + +Config = SafeConfigParser() +Config.read(files) diff --git a/voctogui/lib/uibuilder.py b/voctogui/lib/uibuilder.py new file mode 100644 index 0000000..8d8b245 --- /dev/null +++ b/voctogui/lib/uibuilder.py @@ -0,0 +1,27 @@ +#!/usr/bin/python3 +import gi, logging +from gi.repository import Gtk, Gst + +class UiBuilder(Gtk.Builder): + def __init__(self): + self.log = logging.getLogger('UiBuilder') + super().__init__() + + def setup(self): + # Aquire the Main-Window from the UI-File + self.log.debug('Loading Main-Window "window" from .ui-File') + self.win = self.get_check_widget("window") + + # Connect Close-Handler + self.win.connect("delete-event", Gtk.main_quit) + + def show(self): + self.win.show_all() + + def get_check_widget(self, widget_id): + widget = self.get_object(widget_id) + if not widget: + self.log.error('could not load required widget "%s" from the .ui-File', widget_id) + raise Exception('Widget not found in .ui-File') + + return widget |