[libgnomekbd] Use default font name/size
- From: Sergey V. Udaltsov <svu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgnomekbd] Use default font name/size
- Date: Sat, 6 Mar 2010 15:25:26 +0000 (UTC)
commit 880b8ecf6625ae22350ccaed05328fc9665eff3f
Author: Sergey V. Udaltsov <svu gnome org>
Date: Sat Mar 6 15:23:16 2010 +0000
Use default font name/size
Part of https://bugzilla.gnome.org/show_bug.cgi?id=611875,
the colors should be fixed as well
...sktop_gnome_peripherals_keyboard_xkb.schemas.in | 4 +-
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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]