[gtk+/wip/baedert/drawing: 104/396] scrolledwindow: Remove gadget



commit 2f8644a6aee8ee5209af9ac66276907cb1d50d15
Author: Timm Bäder <mail baedert org>
Date:   Thu May 4 21:50:51 2017 +0200

    scrolledwindow: Remove gadget

 gtk/gtkscrolledwindow.c |   89 ++++++++++++----------------------------------
 1 files changed, 23 insertions(+), 66 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 61615d4..9e5a113 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -29,7 +29,6 @@
 #include "gtkadjustment.h"
 #include "gtkadjustmentprivate.h"
 #include "gtkbindings.h"
-#include "gtkcsscustomgadgetprivate.h"
 #include "gtkdnd.h"
 #include "gtkintl.h"
 #include "gtkmain.h"
@@ -207,7 +206,6 @@ struct _GtkScrolledWindowPrivate
   GtkWidget     *hscrollbar;
   GtkWidget     *vscrollbar;
 
-  GtkCssGadget  *gadget;
   GtkCssNode    *overshoot_node[4];
   GtkCssNode    *undershoot_node[4];
 
@@ -345,14 +343,13 @@ static void     gtk_scrolled_window_adjustment_changed (GtkAdjustment     *adjus
 static void     gtk_scrolled_window_adjustment_value_changed (GtkAdjustment     *adjustment,
                                                               gpointer           data);
 static gboolean gtk_widget_should_animate              (GtkWidget           *widget);
-
-static void gtk_scrolled_window_measure_ (GtkWidget      *widget,
-                                          GtkOrientation  orientation,
-                                          int             for_size,
-                                          int            *minimum,
-                                          int            *natural,
-                                          int            *minimum_baseline,
-                                          int            *natural_baseline);
+static void     gtk_scrolled_window_measure (GtkWidget      *widget,
+                                             GtkOrientation  orientation,
+                                             int             for_size,
+                                             int            *minimum_size,
+                                             int            *natural_size,
+                                             int            *minimum_baseline,
+                                             int            *natural_baseline);
 static void  gtk_scrolled_window_map                   (GtkWidget           *widget);
 static void  gtk_scrolled_window_unmap                 (GtkWidget           *widget);
 static void  gtk_scrolled_window_realize               (GtkWidget           *widget);
@@ -513,7 +510,7 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
   widget_class->size_allocate = gtk_scrolled_window_size_allocate;
   widget_class->scroll_event = gtk_scrolled_window_scroll_event;
   widget_class->focus = gtk_scrolled_window_focus;
-  widget_class->measure = gtk_scrolled_window_measure_;
+  widget_class->measure = gtk_scrolled_window_measure;
   widget_class->map = gtk_scrolled_window_map;
   widget_class->unmap = gtk_scrolled_window_unmap;
   widget_class->grab_notify = gtk_scrolled_window_grab_notify;
@@ -1355,13 +1352,9 @@ captured_event_cb (GtkWidget *widget,
 }
 
 static void
-gtk_scrolled_window_allocate (GtkCssGadget        *gadget,
-                              const GtkAllocation *allocation,
-                              int                  baseline,
-                              GtkAllocation       *out_clip,
-                              gpointer             data)
+gtk_scrolled_window_size_allocate (GtkWidget     *widget,
+                                   GtkAllocation *allocation)
 {
-  GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
   GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
   GtkScrolledWindowPrivate *priv = scrolled_window->priv;
   GtkBin *bin;
@@ -1616,19 +1609,19 @@ gtk_scrolled_window_allocate (GtkCssGadget        *gadget,
     }
 
   gtk_scrolled_window_check_attach_pan_gesture (scrolled_window);
+
+  gtk_widget_set_clip (widget, allocation);
 }
 
 static void
-gtk_scrolled_window_measure (GtkCssGadget   *gadget,
+gtk_scrolled_window_measure (GtkWidget      *widget,
                              GtkOrientation  orientation,
                              int             for_size,
                              int            *minimum_size,
                              int            *natural_size,
                              int            *minimum_baseline,
-                             int            *natural_baseline,
-                             gpointer        data)
+                             int            *natural_baseline)
 {
-  GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
   GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
   GtkScrolledWindowPrivate *priv = scrolled_window->priv;
   GtkBin *bin = GTK_BIN (scrolled_window);
@@ -1942,12 +1935,6 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
   _gtk_widget_set_captured_event_handler (widget, captured_event_cb);
 
   widget_node = gtk_widget_get_css_node (widget);
-  priv->gadget = gtk_css_custom_gadget_new_for_node (widget_node,
-                                                     widget,
-                                                     gtk_scrolled_window_measure,
-                                                     gtk_scrolled_window_allocate,
-                                                     NULL,
-                                                     NULL, NULL);
   for (i = 0; i < 4; i++)
     {
       priv->overshoot_node[i] = gtk_css_node_new ();
@@ -2588,7 +2575,6 @@ gtk_scrolled_window_finalize (GObject *object)
   g_clear_object (&priv->swipe_gesture);
   g_clear_object (&priv->long_press_gesture);
   g_clear_object (&priv->pan_gesture);
-  g_clear_object (&priv->gadget);
   g_clear_pointer (&priv->scroll_history, (GDestroyNotify) g_array_unref);
 
   G_OBJECT_CLASS (gtk_scrolled_window_parent_class)->finalize (object);
@@ -2911,6 +2897,8 @@ gtk_scrolled_window_relative_allocation (GtkWidget     *widget,
   GtkScrolledWindowPrivate *priv;
   gint sb_width;
   gint sb_height;
+  GtkAllocation content_allocation;
+  GtkAllocation widget_allocation;
 
   g_return_if_fail (widget != NULL);
   g_return_if_fail (allocation != NULL);
@@ -2924,7 +2912,13 @@ gtk_scrolled_window_relative_allocation (GtkWidget     *widget,
   gtk_widget_measure (priv->hscrollbar, GTK_ORIENTATION_VERTICAL, -1,
                       &sb_height, NULL, NULL, NULL);
 
-  gtk_css_gadget_get_content_allocation (priv->gadget, allocation, NULL);
+  gtk_widget_get_content_allocation (widget, &content_allocation);
+  gtk_widget_get_allocation (widget, &widget_allocation);
+
+  allocation->x = content_allocation.x - widget_allocation.x;
+  allocation->y = content_allocation.y - widget_allocation.y;
+  allocation->width = content_allocation.width;
+  allocation->height = content_allocation.height;
 
   /* Subtract some things from our available allocation size */
   if (priv->vscrollbar_visible && !priv->use_indicators)
@@ -3092,27 +3086,6 @@ gtk_scrolled_window_allocate_scrollbar (GtkScrolledWindow *scrolled_window,
 }
 
 static void
-gtk_scrolled_window_size_allocate (GtkWidget     *widget,
-                                  GtkAllocation *allocation)
-{
-  GtkScrolledWindow *scrolled_window;
-  GtkScrolledWindowPrivate *priv;
-  GtkAllocation clip;
-
-  scrolled_window = GTK_SCROLLED_WINDOW (widget);
-  priv = scrolled_window->priv;
-
-  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
 install_scroll_cursor (GtkScrolledWindow *scrolled_window)
 {
   GdkDisplay *display;
@@ -3709,22 +3682,6 @@ gtk_scrolled_window_remove (GtkContainer *container,
   priv->auto_added_viewport = FALSE;
 }
 
-static void
-gtk_scrolled_window_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_SCROLLED_WINDOW (widget)->priv->gadget,
-                                     orientation,
-                                     for_size,
-                                     minimum, natural,
-                                     minimum_baseline, natural_baseline);
-}
-
 static gboolean
 gtk_widget_should_animate (GtkWidget *widget)
 {


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