[gtk+/wip/baedert/drawing: 42/99] headerbar: Remove gadget



commit 1c3ac936038338f6bc4ce097db809d9e649c810f
Author: Timm Bäder <mail baedert org>
Date:   Wed May 3 19:44:52 2017 +0200

    headerbar: Remove gadget
    
    both drawing and sizing are done through GtkWidget now.

 gtk/gtkheaderbar.c |   72 ++++++++-------------------------------------------
 1 files changed, 12 insertions(+), 60 deletions(-)
---
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index c325b0b..af8f8a0 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -878,26 +878,6 @@ gtk_header_bar_compute_size_for_opposing_orientation (GtkWidget *widget,
 }
 
 static void
-gtk_header_bar_get_content_size (GtkCssGadget   *gadget,
-                                 GtkOrientation  orientation,
-                                 gint            for_size,
-                                 gint           *minimum,
-                                 gint           *natural,
-                                 gint           *minimum_baseline,
-                                 gint           *natural_baseline,
-                                 gpointer        unused)
-{
-  GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
-
-  if (for_size < 0)
-    gtk_header_bar_get_size (widget, orientation, minimum, natural);
-  else if (orientation == GTK_ORIENTATION_HORIZONTAL)
-    gtk_header_bar_compute_size_for_orientation (widget, for_size, minimum, natural);
-  else
-    gtk_header_bar_compute_size_for_opposing_orientation (widget, for_size, minimum, natural);
-}
-
-static void
 gtk_header_bar_measure (GtkWidget      *widget,
                         GtkOrientation  orientation,
                         int             for_size,
@@ -906,13 +886,12 @@ gtk_header_bar_measure (GtkWidget      *widget,
                         int            *minimum_baseline,
                         int            *natural_baseline)
 {
-  GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (GTK_HEADER_BAR (widget));
-
-  gtk_css_gadget_get_preferred_size (priv->gadget,
-                                     orientation,
-                                     for_size,
-                                     minimum, natural,
-                                     minimum_baseline, natural_baseline);
+  if (for_size < 0)
+    gtk_header_bar_get_size (widget, orientation, minimum, natural);
+  else if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    gtk_header_bar_compute_size_for_orientation (widget, for_size, minimum, natural);
+  else
+    gtk_header_bar_compute_size_for_opposing_orientation (widget, for_size, minimum, natural);
 }
 
 static void
@@ -921,25 +900,8 @@ gtk_header_bar_size_allocate (GtkWidget     *widget,
 {
   GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (GTK_HEADER_BAR (widget));
   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_header_bar_allocate_contents (GtkCssGadget        *gadget,
-                                  const GtkAllocation *allocation,
-                                  int                  baseline,
-                                  GtkAllocation       *out_clip,
-                                  gpointer             unused)
-{
-  GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
   GtkWidget *title_widget;
   GtkHeaderBar *bar = GTK_HEADER_BAR (widget);
-  GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
   GtkRequestedSize *sizes;
   gint width, height;
   gint nvis_children;
@@ -1138,7 +1100,7 @@ gtk_header_bar_allocate_contents (GtkCssGadget        *gadget,
 
           gtk_widget_size_allocate (child->widget, &child_allocation);
           gtk_widget_get_clip (child->widget, &child_clip);
-          gdk_rectangle_union (&child_clip, out_clip, out_clip);
+          gdk_rectangle_union (&child_clip, &clip, &clip);
 
         next:
           i++;
@@ -1177,7 +1139,7 @@ gtk_header_bar_allocate_contents (GtkCssGadget        *gadget,
     {
       gtk_widget_size_allocate (title_widget, &child_allocation);
       gtk_widget_get_clip (title_widget, &child_clip);
-      gdk_rectangle_union (&child_clip, out_clip, out_clip);
+      gdk_rectangle_union (&child_clip, &clip, &clip);
     }
 
   child_allocation.y = allocation->y;
@@ -1193,7 +1155,7 @@ gtk_header_bar_allocate_contents (GtkCssGadget        *gadget,
       child_allocation.width = start_width - priv->spacing;
       gtk_widget_size_allocate (priv->titlebar_start_box, &child_allocation);
       gtk_widget_get_clip (priv->titlebar_start_box, &child_clip);
-      gdk_rectangle_union (&child_clip, out_clip, out_clip);
+      gdk_rectangle_union (&child_clip, &clip, &clip);
     }
 
   if (priv->titlebar_end_box)
@@ -1206,8 +1168,10 @@ gtk_header_bar_allocate_contents (GtkCssGadget        *gadget,
       child_allocation.width = end_width - priv->spacing;
       gtk_widget_size_allocate (priv->titlebar_end_box, &child_allocation);
       gtk_widget_get_clip (priv->titlebar_end_box, &child_clip);
-      gdk_rectangle_union (&child_clip, out_clip, out_clip);
+      gdk_rectangle_union (&child_clip, &clip, &clip);
     }
+
+  gtk_widget_set_clip (widget, &clip);
 }
 
 /**
@@ -1467,8 +1431,6 @@ gtk_header_bar_finalize (GObject *object)
   g_free (priv->subtitle);
   g_free (priv->decoration_layout);
 
-  g_clear_object (&priv->gadget);
-
   G_OBJECT_CLASS (gtk_header_bar_parent_class)->finalize (object);
 }
 
@@ -2019,7 +1981,6 @@ static void
 gtk_header_bar_init (GtkHeaderBar *bar)
 {
   GtkHeaderBarPrivate *priv;
-  GtkCssNode *widget_node;
 
   priv = gtk_header_bar_get_instance_private (bar);
 
@@ -2038,15 +1999,6 @@ gtk_header_bar_init (GtkHeaderBar *bar)
 
   init_sizing_box (bar);
   construct_label_box (bar);
-
-  widget_node = gtk_widget_get_css_node (GTK_WIDGET (bar));
-  priv->gadget = gtk_css_custom_gadget_new_for_node (widget_node,
-                                                     GTK_WIDGET (bar),
-                                                     gtk_header_bar_get_content_size,
-                                                     gtk_header_bar_allocate_contents,
-                                                     NULL,
-                                                     NULL,
-                                                     NULL);
 }
 
 static void


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