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> 2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c: * 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> 2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c: * 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> 2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c: * 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> 2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c: * 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> 2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c: * 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> 2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c: * 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> 2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c: * gdk/linux-fb/gdkwindow-fb.c:
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
#include "gtkintl.h" #include "gtkintl.h"
#define CHILD_SPACING 1 #define CHILD_SPACING 1
#define DEFAULT_LEFT_POS 4
#define DEFAULT_TOP_POS 4
#define DEFAULT_SPACING 7 #define DEFAULT_SPACING 7
/* Time out before giving up on getting a key release when animatng /* Time out before giving up on getting a key release when animatng
...@@ -233,6 +231,15 @@ gtk_button_class_init (GtkButtonClass *klass) ...@@ -233,6 +231,15 @@ gtk_button_class_init (GtkButtonClass *klass)
gtk_marshal_VOID__VOID, gtk_marshal_VOID__VOID,
GTK_TYPE_NONE, 0); GTK_TYPE_NONE, 0);
widget_class->activate_signal = button_signals[ACTIVATE]; 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 static void
...@@ -532,17 +539,29 @@ gtk_button_unrealize (GtkWidget *widget) ...@@ -532,17 +539,29 @@ gtk_button_unrealize (GtkWidget *widget)
} }
static void static void
gtk_button_size_request (GtkWidget *widget, gtk_button_get_props (GtkButton *button,
GtkRequisition *requisition) gint *default_spacing,
gboolean *interior_focus)
{ {
GtkButton *button; GtkWidget *widget = GTK_WIDGET (button);
g_return_if_fail (widget != NULL); if (default_spacing)
g_return_if_fail (GTK_IS_BUTTON (widget)); gtk_widget_style_get (widget, "default_spacing", default_spacing, NULL);
g_return_if_fail (requisition != 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 + requisition->width = (GTK_CONTAINER (widget)->border_width + CHILD_SPACING +
GTK_WIDGET (widget)->style->xthickness) * 2; GTK_WIDGET (widget)->style->xthickness) * 2;
requisition->height = (GTK_CONTAINER (widget)->border_width + CHILD_SPACING + requisition->height = (GTK_CONTAINER (widget)->border_width + CHILD_SPACING +
...@@ -551,9 +570,9 @@ gtk_button_size_request (GtkWidget *widget, ...@@ -551,9 +570,9 @@ gtk_button_size_request (GtkWidget *widget,
if (GTK_WIDGET_CAN_DEFAULT (widget)) if (GTK_WIDGET_CAN_DEFAULT (widget))
{ {
requisition->width += (GTK_WIDGET (widget)->style->xthickness * 2 + requisition->width += (GTK_WIDGET (widget)->style->xthickness * 2 +
DEFAULT_SPACING); default_spacing);
requisition->height += (GTK_WIDGET (widget)->style->ythickness * 2 + requisition->height += (GTK_WIDGET (widget)->style->ythickness * 2 +
DEFAULT_SPACING); default_spacing);
} }
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child)) if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
...@@ -565,22 +584,29 @@ gtk_button_size_request (GtkWidget *widget, ...@@ -565,22 +584,29 @@ gtk_button_size_request (GtkWidget *widget,
requisition->width += child_requisition.width; requisition->width += child_requisition.width;
requisition->height += child_requisition.height; requisition->height += child_requisition.height;
} }
if (interior_focus)
{
requisition->width += 2;
requisition->height += 2;
}
} }
static void static void
gtk_button_size_allocate (GtkWidget *widget, gtk_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation) GtkAllocation *allocation)
{ {
GtkButton *button; GtkButton *button = GTK_BUTTON (widget);
GtkAllocation child_allocation; GtkAllocation child_allocation;
gint border_width;
g_return_if_fail (widget != NULL); gint border_width = GTK_CONTAINER (widget)->border_width;
g_return_if_fail (GTK_IS_BUTTON (widget)); gint xthickness = GTK_WIDGET (widget)->style->xthickness;
g_return_if_fail (allocation != NULL); gint ythickness = GTK_WIDGET (widget)->style->ythickness;
gint default_spacing;
gtk_button_get_props (button, &default_spacing, NULL);
widget->allocation = *allocation; widget->allocation = *allocation;
border_width = GTK_CONTAINER (widget)->border_width;
if (GTK_WIDGET_REALIZED (widget)) if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window, gdk_window_move_resize (widget->window,
...@@ -589,12 +615,10 @@ gtk_button_size_allocate (GtkWidget *widget, ...@@ -589,12 +615,10 @@ gtk_button_size_allocate (GtkWidget *widget,
widget->allocation.width - border_width * 2, widget->allocation.width - border_width * 2,
widget->allocation.height - 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)) if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
{ {
child_allocation.x = (CHILD_SPACING + GTK_WIDGET (widget)->style->xthickness); child_allocation.x = (CHILD_SPACING + xthickness);
child_allocation.y = (CHILD_SPACING + GTK_WIDGET (widget)->style->ythickness); child_allocation.y = (CHILD_SPACING + ythickness);
child_allocation.width = MAX (1, (gint)widget->allocation.width - child_allocation.x * 2 - child_allocation.width = MAX (1, (gint)widget->allocation.width - child_allocation.x * 2 -
border_width * 2); border_width * 2);
...@@ -604,13 +628,13 @@ gtk_button_size_allocate (GtkWidget *widget, ...@@ -604,13 +628,13 @@ gtk_button_size_allocate (GtkWidget *widget,
if (GTK_WIDGET_CAN_DEFAULT (button)) if (GTK_WIDGET_CAN_DEFAULT (button))
{ {
child_allocation.x += (GTK_WIDGET (widget)->style->xthickness + child_allocation.x += (GTK_WIDGET (widget)->style->xthickness +
DEFAULT_LEFT_POS); (1 + default_spacing) / 2);
child_allocation.y += (GTK_WIDGET (widget)->style->ythickness + child_allocation.y += (GTK_WIDGET (widget)->style->ythickness +
DEFAULT_TOP_POS); (1 + default_spacing) / 2);
child_allocation.width = MAX (1, (gint)child_allocation.width - 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 - 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); gtk_widget_size_allocate (GTK_BIN (button)->child, &child_allocation);
...@@ -651,10 +675,14 @@ gtk_button_paint (GtkWidget *widget, ...@@ -651,10 +675,14 @@ gtk_button_paint (GtkWidget *widget,
GtkShadowType shadow_type; GtkShadowType shadow_type;
gint width, height; gint width, height;
gint x, y; gint x, y;
gint default_spacing;
gboolean interior_focus;
if (GTK_WIDGET_DRAWABLE (widget)) if (GTK_WIDGET_DRAWABLE (widget))
{ {
button = GTK_BUTTON (widget); button = GTK_BUTTON (widget);
gtk_button_get_props (button, &default_spacing, &interior_focus);
x = 0; x = 0;
y = 0; y = 0;
...@@ -677,13 +705,13 @@ gtk_button_paint (GtkWidget *widget, ...@@ -677,13 +705,13 @@ gtk_button_paint (GtkWidget *widget,
{ {
x += widget->style->xthickness; x += widget->style->xthickness;
y += widget->style->ythickness; y += widget->style->ythickness;
width -= 2 * x + DEFAULT_SPACING; width -= 2 * x + default_spacing;
height -= 2 * y + DEFAULT_SPACING; height -= 2 * y + default_spacing;
x += DEFAULT_LEFT_POS; x += (1 + default_spacing) / 2;
y += DEFAULT_TOP_POS; y += (1 + default_spacing) / 2;
} }
if (GTK_WIDGET_HAS_FOCUS (widget)) if (!interior_focus && GTK_WIDGET_HAS_FOCUS (widget))
{ {
x += 1; x += 1;
y += 1; y += 1;
...@@ -706,10 +734,20 @@ gtk_button_paint (GtkWidget *widget, ...@@ -706,10 +734,20 @@ gtk_button_paint (GtkWidget *widget,
if (GTK_WIDGET_HAS_FOCUS (widget)) if (GTK_WIDGET_HAS_FOCUS (widget))
{ {
x -= 1; if (interior_focus)
y -= 1; {
width += 2; x += widget->style->xthickness + 1;
height += 2; 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, gtk_paint_focus (widget->style, widget->window,
area, widget, "button", area, widget, "button",
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
*/ */
#include "gtkcheckbutton.h" #include "gtkcheckbutton.h"
#include "gtkintl.h"
#include "gtklabel.h" #include "gtklabel.h"
...@@ -86,10 +87,25 @@ gtk_check_button_class_init (GtkCheckButtonClass *class) ...@@ -86,10 +87,25 @@ gtk_check_button_class_init (GtkCheckButtonClass *class)
widget_class->size_request = gtk_check_button_size_request; widget_class->size_request = gtk_check_button_size_request;
widget_class->size_allocate = gtk_check_button_size_allocate; widget_class->size_allocate = gtk_check_button_size_allocate;
widget_class->expose_event = gtk_check_button_expose; 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; 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 static void
...@@ -159,36 +175,62 @@ static void ...@@ -159,36 +175,62 @@ static void
gtk_check_button_paint (GtkWidget *widget, gtk_check_button_paint (GtkWidget *widget,
GdkRectangle *area) GdkRectangle *area)
{ {
GtkCheckButton *check_button; GtkCheckButton *check_button = GTK_CHECK_BUTTON (widget);
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CHECK_BUTTON (widget));
check_button = GTK_CHECK_BUTTON (widget);
if (GTK_WIDGET_DRAWABLE (widget)) if (GTK_WIDGET_DRAWABLE (widget))
{ {
gint border_width; gint border_width;
gint interior_focus;
gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
gtk_check_button_draw_indicator (check_button, area); gtk_check_button_draw_indicator (check_button, area);
border_width = GTK_CONTAINER (widget)->border_width; border_width = GTK_CONTAINER (widget)->border_width;
if (GTK_WIDGET_HAS_FOCUS (widget)) if (GTK_WIDGET_HAS_FOCUS (widget))
gtk_paint_focus (widget->style, widget->window, {
NULL, widget, "checkbutton", if (interior_focus)
border_width + widget->allocation.x, {
border_width + widget->allocation.y, GtkWidget *child = GTK_BIN (widget)->child;
widget->allocation.width - 2 * border_width - 1,
widget->allocation.height - 2 * border_width - 1); 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 static void
gtk_check_button_size_request (GtkWidget *widget, gtk_check_button_size_request (GtkWidget *widget,
GtkRequisition *requisition) GtkRequisition *requisition)
{ {
GtkToggleButton *toggle_button; GtkToggleButton *toggle_button;
gint temp;
g_return_if_fail (widget != NULL); g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CHECK_BUTTON (widget)); g_return_if_fail (GTK_IS_CHECK_BUTTON (widget));
...@@ -196,18 +238,38 @@ gtk_check_button_size_request (GtkWidget *widget, ...@@ -196,18 +238,38 @@ gtk_check_button_size_request (GtkWidget *widget,
toggle_button = GTK_TOGGLE_BUTTON (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) if (toggle_button->draw_indicator)
{ {
requisition->width += (GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size + GtkWidget *child;
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 3 + 2); 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 + requisition->width += (indicator_size + indicator_spacing * 3 + 2);
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 2);
temp = (indicator_size + indicator_spacing * 2);
requisition->height = MAX (requisition->height, temp) + 2; requisition->height = MAX (requisition->height, temp) + 2;
} }
else
(* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition);
} }