[gnome-shell] theme-context: Use interface font instead of hardcoded default
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] theme-context: Use interface font instead of hardcoded default
- Date: Fri, 8 Nov 2019 23:55:44 +0000 (UTC)
commit f28f041a95dca2709ee43bdaa4762487588e3246
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Apr 8 17:50:08 2019 +0200
theme-context: Use interface font instead of hardcoded default
With this, gnome-shell will now follow the interface setting instead
of hardcoding a default font, unless when overwritten by the CSS.
https://bugzilla.gnome.org/show_bug.cgi?id=688288
src/st/st-theme-context.c | 37 ++++++++++++++++++++++++++++++++++---
1 file changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/src/st/st-theme-context.c b/src/st/st-theme-context.c
index 7b1b03a45b..de112aa499 100644
--- a/src/st/st-theme-context.c
+++ b/src/st/st-theme-context.c
@@ -22,6 +22,7 @@
#include <config.h>
#include "st-private.h"
+#include "st-settings.h"
#include "st-texture-cache.h"
#include "st-theme.h"
#include "st-theme-context.h"
@@ -42,8 +43,6 @@ struct _StThemeContext {
int scale_factor;
};
-#define DEFAULT_FONT "sans-serif 10"
-
enum
{
PROP_0,
@@ -61,6 +60,10 @@ static guint signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (StThemeContext, st_theme_context, G_TYPE_OBJECT)
+static PangoFontDescription *get_interface_font_description (void);
+static void on_font_name_changed (StSettings *settings,
+ GParamSpec *pspec,
+ StThemeContext *context);
static void on_icon_theme_changed (StTextureCache *cache,
StThemeContext *context);
static void st_theme_context_changed (StThemeContext *context);
@@ -79,6 +82,9 @@ st_theme_context_finalize (GObject *object)
{
StThemeContext *context = ST_THEME_CONTEXT (object);
+ g_signal_handlers_disconnect_by_func (st_settings_get (),
+ (gpointer) on_font_name_changed,
+ context);
g_signal_handlers_disconnect_by_func (st_texture_cache_get_default (),
(gpointer) on_icon_theme_changed,
context);
@@ -134,8 +140,12 @@ st_theme_context_class_init (StThemeContextClass *klass)
static void
st_theme_context_init (StThemeContext *context)
{
- context->font = pango_font_description_from_string (DEFAULT_FONT);
+ context->font = get_interface_font_description ();
+ g_signal_connect (st_settings_get (),
+ "notify::font-name",
+ G_CALLBACK (on_font_name_changed),
+ context);
g_signal_connect (st_texture_cache_get_default (),
"icon-theme-changed",
G_CALLBACK (on_icon_theme_changed),
@@ -215,6 +225,16 @@ st_theme_context_new (void)
return context;
}
+static PangoFontDescription *
+get_interface_font_description (void)
+{
+ StSettings *settings = st_settings_get ();
+ g_autofree char *font_name = NULL;
+
+ g_object_get (settings, "font-name", &font_name, NULL);
+ return pango_font_description_from_string (font_name);
+}
+
static void
on_stage_destroy (ClutterStage *stage)
{
@@ -237,6 +257,17 @@ st_theme_context_changed (StThemeContext *context)
g_object_unref (old_root);
}
+static void
+on_font_name_changed (StSettings *settings,
+ GParamSpec *pspect,
+ StThemeContext *context)
+{
+ PangoFontDescription *font_desc = get_interface_font_description ();
+ st_theme_context_set_font (context, font_desc);
+
+ pango_font_description_free (font_desc);
+}
+
static gboolean
changed_idle (gpointer userdata)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]