[Goodies-commits] r5451 - xfce4-xkb-plugin/trunk/panel-plugin
Alexander Iliev
sasoiliev at xfce.org
Wed Sep 24 11:37:10 CEST 2008
Author: sasoiliev
Date: 2008-09-24 09:37:10 +0000 (Wed, 24 Sep 2008)
New Revision: 5451
Modified:
xfce4-xkb-plugin/trunk/panel-plugin/xkb-cairo.c
xfce4-xkb-plugin/trunk/panel-plugin/xkb-util.c
xfce4-xkb-plugin/trunk/panel-plugin/xkb-util.h
Log:
only the first 3 characters are displayed for layout names which are longer
Modified: xfce4-xkb-plugin/trunk/panel-plugin/xkb-cairo.c
===================================================================
--- xfce4-xkb-plugin/trunk/panel-plugin/xkb-cairo.c 2008-09-24 07:37:14 UTC (rev 5450)
+++ xfce4-xkb-plugin/trunk/panel-plugin/xkb-cairo.c 2008-09-24 09:37:10 UTC (rev 5451)
@@ -155,6 +155,7 @@
{
g_assert (cr != NULL);
+ gchar **normalized_group_name;
gchar font_str[80];
gint pango_width, pango_height;
gint layoutx, layouty;
@@ -162,11 +163,13 @@
gint i;
gint radius;
+ normalized_group_name = xkb_util_normalize_group_name (group_name);
+
PangoLayout *layout;
PangoFontDescription *desc;
layout = pango_cairo_create_layout (cr);
- pango_layout_set_text (layout, group_name, -1);
+ pango_layout_set_text (layout, normalized_group_name, -1);
g_sprintf (font_str, XKB_PREFERRED_FONT, font_sizes[panel_size - 16]);
desc = pango_font_description_from_string (font_str);
pango_layout_set_font_description (layout, desc);
@@ -194,6 +197,7 @@
cairo_fill (cr);
}
+ g_free (normalized_group_name);
g_object_unref (layout);
}
Modified: xfce4-xkb-plugin/trunk/panel-plugin/xkb-util.c
===================================================================
--- xfce4-xkb-plugin/trunk/panel-plugin/xkb-util.c 2008-09-24 07:37:14 UTC (rev 5450)
+++ xfce4-xkb-plugin/trunk/panel-plugin/xkb-util.c 2008-09-24 09:37:10 UTC (rev 5451)
@@ -59,3 +59,34 @@
return layout;
}
+gchar*
+xkb_util_normalize_group_name (gchar* group_name)
+{
+ if (strlen (group_name) <= 3)
+ {
+ return g_strdup (group_name);
+ }
+
+ gchar *c = group_name;
+ gchar *result;
+ gint cut_length;
+ gint index_of_na = -1;
+
+ while (*c)
+ {
+ if (!((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z')))
+ {
+ index_of_na = (int) c - (int) group_name;
+ break;
+ }
+
+ c++;
+ }
+
+ cut_length = (index_of_na != -1 && index_of_na <= 3) ? index_of_na : 3;
+
+ result = g_strndup (group_name, cut_length);
+
+ return result;
+}
+
Modified: xfce4-xkb-plugin/trunk/panel-plugin/xkb-util.h
===================================================================
--- xfce4-xkb-plugin/trunk/panel-plugin/xkb-util.h 2008-09-24 07:37:14 UTC (rev 5450)
+++ xfce4-xkb-plugin/trunk/panel-plugin/xkb-util.h 2008-09-24 09:37:10 UTC (rev 5451)
@@ -34,6 +34,7 @@
gchar* xkb_util_get_layout_string (gchar* group_name,
gchar* variant);
+gchar* xkb_util_normalize_group_name (gchar* group_name);
#endif
More information about the Goodies-commits
mailing list