[gtk+/wip/baedert/drawing: 62/186] menuitem: Stop using gadget



commit 4b1b71c9857a5cf7a96ee88730b5f5b7f1507b95
Author: Timm Bäder <mail baedert org>
Date:   Thu May 4 09:16:49 2017 +0200

    menuitem: Stop using gadget
    
    Once again, we can't really delete it yet since other widgets use it...

 gtk/gtkmenuitem.c |   99 ++++++++++++----------------------------------------
 1 files changed, 23 insertions(+), 76 deletions(-)
---
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index c659d3a..0b179ec 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -250,16 +250,10 @@ gtk_menu_item_actionable_interface_init (GtkActionableInterface *iface)
   iface->get_action_target_value = gtk_menu_item_get_action_target_value;
 }
 
-static gboolean
-gtk_menu_item_render (GtkCssGadget *gadget,
-                      GtkSnapshot  *snapshot,
-                      int           x,
-                      int           y,
-                      int           width,
-                      int           height,
-                      gpointer      data)
-{
-  GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
+static void
+gtk_menu_item_snapshot (GtkWidget   *widget,
+                        GtkSnapshot *snapshot)
+{
   GtkMenuItem *menu_item = GTK_MENU_ITEM (widget);
   GtkMenuItemPrivate *priv = menu_item->priv;
   GtkWidget *parent;
@@ -270,34 +264,28 @@ gtk_menu_item_render (GtkCssGadget *gadget,
     gtk_css_gadget_snapshot (priv->arrow_gadget, snapshot);
 
   GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->snapshot (widget, snapshot);
-
-  return FALSE;
-}
-
-static void
-gtk_menu_item_snapshot (GtkWidget   *widget,
-                        GtkSnapshot *snapshot)
-{
-  gtk_css_gadget_snapshot (GTK_MENU_ITEM (widget)->priv->gadget, snapshot);
 }
 
 static void
-gtk_menu_item_allocate (GtkCssGadget        *gadget,
-                        const GtkAllocation *allocation,
-                        int                  baseline,
-                        GtkAllocation       *out_clip,
-                        gpointer             data)
+gtk_menu_item_size_allocate (GtkWidget     *widget,
+                             GtkAllocation *allocation)
 {
-  GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
   GtkMenuItem *menu_item = GTK_MENU_ITEM (widget);
   GtkMenuItemPrivate *priv = menu_item->priv;
+  GtkAllocation clip = *allocation;
   GtkAllocation child_allocation;
   GtkAllocation arrow_clip = { 0 };
+  GtkAllocation child_clip = *allocation;
   GtkTextDirection direction;
   GtkPackDirection child_pack_dir;
   GtkWidget *child;
   GtkWidget *parent;
 
+  if (gtk_widget_get_realized (widget))
+    gdk_window_move_resize (priv->event_window,
+                            allocation->x, allocation->y,
+                            allocation->width, allocation->height);
+
   g_return_if_fail (GTK_IS_MENU_ITEM (widget));
   g_return_if_fail (allocation != NULL);
 
@@ -364,41 +352,19 @@ gtk_menu_item_allocate (GtkCssGadget        *gadget,
 
           gtk_css_gadget_allocate (priv->arrow_gadget,
                                    &arrow_alloc,
-                                   baseline,
+                                   -1,
                                    &arrow_clip);
        }
 
       child_allocation.width = MAX (1, child_allocation.width);
 
       gtk_widget_size_allocate (child, &child_allocation);
-
-      gtk_container_get_children_clip (GTK_CONTAINER (widget), out_clip);
-      gdk_rectangle_union (out_clip, &arrow_clip, out_clip);
+      gtk_widget_get_clip (child, &child_clip);
+      gdk_rectangle_union (&child_clip, &clip, &clip);
     }
 
   if (priv->submenu)
     gtk_menu_reposition (GTK_MENU (priv->submenu));
-}
-
-static void
-gtk_menu_item_size_allocate (GtkWidget     *widget,
-                             GtkAllocation *allocation)
-{
-  GtkMenuItem *menu_item = GTK_MENU_ITEM (widget);
-  GtkMenuItemPrivate *priv = menu_item->priv;
-  GtkAllocation clip;
-  
-  gtk_widget_set_allocation (widget, allocation);
-
-  if (gtk_widget_get_realized (widget))
-    gdk_window_move_resize (priv->event_window,
-                            allocation->x, allocation->y,
-                            allocation->width, allocation->height);
-
-  gtk_css_gadget_allocate (priv->gadget,
-                           allocation,
-                           gtk_widget_get_allocated_baseline (widget),
-                           &clip);
 
   gtk_widget_set_clip (widget, &clip);
 }
@@ -542,37 +508,18 @@ gtk_menu_item_real_get_height (GtkWidget *widget,
 }
 
 static void
-gtk_menu_item_measure (GtkCssGadget   *gadget,
+gtk_menu_item_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);
-
   if (orientation == GTK_ORIENTATION_HORIZONTAL)
     gtk_menu_item_real_get_width (widget, minimum, natural);
   else
-    gtk_menu_item_real_get_height (widget, size, minimum, natural);
-}
-
-static void
-gtk_menu_item_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_MENU_ITEM (widget)->priv->gadget,
-                                     orientation,
-                                     for_size,
-                                     minimum, natural,
-                                     minimum_baseline, natural_baseline);
+    gtk_menu_item_real_get_height (widget, for_size, minimum, natural);
 }
 
 
@@ -600,7 +547,7 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
   widget_class->mnemonic_activate = gtk_menu_item_mnemonic_activate;
   widget_class->parent_set = gtk_menu_item_parent_set;
   widget_class->can_activate_accel = gtk_menu_item_can_activate_accel;
-  widget_class->measure = gtk_menu_item_measure_;
+  widget_class->measure = gtk_menu_item_measure;
   widget_class->direction_changed = gtk_menu_item_direction_changed;
 
   container_class->forall = gtk_menu_item_forall;
@@ -780,9 +727,9 @@ gtk_menu_item_init (GtkMenuItem *menu_item)
   widget_node = gtk_widget_get_css_node (GTK_WIDGET (menu_item));
   priv->gadget = gtk_css_custom_gadget_new_for_node (widget_node,
                                                      GTK_WIDGET (menu_item),
-                                                     gtk_menu_item_measure,
-                                                     gtk_menu_item_allocate,
-                                                     gtk_menu_item_render,
+                                                     NULL,
+                                                     NULL,
+                                                     NULL,
                                                      NULL, NULL);
 }
 


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