From 036e666c9b353a894e78f3c1efb9d358cd0cc0c6 Mon Sep 17 00:00:00 2001 From: DYefremov Date: Mon, 13 Apr 2020 20:07:57 +0300 Subject: [PATCH] styles decoupling --- app/ui/default_style.css | 78 +++++++++++++++++++++++++++++++++++++++ app/ui/style.css | 79 ---------------------------------------- app/ui/uicommons.py | 17 ++++++--- 3 files changed, 89 insertions(+), 85 deletions(-) create mode 100644 app/ui/default_style.css diff --git a/app/ui/default_style.css b/app/ui/default_style.css new file mode 100644 index 00000000..13634b7f --- /dev/null +++ b/app/ui/default_style.css @@ -0,0 +1,78 @@ +* { + -GtkDialog-action-area-border: 5; +} + +entry { + min-height: 24px; +} + +button { + min-height: 20px; + padding-top: 1px; + padding-bottom: 1px; +} + +button.image-button { + min-height: 24px; + padding-left: 2px; + padding-right: 2px; +} + +button.text-button.image-button { + min-height: 24px; + padding-left: 2px; + padding-right: 2px; +} + +spinbutton { + min-height: 20px; +} + +toolbutton { + padding: 2px; +} + +spinner { + padding-left: 10px; + padding-right: 10px; +} + +headerbar { + min-height: 34px; + padding-top: 1px; + padding-left: 5px; + padding-right: 5px; + padding-bottom: 1px; +} + +headerbar button { + min-height: 24px; + min-width: 24px; + padding-left: 2px; + padding-right: 2px; +} + +box button { + padding-left: 4px; + padding-right: 4px; +} + +infobar { + min-height: 24px; +} + +infobar button { + min-height: 16px; + min-width: 16px; + padding-left: 2px; + padding-right: 2px; +} + +switch { + border-radius: 50px; +} + +switch slider { + min-height: 18px; + min-width: 18px; +} diff --git a/app/ui/style.css b/app/ui/style.css index 7297cb33..fe517afd 100644 --- a/app/ui/style.css +++ b/app/ui/style.css @@ -10,82 +10,3 @@ #textview-large { font-size: 14px; } - -* { - -GtkDialog-action-area-border: 5; -} - -entry { - min-height: 24px; -} - -button { - min-height: 20px; - padding-top: 1px; - padding-bottom: 1px; -} - -button.image-button { - min-height: 24px; - padding-left: 2px; - padding-right: 2px; -} - -button.text-button.image-button { - min-height: 24px; - padding-left: 2px; - padding-right: 2px; -} - -spinbutton { - min-height: 20px; -} - -toolbutton { - padding: 2px; -} - -spinner { - padding-left: 10px; - padding-right: 10px; -} - -headerbar { - min-height: 34px; - padding-top: 1px; - padding-left: 5px; - padding-right: 5px; - padding-bottom: 1px; -} - -headerbar button { - min-height: 24px; - min-width: 24px; - padding-left: 2px; - padding-right: 2px; -} - -box button { - padding-left: 4px; - padding-right: 4px; -} - -infobar { - min-height: 24px; -} - -infobar button { - min-height: 16px; - min-width: 16px; - padding-left: 2px; - padding-right: 2px; -} - -switch { - border-radius: 50px; -} - -switch slider { - min-height: 18px; - min-width: 18px; -} diff --git a/app/ui/uicommons.py b/app/ui/uicommons.py index 9ca64e58..0a2cfd6b 100644 --- a/app/ui/uicommons.py +++ b/app/ui/uicommons.py @@ -1,7 +1,6 @@ import os import sys from enum import Enum, IntEnum -from app.settings import Settings, SettingsException from functools import lru_cache from app.settings import Settings, SettingsException @@ -29,6 +28,17 @@ except SettingsException: else: os.environ["LANGUAGE"] = settings.language + if settings.is_themes_support: + st = Gtk.Settings().get_default() + st.set_property("gtk-theme-name", settings.theme) + st.set_property("gtk-icon-theme-name", settings.icon_theme) + else: + style_provider = Gtk.CssProvider() + s_path = "{}default_style.css".format(GTK_PATH + "/" + UI_RESOURCES_PATH if GTK_PATH else UI_RESOURCES_PATH) + style_provider.load_from_path(s_path) + Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), style_provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + if IS_DARWIN: import gettext @@ -43,11 +53,6 @@ else: locale.bindtextdomain(TEXT_DOMAIN, LANG_PATH) - if settings.is_themes_support: - st = Gtk.Settings().get_default() - st.set_property("gtk-theme-name", settings.theme) - st.set_property("gtk-icon-theme-name", settings.icon_theme) - theme = Gtk.IconTheme.get_default() theme.append_search_path(GTK_PATH + "/share/icons" if GTK_PATH else UI_RESOURCES_PATH + "icons")