[gnome-todo] css-provider: Adjust to AdwStyleManager
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] css-provider: Adjust to AdwStyleManager
- Date: Fri, 8 Oct 2021 15:58:49 +0000 (UTC)
commit f7189ccf6c13f77ff4106323aaa57ae054092450
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Oct 8 12:55:46 2021 -0300
css-provider: Adjust to AdwStyleManager
src/gui/gtd-css-provider.c | 53 +++++++++++++---------------------------------
1 file changed, 15 insertions(+), 38 deletions(-)
---
diff --git a/src/gui/gtd-css-provider.c b/src/gui/gtd-css-provider.c
index 8a358bd0..e8524fa2 100644
--- a/src/gui/gtd-css-provider.c
+++ b/src/gui/gtd-css-provider.c
@@ -22,6 +22,8 @@
#include "gtd-css-provider.h"
+#include <adwaita.h>
+
struct _GtdCssProvider
{
GObject parent_instance;
@@ -83,10 +85,8 @@ update_css_provider (GtdCssProvider *self)
{
g_autofree gchar *theme_name = NULL;
g_autofree gchar *resource_path = NULL;
- GtkSettings *settings;
- gboolean prefer_dark_theme = FALSE;
+ gboolean dark_theme = FALSE;
- settings = gtk_settings_get_default ();
theme_name = g_strdup (g_getenv ("GTK_THEME"));
if (theme_name != NULL)
@@ -99,21 +99,19 @@ update_css_provider (GtdCssProvider *self)
{
*p = '\0';
p++;
- prefer_dark_theme = g_strcmp0 (p, "dark") == 0;
+ dark_theme = g_strcmp0 (p, "dark") == 0;
}
}
else
{
- g_object_get (settings,
- "gtk-theme-name", &theme_name,
- "gtk-application-prefer-dark-theme", &prefer_dark_theme,
- NULL);
+ theme_name = g_strdup ("Adwaita");
+ dark_theme = adw_style_manager_get_dark (adw_style_manager_get_default ());
}
/* First check with full path to theme+variant */
resource_path = g_strdup_printf ("%s/%s%s.css",
self->base_path,
- theme_name, prefer_dark_theme ? "-dark" : "");
+ theme_name, dark_theme ? "-dark" : "");
if (!resource_exists (resource_path))
{
@@ -151,53 +149,32 @@ do_update_cb (gpointer user_data)
}
static void
-dzl_css_provider_queue_update (GtdCssProvider *self)
+on_style_manager_color_scheme_changed_cb (GtdCssProvider *self,
+ GParamSpec *pspec,
+ AdwStyleManager *style_manager)
{
if (self->queued_update > 0)
return;
-
self->queued_update = g_idle_add_full (G_PRIORITY_LOW,
do_update_cb,
g_object_ref (self),
g_object_unref);
}
-static void
-on_settings_notify_gtk_theme_name_cb (GtdCssProvider *self,
- GParamSpec *pspec,
- GtkSettings *settings)
-{
- dzl_css_provider_queue_update (self);
-}
-
-static void
-on_settings_notify_gtk_application_prefer_dark_theme_cb (GtdCssProvider *self,
- GParamSpec *pspec,
- GtkSettings *settings)
-{
- dzl_css_provider_queue_update (self);
-}
-
static void
gtd_css_provider_constructed (GObject *object)
{
GtdCssProvider *self = (GtdCssProvider *)object;
- GtkSettings *settings;
+ AdwStyleManager *style_manager;
G_OBJECT_CLASS (gtd_css_provider_parent_class)->constructed (object);
- settings = gtk_settings_get_default ();
-
- g_signal_connect_object (settings,
- "notify::gtk-theme-name",
- G_CALLBACK (on_settings_notify_gtk_theme_name_cb),
- self,
- G_CONNECT_SWAPPED);
+ style_manager = adw_style_manager_get_default ();
- g_signal_connect_object (settings,
- "notify::gtk-application-prefer-dark-theme",
- G_CALLBACK (on_settings_notify_gtk_application_prefer_dark_theme_cb),
+ g_signal_connect_object (style_manager,
+ "notify::color-scheme",
+ G_CALLBACK (on_style_manager_color_scheme_changed_cb),
self,
G_CONNECT_SWAPPED);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]