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
|
#define INDICATOR_SPACING 2
|
||||||
|
|
||||||
|
|
||||||
static void gtk_check_button_size_request (GtkWidget *widget,
|
static void gtk_check_button_get_preferred_width (GtkWidget *widget,
|
||||||
GtkRequisition *requisition);
|
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,
|
static void gtk_check_button_size_allocate (GtkWidget *widget,
|
||||||
GtkAllocation *allocation);
|
GtkAllocation *allocation);
|
||||||
static gboolean gtk_check_button_draw (GtkWidget *widget,
|
static gboolean gtk_check_button_draw (GtkWidget *widget,
|
||||||
@ -57,10 +61,11 @@ static void
|
|||||||
gtk_check_button_class_init (GtkCheckButtonClass *class)
|
gtk_check_button_class_init (GtkCheckButtonClass *class)
|
||||||
{
|
{
|
||||||
GtkWidgetClass *widget_class;
|
GtkWidgetClass *widget_class;
|
||||||
|
|
||||||
widget_class = (GtkWidgetClass*) 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->size_allocate = gtk_check_button_size_allocate;
|
||||||
widget_class->draw = gtk_check_button_draw;
|
widget_class->draw = gtk_check_button_draw;
|
||||||
|
|
||||||
@ -195,11 +200,58 @@ _gtk_check_button_get_props (GtkCheckButton *check_button,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_check_button_size_request (GtkWidget *widget,
|
gtk_check_button_get_preferred_width (GtkWidget *widget,
|
||||||
GtkRequisition *requisition)
|
gint *minimum,
|
||||||
|
gint *natural)
|
||||||
{
|
{
|
||||||
GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (widget);
|
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))
|
if (gtk_toggle_button_get_mode (toggle_button))
|
||||||
{
|
{
|
||||||
GtkWidget *child;
|
GtkWidget *child;
|
||||||
@ -213,34 +265,33 @@ gtk_check_button_size_request (GtkWidget *widget,
|
|||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
||||||
|
|
||||||
gtk_widget_style_get (GTK_WIDGET (widget),
|
gtk_widget_style_get (GTK_WIDGET (widget),
|
||||||
"focus-line-width", &focus_width,
|
"focus-line-width", &focus_width,
|
||||||
"focus-padding", &focus_pad,
|
"focus-padding", &focus_pad,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
requisition->width = border_width * 2;
|
*minimum = border_width * 2;
|
||||||
requisition->height = border_width * 2;
|
*natural = border_width * 2;
|
||||||
|
|
||||||
_gtk_check_button_get_props (GTK_CHECK_BUTTON (widget),
|
_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));
|
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||||
if (child && gtk_widget_get_visible (child))
|
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;
|
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
|
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
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user