Package: xfce4-xkb-plugin
Version: 0.4.3-1
Severity: wishlist
Tags: patch

I'm a user of the Dvorak keyboard layout, so I have an xkb entry with
XkbLayout=us, XkbVariant=dvorak.  And I want other non-Dvorak users to
be able to type on my keyboard, so I have an extra entry with
XkbLayout=us, XkbVariant=(empty).  But since XkbLayout is the same, the
labels shown in xfce4-xkb-plugin is exactly the same.  I'd like to have
it at least showing a suffix like "(2)" and "(3)" in such cases so that
they are distinguishable.  The attached patch does just that.

Please also forward to upstream.

-- System Information:
Debian Release: lenny/sid
 APT prefers unstable
 APT policy: (500, 'unstable'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.21-2-686 (SMP w/1 CPU core)
Locale: LANG=zh_TW.big5, LC_CTYPE=zh_TW.big5 (charmap=BIG5)
Shell: /bin/sh linked to /bin/bash

Versions of packages xfce4-xkb-plugin depends on:
ii  libatk1.0-0                   1.18.0-2   The ATK accessibility toolkit
ii  libc6                         2.6-2      GNU C Library: Shared libraries
ii  libcairo2                     1.4.10-1   The Cairo 2D vector graphics libra
ii  libfontconfig1                2.4.2-1.2  generic font configuration library
ii  libglib2.0-0                  2.12.13-1  The GLib library of C routines
ii  libgtk2.0-0                   2.10.13-1  The GTK+ graphical user interface
ii  libpango1.0-0                 1.16.4-3   Layout and rendering of internatio
ii  libx11-6                      2:1.0.3-7  X11 client-side library
ii  libxcursor1                   1:1.1.8-2  X cursor management library
ii  libxext6                      1:1.0.3-2  X11 miscellaneous extension librar
ii  libxfce4util4                 4.4.1-1    Utility functions library for Xfce
ii  libxfcegui4-4                 4.4.1-1    Basic GUI C functions for Xfce4
ii  libxfixes3                    1:4.0.3-2  X11 miscellaneous 'fixes' extensio
ii  libxi6                        2:1.1.1-1  X11 Input extension library
ii  libxinerama1                  1:1.0.2-1  X11 Xinerama extension library
ii  libxrandr2                    2:1.2.1-1  X11 RandR extension library
ii  libxrender1                   1:0.9.2-1  X Rendering Extension client libra
ii  xfce4-panel                   4.4.1-1    The Xfce4 desktop environment pane

xfce4-xkb-plugin recommends no packages.

-- no debconf information
diff -ru xfce4-xkb-plugin-0.4.3.orig/panel-plugin/xkb.c xfce4-xkb-plugin-0.4.3/panel-plugin/xkb.c
--- xfce4-xkb-plugin-0.4.3.orig/panel-plugin/xkb.c	2007-01-17 18:02:57.000000000 +0000
+++ xfce4-xkb-plugin-0.4.3/panel-plugin/xkb.c	2007-07-21 17:58:12.000000000 +0100
@@ -103,7 +103,11 @@
 get_current_group_name(void) 
 {
   const char *tmp = get_symbol_name_by_res_no(current_group_xkb_no);
-  return g_utf8_strdown (tmp, -1);
+  char *tmp2 = g_utf8_strdown (tmp, -1);
+  char *start = strchr(tmp2, '(');
+  if (start)
+    *start = '\0';
+  return tmp2;
 }
 
 void 
@@ -116,6 +120,33 @@
   current_group_res_no = group_xkb_to_res(current_group_xkb_no);
 }
 
+static void
+differentiate_symbol_names(void)
+{
+  GHashTable* symbol_cnt;
+  int i, cnt;
+  gchar *temp_str;
+
+  symbol_cnt = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+  for (i = 0; i < group_count; ++i) {
+    cnt = GPOINTER_TO_INT
+      (g_hash_table_lookup(symbol_cnt, symbol_names[i]));
+    g_hash_table_insert(symbol_cnt, g_strdup(symbol_names[i]),
+                        GINT_TO_POINTER(cnt + 1));
+  }
+  for (i = group_count - 1; i >= 0; --i) {
+    cnt = GPOINTER_TO_INT(g_hash_table_lookup(symbol_cnt, symbol_names[i]));
+    g_hash_table_insert(symbol_cnt, g_strdup(symbol_names[i]),
+                        GINT_TO_POINTER(cnt - 1));
+    if (cnt > 1) {
+      temp_str = g_strdup_printf("%s(%i)", symbol_names[i], cnt);
+      g_free(symbol_names[i]);
+      symbol_names[i] = temp_str;
+    }
+  }
+  g_hash_table_destroy(symbol_cnt);
+}
+
 int 
 do_init_xkb() 
 {
@@ -270,6 +301,7 @@
         break;
     }
   }
+  differentiate_symbol_names();
 
   XkbGetState(dsp, device_id, &xkb_state);
   current_group_xkb_no = xkb_state.group;

Reply via email to