After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 300730 - Mnemonic activation of panel menu items no longer works
Mnemonic activation of panel menu items no longer works
Status: RESOLVED FIXED
Product: gnome-panel
Classification: Other
Component: panel
2.12.x
Other Linux
: Normal normal
: ---
Assigned To: Panel Maintainers
Panel Maintainers
: 303358 304813 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-04-15 11:20 UTC by Mark McLoughlin
Modified: 2015-03-24 13:00 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
mnemonic patch (2.04 KB, patch)
2006-01-27 21:08 UTC, Matthias Clasen
committed Details | Review

Description Mark McLoughlin 2005-04-15 11:20:55 UTC
From Fedora:

  https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=152259

  With the Gnome in FC3, I could focus on certain parts of the menu by 
  pressing letter keys.  For example, Alt-F1 would start the menu and after 
  pressing the down arrow once, I could move to "System Settings" by pressing 
  "s" several times.  This capability is no longer available.  Only the arrow
  keys work.


I think this is probably down to a change made in gtk+ 2.6 where GtkMenuShell
maintains its own mnemonic hash. See bug #101309. I haven't confirmed that in
great detail, though.
very time-consuming when you are trying to reach the middle line of the menu.
Comment 1 Mark McLoughlin 2005-04-15 11:24:22 UTC
(uggh, don't mind the copy and paste error :-)

Matthias: any thoughts on this? This is what the panel is doing:

static void
setup_mnemonic (GtkWidget *menuitem,
                GtkWidget *old_toplevel,
                gpointer   keyval_as_pointer)
{
  GtkWidget *toplevel;
  guint      keyval;

  keyval = GPOINTER_TO_UINT (keyval_as_pointer);

  if (old_toplevel != NULL)
    gtk_window_remove_mnemonic (GTK_WINDOW (old_toplevel),
                                keyval,
                                GTK_WIDGET (menuitem));

  toplevel = gtk_widget_get_toplevel (menuitem);
  if (GTK_WIDGET_TOPLEVEL (toplevel))
    gtk_window_add_mnemonic (GTK_WINDOW (toplevel),
                             keyval,
                             GTK_WIDGET (menuitem));
}

static void
setup_invisible_mnemonic (GtkWidget *menuitem,
                          char       unicode_char)
{
  guint accel_key;

  accel_key = gdk_keyval_to_lower (gdk_unicode_to_keyval (unicode_char));

  g_signal_connect (menuitem, "hierarchy_changed",
                    G_CALLBACK (setup_mnemonic),
                    GUINT_TO_POINTER (accel_key));

  setup_mnemonic (menuitem, NULL, GUINT_TO_POINTER (accel_key));
}


{
  ...
  if (invisible_mnemonic && title)
    setup_invisible_mnemonic (menuitem, title [0]);
  ...
}
Comment 2 Mark McLoughlin 2005-05-09 05:46:44 UTC
*** Bug 303358 has been marked as a duplicate of this bug. ***
Comment 3 Olav Vitters 2005-05-19 22:16:14 UTC
*** Bug 304813 has been marked as a duplicate of this bug. ***
Comment 4 Wouter Bolsterlee (uws) 2005-10-05 20:11:22 UTC
Is there any activity on this bug? Navigating the menu using the keyboard seems
impossible without using the cursor keys (which I don't use, normally).

I (and I bet I'm not the only one) really love to see this major usability
regression fixed.
Comment 5 Mateusz Łoskot 2005-11-05 11:06:45 UTC
Is there anyone going to fix this bug?
Or may be someone could explain current situation with GTK+ and GNOME Panel
related to this bug - a background. Why this bug is not fixed yet and where is
the real problem? 
Comment 6 Jeff Walden (remove +bgo to email) 2005-12-18 19:05:37 UTC
I've tried stepping through the code in a debugger, and when the following code snippet inside |setup_mnemonic()| is hit:

  toplevel = gtk_widget_get_toplevel (menuitem);
  if (GTK_WIDGET_TOPLEVEL (toplevel))
    gtk_window_add_mnemonic (GTK_WINDOW (toplevel),
                             keyval,
                             GTK_WIDGET (menuitem));

...|GTK_WIDGET_TOPLEVEL(toplevel)| evaluates to 0, and thus mnemonic-adding code is never called.  The problem seems to be that |menuitem| has no parent, so the call simply returns |menuitem|, but |menuitem|'s not a top-level widget.

At first I thought this might be that the passed-in menuitem (because it's only an initialized menuitem) isn't contained inside some other widget.  However, I tested this by rearranging the calls so that |gtk_shell_append()| for the menuitems happens before |setup_menuitem()|, but it didn't seem to work.  I'm not at all familiar with GTK+ or its C-based "object-orientedness" (ugh), so I can't knowledgeably say much beyond this.

I might try poking at this more in the next month or so, but realistically I probably have more useful things to do with my time, even if this bug slows me down and forces me to change the way I use the main menus maybe ten or twenty times a day.
Comment 7 Vincent Untz 2005-12-30 10:50:23 UTC
Adding to 2.14.x milestone.
Comment 8 Matthias Clasen 2006-01-27 20:14:51 UTC
Vincent, I just learned that GtkMenu can already do the invisible mnemonic thing you want here, no hacks with gtk_window_add_accelerator() necessary. Here is how it works:

gtk_menu_item_new_with_mnemonic ("_Foo");
gtk_label_set_pattern (GTK_LABEL (GTK_BIN (menuitem)->child), "");

This makes a menuitem with no underlined characters, and 'F' as the mnemonic.
Comment 9 Matthias Clasen 2006-01-27 21:08:29 UTC
Created attachment 58235 [details] [review]
mnemonic patch
Comment 10 Matthias Clasen 2006-01-27 21:09:00 UTC
The patch has only been superficially tested, but seems to work.
Comment 11 Jeff Walden (remove +bgo to email) 2006-01-27 22:52:38 UTC
Comment on attachment 58235 [details] [review]
mnemonic patch

> void
> setup_menuitem (GtkWidget   *menuitem,
> 		GtkIconSize  icon_size,
>@@ -1199,19 +1162,21 @@
> 			       
> {
> 	GtkWidget *label;
>-
>+	gchar *_title;
>+	
>+	label = g_object_new (GTK_TYPE_ACCEL_LABEL, NULL);
>+	_title = g_strconcat ("_", title, NULL);
>+	gtk_label_set_text_with_mnemonic (GTK_LABEL (label), _title);
>+	g_free (_title);
> 	if (invisible_mnemonic)
>-		label = gtk_label_new (title);
>-	else
>-		label = gtk_label_new_with_mnemonic (title);
>+	  gtk_label_set_pattern (GTK_LABEL (label), "");

I could just be reading this wrong, but doesn't this always make the first character a mnemonic, even if the string already contains a mnemonic (e.g., if title were "The _GIMP")?  Or is it safe to assume that any menu item created here won't have any built-in mnemonics?  API docs don't explicitly specify what happens for a string with multiple underscores (all of them get hooked up?), so I have no idea what the expected behavior's supposed to be.
Comment 12 Matthias Clasen 2006-01-28 02:55:09 UTC
Well, if you look two lines further down in the patch

-	if (invisible_mnemonic && title)
-		setup_invisible_mnemonic (menuitem, title [0]);

you see that that is exactly the same behaviour that the code
was trying to implement before. And no, there will not be any 
underscores in the titles. The I do believe the docs mention
that only the first _ is interpreted as mnemonic.
Comment 13 Vincent Untz 2006-02-12 13:34:38 UTC
I committed a modified part of the patch. Jeff is right: we don't want to make the first character a mnemonic if invisible_mnemonic is FALSE. In fact, this code is a mess since this function is used for other stuff than the main menu...

Thanks Matthias.