st/settings: Expose system color scheme

This is the same interface setting that backs AdwStyleManager.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5545

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2324>
This commit is contained in:
Florian Müllner 2022-06-03 17:19:59 +02:00
parent 170ddda919
commit 4c727b4680
3 changed files with 35 additions and 1 deletions

View File

@ -183,7 +183,7 @@ st_cflags = [
libst = shared_library('st-' + mutter_api_version,
sources: st_gir_sources + st_nogir_sources + croco_sources,
c_args: st_cflags,
dependencies: [clutter_dep, mutter_dep, libxml_dep, gdk_pixbuf_dep, m_dep],
dependencies: [clutter_dep, mutter_dep, libxml_dep, gdk_pixbuf_dep, m_dep, schemas_dep],
build_rpath: mutter_typelibdir,
install_rpath: mutter_typelibdir,
install_dir: pkglibdir,

View File

@ -26,11 +26,13 @@
#include "st-private.h"
#include "st-settings.h"
#include "st-enum-types.h"
#define KEY_ENABLE_ANIMATIONS "enable-animations"
#define KEY_PRIMARY_PASTE "gtk-enable-primary-paste"
#define KEY_DRAG_THRESHOLD "drag-threshold"
#define KEY_FONT_NAME "font-name"
#define KEY_COLOR_SCHEME "color-scheme"
#define KEY_HIGH_CONTRAST "high-contrast"
#define KEY_GTK_ICON_THEME "icon-theme"
#define KEY_MAGNIFIER_ACTIVE "screen-magnifier-enabled"
@ -42,6 +44,7 @@ enum {
PROP_PRIMARY_PASTE,
PROP_DRAG_THRESHOLD,
PROP_FONT_NAME,
PROP_COLOR_SCHEME,
PROP_HIGH_CONTRAST,
PROP_GTK_ICON_THEME,
PROP_MAGNIFIER_ACTIVE,
@ -71,6 +74,7 @@ struct _StSettings
gboolean disable_show_password;
gint drag_threshold;
double slow_down_factor;
StSystemColorScheme color_scheme;
};
G_DEFINE_TYPE (StSettings, st_settings, G_TYPE_OBJECT)
@ -185,6 +189,9 @@ st_settings_get_property (GObject *object,
case PROP_GTK_ICON_THEME:
g_value_set_string (value, settings->gtk_icon_theme);
break;
case PROP_COLOR_SCHEME:
g_value_set_enum (value, settings->color_scheme);
break;
case PROP_MAGNIFIER_ACTIVE:
g_value_set_boolean (value, settings->magnifier_active);
break;
@ -275,6 +282,18 @@ st_settings_class_init (StSettingsClass *klass)
"",
ST_PARAM_READABLE);
/**
* StSettings:color-scheme:
*
* The preferred color-scheme
*/
props[PROP_COLOR_SCHEME] = g_param_spec_enum ("color-scheme",
"Color scheme",
"Color scheme",
ST_TYPE_SYSTEM_COLOR_SCHEME,
ST_SYSTEM_COLOR_SCHEME_DEFAULT,
ST_PARAM_READABLE);
/**
* StSettings:magnifier-active:
*
@ -339,6 +358,12 @@ on_interface_settings_changed (GSettings *g_settings,
g_object_notify_by_pspec (G_OBJECT (settings),
props[PROP_GTK_ICON_THEME]);
}
else if (g_str_equal (key, KEY_COLOR_SCHEME))
{
settings->color_scheme = g_settings_get_enum (g_settings, key);
g_object_notify_by_pspec (G_OBJECT (settings),
props[PROP_COLOR_SCHEME]);
}
}
static void
@ -422,6 +447,8 @@ st_settings_init (StSettings *settings)
KEY_FONT_NAME);
settings->gtk_icon_theme = g_settings_get_string (settings->interface_settings,
KEY_GTK_ICON_THEME);
settings->color_scheme = g_settings_get_enum (settings->interface_settings,
KEY_COLOR_SCHEME);
settings->drag_threshold = g_settings_get_int (settings->mouse_settings,
KEY_DRAG_THRESHOLD);
settings->magnifier_active = g_settings_get_boolean (settings->a11y_applications_settings,

View File

@ -25,9 +25,16 @@
#define __ST_SETTINGS_H__
#include <glib-object.h>
#include <gdesktop-enums.h>
G_BEGIN_DECLS
typedef enum {
ST_SYSTEM_COLOR_SCHEME_DEFAULT = G_DESKTOP_COLOR_SCHEME_DEFAULT,
ST_SYSTEM_COLOR_SCHEME_PREFER_DARK = G_DESKTOP_COLOR_SCHEME_PREFER_DARK,
ST_SYSTEM_COLOR_SCHEME_PREFER_LIGHT = G_DESKTOP_COLOR_SCHEME_PREFER_LIGHT,
} StSystemColorScheme;
#define ST_TYPE_SETTINGS (st_settings_get_type ())
G_DECLARE_FINAL_TYPE (StSettings, st_settings, ST, SETTINGS, GObject)