Fix accels added after the window was shown not working

GtkApplicationWindow would only update its list of captured accels
when realizing the window. This meant that keyboard shortcuts added
after the window was realised (for example, added by plugins) would
be non-functional.

Solve this by updating our accels every time the accel map changes,
not only when realizing the window.

https://bugzilla.gnome.org/show_bug.cgi?id=700079
This commit is contained in:
Bastien Nocera 2013-05-10 16:04:11 +02:00
parent 9289156889
commit 98d33803fb

View File

@ -216,6 +216,7 @@ struct _GtkApplicationWindowPrivate
GtkWidget *menubar;
GtkAccelGroup *accels;
GSList *accel_closures;
guint accel_map_changed_id;
GMenu *app_menu_section;
GMenu *menubar_section;
@ -755,7 +756,12 @@ gtk_application_window_real_realize (GtkWidget *widget)
gtk_application_window_update_shell_shows_app_menu (window, settings);
gtk_application_window_update_shell_shows_menubar (window, settings);
gtk_application_window_update_menubar (window);
/* Update the accelerators, and ensure we do again
* if the accel map changes */
gtk_application_window_update_accels (window);
window->priv->accel_map_changed_id = g_signal_connect_swapped (gtk_accel_map_get (), "changed",
G_CALLBACK (gtk_application_window_update_accels), window);
GTK_WIDGET_CLASS (gtk_application_window_parent_class)
->realize (widget);
@ -793,6 +799,7 @@ gtk_application_window_real_realize (GtkWidget *widget)
static void
gtk_application_window_real_unrealize (GtkWidget *widget)
{
GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
GtkSettings *settings;
settings = gtk_widget_get_settings (widget);
@ -800,6 +807,8 @@ gtk_application_window_real_unrealize (GtkWidget *widget)
g_signal_handlers_disconnect_by_func (settings, gtk_application_window_shell_shows_app_menu_changed, widget);
g_signal_handlers_disconnect_by_func (settings, gtk_application_window_shell_shows_menubar_changed, widget);
g_signal_handler_disconnect (gtk_accel_map_get (), window->priv->accel_map_changed_id);
GTK_WIDGET_CLASS (gtk_application_window_parent_class)
->unrealize (widget);
}