forked from AuroraMiddleware/gtk
Remove size_request from GtkCheckButton
This commit is contained in:
parent
23a9127765
commit
2e4e7264e6
@ -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,
|
||||
@ -60,7 +64,8 @@ gtk_check_button_class_init (GtkCheckButtonClass *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,8 +200,55 @@ _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);
|
||||
|
||||
@ -217,8 +269,8 @@ gtk_check_button_size_request (GtkWidget *widget,
|
||||
"focus-padding", &focus_pad,
|
||||
NULL);
|
||||
|
||||
requisition->width = border_width * 2;
|
||||
requisition->height = border_width * 2;
|
||||
*minimum = border_width * 2;
|
||||
*natural = border_width * 2;
|
||||
|
||||
_gtk_check_button_get_props (GTK_CHECK_BUTTON (widget),
|
||||
&indicator_size, &indicator_spacing);
|
||||
@ -226,21 +278,20 @@ gtk_check_button_size_request (GtkWidget *widget,
|
||||
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);
|
||||
|
||||
requisition->width += child_requisition.width + indicator_spacing;
|
||||
requisition->height += child_requisition.height;
|
||||
*minimum += child_min;
|
||||
*natural += child_nat;
|
||||
}
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user