[libadwaita/wip/exalm/background-colors: 3/3] stylesheet: Split base and defaults
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/background-colors: 3/3] stylesheet: Split base and defaults
- Date: Tue, 19 Oct 2021 21:38:29 +0000 (UTC)
commit 7df2bdeb051bd729e2e0422573b4a2da5b13ab7e
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Oct 19 14:29:26 2021 +0500
stylesheet: Split base and defaults
Now that everything has been cleaned up, we can split it into a base part
that varies with regular/HC but not colors; and the defaults part that
varies for light/dark but not HC, with the eventual goal of generating
defaults programmatically.
src/adw-style-manager.c | 35 +++++++++++++++-------
src/stylesheet/Adwaita-hc.scss | 10 -------
src/stylesheet/Adwaita-light.scss | 16 ----------
src/stylesheet/adwaita-stylesheet.gresources.xml | 8 ++---
.../{Adwaita-hc-dark.scss => base-hc.scss} | 2 --
src/stylesheet/{Adwaita-dark.scss => base.scss} | 2 --
src/stylesheet/defaults-dark.scss | 3 ++
src/stylesheet/defaults-light.scss | 3 ++
src/stylesheet/meson.build | 24 +++++++--------
9 files changed, 46 insertions(+), 57 deletions(-)
---
diff --git a/src/adw-style-manager.c b/src/adw-style-manager.c
index 49530b59..f9d79144 100644
--- a/src/adw-style-manager.c
+++ b/src/adw-style-manager.c
@@ -54,6 +54,7 @@ struct _AdwStyleManager
GdkDisplay *display;
AdwSettings *settings;
GtkCssProvider *provider;
+ GtkCssProvider *colors_provider;
AdwColorScheme color_scheme;
gboolean dark;
@@ -129,8 +130,6 @@ enable_animations_cb (AdwStyleManager *self)
static void
update_stylesheet (AdwStyleManager *self)
{
- const char *variant;
- g_autofree char *stylesheet_path = NULL;
GtkSettings *gtk_settings;
gboolean enable_animations;
@@ -139,13 +138,6 @@ update_stylesheet (AdwStyleManager *self)
gtk_settings = gtk_settings_get_for_display (self->display);
- if (adw_settings_get_high_contrast (self->settings))
- variant = self->dark ? "hc-dark" : "hc";
- else
- variant = self->dark ? "dark" : "light";
-
- stylesheet_path = g_strdup_printf ("/org/gnome/Adwaita/styles/Adwaita-%s.css", variant);
-
if (self->animation_timeout_id) {
g_clear_handle_id (&self->animation_timeout_id, g_source_remove);
enable_animations = TRUE;
@@ -159,8 +151,23 @@ update_stylesheet (AdwStyleManager *self)
"gtk-enable-animations", FALSE,
NULL);
- if (self->provider)
- gtk_css_provider_load_from_resource (self->provider, stylesheet_path);
+ if (self->provider) {
+ if (adw_settings_get_high_contrast (self->settings))
+ gtk_css_provider_load_from_resource (self->provider,
+ "/org/gnome/Adwaita/styles/base-hc.css");
+ else
+ gtk_css_provider_load_from_resource (self->provider,
+ "/org/gnome/Adwaita/styles/base.css");
+ }
+
+ if (self->colors_provider) {
+ if (self->dark)
+ gtk_css_provider_load_from_resource (self->colors_provider,
+ "/org/gnome/Adwaita/styles/defaults-dark.css");
+ else
+ gtk_css_provider_load_from_resource (self->colors_provider,
+ "/org/gnome/Adwaita/styles/defaults-light.css");
+ }
if (enable_animations) {
self->animation_timeout_id =
@@ -255,6 +262,11 @@ adw_style_manager_constructed (GObject *object)
gtk_style_context_add_provider_for_display (self->display,
GTK_STYLE_PROVIDER (self->provider),
GTK_STYLE_PROVIDER_PRIORITY_THEME);
+
+ self->colors_provider = gtk_css_provider_new ();
+ gtk_style_context_add_provider_for_display (self->display,
+ GTK_STYLE_PROVIDER (self->colors_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_THEME);
}
}
@@ -287,6 +299,7 @@ adw_style_manager_dispose (GObject *object)
g_clear_handle_id (&self->animation_timeout_id, g_source_remove);
g_clear_object (&self->provider);
+ g_clear_object (&self->colors_provider);
G_OBJECT_CLASS (adw_style_manager_parent_class)->dispose (object);
}
diff --git a/src/stylesheet/adwaita-stylesheet.gresources.xml
b/src/stylesheet/adwaita-stylesheet.gresources.xml
index 2ce9f66b..de729398 100644
--- a/src/stylesheet/adwaita-stylesheet.gresources.xml
+++ b/src/stylesheet/adwaita-stylesheet.gresources.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/Adwaita/styles">
- <file>Adwaita-light.css</file>
- <file>Adwaita-dark.css</file>
- <file>Adwaita-hc.css</file>
- <file>Adwaita-hc-dark.css</file>
+ <file>base.css</file>
+ <file>base-hc.css</file>
+ <file>defaults-light.css</file>
+ <file>defaults-dark.css</file>
<file>assets/bullet-symbolic.symbolic.png</file>
<file>assets/bullet 2-symbolic symbolic png</file>
diff --git a/src/stylesheet/Adwaita-hc-dark.scss b/src/stylesheet/base-hc.scss
similarity index 78%
rename from src/stylesheet/Adwaita-hc-dark.scss
rename to src/stylesheet/base-hc.scss
index c14fd2bd..278e5379 100644
--- a/src/stylesheet/Adwaita-hc-dark.scss
+++ b/src/stylesheet/base-hc.scss
@@ -1,8 +1,6 @@
-$variant: 'dark';
$contrast: 'high';
@import 'palette';
-@import 'defaults';
@import 'functions';
@import 'colors';
@import 'drawing';
diff --git a/src/stylesheet/Adwaita-dark.scss b/src/stylesheet/base.scss
similarity index 78%
rename from src/stylesheet/Adwaita-dark.scss
rename to src/stylesheet/base.scss
index 6881aee1..ffba5eac 100644
--- a/src/stylesheet/Adwaita-dark.scss
+++ b/src/stylesheet/base.scss
@@ -1,8 +1,6 @@
-$variant: 'dark';
$contrast: 'normal';
@import 'palette';
-@import 'defaults';
@import 'functions';
@import 'colors';
@import 'drawing';
diff --git a/src/stylesheet/defaults-dark.scss b/src/stylesheet/defaults-dark.scss
new file mode 100644
index 00000000..7c56516c
--- /dev/null
+++ b/src/stylesheet/defaults-dark.scss
@@ -0,0 +1,3 @@
+$variant: 'dark';
+
+@import 'defaults';
diff --git a/src/stylesheet/defaults-light.scss b/src/stylesheet/defaults-light.scss
new file mode 100644
index 00000000..97159a23
--- /dev/null
+++ b/src/stylesheet/defaults-light.scss
@@ -0,0 +1,3 @@
+$variant: 'light';
+
+@import 'defaults';
diff --git a/src/stylesheet/meson.build b/src/stylesheet/meson.build
index 188c1740..2c0fa82c 100644
--- a/src/stylesheet/meson.build
+++ b/src/stylesheet/meson.build
@@ -3,7 +3,7 @@ fs = import('fs')
stylesheet_deps = []
# For git checkouts, but not for tarballs...
-if not fs.exists('Adwaita-light.css')
+if not fs.exists('base.css')
sassc = find_program('sassc', required: false)
if not sassc.found()
subproject('sassc')
@@ -13,7 +13,7 @@ if not fs.exists('Adwaita-light.css')
if sassc.found()
sassc_opts = [ '-a', '-M', '-t', 'compact' ]
- scss_files = files([
+ scss_deps = files([
'_colors.scss',
'_common.scss',
'_compat-colors.scss',
@@ -65,21 +65,21 @@ if not fs.exists('Adwaita-light.css')
'widgets/_window.scss',
])
- theme_variants = [
- 'light',
- 'dark',
- 'hc',
- 'hc-dark',
+ scss_files = [
+ 'base',
+ 'base-hc',
+ 'defaults-light',
+ 'defaults-dark',
]
- foreach variant: theme_variants
- stylesheet_deps += custom_target('Stylesheet variant: ' + variant,
- input: 'Adwaita-@0@.scss'.format(variant),
- output: 'Adwaita-@0@.css'.format(variant),
+ foreach scss: scss_files
+ stylesheet_deps += custom_target('@0@.scss'.format(scss),
+ input: '@0@.scss'.format(scss),
+ output: '@0@.css'.format(scss),
command: [
sassc, sassc_opts, '@INPUT@', '@OUTPUT@',
],
- depend_files: scss_files,
+ depend_files: scss_deps,
)
endforeach
endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]