Some improvements to the auto-mnemonics code

This commit is contained in:
Matthias Clasen 2009-12-20 18:20:42 -05:00 committed by Tristan Van Berkom
parent 9de876c222
commit 779d3d58ea
3 changed files with 12 additions and 24 deletions

View File

@ -1615,8 +1615,11 @@ gtk_main_do_event (GdkEvent *event)
if (gtk_invoke_key_snoopers (grab_widget, event))
break;
}
/* catch alt press to enable auto-mnemonics */
if (event->key.keyval == GDK_Alt_L || event->key.keyval == GDK_Alt_R)
/* Catch alt press to enable auto-mnemonics;
* menus are handled elsewhere
*/
if ((event->key.keyval == GDK_Alt_L || event->key.keyval == GDK_Alt_R) &&
!GTK_IS_MENU_SHELL (grab_widget))
{
gboolean auto_mnemonics;

View File

@ -831,8 +831,12 @@ _gtk_menu_shell_update_mnemonics (GtkMenuShell *menu_shell)
* not in the entire window.
*/
if (GTK_IS_MENU_BAR (target))
_gtk_label_mnemonics_visible_apply_recursively (GTK_WIDGET (target),
mnemonics_visible);
{
gtk_window_set_mnemonics_visible (GTK_WINDOW (gtk_widget_get_toplevel (target)),
FALSE);
_gtk_label_mnemonics_visible_apply_recursively (GTK_WIDGET (target),
mnemonics_visible);
}
else
gtk_window_set_mnemonics_visible (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (target))),
mnemonics_visible);

View File

@ -42,6 +42,7 @@
#include "gtkkeyhash.h"
#include "gtkmain.h"
#include "gtkmnemonichash.h"
#include "gtkmenubar.h"
#include "gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkmarshalers.h"
@ -235,8 +236,6 @@ static gint gtk_window_client_event (GtkWidget *widget,
static void gtk_window_check_resize (GtkContainer *container);
static gint gtk_window_focus (GtkWidget *widget,
GtkDirectionType direction);
static void gtk_window_grab_notify (GtkWidget *widget,
gboolean was_grabbed);
static void gtk_window_real_set_focus (GtkWindow *window,
GtkWidget *focus);
@ -464,7 +463,6 @@ gtk_window_class_init (GtkWindowClass *klass)
widget_class->client_event = gtk_window_client_event;
widget_class->focus = gtk_window_focus;
widget_class->expose_event = gtk_window_expose;
widget_class->grab_notify = gtk_window_grab_notify;
container_class->check_resize = gtk_window_check_resize;
@ -5332,7 +5330,6 @@ gtk_window_focus_out_event (GtkWidget *widget,
if (auto_mnemonics)
gtk_window_set_mnemonics_visible (window, FALSE);
return FALSE;
}
@ -8506,22 +8503,6 @@ gtk_window_set_mnemonics_visible (GtkWindow *window,
priv->mnemonics_visible_set = TRUE;
}
static void
gtk_window_grab_notify (GtkWidget *widget,
gboolean was_grabbed)
{
gboolean auto_mnemonics;
if (was_grabbed)
return;
g_object_get (gtk_widget_get_settings (widget), "gtk-auto-mnemonics",
&auto_mnemonics, NULL);
if (auto_mnemonics)
gtk_window_set_mnemonics_visible (GTK_WINDOW (widget), FALSE);
}
#if defined (G_OS_WIN32) && !defined (_WIN64)
#undef gtk_window_set_icon_from_file