[gtk+/wip/csoriano/pathbar-prototype] trying more things with destroy()....



commit d505d673ffd2ac22597ae3f21089ed5ed07f9d4c
Author: Carlos Soriano <csoriano gnome org>
Date:   Thu Nov 12 11:16:10 2015 +0100

    trying more things with destroy()....

 gtk/gtkpathbarcontainer.c |   36 ++++++++++++++++++++++++++++++++++--
 tests/testpathbar.c       |    2 ++
 2 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkpathbarcontainer.c b/gtk/gtkpathbarcontainer.c
index a7ab9a6..3c2b262 100644
--- a/gtk/gtkpathbarcontainer.c
+++ b/gtk/gtkpathbarcontainer.c
@@ -27,6 +27,7 @@
 #include "gtksizerequest.h"
 #include "gtkhidingboxprivate.h"
 #include "gtkwidgetprivate.h"
+#include "glib-object.h"
 
 struct _GtkPathBarContainerPrivate
 {
@@ -67,8 +68,19 @@ container_forall (GtkContainer *container,
 {
   GtkPathBarContainerPrivate *priv = gtk_path_bar_container_get_instance_private (GTK_PATH_BAR_CONTAINER 
(container));
 
-  (* callback) (priv->overflow_button, callback_data);
-  (* callback) (priv->path_box, callback_data);
+  if (include_internals)
+    {
+      (* callback) (priv->overflow_button, callback_data);
+      (* callback) (priv->path_box, callback_data);
+    }
+}
+
+static void
+container_remove (GtkContainer *container,
+                  GtkWidget    *widget)
+{
+  g_print ("container remove\n");
+  gtk_widget_unparent (widget);
 }
 
 static GtkSizeRequestMode
@@ -172,6 +184,24 @@ get_preferred_height (GtkWidget *self,
 }
 
 static void
+widget_destroy (GtkWidget *object)
+{
+  GtkPathBarContainerPrivate *priv = gtk_path_bar_container_get_instance_private (GTK_PATH_BAR_CONTAINER 
(object));
+
+  if (priv->overflow_button && priv->path_box)
+    {
+      g_print ("## internal destroy\n");
+      gtk_widget_unparent (priv->overflow_button);
+      gtk_widget_unparent (priv->path_box);
+
+      priv->overflow_button = NULL;
+      priv->path_box = NULL;
+    }
+
+  GTK_WIDGET_CLASS (gtk_path_bar_container_parent_class)->destroy (object);
+}
+
+static void
 gtk_path_bar_container_class_init (GtkPathBarContainerClass *klass)
 {
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
@@ -181,9 +211,11 @@ gtk_path_bar_container_class_init (GtkPathBarContainerClass *klass)
   widget_class->get_preferred_width = get_preferred_width;
   widget_class->get_preferred_height = get_preferred_height;
   widget_class->size_allocate = size_allocate;
+  widget_class->destroy = widget_destroy;
 
   // Neccesary to draw and realize children
   container_class->forall = container_forall;
+  container_class->remove = container_remove;
 }
 
 static void
diff --git a/tests/testpathbar.c b/tests/testpathbar.c
index 4ddc3c2..f05d011 100644
--- a/tests/testpathbar.c
+++ b/tests/testpathbar.c
@@ -130,6 +130,7 @@ main (int argc, char *argv[])
                     G_CALLBACK (on_path_selected), window);
   path_bars = g_list_append (path_bars, path_bar);
 
+  /*
   path_bar = gtk_path_bar_new ();
   gtk_container_add (GTK_CONTAINER (box), path_bar);
   gtk_path_bar_set_hide_direction (GTK_PATH_BAR (path_bar), GTK_DIR_LEFT);
@@ -150,6 +151,7 @@ main (int argc, char *argv[])
                     G_CALLBACK (on_path_selected_set_path), window);
   path_bars = g_list_append (path_bars, path_bar);
 
+   */
   reset_button = gtk_button_new_with_label ("Reset State");
   gtk_widget_set_hexpand (reset_button, TRUE);
   gtk_container_add (GTK_CONTAINER (box), reset_button);


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