Re: feasibility of non-roman menu keymaps?



I gave this a try today, below is a patch for gtk-2.09 that adds support
for the feature.  In a nutshell the way it works is that the 1st
occurrence of '_' gets setup in the usual way.  If a 2nd occurrence is
found it gets bound to the keyboard only. '__' works as before also.

My rationale for using a 2nd '_' is simply to avoid making some new char
into a metachar, keeping metachars to a minimum.  A simple extension
that would make reading message catalogs a little easier to read would
be to allow a space before the 2nd '_'.  For example "_Test _X".

The only issue that came up was that the accelerator key mappings are
case insensitive.  The Ethiopic IMs are case sensitive (I don't know
about the others).  So we wouldn't want both "T" and "t" to be the same
accelerator.  I suppose a flag of some sort can be set to signal that
both case mappings should not be set (or it could only be set for roman
chars only).

I'm quite willing to work on this if the gtk maintainers are will to
accept the feature into gtk.  LMK.


My only test uses the tests/testtext file and resets the "Test" menu
item to "_Te__st_x" so that it appears as "Te_st" (T underlined) and
maps to Alt+x.



*** gtk+-2.0.9/gtk/gtklabel.c	2002-09-27 16:51:23.000000000 -0400
--- gtk+-2.0.9/gtk/gtklabel-new.c	2002-12-03 19:07:57.000000000 -0500
***************
*** 1835,1841 ****
    gchar *pattern;
    const gchar *src;
    gchar *dest, *pattern_dest;
!   gboolean underscore;
        
    g_return_if_fail (GTK_IS_LABEL (label));
    g_return_if_fail (str != NULL);
--- 1835,1841 ----
    gchar *pattern;
    const gchar *src;
    gchar *dest, *pattern_dest;
!   gboolean underscore, uline_is_set;
        
    g_return_if_fail (GTK_IS_LABEL (label));
    g_return_if_fail (str != NULL);
***************
*** 1847,1853 ****
    new_str = g_new (gchar, strlen (str) + 1);
    pattern = g_new (gchar, g_utf8_strlen (str, -1) + 1);
    
!   underscore = FALSE;
  
    if (str == NULL)
      str = "";
--- 1847,1853 ----
    new_str = g_new (gchar, strlen (str) + 1);
    pattern = g_new (gchar, g_utf8_strlen (str, -1) + 1);
    
!   underscore = uline_is_set = FALSE;
  
    if (str == NULL)
      str = "";
***************
*** 1880,1885 ****
--- 1880,1886 ----
  	      *pattern_dest++ = '_';
  	      if (accel_key == GDK_VoidSymbol)
  		accel_key = gdk_keyval_to_lower (gdk_unicode_to_keyval (c));
+ 	      uline_is_set = TRUE;
  	    }
  
  	  while (src < next_src)
***************
*** 1891,1898 ****
  	{
  	  if (c == '_')
  	    {
! 	      underscore = TRUE;
! 	      src = next_src;
  	    }
  	  else
  	    {
--- 1892,1909 ----
  	{
  	  if (c == '_')
  	    {
! 	      if (uline_is_set && next_src[0] != '_')
! 	        {
!                   c = g_utf8_get_char (next_src);
! 		  accel_key = gdk_keyval_to_lower (gdk_unicode_to_keyval (c));
!                   *src++;  /* step of _ */
!                   *src++;  /* eat c     */
! 	        }
! 	      else
! 	        {
! 	          underscore = TRUE;
!                   src = next_src;
! 	        }
  	    }
  	  else
  	    {


*** gtk+-2.0.9/gtk/gtkitemfactory.c	2002-10-12 18:44:03.000000000 -0400
--- gtk+-2.0.9/gtk/gtkitemfactory-new.c	2002-12-03 18:56:36.000000000 -0500
***************
*** 875,880 ****
--- 875,881 ----
  {
    gchar *translation;
    gchar *p, *q;
+   gboolean uline_seen = FALSE;
    
    *path = g_strdup (str);
  
***************
*** 888,893 ****
--- 889,898 ----
  	      p++;
  	      *q++ = '_';
  	    }
+ 	  else if (uline_seen)
+ 	      p++;
+ 	  else
+ 	      uline_seen = TRUE;
  	}
        else
  	{

*** gtk+-2.0.9/tests/testtext.c	2002-03-02 23:16:30.000000000 -0500
--- gtk+-2.0.9/tests/testtext-new.c	2002-12-03 19:05:49.000000000 -0500
***************
*** 1531,1541 ****
    { "/Attributes/No colors",   	          NULL,         do_apply_colors, FALSE, NULL },
    { "/Attributes/Remove all tags",       NULL, do_remove_tags, 0, NULL },
    { "/Attributes/Properties",       NULL, do_properties, 0, NULL },
!   { "/_Test",   	 NULL,         0,           0, "<Branch>" },
!   { "/Test/_Example",  	 NULL,         do_example,  0, NULL },
!   { "/Test/_Insert and scroll", NULL,         do_insert_and_scroll,  0, NULL },
!   { "/Test/_Add fixed children", NULL,         do_add_children,  0, NULL },
!   { "/Test/A_dd focusable children", NULL,    do_add_focus_children,  0, NULL },
  };
  
  static gboolean
--- 1531,1541 ----
    { "/Attributes/No colors",   	          NULL,         do_apply_colors, FALSE, NULL },
    { "/Attributes/Remove all tags",       NULL, do_remove_tags, 0, NULL },
    { "/Attributes/Properties",       NULL, do_properties, 0, NULL },
!   { "/_Te__st_x",   	 NULL,         0,           0, "<Branch>" },
!   { "/Te__st/_Example",  	 NULL,         do_example,  0, NULL },
!   { "/Te__st/_Insert and scroll", NULL,         do_insert_and_scroll,  0, NULL },
!   { "/Te__st/_Add fi__x__ed children", NULL,         do_add_children,  0, NULL },
!   { "/Te__st/A_dd focusable children", NULL,    do_add_focus_children,  0, NULL },
  };
  
  static gboolean



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]