[gtk+] GtkAssistant: Redo page margins



commit 6cc65260f4ba54ea0ca9f93068050435bd6b9f1a
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jun 14 21:04:15 2015 -0400

    GtkAssistant: Redo page margins
    
    Instead of having padding outside the notebook containing
    all pages, put each page in an extra box and add the padding
    there. This is in preparation for allowing pages without
    padding.

 gtk/gtkassistant.c |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c
index e1a5244..21746a9 100644
--- a/gtk/gtkassistant.c
+++ b/gtk/gtkassistant.c
@@ -1109,8 +1109,8 @@ on_page_notify_visibility (GtkWidget  *widget,
 }
 
 static void
-assistant_remove_page_cb (GtkNotebook *notebook,
-                          GtkWidget *page,
+assistant_remove_page_cb (GtkNotebook  *notebook,
+                          GtkWidget    *page,
                           GtkAssistant *assistant)
 {
   GtkAssistantPrivate *priv = assistant->priv;
@@ -1118,6 +1118,15 @@ assistant_remove_page_cb (GtkNotebook *notebook,
   GList *page_node;
   GList *element;
 
+  if (GTK_IS_BOX (page))
+    {
+      GList *children;
+
+      children = gtk_container_get_children (GTK_CONTAINER (page));
+      page = GTK_WIDGET (children->data);
+      g_list_free (children);
+    }
+
   element = find_page (assistant, page);
   if (!element)
     return;
@@ -1445,12 +1454,14 @@ gtk_assistant_remove (GtkContainer *container,
                       GtkWidget    *page)
 {
   GtkAssistant *assistant = (GtkAssistant*) container;
+  GtkWidget *box;
 
   /* Forward this removal to the content notebook */
-  if (gtk_widget_get_parent (page) == assistant->priv->content)
+  box = gtk_widget_get_parent (page);
+  if (gtk_widget_get_parent (box) == assistant->priv->content)
     {
       container = (GtkContainer *) assistant->priv->content;
-      gtk_container_remove (container, page);
+      gtk_container_remove (container, box);
     }
 }
 
@@ -1743,6 +1754,7 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
   GtkAssistantPage *page_info;
   gint n_pages;
   GtkStyleContext *context;
+  GtkWidget *box;
 
   g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
   g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
@@ -1785,7 +1797,12 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
   gtk_box_reorder_child (GTK_BOX (priv->sidebar), page_info->regular_title, 2 * position);
   gtk_box_reorder_child (GTK_BOX (priv->sidebar), page_info->current_title, 2 * position + 1);
 
-  gtk_notebook_insert_page (GTK_NOTEBOOK (priv->content), page, NULL, position);
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  gtk_widget_show (box);
+  gtk_box_pack_start (GTK_BOX (box), page, TRUE, TRUE, 0);
+  g_object_set (box, "margin", 12, NULL);
+
+  gtk_notebook_insert_page (GTK_NOTEBOOK (priv->content), box, NULL, position);
 
   if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
     {


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