[gtk+/wip/baedert/drawing: 118/262] paned: Remove gadget



commit 3bcf7be6f7ebf5af946d1e2bd586d0a346d83a7c
Author: Timm Bäder <mail baedert org>
Date:   Fri May 5 10:20:58 2017 +0200

    paned: Remove gadget

 gtk/gtkpaned.c |   82 +++++++++++--------------------------------------------
 1 files changed, 17 insertions(+), 65 deletions(-)
---
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index 197931f..22daf2d 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -135,7 +135,6 @@ struct _GtkPanedPrivate
   GdkRectangle   handle_pos;
   GdkWindow     *handle;
 
-  GtkCssGadget  *gadget;
   GtkCssGadget  *handle_gadget;
 
   GtkGesture    *pan_gesture;  /* Used for touch */
@@ -203,7 +202,7 @@ static void     gtk_paned_get_child_property    (GtkContainer     *container,
                                                  GValue           *value,
                                                  GParamSpec       *pspec);
 static void     gtk_paned_finalize              (GObject          *object);
-static void     gtk_paned_measure_ (GtkWidget *widget,
+static void     gtk_paned_measure (GtkWidget *widget,
                                    GtkOrientation  orientation,
                                    int             for_size,
                                    int            *minimum,
@@ -312,7 +311,7 @@ gtk_paned_class_init (GtkPanedClass *class)
   object_class->get_property = gtk_paned_get_property;
   object_class->finalize = gtk_paned_finalize;
 
-  widget_class->measure = gtk_paned_measure_;
+  widget_class->measure = gtk_paned_measure;
   widget_class->size_allocate = gtk_paned_size_allocate;
   widget_class->realize = gtk_paned_realize;
   widget_class->unrealize = gtk_paned_unrealize;
@@ -684,7 +683,7 @@ initiates_touch_drag (GtkPaned *paned,
   GtkAllocation allocation;
 
 #define TOUCH_EXTRA_AREA_WIDTH 50
-  gtk_css_gadget_get_content_allocation (priv->gadget, &allocation, NULL);
+  gtk_widget_get_content_allocation (GTK_WIDGET (paned), &allocation);
   gtk_css_gadget_get_preferred_size (priv->handle_gadget,
                                      priv->orientation,
                                      -1,
@@ -727,7 +726,7 @@ gesture_drag_begin_cb (GtkGestureDrag *gesture,
   sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
   event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
   device = gdk_event_get_source_device (event);
-  gtk_css_gadget_get_content_allocation (priv->gadget, &allocation, NULL);
+  gtk_widget_get_content_allocation (GTK_WIDGET (paned), &allocation);
   paned->priv->panning = FALSE;
 
   is_touch = (event->type == GDK_TOUCH_BEGIN ||
@@ -962,7 +961,6 @@ gtk_paned_finalize (GObject *object)
   g_clear_object (&paned->priv->drag_gesture);
 
   g_clear_object (&paned->priv->handle_gadget);
-  g_clear_object (&paned->priv->gadget);
 
   G_OBJECT_CLASS (gtk_paned_parent_class)->finalize (object);
 }
@@ -1139,39 +1137,21 @@ gtk_paned_get_preferred_size_for_opposite_orientation (GtkWidget      *widget,
 }
 
 static void
-gtk_paned_measure (GtkCssGadget   *gadget,
+gtk_paned_measure (GtkWidget *widget,
                    GtkOrientation  orientation,
-                   int             size,
+                   int             for_size,
                    int            *minimum,
                    int            *natural,
                    int            *minimum_baseline,
-                   int            *natural_baseline,
-                   gpointer        data)
+                   int            *natural_baseline)
 {
-  GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
   GtkPaned *paned = GTK_PANED (widget);
   GtkPanedPrivate *priv = paned->priv;
 
   if (orientation == priv->orientation)
-    gtk_paned_get_preferred_size_for_orientation (widget, size, minimum, natural);
+    gtk_paned_get_preferred_size_for_orientation (widget, for_size, minimum, natural);
   else
-    gtk_paned_get_preferred_size_for_opposite_orientation (widget, size, minimum, natural);
-}
-
-static void
-gtk_paned_measure_ (GtkWidget *widget,
-                   GtkOrientation  orientation,
-                   int             for_size,
-                   int            *minimum,
-                   int            *natural,
-                   int            *minimum_baseline,
-                   int            *natural_baseline)
-{
-  gtk_css_gadget_get_preferred_size (GTK_PANED (widget)->priv->gadget,
-                                     orientation,
-                                     for_size,
-                                     minimum, natural,
-                                     minimum_baseline, natural_baseline);
+    gtk_paned_get_preferred_size_for_opposite_orientation (widget, for_size, minimum, natural);
 }
 
 static void
@@ -1208,29 +1188,7 @@ gtk_paned_size_allocate (GtkWidget     *widget,
 {
   GtkPaned *paned = GTK_PANED (widget);
   GtkPanedPrivate *priv = paned->priv;
-  GtkAllocation clip;
-
-  gtk_widget_set_allocation (widget, allocation);
-
-  gtk_css_gadget_allocate (priv->gadget,
-                           allocation,
-                           gtk_widget_get_allocated_baseline (widget),
-                           &clip);
-
-  gtk_widget_set_clip (widget, &clip);
-}
-
-static void
-gtk_paned_allocate (GtkCssGadget        *gadget,
-                    const GtkAllocation *allocation,
-                    int                  baseline,
-                    GtkAllocation       *out_clip,
-                    gpointer             data)
-{
-  GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
-  GtkPaned *paned = GTK_PANED (widget);
-  GtkPanedPrivate *priv = paned->priv;
-  GtkAllocation clip = { 0 };
+  GtkAllocation clip = *allocation;
 
   if (priv->child1 && gtk_widget_get_visible (priv->child1) &&
       priv->child2 && gtk_widget_get_visible (priv->child2))
@@ -1423,8 +1381,9 @@ gtk_paned_allocate (GtkCssGadget        *gadget,
         }
     }
 
-  gtk_container_get_children_clip (GTK_CONTAINER (paned), out_clip);
-  gdk_rectangle_union (out_clip, &clip, out_clip);
+  gtk_container_get_children_clip (GTK_CONTAINER (paned), &clip);
+
+  gtk_widget_set_clip (widget, &clip);
 }
 
 static void
@@ -1614,7 +1573,6 @@ gtk_paned_init (GtkPaned *paned)
 {
   GtkPanedPrivate *priv;
   GtkGesture *gesture;
-  GtkCssNode *widget_node;
 
   gtk_widget_set_has_window (GTK_WIDGET (paned), FALSE);
   gtk_widget_set_can_focus (GTK_WIDGET (paned), TRUE);
@@ -1664,23 +1622,17 @@ gtk_paned_init (GtkPaned *paned)
   connect_drag_gesture_signals (paned, gesture);
   priv->drag_gesture = gesture;
 
-  widget_node = gtk_widget_get_css_node (GTK_WIDGET (paned));
-  priv->gadget = gtk_css_custom_gadget_new_for_node (widget_node,
-                                                     GTK_WIDGET (paned),
-                                                     gtk_paned_measure,
-                                                     gtk_paned_allocate,
-                                                     NULL,
-                                                     NULL,
-                                                     NULL);
   priv->handle_gadget = gtk_css_custom_gadget_new ("separator",
                                                    GTK_WIDGET (paned),
-                                                   priv->gadget,
+                                                   NULL,
                                                    NULL,
                                                    NULL,
                                                    NULL,
                                                    gtk_paned_render_handle,
                                                    NULL,
                                                    NULL);
+  gtk_css_node_set_parent (gtk_css_gadget_get_node (priv->handle_gadget),
+                           gtk_widget_get_css_node (GTK_WIDGET (paned)));
   update_node_state (GTK_WIDGET (paned));
 }
 
@@ -1711,7 +1663,7 @@ update_drag (GtkPaned *paned,
   gint x, y;
 
   gdk_window_get_position (priv->handle, &x, &y);
-  gtk_css_gadget_get_content_allocation (priv->gadget, &allocation, NULL);
+  gtk_widget_get_content_allocation (GTK_WIDGET (paned), &allocation);
   if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
     pos = xpos;
   else


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