From fa41a4faa630f813097072e9fdf43cdceba177dc Mon Sep 17 00:00:00 2001 From: julian Date: Sat, 31 Mar 2018 15:35:50 +0200 Subject: [PATCH 1/2] add css styling and color indicators to source select buttons Signed-off-by: julian --- voctogui/ui/voctogui.css | 11 +++++++++++ voctogui/ui/voctogui.ui | 6 ++++++ voctogui/voctogui.py | 26 ++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 voctogui/ui/voctogui.css diff --git a/voctogui/ui/voctogui.css b/voctogui/ui/voctogui.css new file mode 100644 index 00000000..f1c59aa0 --- /dev/null +++ b/voctogui/ui/voctogui.css @@ -0,0 +1,11 @@ +.btn_grp_a:checked { + background-image: none; + background-color: blue; + color: white; +} + +.btn_grp_b:checked { + background-image: none; + background-color: red; + color: white; +} \ No newline at end of file diff --git a/voctogui/ui/voctogui.ui b/voctogui/ui/voctogui.ui index 480acc9c..71ddf830 100644 --- a/voctogui/ui/voctogui.ui +++ b/voctogui/ui/voctogui.ui @@ -332,6 +332,9 @@ True 5 False + False @@ -349,6 +352,9 @@ True 5 False + False diff --git a/voctogui/voctogui.py b/voctogui/voctogui.py index 429f4121..98d70c7e 100755 --- a/voctogui/voctogui.py +++ b/voctogui/voctogui.py @@ -68,6 +68,32 @@ def __init__(self): raise Exception("Can't find any .ui-Files to use " "(searched {})".format(', '.join(paths))) + css_provider = Gtk.CssProvider() + context = Gtk.StyleContext() + + css_paths = [ + os.path.join(os.path.dirname(os.path.realpath(__file__)), + 'ui/voctogui.css'), + '/usr/lib/voctogui/ui/voctogui.css' + ] + + for path in css_paths: + self.log.debug('trying to load css-file from file %s', path) + + if os.path.isfile(path): + self.log.info('loading css-file from file %s', path) + css_provider.load_from_path(path) + break + else: + raise Exception("Can't find any .css-Files to use " + "(searched {})".format(', '.join(css_paths))) + + context.add_provider_for_screen( + Gdk.Screen.get_default(), + css_provider, + Gtk.STYLE_PROVIDER_PRIORITY_USER + ) + self.ui.setup() def run(self): From dc3ebcdc38778aaeb71cc5b975ed63fa74d8a8b3 Mon Sep 17 00:00:00 2001 From: julian Date: Sat, 31 Mar 2018 16:23:58 +0200 Subject: [PATCH 2/2] voctogui.py: add source code comment before css file loading section Signed-off-by: julian --- voctogui/voctogui.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/voctogui/voctogui.py b/voctogui/voctogui.py index 98d70c7e..f20889a8 100755 --- a/voctogui/voctogui.py +++ b/voctogui/voctogui.py @@ -68,6 +68,10 @@ def __init__(self): raise Exception("Can't find any .ui-Files to use " "(searched {})".format(', '.join(paths))) + # + # search for a .css style sheet file and load it + # + css_provider = Gtk.CssProvider() context = Gtk.StyleContext()