[gtk+/wip/baedert/drawing: 52/348] expander: Remove gadget



commit 949d9930c54169346e8ce5addeb5ad7949cd2917
Author: Timm Bäder <mail baedert org>
Date:   Thu May 4 08:28:31 2017 +0200

    expander: Remove gadget

 gtk/gtkexpander.c |   74 +++++++++++++++++++---------------------------------
 1 files changed, 27 insertions(+), 47 deletions(-)
---
diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c
index 8aa6ea3..e8daf07 100644
--- a/gtk/gtkexpander.c
+++ b/gtk/gtkexpander.c
@@ -119,8 +119,6 @@
 #include "gtkdnd.h"
 #include "a11y/gtkexpanderaccessible.h"
 #include "gtkstylecontextprivate.h"
-#include "gtkcsscustomgadgetprivate.h"
-#include "gtkboxgadgetprivate.h"
 #include "gtkbuiltiniconprivate.h"
 #include "gtkwidgetprivate.h"
 #include "gtkcontainerprivate.h"
@@ -145,7 +143,7 @@ struct _GtkExpanderPrivate
 {
   GtkWidget        *label_widget;
 
-  GtkCssGadget     *gadget;
+  GtkWidget        *box;
   GtkWidget        *title_widget;
   GtkWidget        *arrow_widget;
 
@@ -175,9 +173,6 @@ static void gtk_expander_get_property (GObject          *object,
 static void     gtk_expander_destroy        (GtkWidget        *widget);
 static void     gtk_expander_size_allocate  (GtkWidget        *widget,
                                              GtkAllocation    *allocation);
-static void     gtk_expander_snapshot       (GtkWidget        *widget,
-                                             GtkSnapshot      *snapshot);
-
 static gboolean gtk_expander_enter_notify   (GtkWidget        *widget,
                                              GdkEventCrossing *event);
 static gboolean gtk_expander_leave_notify   (GtkWidget        *widget,
@@ -242,7 +237,7 @@ gtk_expander_finalize (GObject *obj)
 {
   GtkExpanderPrivate *priv = gtk_expander_get_instance_private (GTK_EXPANDER (obj));
 
-  gtk_widget_unparent (priv->title_widget);
+  gtk_widget_unparent (priv->box);
 
   G_OBJECT_CLASS (gtk_expander_parent_class)->finalize (obj);
 }
@@ -264,7 +259,6 @@ gtk_expander_class_init (GtkExpanderClass *klass)
 
   widget_class->destroy              = gtk_expander_destroy;
   widget_class->size_allocate        = gtk_expander_size_allocate;
-  widget_class->snapshot             = gtk_expander_snapshot;
   widget_class->enter_notify_event   = gtk_expander_enter_notify;
   widget_class->leave_notify_event   = gtk_expander_leave_notify;
   widget_class->focus                = gtk_expander_focus;
@@ -359,7 +353,6 @@ static void
 gtk_expander_init (GtkExpander *expander)
 {
   GtkExpanderPrivate *priv;
-  GtkCssNode *widget_node;
 
   expander->priv = priv = gtk_expander_get_instance_private (expander);
 
@@ -377,14 +370,13 @@ gtk_expander_init (GtkExpander *expander)
   priv->expand_timer = 0;
   priv->resize_toplevel = 0;
 
-  widget_node = gtk_widget_get_css_node (GTK_WIDGET (expander));
-  priv->gadget = gtk_box_gadget_new_for_node (widget_node, GTK_WIDGET (expander));
-  gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->gadget), GTK_ORIENTATION_VERTICAL);
+  priv->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+  gtk_widget_set_parent (priv->box, GTK_WIDGET (expander));
+
   priv->title_widget = g_object_new (GTK_TYPE_BOX,
                                      "css-name", "title",
                                      NULL);
-  gtk_widget_set_parent (priv->title_widget, GTK_WIDGET (expander));
-  gtk_box_gadget_insert_widget (GTK_BOX_GADGET (priv->gadget), -1, priv->title_widget);
+  gtk_container_add (GTK_CONTAINER (priv->box), priv->title_widget);
 
   priv->arrow_widget = gtk_icon_new ("arrow");
   gtk_style_context_add_class (gtk_widget_get_style_context (priv->arrow_widget),
@@ -518,8 +510,6 @@ gtk_expander_destroy (GtkWidget *widget)
   g_clear_object (&priv->multipress_gesture);
 
   GTK_WIDGET_CLASS (gtk_expander_parent_class)->destroy (widget);
-
-  g_clear_object (&priv->gadget);
 }
 
 static void
@@ -527,26 +517,15 @@ gtk_expander_size_allocate (GtkWidget     *widget,
                             GtkAllocation *allocation)
 {
   GtkExpanderPrivate *priv = GTK_EXPANDER (widget)->priv;
-  GtkAllocation clip;
-
-  gtk_widget_set_allocation (widget, allocation);
-
-  gtk_css_gadget_allocate (priv->gadget,
-                           allocation,
-                           gtk_widget_get_allocated_baseline (widget),
-                           &clip);
+  GtkAllocation clip = *allocation;
 
+  gtk_widget_size_allocate_with_baseline (priv->box, allocation,
+                                          gtk_widget_get_allocated_baseline (widget));
+  gtk_widget_get_clip (priv->box, &clip);
   gtk_widget_set_clip (widget, &clip);
 }
 
 static void
-gtk_expander_snapshot (GtkWidget   *widget,
-                       GtkSnapshot *snapshot)
-{
-  gtk_css_gadget_snapshot (GTK_EXPANDER (widget)->priv->gadget, snapshot);
-}
-
-static void
 gesture_multipress_pressed_cb (GtkGestureMultiPress *gesture,
                                gint                  n_press,
                                gdouble               x,
@@ -906,13 +885,10 @@ gtk_expander_add (GtkContainer *container,
                   GtkWidget    *widget)
 {
   GtkExpander *expander = GTK_EXPANDER (container);
+  GtkExpanderPrivate *priv = gtk_expander_get_instance_private (expander);
 
-  GTK_CONTAINER_CLASS (gtk_expander_parent_class)->add (container, widget);
-
-  gtk_widget_queue_resize (GTK_WIDGET (container));
-
-  if (expander->priv->expanded)
-    gtk_box_gadget_insert_widget (GTK_BOX_GADGET (expander->priv->gadget), -1, widget);
+  if (priv->expanded)
+    gtk_container_add (GTK_CONTAINER (priv->box), widget);
 }
 
 static void
@@ -920,12 +896,13 @@ gtk_expander_remove (GtkContainer *container,
                      GtkWidget    *widget)
 {
   GtkExpander *expander = GTK_EXPANDER (container);
+  GtkExpanderPrivate *priv = gtk_expander_get_instance_private (expander);
 
-  if (GTK_EXPANDER (expander)->priv->label_widget == widget)
+  if (priv->label_widget == widget)
     gtk_expander_set_label_widget (expander, NULL);
   else
     {
-      gtk_box_gadget_remove_widget (GTK_BOX_GADGET (expander->priv->gadget), widget);
+      gtk_container_remove (GTK_CONTAINER (priv->box), widget);
       GTK_CONTAINER_CLASS (gtk_expander_parent_class)->remove (container, widget);
     }
 }
@@ -945,11 +922,14 @@ gtk_expander_measure (GtkWidget      *widget,
                       int            *minimum_baseline,
                       int            *natural_baseline)
 {
-  gtk_css_gadget_get_preferred_size (GTK_EXPANDER (widget)->priv->gadget,
-                                     orientation,
-                                     for_size,
-                                     minimum, natural,
-                                     minimum_baseline, natural_baseline);
+  GtkExpander *expander = GTK_EXPANDER (widget);
+  GtkExpanderPrivate *priv = gtk_expander_get_instance_private (expander);
+
+  gtk_widget_measure (priv->box,
+                       orientation,
+                       for_size,
+                       minimum, natural,
+                       minimum_baseline, natural_baseline);
 }
 
 /**
@@ -1029,11 +1009,11 @@ gtk_expander_set_expanded (GtkExpander *expander,
   if (child)
     {
       if (priv->expanded)
-        gtk_box_gadget_insert_widget (GTK_BOX_GADGET (priv->gadget), 1, child);
+        gtk_container_add (GTK_CONTAINER (priv->box), child);
       else
-        gtk_box_gadget_remove_widget (GTK_BOX_GADGET (priv->gadget), child);
+        gtk_container_remove (GTK_CONTAINER (priv->box), child);
+      /* TODO: Yeah, I don't think this will work... */
 
-      gtk_widget_queue_resize (GTK_WIDGET (expander));
       gtk_expander_resize_toplevel (expander);
     }
 


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