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
This commit is contained in:
parent
cd84fa824f
commit
f28f041a95
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user