Commit 479dc131 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Implement get_preferred_width/height in GtkEventBox

And drop size_request.
parent aaf0f0f5
......@@ -53,8 +53,12 @@ static void gtk_event_box_realize (GtkWidget *widget);
static void gtk_event_box_unrealize (GtkWidget *widget);
static void gtk_event_box_map (GtkWidget *widget);
static void gtk_event_box_unmap (GtkWidget *widget);
static void gtk_event_box_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_event_box_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_event_box_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_event_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gboolean gtk_event_box_draw (GtkWidget *widget,
......@@ -84,7 +88,8 @@ gtk_event_box_class_init (GtkEventBoxClass *class)
widget_class->unrealize = gtk_event_box_unrealize;
widget_class->map = gtk_event_box_map;
widget_class->unmap = gtk_event_box_unmap;
widget_class->size_request = gtk_event_box_size_request;
widget_class->get_preferred_width = gtk_event_box_get_preferred_width;
widget_class->get_preferred_height = gtk_event_box_get_preferred_height;
widget_class->size_allocate = gtk_event_box_size_allocate;
widget_class->draw = gtk_event_box_draw;
......@@ -482,33 +487,47 @@ gtk_event_box_unmap (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_event_box_parent_class)->unmap (widget);
}
static void
gtk_event_box_size_request (GtkWidget *widget,
GtkRequisition *requisition)
gtk_event_box_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkBin *bin = GTK_BIN (widget);
GtkWidget *child;
requisition->width = 0;
requisition->height = 0;
if (minimum)
*minimum = 0;
if (natural)
*natural = 0;
child = gtk_bin_get_child (bin);
if (child && gtk_widget_get_visible (child))
{
GtkRequisition child_requisition;
gtk_widget_get_preferred_width (child, minimum, natural);
}
static void
gtk_event_box_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkBin *bin = GTK_BIN (widget);
GtkWidget *child;
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
if (minimum)
*minimum = 0;
requisition->width += child_requisition.width;
requisition->height += child_requisition.height;
}
if (natural)
*natural = 0;
child = gtk_bin_get_child (bin);
if (child && gtk_widget_get_visible (child))
gtk_widget_get_preferred_height (child, minimum, natural);
}
static void
gtk_event_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
GtkAllocation *allocation)
{
GtkBin *bin;
GtkAllocation child_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