Commit 0f9c0476 authored by Tristan Van Berkom's avatar Tristan Van Berkom

Removed size_request from GtkImageMenuItem

parent 8565b862
...@@ -62,8 +62,16 @@ enum { ...@@ -62,8 +62,16 @@ enum {
static GtkActivatableIface *parent_activatable_iface; static GtkActivatableIface *parent_activatable_iface;
static void gtk_image_menu_item_destroy (GtkWidget *widget); static void gtk_image_menu_item_destroy (GtkWidget *widget);
static void gtk_image_menu_item_size_request (GtkWidget *widget, static void gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition); gint *minimum,
gint *natural);
static void gtk_image_menu_item_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_image_menu_item_get_preferred_height_for_width (GtkWidget *widget,
gint width,
gint *minimum,
gint *natural);
static void gtk_image_menu_item_size_allocate (GtkWidget *widget, static void gtk_image_menu_item_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_image_menu_item_map (GtkWidget *widget); static void gtk_image_menu_item_map (GtkWidget *widget);
...@@ -117,7 +125,9 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass) ...@@ -117,7 +125,9 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
widget_class->destroy = gtk_image_menu_item_destroy; widget_class->destroy = gtk_image_menu_item_destroy;
widget_class->screen_changed = gtk_image_menu_item_screen_changed; widget_class->screen_changed = gtk_image_menu_item_screen_changed;
widget_class->size_request = gtk_image_menu_item_size_request; widget_class->get_preferred_width = gtk_image_menu_item_get_preferred_width;
widget_class->get_preferred_height = gtk_image_menu_item_get_preferred_height;
widget_class->get_preferred_height_for_width = gtk_image_menu_item_get_preferred_height_for_width;
widget_class->size_allocate = gtk_image_menu_item_size_allocate; widget_class->size_allocate = gtk_image_menu_item_size_allocate;
widget_class->map = gtk_image_menu_item_map; widget_class->map = gtk_image_menu_item_map;
...@@ -411,13 +421,13 @@ gtk_image_menu_item_get_label (GtkMenuItem *menu_item) ...@@ -411,13 +421,13 @@ gtk_image_menu_item_get_label (GtkMenuItem *menu_item)
} }
static void static void
gtk_image_menu_item_size_request (GtkWidget *widget, gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
GtkRequisition *requisition) gint *minimum,
gint *natural)
{ {
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget); GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
GtkImageMenuItemPrivate *priv = image_menu_item->priv; GtkImageMenuItemPrivate *priv = image_menu_item->priv;
gint child_width = 0; gint child_width = 0;
gint child_height = 0;
GtkPackDirection pack_dir; GtkPackDirection pack_dir;
GtkWidget *parent; GtkWidget *parent;
...@@ -435,26 +445,92 @@ gtk_image_menu_item_size_request (GtkWidget *widget, ...@@ -435,26 +445,92 @@ gtk_image_menu_item_size_request (GtkWidget *widget,
gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL); gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
child_width = child_requisition.width; child_width = child_requisition.width;
}
GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->get_preferred_width (widget, minimum, natural);
if (pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT)
{
*minimum = MAX (*minimum, child_width);
*natural = MAX (*natural, child_width);
}
}
static void
gtk_image_menu_item_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
gint child_height = 0;
GtkPackDirection pack_dir;
GtkWidget *parent;
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU_BAR (parent))
pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
else
pack_dir = GTK_PACK_DIRECTION_LTR;
if (priv->image && gtk_widget_get_visible (priv->image))
{
GtkRequisition child_requisition;
gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
child_height = child_requisition.height; child_height = child_requisition.height;
} }
GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->size_request (widget, requisition); GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->get_preferred_height (widget, minimum, natural);
/* not done with height since that happens via the if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR)
* toggle_size_request {
*/ *minimum = MAX (*minimum, child_height);
if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) *natural = MAX (*natural, child_height);
requisition->height = MAX (requisition->height, child_height); }
}
static void
gtk_image_menu_item_get_preferred_height_for_width (GtkWidget *widget,
gint width,
gint *minimum,
gint *natural)
{
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
gint child_height = 0;
GtkPackDirection pack_dir;
GtkWidget *parent;
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU_BAR (parent))
pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
else else
requisition->width = MAX (requisition->width, child_width); pack_dir = GTK_PACK_DIRECTION_LTR;
if (priv->image && gtk_widget_get_visible (priv->image))
{
GtkRequisition child_requisition;
gtk_widget_get_preferred_size (priv->image, &child_requisition, NULL);
/* Note that GtkMenuShell always size requests before child_height = child_requisition.height;
* toggle_size_request, so toggle_size_request will be able to use }
* priv->image->requisition
*/ GTK_WIDGET_CLASS
(gtk_image_menu_item_parent_class)->get_preferred_height_for_width (widget, width, minimum, natural);
if (pack_dir == GTK_PACK_DIRECTION_RTL || pack_dir == GTK_PACK_DIRECTION_LTR)
{
*minimum = MAX (*minimum, child_height);
*natural = MAX (*natural, child_height);
}
} }
static void static void
gtk_image_menu_item_size_allocate (GtkWidget *widget, gtk_image_menu_item_size_allocate (GtkWidget *widget,
GtkAllocation *allocation) GtkAllocation *allocation)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment