Allow applications to use gtk-menu-bar-accel in 3.12

gnome-terminal is still using this setting, so we'll let
applications override it for another cycle. It is no longer
backed by a system-wide setting, though, and it will still
go away eventually.

This partically reverts b26c74e5da
This commit is contained in:
Matthias Clasen 2013-09-23 13:10:19 -04:00
parent ba0542dc51
commit fac8d6deea
2 changed files with 39 additions and 19 deletions

View File

@ -696,35 +696,54 @@ window_key_press_handler (GtkWidget *widget,
GdkEventKey *event,
gpointer data)
{
gchar *accel = NULL;
gboolean retval = FALSE;
guint keyval = GDK_KEY_F10;
/* FIXME this is wrong, needs to be in the global accel resolution
* thing, to properly consider i18n etc., but that probably requires
* AccelGroup changes etc.
*/
if (event->keyval == keyval && event->state == 0)
g_object_get (gtk_widget_get_settings (widget),
"gtk-menu-bar-accel", &accel,
NULL);
if (accel && *accel)
{
GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
GList *menubars;
guint keyval = 0;
GdkModifierType mods = 0;
menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
GTK_DIR_TAB_FORWARD, NULL);
g_list_free (tmp_menubars);
gtk_accelerator_parse (accel, &keyval, &mods);
if (menubars)
if (keyval == 0)
g_warning ("Failed to parse menu bar accelerator '%s'\n", accel);
/* FIXME this is wrong, needs to be in the global accel resolution
* thing, to properly consider i18n etc., but that probably requires
* AccelGroup changes etc.
*/
if (event->keyval == keyval &&
((event->state & gtk_accelerator_get_default_mod_mask ()) ==
(mods & gtk_accelerator_get_default_mod_mask ())))
{
GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
GList *tmp_menubars = get_viewable_menu_bars (GTK_WINDOW (widget));
GList *menubars;
_gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
gtk_menu_shell_select_first (menu_shell, FALSE);
menubars = _gtk_container_focus_sort (GTK_CONTAINER (widget), tmp_menubars,
GTK_DIR_TAB_FORWARD, NULL);
g_list_free (tmp_menubars);
g_list_free (menubars);
if (menubars)
{
GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
retval = TRUE;
_gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
gtk_menu_shell_select_first (menu_shell, FALSE);
g_list_free (menubars);
retval = TRUE;
}
}
}
g_free (accel);
return retval;
}

View File

@ -482,14 +482,15 @@ gtk_settings_class_init (GtkSettingsClass *class)
*
* Keybinding to activate the menu bar.
*
* Deprecated: 3.10: This setting is ignored.
* Deprecated: 3.10: This setting can still be used for application
* overrides, but will be ignored in the future
*/
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-menu-bar-accel",
P_("Menu bar accelerator"),
P_("Keybinding to activate the menu bar"),
"F10",
GTK_PARAM_READWRITE | G_PARAM_DEPRECATED),
GTK_PARAM_READWRITE),
NULL);
g_assert (result == PROP_MENU_BAR_ACCEL);