[gtk/assistant-cleanup: 3/4] assistant: Use a stack



commit d327d3fab232eda14acc5d0610845f9c679bc5c4
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Feb 14 14:07:46 2019 -0500

    assistant: Use a stack
    
    We don't use any non-stack features of the notebook here.

 gtk/gtkassistant.c     | 25 +++++++++++++++----------
 gtk/ui/gtkassistant.ui |  4 +---
 2 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c
index f5a275260b..b78089e0fe 100644
--- a/gtk/gtkassistant.c
+++ b/gtk/gtkassistant.c
@@ -74,7 +74,7 @@
 #include "gtkintl.h"
 #include "gtkimage.h"
 #include "gtklabel.h"
-#include "gtknotebook.h"
+#include "gtkstack.h"
 #include "gtkprivate.h"
 #include "gtksettings.h"
 #include "gtksizegroup.h"
@@ -967,7 +967,7 @@ set_current_page (GtkAssistant *assistant,
 
   gtk_window_set_title (GTK_WINDOW (assistant), priv->current_page->title);
 
-  gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->content), page_num);
+  gtk_stack_set_visible_child (GTK_STACK (priv->content), priv->current_page->box);
 
   /* update buttons state, flow may have changed */
   if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
@@ -1348,13 +1348,15 @@ gtk_assistant_destroy (GtkWidget *widget)
 
   if (priv->content)
     {
-      GtkNotebook *notebook;
-      GtkWidget *page;
+      GList *children, *l;
 
-      /* Remove all pages from the content notebook. */
-      notebook = (GtkNotebook *) priv->content;
-      while ((page = gtk_notebook_get_nth_page (notebook, 0)) != NULL)
-        gtk_container_remove ((GtkContainer *) notebook, page);
+      children = gtk_container_get_children (GTK_CONTAINER (priv->content));
+      for (l = children; l; l = l->next)
+        {
+          GtkWidget *page = l->data;
+          gtk_container_remove (GTK_CONTAINER (priv->content), page);
+        }
+      g_list_free (children);
 
       /* Our GtkAssistantPage list should be empty now. */
       g_warn_if_fail (priv->pages == NULL);
@@ -1500,7 +1502,7 @@ gtk_assistant_remove (GtkContainer *container,
   GtkAssistant *assistant = (GtkAssistant*) container;
   GtkWidget *box;
 
-  /* Forward this removal to the content notebook */
+  /* Forward this removal to the content stack */
   box = gtk_widget_get_parent (page);
   if (GTK_IS_BOX (box) &&
       assistant->priv->content != NULL &&
@@ -1806,6 +1808,7 @@ gtk_assistant_add_page (GtkAssistant *assistant,
   GtkStyleContext *context;
   GtkWidget *box;
   GtkWidget *sibling;
+  char *name;
 
   page_info->regular_title = gtk_label_new (page_info->title);
   page_info->current_title = gtk_label_new (page_info->title);
@@ -1857,7 +1860,9 @@ gtk_assistant_add_page (GtkAssistant *assistant,
   g_object_set (box, "margin", 12, NULL);
   g_signal_connect (box, "remove", G_CALLBACK (assistant_remove_page_cb), assistant);
 
-  gtk_notebook_insert_page (GTK_NOTEBOOK (priv->content), box, NULL, position);
+  name = g_strdup_printf ("page%d", position);
+  gtk_stack_add_named (GTK_STACK (priv->content), box, name);
+  g_free (name);
 
   page_info->box = box;
 
diff --git a/gtk/ui/gtkassistant.ui b/gtk/ui/gtkassistant.ui
index d519a79ce9..f39fbf494b 100644
--- a/gtk/ui/gtkassistant.ui
+++ b/gtk/ui/gtkassistant.ui
@@ -18,10 +18,8 @@
             <property name="orientation">vertical</property>
             <property name="hexpand">1</property>
             <child>
-              <object class="GtkNotebook" id="content">
+              <object class="GtkStack" id="content">
                 <property name="can-focus">1</property>
-                <property name="show-tabs">0</property>
-                <property name="show-border">0</property>
                 <property name="vexpand">1</property>
                 <signal name="remove" handler="assistant_remove_page_cb" swapped="no"/>
                 <child type="tab"/>


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