[gtk+/wip/baedert/drawing: 37/143] toolbar: Remove gadget



commit 8b634688b0c4e0cda564b2f8f556ab00229d28f0
Author: Timm Bäder <mail baedert org>
Date:   Thu May 4 18:33:54 2017 +0200

    toolbar: Remove gadget

 gtk/gtktoolbar.c |   90 ++++++-----------------------------------------------
 1 files changed, 11 insertions(+), 79 deletions(-)
---
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index 1697fda..6a1e32e 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -39,7 +39,6 @@
 #include "gtkbindings.h"
 #include "gtkbox.h"
 #include "gtkcontainerprivate.h"
-#include "gtkcsscustomgadgetprivate.h"
 #include "gtkcssnodeprivate.h"
 #include "gtkimage.h"
 #include "gtkintl.h"
@@ -124,7 +123,6 @@ struct _GtkToolbarPrivate
 
   GdkWindow       *event_window;
 
-  GtkCssGadget    *gadget;
   GtkAllocation    prev_allocation;
 
   GList           *content;
@@ -199,13 +197,6 @@ static void       gtk_toolbar_snapshot             (GtkWidget           *widget,
                                                     GtkSnapshot         *snapshot);
 static void       gtk_toolbar_realize              (GtkWidget           *widget);
 static void       gtk_toolbar_unrealize            (GtkWidget           *widget);
-static void       gtk_toolbar_measure_             (GtkWidget      *widget,
-                                                    GtkOrientation  orientation,
-                                                    int             for_size,
-                                                    int            *minimum,
-                                                    int            *natural,
-                                                    int            *minimum_baseline,
-                                                    int            *natural_baseline);
 static void       gtk_toolbar_size_allocate        (GtkWidget           *widget,
                                                    GtkAllocation       *allocation);
 static void       gtk_toolbar_style_updated        (GtkWidget           *widget);
@@ -254,19 +245,13 @@ static void       gtk_toolbar_arrow_button_clicked (GtkWidget           *button,
 static gboolean   gtk_toolbar_popup_menu           (GtkWidget           *toolbar);
 static void       gtk_toolbar_reconfigured         (GtkToolbar          *toolbar);
 
-static void       gtk_toolbar_allocate             (GtkCssGadget        *gadget,
-                                                    const GtkAllocation *allocation,
-                                                    int                  baseline,
-                                                    GtkAllocation       *out_clip,
-                                                    gpointer             data);
-static void       gtk_toolbar_measure              (GtkCssGadget   *gadget,
+static void       gtk_toolbar_measure              (GtkWidget      *widget,
                                                     GtkOrientation  orientation,
                                                     int             for_size,
                                                     int            *minimum,
                                                     int            *natural,
                                                     int            *minimum_baseline,
-                                                    int            *natural_baseline,
-                                                    gpointer        data);
+                                                    int            *natural_baseline);
 static void       gtk_toolbar_pressed_cb           (GtkGestureMultiPress *gesture,
                                                     int                   n_press,
                                                     double                x,
@@ -393,7 +378,7 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
   gobject_class->dispose = gtk_toolbar_dispose;
   
   widget_class->snapshot = gtk_toolbar_snapshot;
-  widget_class->measure = gtk_toolbar_measure_;
+  widget_class->measure = gtk_toolbar_measure;
   widget_class->size_allocate = gtk_toolbar_size_allocate;
   widget_class->style_updated = gtk_toolbar_style_updated;
   widget_class->focus = gtk_toolbar_focus;
@@ -621,7 +606,6 @@ gtk_toolbar_init (GtkToolbar *toolbar)
 {
   GtkToolbarPrivate *priv;
   GtkWidget *widget;
-  GtkCssNode *widget_node;
 
   widget = GTK_WIDGET (toolbar);
   toolbar->priv = gtk_toolbar_get_instance_private (toolbar);
@@ -637,14 +621,6 @@ gtk_toolbar_init (GtkToolbar *toolbar)
 
   _gtk_orientable_set_style_classes (GTK_ORIENTABLE (toolbar));
 
-  widget_node = gtk_widget_get_css_node (widget);
-  priv->gadget = gtk_css_custom_gadget_new_for_node (widget_node,
-                                                     widget,
-                                                     gtk_toolbar_measure,
-                                                     gtk_toolbar_allocate,
-                                                     NULL,
-                                                     NULL, NULL);
-
   priv->arrow_button = gtk_toggle_button_new ();
   g_signal_connect (priv->arrow_button, "button-press-event",
                    G_CALLBACK (gtk_toolbar_arrow_button_press), toolbar);
@@ -826,16 +802,14 @@ gtk_toolbar_snapshot (GtkWidget   *widget,
 }
 
 static void
-gtk_toolbar_measure (GtkCssGadget   *gadget,
+gtk_toolbar_measure (GtkWidget      *widget,
                      GtkOrientation  orientation,
                      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);
   GtkToolbar *toolbar = GTK_TOOLBAR (widget);
   GtkToolbarPrivate *priv = toolbar->priv;
   GList *list;
@@ -943,26 +917,6 @@ gtk_toolbar_measure (GtkCssGadget   *gadget,
     }
 }
 
-static void
-gtk_toolbar_measure_ (GtkWidget      *widget,
-                      GtkOrientation  orientation,
-                      int             for_size,
-                      int            *minimum,
-                      int            *natural,
-                      int            *minimum_baseline,
-                      int            *natural_baseline)
-{
-  GtkToolbar *toolbar = GTK_TOOLBAR (widget);
-  GtkToolbarPrivate *priv = toolbar->priv;
-
-  gtk_css_gadget_get_preferred_size (priv->gadget,
-                                     orientation,
-                                     for_size,
-                                     minimum, natural,
-                                     minimum_baseline, natural_baseline);
-
-}
-
 static gint
 position (GtkToolbar *toolbar,
           gint        from,
@@ -1183,8 +1137,7 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
       g_source_set_name_by_id (priv->idle_id, "[gtk+] slide_idle_handler");
     }
 
-  gtk_css_gadget_get_content_allocation (priv->gadget,
-                                         &content_allocation, NULL);
+  gtk_widget_get_content_allocation (widget, &content_allocation);
 
   rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
   vertical = (priv->orientation == GTK_ORIENTATION_VERTICAL);
@@ -1382,13 +1335,9 @@ rebuild_menu (GtkToolbar *toolbar)
 }
 
 static void
-gtk_toolbar_allocate (GtkCssGadget        *gadget,
-                      const GtkAllocation *allocation,
-                      int                  baseline,
-                      GtkAllocation       *out_clip,
-                      gpointer             data)
+gtk_toolbar_size_allocate (GtkWidget     *widget,
+                           GtkAllocation *allocation)
 {
-  GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
   GtkToolbar *toolbar = GTK_TOOLBAR (widget);
   GtkToolbarPrivate *priv = toolbar->priv;
   GtkAllocation arrow_allocation, item_area, widget_allocation;
@@ -1706,20 +1655,6 @@ gtk_toolbar_allocate (GtkCssGadget        *gadget,
         gtk_menu_shell_deactivate (GTK_MENU_SHELL (priv->menu));
     }
 
-  g_free (allocations);
-  g_free (new_states);
-}
-
-static void
-gtk_toolbar_size_allocate (GtkWidget     *widget,
-                          GtkAllocation *allocation)
-{
-  GtkToolbar *toolbar = GTK_TOOLBAR (widget);
-  GtkToolbarPrivate *priv = toolbar->priv;
-  GtkAllocation clip;
-
-  gtk_widget_set_allocation (widget, allocation);
-
   if (gtk_widget_get_realized (widget))
     gdk_window_move_resize (priv->event_window,
                             allocation->x,
@@ -1727,12 +1662,10 @@ gtk_toolbar_size_allocate (GtkWidget     *widget,
                             allocation->width,
                             allocation->height);
 
-  gtk_css_gadget_allocate (priv->gadget,
-                           allocation,
-                           gtk_widget_get_allocated_baseline (widget),
-                           &clip);
+  g_free (allocations);
+  g_free (new_states);
 
-  gtk_widget_set_clip (widget, &clip);
+  gtk_widget_set_clip (widget, allocation);
 }
 
 static void
@@ -2905,7 +2838,6 @@ gtk_toolbar_finalize (GObject *object)
   if (priv->idle_id)
     g_source_remove (priv->idle_id);
 
-  g_clear_object (&priv->gadget);
   g_clear_object (&priv->click_gesture);
 
   G_OBJECT_CLASS (gtk_toolbar_parent_class)->finalize (object);


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