diff options
author | Sergey V. Udaltsov <svu@gnome.org> | 2010-03-11 02:04:40 +0000 |
---|---|---|
committer | Sergey V. Udaltsov <svu@gnome.org> | 2010-03-11 02:04:40 +0000 |
commit | bede9856e63a79322a6301ca4d341f947f5c9b02 (patch) | |
tree | 844e407463b5c11e4d0f52ee0460aa6d9fd4683d /libgnomekbd/gkbd-indicator-config.c | |
parent | 771c2007f51fa5ed0607bbde23d7a5b062e6c5fc (diff) | |
download | libgnomekbd-bede9856e63a79322a6301ca4d341f947f5c9b02.tar.gz |
Using the font name from gtk, listening to theme changes
https://bugzilla.gnome.org/show_bug.cgi?id=612371
Diffstat (limited to 'libgnomekbd/gkbd-indicator-config.c')
-rw-r--r-- | libgnomekbd/gkbd-indicator-config.c | 86 |
1 files changed, 48 insertions, 38 deletions
diff --git a/libgnomekbd/gkbd-indicator-config.c b/libgnomekbd/gkbd-indicator-config.c index 89e6385..38acecc 100644 --- a/libgnomekbd/gkbd-indicator-config.c +++ b/libgnomekbd/gkbd-indicator-config.c @@ -38,6 +38,7 @@ * GkbdIndicatorConfig */ #define GKBD_INDICATOR_CONFIG_KEY_PREFIX GKBD_CONFIG_KEY_PREFIX "/indicator" +#define GTK_STYLE_PATH "*.GtkLabel" const gchar GKBD_INDICATOR_CONFIG_DIR[] = GKBD_INDICATOR_CONFIG_KEY_PREFIX; const gchar GKBD_INDICATOR_CONFIG_KEY_SHOW_FLAGS[] = @@ -79,8 +80,7 @@ gkbd_indicator_config_free_enabled_plugins (GkbdIndicatorConfig * } static void -gkbd_indicator_config_load_font_from_gconf (GkbdIndicatorConfig * - ind_config) +gkbd_indicator_config_load_font (GkbdIndicatorConfig * ind_config) { GError *gerror = NULL; @@ -111,18 +111,12 @@ gkbd_indicator_config_load_font_from_gconf (GkbdIndicatorConfig * if (ind_config->font_family == NULL || ind_config->font_family[0] == '\0') { PangoFontDescription *fd; - gchar *sysfontname = - gconf_client_get_string (ind_config->conf_client, - SYSTEM_FONT_GCONF_ENTRY, - &gerror); - if (gerror != NULL) { - g_warning ("Error reading configuration:%s\n", - gerror->message); - sysfontname = g_strdup ("Sans 10"); - g_error_free (gerror); - gerror = NULL; - } - fd = pango_font_description_from_string (sysfontname); + GtkStyle *style = + gtk_rc_get_style_by_paths (gtk_settings_get_default (), + GTK_STYLE_PATH, + GTK_STYLE_PATH, + GTK_TYPE_LABEL); + fd = style->font_desc; if (fd != NULL) { ind_config->font_family = g_strdup (pango_font_description_get_family @@ -130,13 +124,18 @@ gkbd_indicator_config_load_font_from_gconf (GkbdIndicatorConfig * ind_config->font_size = pango_font_description_get_size (fd) / PANGO_SCALE; - pango_font_description_free (fd); } - g_free (sysfontname); } xkl_debug (150, "font: [%s], size %d\n", ind_config->font_family, ind_config->font_size); +} + +static void +gkbd_indicator_config_load_colors (GkbdIndicatorConfig * ind_config) +{ + GError *gerror = NULL; + ind_config->foreground_color = gconf_client_get_string (ind_config->conf_client, GKBD_INDICATOR_CONFIG_KEY_FOREGROUND_COLOR, @@ -148,6 +147,26 @@ gkbd_indicator_config_load_font_from_gconf (GkbdIndicatorConfig * gerror = NULL; } + if (ind_config->foreground_color == NULL || + ind_config->foreground_color[0] == '\0') { + GtkStyle *style = + gtk_rc_get_style_by_paths (gtk_settings_get_default (), + GTK_STYLE_PATH, + GTK_STYLE_PATH, + GTK_TYPE_LABEL); + ind_config->foreground_color = + g_strdup_printf ("%lg %lg %lg", + ((double) style-> + fg[GTK_STATE_NORMAL].red) / 0x10000, + ((double) style-> + fg[GTK_STATE_NORMAL].green) / + 0x10000, + ((double) style-> + fg[GTK_STATE_NORMAL].blue) / + 0x10000); + + } + ind_config->background_color = gconf_client_get_string (ind_config->conf_client, GKBD_INDICATOR_CONFIG_KEY_BACKGROUND_COLOR, @@ -158,24 +177,16 @@ gkbd_indicator_config_load_font_from_gconf (GkbdIndicatorConfig * g_error_free (gerror); gerror = NULL; } +} - if (ind_config->foreground_color == NULL || - ind_config->foreground_color[0] == '\0') { - GtkSettings *settings = gtk_settings_get_default (); - GtkStyle *style = gtk_rc_get_style_by_paths (settings, - "*.GtkLabel", - "*.GtkLabel", - GTK_TYPE_LABEL); - ind_config->foreground_color = - g_strdup_printf ("%lg %lg %lg", - ((double) style->fg[GTK_STATE_NORMAL]. - red) / 0x10000, - ((double) style->fg[GTK_STATE_NORMAL]. - green) / 0x10000, - ((double) style->fg[GTK_STATE_NORMAL]. - blue) / 0x10000); - - } +void +gkbd_indicator_config_refresh_style (GkbdIndicatorConfig * ind_config) +{ + g_free (ind_config->font_family); + g_free (ind_config->foreground_color); + g_free (ind_config->background_color); + gkbd_indicator_config_load_font (ind_config); + gkbd_indicator_config_load_colors (ind_config); } char * @@ -352,7 +363,8 @@ gkbd_indicator_config_load_from_gconf (GkbdIndicatorConfig * ind_config) gerror = NULL; } - gkbd_indicator_config_load_font_from_gconf (ind_config); + gkbd_indicator_config_load_font (ind_config); + gkbd_indicator_config_load_colors (ind_config); gkbd_indicator_config_free_enabled_plugins (ind_config); ind_config->enabled_plugins = @@ -403,8 +415,7 @@ void gkbd_indicator_config_activate (GkbdIndicatorConfig * ind_config) { xkl_engine_set_secondary_groups_mask (ind_config->engine, - ind_config-> - secondary_groups_mask); + ind_config->secondary_groups_mask); } void @@ -423,6 +434,5 @@ void gkbd_indicator_config_stop_listen (GkbdIndicatorConfig * ind_config) { gkbd_desktop_config_remove_listener (ind_config->conf_client, - &ind_config-> - config_listener_id); + &ind_config->config_listener_id); } |