[gnome-text-editor/wip/exalm/dark] Use the libadwaita color scheme API
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor/wip/exalm/dark] Use the libadwaita color scheme API
- Date: Tue, 28 Sep 2021 22:04:59 +0000 (UTC)
commit db19378c41e61906e41053f4032f5a0a5625886e
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Sep 29 02:59:46 2021 +0500
Use the libadwaita color scheme API
Replace gtk-application-prefer-dark-theme uses with that. This doesn't do
anything for supporting the future dark preference yet, just keeps the app
working.
src/editor-application.c | 20 ++++++++++++--------
src/editor-theme-selector.c | 6 ++----
2 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/src/editor-application.c b/src/editor-application.c
index 4255fda..eb93afc 100644
--- a/src/editor-application.c
+++ b/src/editor-application.c
@@ -129,11 +129,15 @@ editor_application_open (GApplication *application,
}
static gboolean
-style_variant_to_boolean (GValue *value,
- GVariant *variant,
- gpointer user_data)
+style_variant_to_color_scheme (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
{
- g_value_set_boolean (value, g_strcmp0 (g_variant_get_string (variant, NULL), "dark") == 0);
+ if (g_strcmp0 (g_variant_get_string (variant, NULL), "dark") == 0)
+ g_value_set_enum (value, ADW_COLOR_SCHEME_FORCE_DARK);
+ else
+ g_value_set_enum (value, ADW_COLOR_SCHEME_FORCE_LIGHT);
+
return TRUE;
}
@@ -142,7 +146,7 @@ editor_application_startup (GApplication *application)
{
EditorApplication *self = (EditorApplication *)application;
g_autoptr(GtkCssProvider) css_provider = NULL;
- GtkSettings *gtk_settings;
+ AdwStyleManager *style_manager;
static const gchar *quit_accels[] = { "<Primary>Q", NULL };
static const gchar *help_accels[] = { "F1", NULL };
@@ -159,15 +163,15 @@ editor_application_startup (GApplication *application)
_editor_application_actions_init (self);
- gtk_settings = gtk_settings_get_default ();
+ style_manager = adw_style_manager_get_default ();
g_settings_bind (self->settings, "auto-save-delay",
self->session, "auto-save-delay",
G_SETTINGS_BIND_GET);
g_settings_bind_with_mapping (self->settings, "style-variant",
- gtk_settings, "gtk-application-prefer-dark-theme",
+ style_manager, "color-scheme",
G_SETTINGS_BIND_GET,
- style_variant_to_boolean,
+ style_variant_to_color_scheme,
NULL, NULL, NULL);
/* Setup CSS overrides */
diff --git a/src/editor-theme-selector.c b/src/editor-theme-selector.c
index ac70fdf..db3f93d 100644
--- a/src/editor-theme-selector.c
+++ b/src/editor-theme-selector.c
@@ -23,6 +23,7 @@
#include "config.h"
#include "editor-theme-selector-private.h"
+#include <adwaita.h>
struct _EditorThemeSelector
{
@@ -128,13 +129,10 @@ editor_theme_selector_class_init (EditorThemeSelectorClass *klass)
static void
editor_theme_selector_init (EditorThemeSelector *self)
{
- gboolean dark = FALSE;
+ gboolean dark = adw_style_manager_get_dark (adw_style_manager_get_default ());
gtk_widget_init_template (GTK_WIDGET (self));
- g_object_get (gtk_settings_get_default (),
- "gtk-application-prefer-dark-theme", &dark,
- NULL);
self->theme = g_strdup (dark ? "dark" : "light");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]