[gtk+] Fix accels added after the window was shown not working



commit 98d33803fbd0314dbece535bf24497cbf70dd364
Author: Bastien Nocera <hadess hadess net>
Date:   Fri May 10 16:04:11 2013 +0200

    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

 gtk/gtkapplicationwindow.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkapplicationwindow.c b/gtk/gtkapplicationwindow.c
index 541baf6..10fc588 100644
--- a/gtk/gtkapplicationwindow.c
+++ b/gtk/gtkapplicationwindow.c
@@ -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);
 }


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