Commit c944151a authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Fix G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE

Mon Apr  2 10:47:57 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.c (gtk_widget_class_init): Fix
	G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
	stupidity.

Mon Apr  2 00:51:11 2001  Owen Taylor  <otaylor@redhat.com>

	[ First pass at adding style properties. Still needs some definite
	fine-tuning. ]

        * gtk/gtkbutton.c: Add ::default_spacing style property.

	* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
	::indicator_spacing style properties.

	* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
	style properties.

	* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
	rather than a normal property.

	* gtk/gtkwidget.c: Add an ::interior_focus style property to
	draw focus inside buttons, in the Windows/Java Metal/etc. style.

	* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
	Honor ::interior_focus.

	* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
	TRUE.

	* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
	Add ::slider_width, ::trough_border, ::stepper_size,
	::stepper_spacing style properties.

	* gtk/gtkscale.[ch] Add ::slider-length style property.
parent 5d1ee092
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
......
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
......
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
......
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
......
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
......
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
......
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:
......
......@@ -36,8 +36,6 @@
#include "gtkintl.h"
#define CHILD_SPACING 1
#define DEFAULT_LEFT_POS 4
#define DEFAULT_TOP_POS 4
#define DEFAULT_SPACING 7
/* Time out before giving up on getting a key release when animatng
......@@ -233,6 +231,15 @@ gtk_button_class_init (GtkButtonClass *klass)
gtk_marshal_VOID__VOID,
GTK_TYPE_NONE, 0);
widget_class->activate_signal = button_signals[ACTIVATE];
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("default_spacing",
_("Default Spacing"),
_("Extra space to add for CAN_DEFAULT buttons"),
0,
G_MAXINT,
DEFAULT_SPACING,
G_PARAM_READABLE));
}
static void
......@@ -532,17 +539,29 @@ gtk_button_unrealize (GtkWidget *widget)
}
static void
gtk_button_size_request (GtkWidget *widget,
GtkRequisition *requisition)
gtk_button_get_props (GtkButton *button,
gint *default_spacing,
gboolean *interior_focus)
{
GtkButton *button;
GtkWidget *widget = GTK_WIDGET (button);
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_BUTTON (widget));
g_return_if_fail (requisition != NULL);
if (default_spacing)
gtk_widget_style_get (widget, "default_spacing", default_spacing, NULL);
button = GTK_BUTTON (widget);
if (interior_focus)
gtk_widget_style_get (widget, "interior_focus", interior_focus, NULL);
}
static void
gtk_button_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkButton *button = GTK_BUTTON (widget);
gint default_spacing;
gboolean interior_focus;
gtk_button_get_props (button, &default_spacing, &interior_focus);
requisition->width = (GTK_CONTAINER (widget)->border_width + CHILD_SPACING +
GTK_WIDGET (widget)->style->xthickness) * 2;
requisition->height = (GTK_CONTAINER (widget)->border_width + CHILD_SPACING +
......@@ -551,9 +570,9 @@ gtk_button_size_request (GtkWidget *widget,
if (GTK_WIDGET_CAN_DEFAULT (widget))
{
requisition->width += (GTK_WIDGET (widget)->style->xthickness * 2 +
DEFAULT_SPACING);
default_spacing);
requisition->height += (GTK_WIDGET (widget)->style->ythickness * 2 +
DEFAULT_SPACING);
default_spacing);
}
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
......@@ -565,22 +584,29 @@ gtk_button_size_request (GtkWidget *widget,
requisition->width += child_requisition.width;
requisition->height += child_requisition.height;
}
if (interior_focus)
{
requisition->width += 2;
requisition->height += 2;
}
}
static void
gtk_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkButton *button;
GtkButton *button = GTK_BUTTON (widget);
GtkAllocation child_allocation;
gint border_width;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_BUTTON (widget));
g_return_if_fail (allocation != NULL);
gint border_width = GTK_CONTAINER (widget)->border_width;
gint xthickness = GTK_WIDGET (widget)->style->xthickness;
gint ythickness = GTK_WIDGET (widget)->style->ythickness;
gint default_spacing;
gtk_button_get_props (button, &default_spacing, NULL);
widget->allocation = *allocation;
border_width = GTK_CONTAINER (widget)->border_width;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window,
......@@ -589,12 +615,10 @@ gtk_button_size_allocate (GtkWidget *widget,
widget->allocation.width - border_width * 2,
widget->allocation.height - border_width * 2);
button = GTK_BUTTON (widget);
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
{
child_allocation.x = (CHILD_SPACING + GTK_WIDGET (widget)->style->xthickness);
child_allocation.y = (CHILD_SPACING + GTK_WIDGET (widget)->style->ythickness);
child_allocation.x = (CHILD_SPACING + xthickness);
child_allocation.y = (CHILD_SPACING + ythickness);
child_allocation.width = MAX (1, (gint)widget->allocation.width - child_allocation.x * 2 -
border_width * 2);
......@@ -604,13 +628,13 @@ gtk_button_size_allocate (GtkWidget *widget,
if (GTK_WIDGET_CAN_DEFAULT (button))
{
child_allocation.x += (GTK_WIDGET (widget)->style->xthickness +
DEFAULT_LEFT_POS);
(1 + default_spacing) / 2);
child_allocation.y += (GTK_WIDGET (widget)->style->ythickness +
DEFAULT_TOP_POS);
(1 + default_spacing) / 2);
child_allocation.width = MAX (1, (gint)child_allocation.width -
(gint)(GTK_WIDGET (widget)->style->xthickness * 2 + DEFAULT_SPACING));
(gint)(GTK_WIDGET (widget)->style->xthickness * 2 + default_spacing));
child_allocation.height = MAX (1, (gint)child_allocation.height -
(gint)(GTK_WIDGET (widget)->style->xthickness * 2 + DEFAULT_SPACING));
(gint)(GTK_WIDGET (widget)->style->xthickness * 2 + default_spacing));
}
gtk_widget_size_allocate (GTK_BIN (button)->child, &child_allocation);
......@@ -651,10 +675,14 @@ gtk_button_paint (GtkWidget *widget,
GtkShadowType shadow_type;
gint width, height;
gint x, y;
gint default_spacing;
gboolean interior_focus;
if (GTK_WIDGET_DRAWABLE (widget))
{
button = GTK_BUTTON (widget);
gtk_button_get_props (button, &default_spacing, &interior_focus);
x = 0;
y = 0;
......@@ -677,13 +705,13 @@ gtk_button_paint (GtkWidget *widget,
{
x += widget->style->xthickness;
y += widget->style->ythickness;
width -= 2 * x + DEFAULT_SPACING;
height -= 2 * y + DEFAULT_SPACING;
x += DEFAULT_LEFT_POS;
y += DEFAULT_TOP_POS;
width -= 2 * x + default_spacing;
height -= 2 * y + default_spacing;
x += (1 + default_spacing) / 2;
y += (1 + default_spacing) / 2;
}
if (GTK_WIDGET_HAS_FOCUS (widget))
if (!interior_focus && GTK_WIDGET_HAS_FOCUS (widget))
{
x += 1;
y += 1;
......@@ -706,10 +734,20 @@ gtk_button_paint (GtkWidget *widget,
if (GTK_WIDGET_HAS_FOCUS (widget))
{
x -= 1;
y -= 1;
width += 2;
height += 2;
if (interior_focus)
{
x += widget->style->xthickness + 1;
y += widget->style->ythickness + 1;
width -= 2 * (widget->style->xthickness + 1);
height -= 2 * (widget->style->xthickness + 1);
}
else
{
x -= 1;
y -= 1;
width += 2;
height += 2;
}
gtk_paint_focus (widget->style, widget->window,
area, widget, "button",
......
......@@ -25,6 +25,7 @@
*/
#include "gtkcheckbutton.h"
#include "gtkintl.h"
#include "gtklabel.h"
......@@ -86,10 +87,25 @@ gtk_check_button_class_init (GtkCheckButtonClass *class)
widget_class->size_request = gtk_check_button_size_request;
widget_class->size_allocate = gtk_check_button_size_allocate;
widget_class->expose_event = gtk_check_button_expose;
class->indicator_size = INDICATOR_SIZE;
class->indicator_spacing = INDICATOR_SPACING;
class->draw_indicator = gtk_real_check_button_draw_indicator;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("indicator_size",
_("Indicator Size"),
_("Size of check or radio indicator"),
0,
G_MAXINT,
INDICATOR_SIZE,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("indicator_spacing",
_("Indicator Spacing"),
_("Spacing around check or radio indicator"),
0,
G_MAXINT,
INDICATOR_SPACING,
G_PARAM_READABLE));
}
static void
......@@ -159,36 +175,62 @@ static void
gtk_check_button_paint (GtkWidget *widget,
GdkRectangle *area)
{
GtkCheckButton *check_button;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CHECK_BUTTON (widget));
check_button = GTK_CHECK_BUTTON (widget);
GtkCheckButton *check_button = GTK_CHECK_BUTTON (widget);
if (GTK_WIDGET_DRAWABLE (widget))
{
gint border_width;
gint interior_focus;
gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
gtk_check_button_draw_indicator (check_button, area);
border_width = GTK_CONTAINER (widget)->border_width;
if (GTK_WIDGET_HAS_FOCUS (widget))
gtk_paint_focus (widget->style, widget->window,
NULL, widget, "checkbutton",
border_width + widget->allocation.x,
border_width + widget->allocation.y,
widget->allocation.width - 2 * border_width - 1,
widget->allocation.height - 2 * border_width - 1);
{
if (interior_focus)
{
GtkWidget *child = GTK_BIN (widget)->child;
if (child && GTK_WIDGET_VISIBLE (child))
gtk_paint_focus (widget->style, widget->window,
NULL, widget, "checkbutton",
child->allocation.x - 1,
child->allocation.y - 1,
child->allocation.width + 1,
child->allocation.height + 1);
}
else
gtk_paint_focus (widget->style, widget->window,
NULL, widget, "checkbutton",
border_width + widget->allocation.x,
border_width + widget->allocation.y,
widget->allocation.width - 2 * border_width - 1,
widget->allocation.height - 2 * border_width - 1);
}
}
}
void
_gtk_check_button_get_props (GtkCheckButton *check_button,
gint *indicator_size,
gint *indicator_spacing)
{
GtkWidget *widget = GTK_WIDGET (check_button);
if (indicator_size)
gtk_widget_style_get (widget, "indicator_size", indicator_size, NULL);
if (indicator_spacing)
gtk_widget_style_get (widget, "indicator_spacing", indicator_spacing, NULL);
}
static void
gtk_check_button_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkToggleButton *toggle_button;
gint temp;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CHECK_BUTTON (widget));
......@@ -196,18 +238,38 @@ gtk_check_button_size_request (GtkWidget *widget,
toggle_button = GTK_TOGGLE_BUTTON (widget);
if (GTK_WIDGET_CLASS (parent_class)->size_request)
(* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition);
if (toggle_button->draw_indicator)
{
requisition->width += (GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 3 + 2);
GtkWidget *child;
gint temp;
gint indicator_size;
gint indicator_spacing;
gint border_width = GTK_CONTAINER (widget)->border_width;
requisition->width = border_width + 2;
requisition->height = border_width + 2;
child = GTK_BIN (widget)->child;
if (child && GTK_WIDGET_VISIBLE (child))
{
GtkRequisition child_requisition;
gtk_widget_size_request (child, &child_requisition);
requisition->width += child_requisition.width;
requisition->height += child_requisition.height;
}
_gtk_check_button_get_props (GTK_CHECK_BUTTON (widget),
&indicator_size, &indicator_spacing);
temp = (GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 2);
requisition->width += (indicator_size + indicator_spacing * 3 + 2);
temp = (indicator_size + indicator_spacing * 2);
requisition->height = MAX (requisition->height, temp) + 2;
}
else
(* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition);
}
static void
......@@ -228,6 +290,11 @@ gtk_check_button_size_allocate (GtkWidget *widget,
if (toggle_button->draw_indicator)
{
gint indicator_size;
gint indicator_spacing;
_gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing);
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (toggle_button->event_window,
......@@ -238,18 +305,15 @@ gtk_check_button_size_allocate (GtkWidget *widget,
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
{
child_allocation.x = (GTK_CONTAINER (widget)->border_width +
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 3 + 1 +
gint border_width = GTK_CONTAINER (widget)->border_width;
child_allocation.x = (border_width + indicator_size + indicator_spacing * 3 + 1 +
widget->allocation.x);
child_allocation.y = GTK_CONTAINER (widget)->border_width + 1 +
widget->allocation.y;
child_allocation.y = border_width + 1 + widget->allocation.y;
child_allocation.width = MAX (1, allocation->width -
(GTK_CONTAINER (widget)->border_width +
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 3 + 1) -
GTK_CONTAINER (widget)->border_width - 1);
child_allocation.height = MAX (1, allocation->height - (GTK_CONTAINER (widget)->border_width + 1) * 2);
(border_width + indicator_size + indicator_spacing * 3 + 1) -
border_width - 1);
child_allocation.height = MAX (1, allocation->height - (border_width + 1) * 2);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
child_allocation.x = allocation->x + allocation->width
......@@ -259,10 +323,7 @@ gtk_check_button_size_allocate (GtkWidget *widget,
}
}
else
{
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
(* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
}
(* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
}
static gint
......@@ -327,6 +388,8 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
GdkRectangle new_area;
gint width, height;
gint x, y;
gint indicator_size;
gint indicator_spacing;
GdkWindow *window;
g_return_if_fail (check_button != NULL);
......@@ -339,6 +402,8 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
{
window = widget->window;
_gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing);
state_type = GTK_WIDGET_STATE (widget);
if (state_type != GTK_STATE_NORMAL &&
state_type != GTK_STATE_PRELIGHT)
......@@ -359,10 +424,10 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
new_area.width, new_area.height);
}
x = widget->allocation.x + GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width;
y = widget->allocation.y + (widget->allocation.height - GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size) / 2;
width = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
height = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
x = widget->allocation.x + indicator_spacing + GTK_CONTAINER (widget)->border_width;
y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2;
width = indicator_size;
height = indicator_size;
if (GTK_TOGGLE_BUTTON (widget)->inconsistent)
{
......
......@@ -57,9 +57,6 @@ struct _GtkCheckButtonClass
{
GtkToggleButtonClass parent_class;
guint16 indicator_size;
guint16 indicator_spacing;
void (* draw_indicator) (GtkCheckButton *check_button,
GdkRectangle *area);
};
......@@ -70,6 +67,9 @@ GtkWidget* gtk_check_button_new (void);
GtkWidget* gtk_check_button_new_with_label (const gchar *label);
GtkWidget* gtk_check_button_new_with_mnemonic (const gchar *label);