diff options
author | Sergey V. Udaltsov <svu@gnome.org> | 2009-12-21 01:09:12 +0000 |
---|---|---|
committer | Sergey V. Udaltsov <svu@gnome.org> | 2009-12-21 01:09:12 +0000 |
commit | 80e56c6dce5b34149b9df60033789db5dd2e63c8 (patch) | |
tree | 66e3d8a1d1abf5d7ddd9a9e45c7848b544dcd4a5 | |
parent | bec935f1fd73e62c64c35d533e14db3d1c0156ac (diff) | |
download | libgnomekbd-80e56c6dce5b34149b9df60033789db5dd2e63c8.tar.gz |
Making status icon configurable
Use gconf for font and colors
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | libgnomekbd/desktop_gnome_peripherals_keyboard_xkb.schemas.in | 48 | ||||
-rw-r--r-- | libgnomekbd/gkbd-indicator-config.c | 75 | ||||
-rw-r--r-- | libgnomekbd/gkbd-indicator-config.h | 5 | ||||
-rw-r--r-- | libgnomekbd/gkbd-status.c | 44 |
5 files changed, 161 insertions, 18 deletions
@@ -1,3 +1,10 @@ +2009-12-21 svu + + * libgnomekbd/desktop_gnome_peripherals_keyboard_xkb.schemas.in, + libgnomekbd/gkbd-indicator-config.c, + libgnomekbd/gkbd-indicator-config.h, libgnomekbd/gkbd-status.c: making + font and color of the status icon configurable in gconf + 2009-12-20 svu * libgnomekbd/gkbd-status.c: initial implementation of "labels" in diff --git a/libgnomekbd/desktop_gnome_peripherals_keyboard_xkb.schemas.in b/libgnomekbd/desktop_gnome_peripherals_keyboard_xkb.schemas.in index f4dc889..6825054 100644 --- a/libgnomekbd/desktop_gnome_peripherals_keyboard_xkb.schemas.in +++ b/libgnomekbd/desktop_gnome_peripherals_keyboard_xkb.schemas.in @@ -212,6 +212,54 @@ </schema> <schema> + <key>/schemas/desktop/gnome/peripherals/keyboard/indicator/fontFamily</key> + <applyto>/desktop/gnome/peripherals/keyboard/indicator/fontFamily</applyto> + <owner>gnome</owner> + <type>string</type> + <default>Helvetica</default> + <locale name="C"> + <short>The font family</short> + <long>The font family for the layout indicator</long> + </locale> + </schema> + + <schema> + <key>/schemas/desktop/gnome/peripherals/keyboard/indicator/fontSize</key> + <applyto>/desktop/gnome/peripherals/keyboard/indicator/fontSize</applyto> + <owner>gnome</owner> + <type>int</type> + <default>10</default> + <locale name="C"> + <short>The font size</short> + <long>The font size for the layout indicator</long> + </locale> + </schema> + + <schema> + <key>/schemas/desktop/gnome/peripherals/keyboard/indicator/foregroundColor</key> + <applyto>/desktop/gnome/peripherals/keyboard/indicator/foregroundColor</applyto> + <owner>gnome</owner> + <type>string</type> + <default></default> + <locale name="C"> + <short>The foreground color</short> + <long>The foreground color for the layout indicator</long> + </locale> + </schema> + + <schema> + <key>/schemas/desktop/gnome/peripherals/keyboard/indicator/backgroundColor</key> + <applyto>/desktop/gnome/peripherals/keyboard/indicator/backgroundColor</applyto> + <owner>gnome</owner> + <type>string</type> + <default></default> + <locale name="C"> + <short>The background color</short> + <long>The background color for the layout indicator</long> + </locale> + </schema> + + <schema> <key>/schemas/desktop/gnome/peripherals/keyboard/indicator/enabledPlugins</key> <applyto>/desktop/gnome/peripherals/keyboard/indicator/enabledPlugins</applyto> <owner>gnome</owner> diff --git a/libgnomekbd/gkbd-indicator-config.c b/libgnomekbd/gkbd-indicator-config.c index 45d1d8f..bd302d8 100644 --- a/libgnomekbd/gkbd-indicator-config.c +++ b/libgnomekbd/gkbd-indicator-config.c @@ -44,6 +44,14 @@ const gchar GKBD_INDICATOR_CONFIG_KEY_ENABLED_PLUGINS[] = GKBD_INDICATOR_CONFIG_KEY_PREFIX "/enabledPlugins"; const gchar GKBD_INDICATOR_CONFIG_KEY_SECONDARIES[] = GKBD_INDICATOR_CONFIG_KEY_PREFIX "/secondary"; +const gchar GKBD_INDICATOR_CONFIG_KEY_FONT_FAMILY[] = + GKBD_INDICATOR_CONFIG_KEY_PREFIX "/fontFamily"; +const gchar GKBD_INDICATOR_CONFIG_KEY_FONT_SIZE[] = + GKBD_INDICATOR_CONFIG_KEY_PREFIX "/fontSize"; +const gchar GKBD_INDICATOR_CONFIG_KEY_FOREGROUND_COLOR[] = + GKBD_INDICATOR_CONFIG_KEY_PREFIX "/foregroundColor"; +const gchar GKBD_INDICATOR_CONFIG_KEY_BACKGROUND_COLOR[] = + GKBD_INDICATOR_CONFIG_KEY_PREFIX "/backgroundColor"; /** * static applet config functions @@ -193,9 +201,15 @@ gkbd_indicator_config_init (GkbdIndicatorConfig * ind_config, void gkbd_indicator_config_term (GkbdIndicatorConfig * ind_config) { -#if 0 - g_object_unref (G_OBJECT (ind_config->icon_theme)); -#endif + g_free (ind_config->font_family); + ind_config->font_family = NULL; + + g_free (ind_config->foreground_color); + ind_config->foreground_color = NULL; + + g_free (ind_config->background_color); + ind_config->background_color = NULL; + ind_config->icon_theme = NULL; gkbd_indicator_config_free_image_filenames (ind_config); @@ -234,6 +248,55 @@ 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; + } + + ind_config->foreground_color = + gconf_client_get_string (ind_config->conf_client, + GKBD_INDICATOR_CONFIG_KEY_FOREGROUND_COLOR, + &gerror); + if (gerror != NULL) { + g_warning ("Error reading configuration:%s\n", + gerror->message); + g_error_free (gerror); + gerror = NULL; + } + + ind_config->background_color = + gconf_client_get_string (ind_config->conf_client, + GKBD_INDICATOR_CONFIG_KEY_BACKGROUND_COLOR, + &gerror); + if (gerror != NULL) { + g_warning ("Error reading configuration:%s\n", + gerror->message); + g_error_free (gerror); + gerror = NULL; + } + + + gkbd_indicator_config_free_enabled_plugins (ind_config); ind_config->enabled_plugins = gconf_client_get_list (ind_config->conf_client, @@ -283,8 +346,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 @@ -303,6 +365,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); } diff --git a/libgnomekbd/gkbd-indicator-config.h b/libgnomekbd/gkbd-indicator-config.h index 38173bf..9542d12 100644 --- a/libgnomekbd/gkbd-indicator-config.h +++ b/libgnomekbd/gkbd-indicator-config.h @@ -31,6 +31,11 @@ typedef struct _GkbdIndicatorConfig { int secondary_groups_mask; gboolean show_flags; + gchar * font_family; + int font_size; + gchar * foreground_color; + gchar * background_color; + GSList *enabled_plugins; /* private, transient */ diff --git a/libgnomekbd/gkbd-status.c b/libgnomekbd/gkbd-status.c index 0e95881..986ad0f 100644 --- a/libgnomekbd/gkbd-status.c +++ b/libgnomekbd/gkbd-status.c @@ -125,18 +125,40 @@ gkbd_status_render_cairo (cairo_t * cr, int group) { cairo_text_extents_t te; gchar *lbl = globals.short_group_names[group]; + double r, g, b; + + if (globals.ind_cfg.background_color != NULL && + globals.ind_cfg.background_color[0] != 0) { + if (sscanf + (globals.ind_cfg.background_color, "%lg %lg %lg", &r, + &g, &b) == 3) { + cairo_set_source_rgb (cr, r, g, b); + cairo_rectangle (cr, 0, 0, globals.current_size, + globals.current_size); + cairo_fill (cr); + } + } + + if (globals.ind_cfg.foreground_color != NULL && + globals.ind_cfg.foreground_color[0] != 0) { + if (sscanf + (globals.ind_cfg.foreground_color, "%lg %lg %lg", &r, + &g, &b) == 3) { + cairo_set_source_rgb (cr, r, g, b); + } + } + + if (globals.ind_cfg.font_family != NULL && + globals.ind_cfg.font_family[0] != 0) { + cairo_select_font_face (cr, globals.ind_cfg.font_family, + CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_NORMAL); + } + + if (globals.ind_cfg.font_size > 0) { + cairo_set_font_size (cr, globals.ind_cfg.font_size); + } - cairo_set_source_rgba (cr, 0, 1 - group, group, 1); - cairo_rectangle (cr, globals.current_size >> 2, - globals.current_size >> 2, - globals.current_size >> 1, - globals.current_size >> 1); - cairo_fill (cr); - - cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); -/*cairo_select_font_face (cr, "Georgia", - CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); -cairo_set_font_size (cr, 10);*/ cairo_text_extents (cr, lbl, &te); cairo_move_to (cr, (globals.current_size >> 1) - te.width / 2 - |