[libgnomekbd] Improving rendering of long strings in the kbd preview
- From: Sergey V. Udaltsov <svu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgnomekbd] Improving rendering of long strings in the kbd preview
- Date: Wed, 22 Dec 2010 23:00:44 +0000 (UTC)
commit 9708664343b0b4a40d6af82e1bc3e63e9c63fb23
Author: Sergey V. Udaltsov <svu gnome org>
Date: Sun Dec 5 01:17:48 2010 +0000
Improving rendering of long strings in the kbd preview
https://bugzilla.gnome.org/show_bug.cgi?id=633680
libgnomekbd/gkbd-keyboard-drawing.c | 97 ++++++++++++++++++++---------------
1 files changed, 56 insertions(+), 41 deletions(-)
---
diff --git a/libgnomekbd/gkbd-keyboard-drawing.c b/libgnomekbd/gkbd-keyboard-drawing.c
index 85d86e8..9b9b72b 100644
--- a/libgnomekbd/gkbd-keyboard-drawing.c
+++ b/libgnomekbd/gkbd-keyboard-drawing.c
@@ -610,6 +610,21 @@ find_keycode (GkbdKeyboardDrawing * drawing, gchar * key_name)
return INVALID_KEYCODE;
}
+static void
+set_markup(GkbdKeyboardDrawingRenderContext * context,
+ gchar *txt)
+{
+ PangoLayout *layout = context->layout;
+ txt = strcmp("<", txt) ? txt : "<";
+ txt = strcmp("&", txt) ? txt : "&";
+ if (g_utf8_strlen (txt, -1) > 1) {
+ gchar* buf = g_strdup_printf ("<span size=\"x-small\">%s</span>", txt);
+ pango_layout_set_markup (layout, buf, -1);
+ g_free (buf);
+ } else {
+ pango_layout_set_markup (layout, txt, -1);
+ }
+}
static void
set_key_label_in_layout (GkbdKeyboardDrawingRenderContext * context,
@@ -617,131 +632,130 @@ set_key_label_in_layout (GkbdKeyboardDrawingRenderContext * context,
{
gchar buf[5];
gunichar uc;
- PangoLayout *layout = context->layout;
switch (keyval) {
case GDK_KEY_Scroll_Lock:
- pango_layout_set_text (layout, "Scroll\nLock", -1);
+ set_markup (context, "Scroll\nLock");
break;
case GDK_KEY_space:
- pango_layout_set_text (layout, "", -1);
+ set_markup(context, "");
break;
case GDK_KEY_Sys_Req:
- pango_layout_set_text (layout, "Sys Rq", -1);
+ set_markup(context, "Sys Rq");
break;
case GDK_KEY_Page_Up:
- pango_layout_set_text (layout, "Page\nUp", -1);
+ set_markup(context, "Page\nUp");
break;
case GDK_KEY_Page_Down:
- pango_layout_set_text (layout, "Page\nDown", -1);
+ set_markup(context, "Page\nDown");
break;
case GDK_KEY_Num_Lock:
- pango_layout_set_text (layout, "Num\nLock", -1);
+ set_markup(context, "Num\nLock");
break;
case GDK_KEY_KP_Page_Up:
- pango_layout_set_text (layout, "Pg Up", -1);
+ set_markup(context, "Pg Up");
break;
case GDK_KEY_KP_Page_Down:
- pango_layout_set_text (layout, "Pg Dn", -1);
+ set_markup(context, "Pg Dn");
break;
case GDK_KEY_KP_Home:
- pango_layout_set_text (layout, "Home", -1);
+ set_markup(context, "Home");
break;
case GDK_KEY_KP_Left:
- pango_layout_set_text (layout, "Left", -1);
+ set_markup(context, "Left");
break;
case GDK_KEY_KP_End:
- pango_layout_set_text (layout, "End", -1);
+ set_markup(context, "End");
break;
case GDK_KEY_KP_Up:
- pango_layout_set_text (layout, "Up", -1);
+ set_markup(context, "Up");
break;
case GDK_KEY_KP_Begin:
- pango_layout_set_text (layout, "Begin", -1);
+ set_markup(context, "Begin");
break;
case GDK_KEY_KP_Right:
- pango_layout_set_text (layout, "Right", -1);
+ set_markup(context, "Right");
break;
case GDK_KEY_KP_Enter:
- pango_layout_set_text (layout, "Enter", -1);
+ set_markup(context, "Enter");
break;
case GDK_KEY_KP_Down:
- pango_layout_set_text (layout, "Down", -1);
+ set_markup(context, "Down");
break;
case GDK_KEY_KP_Insert:
- pango_layout_set_text (layout, "Ins", -1);
+ set_markup(context, "Ins");
break;
case GDK_KEY_KP_Delete:
- pango_layout_set_text (layout, "Del", -1);
+ set_markup(context, "Del");
break;
case GDK_KEY_dead_grave:
- pango_layout_set_text (layout, "Ë?", -1);
+ set_markup(context, "Ë?");
break;
case GDK_KEY_dead_acute:
- pango_layout_set_text (layout, "Ë?", -1);
+ set_markup(context, "Ë?");
break;
case GDK_KEY_dead_circumflex:
- pango_layout_set_text (layout, "Ë?", -1);
+ set_markup(context, "Ë?");
break;
case GDK_KEY_dead_tilde:
- pango_layout_set_text (layout, "~", -1);
+ set_markup(context, "~");
break;
case GDK_KEY_dead_macron:
- pango_layout_set_text (layout, "Ë?", -1);
+ set_markup(context, "Ë?");
break;
case GDK_KEY_dead_breve:
- pango_layout_set_text (layout, "Ë?", -1);
+ set_markup(context, "Ë?");
break;
case GDK_KEY_dead_abovedot:
- pango_layout_set_text (layout, "Ë?", -1);
+ set_markup(context, "Ë?");
break;
case GDK_KEY_dead_diaeresis:
- pango_layout_set_text (layout, "¨", -1);
+ set_markup(context, "¨");
break;
case GDK_KEY_dead_abovering:
- pango_layout_set_text (layout, "Ë?", -1);
+ set_markup(context, "Ë?");
break;
case GDK_KEY_dead_doubleacute:
- pango_layout_set_text (layout, "Ë?", -1);
+ set_markup(context, "Ë?");
break;
case GDK_KEY_dead_caron:
- pango_layout_set_text (layout, "Ë?", -1);
+ set_markup(context, "Ë?");
break;
case GDK_KEY_dead_cedilla:
- pango_layout_set_text (layout, "¸", -1);
+ set_markup(context, "¸");
break;
case GDK_KEY_dead_ogonek:
- pango_layout_set_text (layout, "Ë?", -1);
+ set_markup(context, "Ë?");
break;
/* case GDK_KEY_dead_iota:
@@ -749,32 +763,33 @@ set_key_label_in_layout (GkbdKeyboardDrawingRenderContext * context,
* case GDK_KEY_dead_semivoiced_sound: */
case GDK_KEY_dead_belowdot:
- pango_layout_set_text (layout, " ̣", -1);
+ set_markup(context, " ̣");
break;
case GDK_KEY_horizconnector:
- pango_layout_set_text (layout, "horiz\nconn", -1);
+ set_markup(context, "horiz\nconn");
break;
case GDK_KEY_Mode_switch:
- pango_layout_set_text (layout, "AltGr", -1);
+ set_markup(context, "AltGr");
break;
case GDK_KEY_Multi_key:
- pango_layout_set_text (layout, "Compose", -1);
+ set_markup(context, "Compose");
break;
default:
uc = gdk_keyval_to_unicode (keyval);
if (uc != 0 && g_unichar_isgraph (uc)) {
buf[g_unichar_to_utf8 (uc, buf)] = '\0';
- pango_layout_set_text (layout, buf, -1);
+ set_markup(context, buf);
} else {
gchar *name = gdk_keyval_name (keyval);
- if (name)
- pango_layout_set_text (layout, name, -1);
+ if (name) {
+ set_markup(context, name);
+ }
else
- pango_layout_set_text (layout, "", -1);
+ set_markup(context, "");
}
}
}
@@ -1136,7 +1151,7 @@ draw_text_doodad (GkbdKeyboardDrawingRenderContext * context,
y = xkb_to_pixmap_coord (context,
doodad->origin_y + text_doodad->top);
- pango_layout_set_text (context->layout, text_doodad->text, -1);
+ set_markup (context, text_doodad->text);
draw_pango_layout (context, drawing, doodad->angle, x, y);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]