summaryrefslogtreecommitdiff
path: root/gtk/gtkmenuitem.c
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2017-05-04 09:16:49 +0200
committerMatthias Clasen <mclasen@redhat.com>2017-07-19 21:27:11 -0400
commitb9fb186f465e055353883b825a670d95f83124de (patch)
treeae8a0c11ccf7db9418c2dbe0306fce02dc0dc88f /gtk/gtkmenuitem.c
parentb4e26e686dd36e1a3b22e97f1373cb72333b2595 (diff)
downloadgtk+-b9fb186f465e055353883b825a670d95f83124de.tar.gz
menuitem: Stop using gadget
Once again, we can't really delete it yet since other widgets use it...
Diffstat (limited to 'gtk/gtkmenuitem.c')
-rw-r--r--gtk/gtkmenuitem.c91
1 files changed, 19 insertions, 72 deletions
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index 1191fca2ea..b58b91d022 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -246,16 +246,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;
@@ -266,29 +260,18 @@ 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;
@@ -360,36 +343,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);
-
- gtk_css_gadget_allocate (priv->gadget,
- allocation,
- gtk_widget_get_allocated_baseline (widget),
- &clip);
gtk_widget_set_clip (widget, &clip);
}
@@ -533,37 +499,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);
}
@@ -587,7 +534,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;
@@ -767,9 +714,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);
}