mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
st/theme-context: Expose accent color
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2715>
This commit is contained in:
parent
ec9217bc0d
commit
1ce6193f4e
2 changed files with 115 additions and 9 deletions
|
|
@ -28,10 +28,25 @@
|
|||
#include "st-theme-context.h"
|
||||
#include "st-theme-node-private.h"
|
||||
|
||||
#define ACCENT_COLOR_BLUE "#3584e4"
|
||||
#define ACCENT_COLOR_TEAL "#2190a4"
|
||||
#define ACCENT_COLOR_GREEN "#3a944a"
|
||||
#define ACCENT_COLOR_YELLOW "#c88800"
|
||||
#define ACCENT_COLOR_ORANGE "#ed5b00"
|
||||
#define ACCENT_COLOR_RED "#e62d42"
|
||||
#define ACCENT_COLOR_PINK "#d56199"
|
||||
#define ACCENT_COLOR_PURPLE "#9141ac"
|
||||
#define ACCENT_COLOR_SLATE "#6f8396"
|
||||
|
||||
#define ACCENT_FG_COLOR "#ffffff"
|
||||
|
||||
struct _StThemeContext {
|
||||
GObject parent;
|
||||
|
||||
PangoFontDescription *font;
|
||||
CoglColor accent_color;
|
||||
CoglColor accent_fg_color;
|
||||
|
||||
StThemeNode *root_node;
|
||||
StTheme *theme;
|
||||
|
||||
|
|
@ -68,6 +83,7 @@ static PangoFontDescription *get_interface_font_description (void);
|
|||
static void on_font_name_changed (StSettings *settings,
|
||||
GParamSpec *pspec,
|
||||
StThemeContext *context);
|
||||
static void update_accent_colors (StThemeContext *context);
|
||||
static void on_icon_theme_changed (StTextureCache *cache,
|
||||
StThemeContext *context);
|
||||
static void st_theme_context_changed (StThemeContext *context);
|
||||
|
|
@ -102,6 +118,9 @@ st_theme_context_finalize (GObject *object)
|
|||
g_signal_handlers_disconnect_by_func (st_settings_get (),
|
||||
(gpointer) on_font_name_changed,
|
||||
context);
|
||||
g_signal_handlers_disconnect_by_func (st_settings_get (),
|
||||
(gpointer) update_accent_colors,
|
||||
context);
|
||||
g_signal_handlers_disconnect_by_func (st_texture_cache_get_default (),
|
||||
(gpointer) on_icon_theme_changed,
|
||||
context);
|
||||
|
|
@ -171,6 +190,10 @@ st_theme_context_init (StThemeContext *context)
|
|||
"notify::font-name",
|
||||
G_CALLBACK (on_font_name_changed),
|
||||
context);
|
||||
g_signal_connect_swapped (st_settings_get (),
|
||||
"notify::accent-color",
|
||||
G_CALLBACK (update_accent_colors),
|
||||
context);
|
||||
g_signal_connect (st_texture_cache_get_default (),
|
||||
"icon-theme-changed",
|
||||
G_CALLBACK (on_icon_theme_changed),
|
||||
|
|
@ -184,6 +207,8 @@ st_theme_context_init (StThemeContext *context)
|
|||
(GEqualFunc) st_theme_node_equal,
|
||||
g_object_unref, NULL);
|
||||
context->scale_factor = 1;
|
||||
|
||||
update_accent_colors (context);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -254,6 +279,61 @@ get_interface_font_description (void)
|
|||
return pango_font_description_from_string (font_name);
|
||||
}
|
||||
|
||||
static void
|
||||
update_accent_colors (StThemeContext *context)
|
||||
{
|
||||
StSettings *settings = st_settings_get ();
|
||||
StSystemAccentColor accent_color;
|
||||
|
||||
g_object_get (settings, "accent-color", &accent_color, NULL);
|
||||
|
||||
switch (accent_color)
|
||||
{
|
||||
case ST_SYSTEM_ACCENT_COLOR_BLUE:
|
||||
cogl_color_from_string (&context->accent_color, ACCENT_COLOR_BLUE);
|
||||
break;
|
||||
|
||||
case ST_SYSTEM_ACCENT_COLOR_TEAL:
|
||||
cogl_color_from_string (&context->accent_color, ACCENT_COLOR_TEAL);
|
||||
break;
|
||||
|
||||
case ST_SYSTEM_ACCENT_COLOR_GREEN:
|
||||
cogl_color_from_string (&context->accent_color, ACCENT_COLOR_GREEN);
|
||||
break;
|
||||
|
||||
case ST_SYSTEM_ACCENT_COLOR_YELLOW:
|
||||
cogl_color_from_string (&context->accent_color, ACCENT_COLOR_YELLOW);
|
||||
break;
|
||||
|
||||
case ST_SYSTEM_ACCENT_COLOR_ORANGE:
|
||||
cogl_color_from_string (&context->accent_color, ACCENT_COLOR_ORANGE);
|
||||
break;
|
||||
|
||||
case ST_SYSTEM_ACCENT_COLOR_RED:
|
||||
cogl_color_from_string (&context->accent_color, ACCENT_COLOR_RED);
|
||||
break;
|
||||
|
||||
case ST_SYSTEM_ACCENT_COLOR_PINK:
|
||||
cogl_color_from_string (&context->accent_color, ACCENT_COLOR_PINK);
|
||||
break;
|
||||
|
||||
case ST_SYSTEM_ACCENT_COLOR_PURPLE:
|
||||
cogl_color_from_string (&context->accent_color, ACCENT_COLOR_PURPLE);
|
||||
break;
|
||||
|
||||
case ST_SYSTEM_ACCENT_COLOR_SLATE:
|
||||
cogl_color_from_string (&context->accent_color, ACCENT_COLOR_SLATE);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
cogl_color_from_string (&context->accent_fg_color, ACCENT_FG_COLOR);
|
||||
|
||||
st_theme_context_changed (context);
|
||||
}
|
||||
|
||||
static void
|
||||
on_stage_destroy (ClutterStage *stage)
|
||||
{
|
||||
|
|
@ -431,6 +511,28 @@ st_theme_context_get_font (StThemeContext *context)
|
|||
return context->font;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_theme_context_get_accent_color:
|
||||
* @context: a #StThemeContext
|
||||
* @color: (out) (nullable): the accent color
|
||||
* @fg_color: (out) (nullable): the foreground accent color
|
||||
*
|
||||
* Gets the current accent color for the theme context.
|
||||
*/
|
||||
void
|
||||
st_theme_context_get_accent_color (StThemeContext *context,
|
||||
CoglColor *color,
|
||||
CoglColor *fg_color)
|
||||
{
|
||||
g_return_if_fail (ST_IS_THEME_CONTEXT (context));
|
||||
|
||||
if (color)
|
||||
memcpy (color, &context->accent_color, sizeof (CoglColor));
|
||||
|
||||
if (fg_color)
|
||||
memcpy (fg_color, &context->accent_fg_color, sizeof (CoglColor));
|
||||
}
|
||||
|
||||
/**
|
||||
* st_theme_context_get_root_node:
|
||||
* @context: a #StThemeContext
|
||||
|
|
|
|||
|
|
@ -45,18 +45,22 @@ G_DECLARE_FINAL_TYPE (StThemeContext, st_theme_context,
|
|||
StThemeContext *st_theme_context_new (void);
|
||||
StThemeContext *st_theme_context_get_for_stage (ClutterStage *stage);
|
||||
|
||||
void st_theme_context_set_theme (StThemeContext *context,
|
||||
StTheme *theme);
|
||||
StTheme * st_theme_context_get_theme (StThemeContext *context);
|
||||
void st_theme_context_set_theme (StThemeContext *context,
|
||||
StTheme *theme);
|
||||
StTheme * st_theme_context_get_theme (StThemeContext *context);
|
||||
|
||||
void st_theme_context_set_font (StThemeContext *context,
|
||||
const PangoFontDescription *font);
|
||||
const PangoFontDescription *st_theme_context_get_font (StThemeContext *context);
|
||||
void st_theme_context_set_font (StThemeContext *context,
|
||||
const PangoFontDescription *font);
|
||||
const PangoFontDescription *st_theme_context_get_font (StThemeContext *context);
|
||||
|
||||
StThemeNode * st_theme_context_get_root_node (StThemeContext *context);
|
||||
void st_theme_context_get_accent_color (StThemeContext *context,
|
||||
CoglColor *color,
|
||||
CoglColor *fg_color);
|
||||
|
||||
StThemeNode * st_theme_context_intern_node (StThemeContext *context,
|
||||
StThemeNode *node);
|
||||
StThemeNode * st_theme_context_get_root_node (StThemeContext *context);
|
||||
|
||||
StThemeNode * st_theme_context_intern_node (StThemeContext *context,
|
||||
StThemeNode *node);
|
||||
|
||||
int st_theme_context_get_scale_factor (StThemeContext *context);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue