[gnome-initial-setup] Add a way for pages to add an action widget



commit f4e4d08ffcf51e95f32f849bfc55c5ec3abe646e
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jan 19 18:04:54 2013 -0500

    Add a way for pages to add an action widget
    
    This will be used in the following commits.

 gnome-initial-setup/gis-assistant.c |   35 ++++++++++++++++++++++++++++-------
 gnome-initial-setup/gis-page.c      |    8 ++++++++
 gnome-initial-setup/gis-page.h      |    2 ++
 3 files changed, 38 insertions(+), 7 deletions(-)
---
diff --git a/gnome-initial-setup/gis-assistant.c b/gnome-initial-setup/gis-assistant.c
index 9bfb3d3..8888535 100644
--- a/gnome-initial-setup/gis-assistant.c
+++ b/gnome-initial-setup/gis-assistant.c
@@ -56,6 +56,9 @@ struct _GisAssistantPrivate
   GtkWidget *forward;
   GtkWidget *back;
   GtkWidget *main_layout;
+  GtkWidget *action_area;
+  GtkWidget *navigation;
+  GtkWidget *current_action;
 
   GList *pages;
   GisPage *current_page;
@@ -137,6 +140,20 @@ gis_assistant_previous_page (GisAssistant *assistant)
 }
 
 static void
+update_action_widget (GisAssistant *assistant)
+{
+  GisAssistantPrivate *priv = assistant->priv;
+
+  if (priv->current_action)
+    gtk_container_remove (GTK_CONTAINER (priv->action_area), priv->current_action);
+
+  priv->current_action = gis_page_get_action_widget (priv->current_page);
+  if (priv->current_action)
+    gtk_box_pack_start (GTK_BOX (priv->action_area), priv->current_action,
+                        FALSE, FALSE, 0);
+}
+
+static void
 update_navigation_buttons (GisAssistant *assistant)
 {
   GisAssistantPrivate *priv = assistant->priv;
@@ -161,6 +178,7 @@ static void
 gis_assistant_real_prepare (GisAssistant *assistant,
                             GisPage      *page)
 {
+  update_action_widget (assistant);
   update_navigation_buttons (assistant);
 }
 
@@ -275,7 +293,7 @@ static void
 gis_assistant_init (GisAssistant *assistant)
 {
   GisAssistantPrivate *priv = GET_PRIVATE (assistant);
-  GtkWidget *action_area;
+  GtkWidget *navigation;
   assistant->priv = priv;
 
   priv->main_layout = gtk_box_new (GTK_ORIENTATION_VERTICAL, 20);
@@ -285,9 +303,12 @@ gis_assistant_init (GisAssistant *assistant)
   gtk_frame_set_shadow_type (GTK_FRAME (priv->frame), GTK_SHADOW_NONE);
   gtk_box_pack_start (GTK_BOX (priv->main_layout), priv->frame, TRUE, TRUE, 0);
 
-  action_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-  gtk_box_set_homogeneous (GTK_BOX (action_area), TRUE);
-  gtk_widget_set_halign (action_area, GTK_ALIGN_END);
+  priv->action_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+  navigation = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+  gtk_box_set_homogeneous (GTK_BOX (navigation), TRUE);
+  gtk_widget_set_halign (navigation, GTK_ALIGN_END);
+  gtk_widget_set_hexpand (navigation, TRUE);
+  gtk_box_pack_end (GTK_BOX (priv->action_area), navigation, TRUE, TRUE, 0);
 
   priv->forward = gtk_button_new ();
   gtk_button_set_image (GTK_BUTTON (priv->forward),
@@ -300,14 +321,14 @@ gis_assistant_init (GisAssistant *assistant)
                         gtk_image_new_from_stock (GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON));
   gtk_button_set_use_underline (GTK_BUTTON (priv->back), TRUE);
 
-  gtk_box_pack_start (GTK_BOX (action_area), priv->back, FALSE, FALSE, 0);
-  gtk_box_pack_start (GTK_BOX (action_area), priv->forward, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (navigation), priv->back, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (navigation), priv->forward, FALSE, FALSE, 0);
 
   g_signal_connect (priv->forward, "clicked", G_CALLBACK (go_forward), assistant);
   g_signal_connect (priv->back, "clicked", G_CALLBACK (go_backward), assistant);
 
   gis_assistant_locale_changed (assistant);
-  gtk_box_pack_start (GTK_BOX (priv->main_layout), action_area, FALSE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (priv->main_layout), priv->action_area, FALSE, TRUE, 0);
 
   gtk_widget_show_all (GTK_WIDGET (assistant));
 }
diff --git a/gnome-initial-setup/gis-page.c b/gnome-initial-setup/gis-page.c
index fee0b03..697f4d4 100644
--- a/gnome-initial-setup/gis-page.c
+++ b/gnome-initial-setup/gis-page.c
@@ -225,3 +225,11 @@ gis_page_set_complete (GisPage *page, gboolean complete)
   page->priv->complete = complete;
   g_object_notify_by_pspec (G_OBJECT (page), obj_props[PROP_COMPLETE]);
 }
+
+GtkWidget *
+gis_page_get_action_widget (GisPage *page)
+{
+  if (GIS_PAGE_GET_CLASS (page)->get_action_widget)
+    return GIS_PAGE_GET_CLASS (page)->get_action_widget (page);
+  return NULL;
+}
diff --git a/gnome-initial-setup/gis-page.h b/gnome-initial-setup/gis-page.h
index f92a947..ec0387c 100644
--- a/gnome-initial-setup/gis-page.h
+++ b/gnome-initial-setup/gis-page.h
@@ -57,6 +57,7 @@ struct _GisPageClass
   char *page_id;
 
   GtkBuilder * (*get_builder) (GisPage *page);
+  GtkWidget  * (*get_action_widget) (GisPage *page);
 };
 
 GType gis_page_get_type (void);
@@ -65,6 +66,7 @@ char *       gis_page_get_title (GisPage *page);
 void         gis_page_set_title (GisPage *page, char *title);
 gboolean     gis_page_get_complete (GisPage *page);
 void         gis_page_set_complete (GisPage *page, gboolean complete);
+GtkWidget *  gis_page_get_action_widget (GisPage *page);
 
 G_END_DECLS
 



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