[gnome-initial-setup/wip/pwithnall/misc-fixes: 27/70] Allow pages to specify a GtkAccelGroup




commit 436b2a3e993f0ca1320d1409a806def74676b35a
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Wed Apr 30 12:12:59 2014 +0200

    Allow pages to specify a GtkAccelGroup
    
    This will be used by subsequent downstream changes, where pages show
    dialogs in response to "hidden" key combinations.
    
    (Rebase 3.38: Fix minor rebase conflicts.)

 gnome-initial-setup/gis-assistant.c | 19 +++++++++++++++++++
 gnome-initial-setup/gis-page.c      |  8 ++++++++
 gnome-initial-setup/gis-page.h      |  2 ++
 3 files changed, 29 insertions(+)
---
diff --git a/gnome-initial-setup/gis-assistant.c b/gnome-initial-setup/gis-assistant.c
index 14887f66..65e7824b 100644
--- a/gnome-initial-setup/gis-assistant.c
+++ b/gnome-initial-setup/gis-assistant.c
@@ -174,6 +174,24 @@ gis_assistant_previous_page (GisAssistant *assistant)
   switch_to (assistant, find_prev_page (priv->current_page));
 }
 
+static void
+update_accel_group (GisAssistant *assistant)
+{
+  GisAssistantPrivate *priv = gis_assistant_get_instance_private (assistant);
+  GtkWindow *window;
+  static GtkAccelGroup *accel_group = NULL;
+
+  window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (assistant)));
+
+/* Remove previous accel group */
+  if (accel_group)
+    gtk_window_remove_accel_group (window, accel_group);
+
+  accel_group = gis_page_get_accel_group (priv->current_page);
+  if (accel_group)
+    gtk_window_add_accel_group (window, accel_group);
+}
+
 static void
 set_suggested_action_sensitive (GtkWidget *widget,
                                 gboolean   sensitive)
@@ -395,6 +413,7 @@ update_current_page (GisAssistant *assistant,
   update_titlebar (assistant);
   update_applying_state (assistant);
   update_navigation_buttons (assistant);
+  update_accel_group (assistant);
 
   gtk_widget_grab_focus (priv->forward);
 
diff --git a/gnome-initial-setup/gis-page.c b/gnome-initial-setup/gis-page.c
index 25729d09..27c0ff66 100644
--- a/gnome-initial-setup/gis-page.c
+++ b/gnome-initial-setup/gis-page.c
@@ -326,6 +326,14 @@ gis_page_set_has_forward (GisPage *page, gboolean has_forward)
     }
 }
 
+GtkAccelGroup *
+gis_page_get_accel_group (GisPage *page)
+{
+  if (GIS_PAGE_GET_CLASS (page)->get_accel_group)
+    return GIS_PAGE_GET_CLASS (page)->get_accel_group (page);
+  return NULL;
+}
+
 void
 gis_page_locale_changed (GisPage *page)
 {
diff --git a/gnome-initial-setup/gis-page.h b/gnome-initial-setup/gis-page.h
index 56aa0f86..0cf196b9 100644
--- a/gnome-initial-setup/gis-page.h
+++ b/gnome-initial-setup/gis-page.h
@@ -58,6 +58,7 @@ struct _GisPageClass
   char *page_id;
 
   void         (*locale_changed) (GisPage *page);
+  GtkAccelGroup * (*get_accel_group) (GisPage *page);
   gboolean     (*apply) (GisPage *page,
                          GCancellable *cancellable);
   gboolean     (*save_data) (GisPage  *page,
@@ -78,6 +79,7 @@ gboolean     gis_page_get_needs_accept (GisPage *page);
 void         gis_page_set_needs_accept (GisPage *page, gboolean needs_accept);
 gboolean     gis_page_get_has_forward (GisPage *page);
 void         gis_page_set_has_forward (GisPage *page, gboolean has_forward);
+GtkAccelGroup *  gis_page_get_accel_group (GisPage *page);
 void         gis_page_locale_changed (GisPage *page);
 void         gis_page_apply_begin (GisPage *page, GisPageApplyCallback callback, gpointer user_data);
 void         gis_page_apply_cancel (GisPage *page);


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