[gtk+/treeview-refactor] GtkAssistant: Add custom page type



commit 76a0b9e5fa1436ebe20c344f6320cecd541148f1
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Oct 30 20:12:58 2010 +0100

    GtkAssistant: Add custom page type
    
    The custom page type will not show any buttons by default, and
    it is left to the application to add its own buttons instead.
    
    The _next_page() and _previous_page() functions can be used
    for the back and forward buttons used by the application.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=576498

 gtk/gtk.symbols    |    2 +
 gtk/gtkassistant.c |  102 ++++++++++++++++++++++++++++++++++++++++------------
 gtk/gtkassistant.h |    8 ++++-
 3 files changed, 88 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 26b99be..cd88fda 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -262,6 +262,8 @@ gtk_application_remove_window
 #if IN_FILE(__GTK_ASSISTANT_C__)
 gtk_assistant_get_type G_GNUC_CONST
 gtk_assistant_new
+gtk_assistant_next_page
+gtk_assistant_previous_page
 gtk_assistant_get_current_page
 gtk_assistant_set_current_page
 gtk_assistant_get_n_pages
diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c
index 10241a3..d5ceb82 100644
--- a/gtk/gtkassistant.c
+++ b/gtk/gtkassistant.c
@@ -590,13 +590,22 @@ set_assistant_buttons_state (GtkAssistant *assistant)
       gtk_widget_hide (priv->last);
       compute_progress_state (assistant);
       break;
+    case GTK_ASSISTANT_PAGE_CUSTOM:
+      gtk_widget_hide (priv->cancel);
+      gtk_widget_hide (priv->back);
+      gtk_widget_hide (priv->forward);
+      gtk_widget_hide (priv->apply);
+      gtk_widget_hide (priv->last);
+      gtk_widget_hide (priv->close);
+      break;
     default:
       g_assert_not_reached ();
     }
 
   if (priv->committed)
     gtk_widget_hide (priv->cancel);
-  else if (priv->current_page->type == GTK_ASSISTANT_PAGE_SUMMARY)
+  else if (priv->current_page->type == GTK_ASSISTANT_PAGE_SUMMARY ||
+           priv->current_page->type == GTK_ASSISTANT_PAGE_CUSTOM)
     gtk_widget_hide (priv->cancel);
   else
     gtk_widget_show (priv->cancel);
@@ -720,34 +729,14 @@ static void
 on_assistant_forward (GtkWidget    *widget,
                       GtkAssistant *assistant)
 {
-  if (!compute_next_step (assistant))
-    g_critical ("Page flow is broken, you may want to end it with a page of "
-		"type GTK_ASSISTANT_PAGE_CONFIRM or GTK_ASSISTANT_PAGE_SUMMARY");
+  gtk_assistant_next_page (assistant);
 }
 
 static void
 on_assistant_back (GtkWidget    *widget,
                    GtkAssistant *assistant)
 {
-  GtkAssistantPrivate *priv = assistant->priv;
-  GtkAssistantPage *page_info;
-  GSList *page_node;
-
-  /* skip the progress pages when going back */
-  do
-    {
-      page_node = priv->visited_pages;
-
-      g_return_if_fail (page_node != NULL);
-
-      priv->visited_pages = priv->visited_pages->next;
-      page_info = (GtkAssistantPage *) page_node->data;
-      g_slist_free_1 (page_node);
-    }
-  while (page_info->type == GTK_ASSISTANT_PAGE_PROGRESS ||
-	 !gtk_widget_get_visible (page_info->page));
-
-  set_current_page (assistant, page_info);
+  gtk_assistant_previous_page (assistant);
 }
 
 static void
@@ -1685,6 +1674,73 @@ gtk_assistant_set_current_page (GtkAssistant *assistant,
 }
 
 /**
+ * gtk_assistant_next_page:
+ * @assistant: a #GtkAssistant
+ *
+ * Navigate to the next page. It is a programming
+ *  error to call this function if there is no next page.
+ *
+ * This function is for use when creating pages of the
+ *  #GTK_ASSISTANT_PAGE_CUSTOM type.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_assistant_next_page (GtkAssistant *assistant)
+{
+  GtkAssistantPrivate *priv;
+
+  g_return_if_fail (GTK_IS_ASSISTANT (assistant));
+
+  priv = assistant->priv;
+
+  if (!compute_next_step (assistant))
+    g_critical ("Page flow is broken, you may want to end it with a page of "
+		"type GTK_ASSISTANT_PAGE_CONFIRM or GTK_ASSISTANT_PAGE_SUMMARY");
+}
+
+/**
+ * gtk_assistant_previous_page:
+ * @assistant: a #GtkAssistant
+ *
+ * Navigate to the previous visited page. It is a programming
+ *  error to call this function if no previous page is
+ *  available.
+ *
+ * This function is for use when creating pages of the
+ *  #GTK_ASSISTANT_PAGE_CUSTOM type.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_assistant_previous_page (GtkAssistant *assistant)
+{
+  GtkAssistantPrivate *priv;
+  GtkAssistantPage *page_info;
+  GSList *page_node;
+
+  g_return_if_fail (GTK_IS_ASSISTANT (assistant));
+
+  priv = assistant->priv;
+
+  /* skip the progress pages when going back */
+  do
+    {
+      page_node = priv->visited_pages;
+
+      g_return_if_fail (page_node != NULL);
+
+      priv->visited_pages = priv->visited_pages->next;
+      page_info = (GtkAssistantPage *) page_node->data;
+      g_slist_free_1 (page_node);
+    }
+  while (page_info->type == GTK_ASSISTANT_PAGE_PROGRESS ||
+	 !gtk_widget_get_visible (page_info->page));
+
+  set_current_page (assistant, page_info);
+}
+
+/**
  * gtk_assistant_get_n_pages:
  * @assistant: a #GtkAssistant
  *
diff --git a/gtk/gtkassistant.h b/gtk/gtkassistant.h
index d745b50..ea3ae81 100644
--- a/gtk/gtkassistant.h
+++ b/gtk/gtkassistant.h
@@ -55,6 +55,9 @@ G_BEGIN_DECLS
  * @GTK_ASSISTANT_PAGE_PROGRESS: Used for tasks that take a long time to
  *  complete, blocks the assistant until the page is marked as complete.
  *   Only the back button will be shown.
+ * @GTK_ASSISTANT_PAGE_CUSTOM: Used for when other page types are not
+ *  appropriate. No buttons will be shown, and the application must
+ *  add its own buttons through gtk_assistant_add_action_widget().
  *
  * An enum for determining the page role inside the #GtkAssistant. It's
  * used to handle buttons sensitivity and visibility.
@@ -72,7 +75,8 @@ typedef enum
   GTK_ASSISTANT_PAGE_INTRO,
   GTK_ASSISTANT_PAGE_CONFIRM,
   GTK_ASSISTANT_PAGE_SUMMARY,
-  GTK_ASSISTANT_PAGE_PROGRESS
+  GTK_ASSISTANT_PAGE_PROGRESS,
+  GTK_ASSISTANT_PAGE_CUSTOM
 } GtkAssistantPageType;
 
 typedef struct _GtkAssistant        GtkAssistant;
@@ -120,6 +124,8 @@ typedef gint (*GtkAssistantPageFunc) (gint current_page, gpointer data);
 
 GType                 gtk_assistant_get_type              (void) G_GNUC_CONST;
 GtkWidget            *gtk_assistant_new                   (void);
+void                  gtk_assistant_next_page             (GtkAssistant         *assistant);
+void                  gtk_assistant_previous_page         (GtkAssistant         *assistant);
 gint                  gtk_assistant_get_current_page      (GtkAssistant         *assistant);
 void                  gtk_assistant_set_current_page      (GtkAssistant         *assistant,
 							   gint                  page_num);



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