From b4c086c04989e8c6f55a4421dfab4b3fa335a494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Sun, 26 Dec 2021 21:09:20 +0100 Subject: [PATCH] Add sample CSS styling. --- main.py | 11 ++++++++++- style.css | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 style.css diff --git a/main.py b/main.py index 8a7fdb1..f908d2d 100644 --- a/main.py +++ b/main.py @@ -9,6 +9,9 @@ import task_manager APP_TITLE = "Org-mob" DOCS_PATH = os.environ["ORG_PATH"] +STYLE_FILE_PATH = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "style.css") import gi @@ -16,7 +19,7 @@ gi.require_version("Gtk", "4.0") gi.require_version('Polkit', '1.0') gi.require_version(namespace='Adw', version='1') -from gi.repository import Gtk, Polkit, GObject, Gio, Adw +from gi.repository import Gtk, Polkit, GObject, Gio, Adw, Gdk class MainWindow(Gtk.Window): @@ -67,11 +70,17 @@ class Application(Gtk.Application): def do_activate(self): win = self.props.active_window if not win: + if os.path.exists(STYLE_FILE_PATH): + style_provider = Gtk.CssProvider() + Gtk.StyleContext.add_provider_for_display(Gdk.Display.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + style_provider.load_from_path(STYLE_FILE_PATH) + win = MainWindow( title=APP_TITLE, application=self, task_manager=self.task_manager, ) + win.present() diff --git a/style.css b/style.css new file mode 100644 index 0000000..c1f7a5d --- /dev/null +++ b/style.css @@ -0,0 +1,10 @@ +label { + padding-top: 20px; + background-color: red; + /* font: Vera 20px; */ +} + +entry { + color: #0f0; +} +