diff options
author | Sergey V. Udaltsov <svu@gnome.org> | 2010-03-06 15:23:16 +0000 |
---|---|---|
committer | Sergey V. Udaltsov <svu@gnome.org> | 2010-03-06 15:23:16 +0000 |
commit | 880b8ecf6625ae22350ccaed05328fc9665eff3f (patch) | |
tree | a8f89316a7611dabcf0235b1b6b3b4f08953cf7c | |
parent | c40c9d76510fcde18af032d8e6e53b164a4dee81 (diff) | |
download | libgnomekbd-880b8ecf6625ae22350ccaed05328fc9665eff3f.tar.gz |
Use default font name/size
Part of https://bugzilla.gnome.org/show_bug.cgi?id=611875,
the colors should be fixed as well
-rw-r--r-- | libgnomekbd/desktop_gnome_peripherals_keyboard_xkb.schemas.in | 4 | ||||
-rw-r--r-- | libgnomekbd/gkbd-indicator-config.c | 96 |
2 files changed, 70 insertions, 30 deletions
diff --git a/libgnomekbd/desktop_gnome_peripherals_keyboard_xkb.schemas.in b/libgnomekbd/desktop_gnome_peripherals_keyboard_xkb.schemas.in index f65ea46..c694877 100644 --- a/libgnomekbd/desktop_gnome_peripherals_keyboard_xkb.schemas.in +++ b/libgnomekbd/desktop_gnome_peripherals_keyboard_xkb.schemas.in @@ -216,7 +216,7 @@ <applyto>/desktop/gnome/peripherals/keyboard/indicator/fontFamily</applyto> <owner>gnome</owner> <type>string</type> - <default>Sans</default> + <default></default> <locale name="C"> <short>The font family</short> <long>The font family for the layout indicator</long> @@ -228,7 +228,7 @@ <applyto>/desktop/gnome/peripherals/keyboard/indicator/fontSize</applyto> <owner>gnome</owner> <type>int</type> - <default>10</default> + <default></default> <locale name="C"> <short>The font size</short> <long>The font size for the layout indicator</long> diff --git a/libgnomekbd/gkbd-indicator-config.c b/libgnomekbd/gkbd-indicator-config.c index bd302d8..b15d872 100644 --- a/libgnomekbd/gkbd-indicator-config.c +++ b/libgnomekbd/gkbd-indicator-config.c @@ -24,6 +24,8 @@ #include <stdlib.h> #include <X11/keysym.h> +#include <pango/pango.h> + #include <glib/gi18n.h> #include <gdk/gdkx.h> @@ -53,6 +55,8 @@ const gchar GKBD_INDICATOR_CONFIG_KEY_FOREGROUND_COLOR[] = const gchar GKBD_INDICATOR_CONFIG_KEY_BACKGROUND_COLOR[] = GKBD_INDICATOR_CONFIG_KEY_PREFIX "/backgroundColor"; +#define SYSTEM_FONT_GCONF_ENTRY "/desktop/gnome/interface/font_name" + /** * static applet config functions */ @@ -74,6 +78,65 @@ gkbd_indicator_config_free_enabled_plugins (GkbdIndicatorConfig * } } +static void +gkbd_indicator_config_load_font_from_gconf (GkbdIndicatorConfig * + ind_config) +{ + GError *gerror = NULL; + + ind_config->font_family = + gconf_client_get_string (ind_config->conf_client, + GKBD_INDICATOR_CONFIG_KEY_FONT_FAMILY, + &gerror); + if (gerror != NULL) { + g_warning ("Error reading configuration:%s\n", + gerror->message); + ind_config->font_family = g_strdup ("Helvetica"); + g_error_free (gerror); + gerror = NULL; + } + + ind_config->font_size = + gconf_client_get_int (ind_config->conf_client, + GKBD_INDICATOR_CONFIG_KEY_FONT_SIZE, + &gerror); + if (gerror != NULL) { + g_warning ("Error reading configuration:%s\n", + gerror->message); + ind_config->font_size = 10; + g_error_free (gerror); + gerror = NULL; + } + + 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); + if (fd != NULL) { + ind_config->font_family = + g_strdup (pango_font_description_get_family + (fd)); + 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); +} + char * gkbd_indicator_config_get_images_file (GkbdIndicatorConfig * ind_config, @@ -248,30 +311,7 @@ gkbd_indicator_config_load_from_gconf (GkbdIndicatorConfig * ind_config) gerror = NULL; } - - ind_config->font_family = - gconf_client_get_string (ind_config->conf_client, - GKBD_INDICATOR_CONFIG_KEY_FONT_FAMILY, - &gerror); - if (gerror != NULL) { - g_warning ("Error reading configuration:%s\n", - gerror->message); - ind_config->font_family = g_strdup ("Helvetica"); - g_error_free (gerror); - gerror = NULL; - } - - ind_config->font_size = - gconf_client_get_int (ind_config->conf_client, - GKBD_INDICATOR_CONFIG_KEY_FONT_SIZE, - &gerror); - if (gerror != NULL) { - g_warning ("Error reading configuration:%s\n", - gerror->message); - ind_config->font_size = 10; - g_error_free (gerror); - gerror = NULL; - } + gkbd_indicator_config_load_font_from_gconf (ind_config); ind_config->foreground_color = gconf_client_get_string (ind_config->conf_client, @@ -295,8 +335,6 @@ gkbd_indicator_config_load_from_gconf (GkbdIndicatorConfig * ind_config) gerror = NULL; } - - gkbd_indicator_config_free_enabled_plugins (ind_config); ind_config->enabled_plugins = gconf_client_get_list (ind_config->conf_client, @@ -346,7 +384,8 @@ 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 @@ -365,5 +404,6 @@ 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); } |