Commit 3bb3dc72 authored by Matthias Clasen's avatar Matthias Clasen

Remove size_request from GtkCheckButton

parent f85543af
......@@ -38,8 +38,12 @@
#define INDICATOR_SPACING 2
static void gtk_check_button_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_check_button_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_check_button_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void gtk_check_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gboolean gtk_check_button_draw (GtkWidget *widget,
......@@ -57,10 +61,11 @@ static void
gtk_check_button_class_init (GtkCheckButtonClass *class)
{
GtkWidgetClass *widget_class;
widget_class = (GtkWidgetClass*) class;
widget_class->size_request = gtk_check_button_size_request;
widget_class->get_preferred_width = gtk_check_button_get_preferred_width;
widget_class->get_preferred_height = gtk_check_button_get_preferred_height;
widget_class->size_allocate = gtk_check_button_size_allocate;
widget_class->draw = gtk_check_button_draw;
......@@ -195,11 +200,58 @@ _gtk_check_button_get_props (GtkCheckButton *check_button,
}
static void
gtk_check_button_size_request (GtkWidget *widget,
GtkRequisition *requisition)
gtk_check_button_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (widget);
if (gtk_toggle_button_get_mode (toggle_button))
{
GtkWidget *child;
gint indicator_size;
gint indicator_spacing;
gint focus_width;
gint focus_pad;
guint border_width;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
gtk_widget_style_get (GTK_WIDGET (widget),
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
*minimum = 2 * border_width;
*natural = 2 * border_width;
_gtk_check_button_get_props (GTK_CHECK_BUTTON (widget),
&indicator_size, &indicator_spacing);
child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child))
{
gint child_min, child_nat;
gtk_widget_get_preferred_width (child, &child_min, &child_nat);
*minimum += child_min + indicator_spacing;
*natural += child_nat + indicator_spacing;
}
*minimum += (indicator_size + indicator_spacing * 2 + 2 * (focus_width + focus_pad));
*natural += (indicator_size + indicator_spacing * 2 + 2 * (focus_width + focus_pad));
}
else
GTK_WIDGET_CLASS (gtk_check_button_parent_class)->get_preferred_width (widget, minimum, natural);
}
static void
gtk_check_button_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (widget);
if (gtk_toggle_button_get_mode (toggle_button))
{
GtkWidget *child;
......@@ -213,34 +265,33 @@ gtk_check_button_size_request (GtkWidget *widget,
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
gtk_widget_style_get (GTK_WIDGET (widget),
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
requisition->width = border_width * 2;
requisition->height = border_width * 2;
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
*minimum = border_width * 2;
*natural = border_width * 2;
_gtk_check_button_get_props (GTK_CHECK_BUTTON (widget),
&indicator_size, &indicator_spacing);
&indicator_size, &indicator_spacing);
child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child))
{
GtkRequisition child_requisition;
{
gint child_min, child_nat;
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
gtk_widget_get_preferred_height (child, &child_min, &child_nat);
*minimum += child_min;
*natural += child_nat;
}
requisition->width += child_requisition.width + indicator_spacing;
requisition->height += child_requisition.height;
}
requisition->width += (indicator_size + indicator_spacing * 2 + 2 * (focus_width + focus_pad));
temp = indicator_size + indicator_spacing * 2;
requisition->height = MAX (requisition->height, temp) + 2 * (focus_width + focus_pad);
*minimum = MAX (*minimum, temp) + 2 * (focus_width + focus_pad);
*natural = MAX (*natural, temp) + 2 * (focus_width + focus_pad);
}
else
GTK_WIDGET_CLASS (gtk_check_button_parent_class)->size_request (widget, requisition);
GTK_WIDGET_CLASS (gtk_check_button_parent_class)->get_preferred_height (widget, minimum, natural);
}
static void
......
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