gtk/gtkradiobutton.c: use accessor functions to access GtkWidget

This commit is contained in:
Javier Jardón
2010-08-11 23:03:29 +02:00
parent c6f4e71a31
commit d52eb49529

View File

@ -545,9 +545,12 @@ get_coordinates (GtkWidget *widget,
gint *x, gint *x,
gint *y) gint *y)
{ {
*x = widget->allocation.x + widget->allocation.width / 2; GtkAllocation allocation;
*y = widget->allocation.y + widget->allocation.height / 2;
gtk_widget_get_allocation (widget, &allocation);
*x = allocation.x + allocation.width / 2;
*y = allocation.y + allocation.height / 2;
gtk_widget_translate_coordinates (widget, reference, *x, *y, x, y); gtk_widget_translate_coordinates (widget, reference, *x, *y, x, y);
} }
@ -813,12 +816,15 @@ static void
gtk_radio_button_draw_indicator (GtkCheckButton *check_button, gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
GdkRectangle *area) GdkRectangle *area)
{ {
GtkAllocation allocation;
GtkWidget *widget; GtkWidget *widget;
GtkWidget *child; GtkWidget *child;
GtkButton *button; GtkButton *button;
GtkToggleButton *toggle_button; GtkToggleButton *toggle_button;
GtkStateType state_type; GtkStateType state_type;
GtkShadowType shadow_type; GtkShadowType shadow_type;
GtkStyle *style;
GdkWindow *window;
gint x, y; gint x, y;
gint indicator_size, indicator_spacing; gint indicator_size, indicator_spacing;
gint focus_width; gint focus_width;
@ -835,16 +841,21 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget, gtk_widget_style_get (widget,
"interior-focus", &interior_focus, "interior-focus", &interior_focus,
"focus-line-width", &focus_width, "focus-line-width", &focus_width,
"focus-padding", &focus_pad, "focus-padding", &focus_pad,
NULL); NULL);
window = gtk_widget_get_window (widget);
_gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing); _gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing);
x = widget->allocation.x + indicator_spacing + border_width; gtk_widget_get_allocation (widget, &allocation);
y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2;
x = allocation.x + indicator_spacing + border_width;
y = allocation.y + (allocation.height - indicator_size) / 2;
child = gtk_bin_get_child (GTK_BIN (check_button)); child = gtk_bin_get_child (GTK_BIN (check_button));
if (!interior_focus || !(child && gtk_widget_get_visible (child))) if (!interior_focus || !(child && gtk_widget_get_visible (child)))
@ -867,21 +878,22 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
state_type = GTK_STATE_NORMAL; state_type = GTK_STATE_NORMAL;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
x = widget->allocation.x + widget->allocation.width - (indicator_size + x - widget->allocation.x); x = allocation.x + allocation.width - (indicator_size + x - allocation.x);
if (gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT) if (gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT)
{ {
GdkRectangle restrict_area; GdkRectangle restrict_area;
GdkRectangle new_area; GdkRectangle new_area;
restrict_area.x = widget->allocation.x + border_width; restrict_area.x = allocation.x + border_width;
restrict_area.y = widget->allocation.y + border_width; restrict_area.y = allocation.y + border_width;
restrict_area.width = widget->allocation.width - (2 * border_width); restrict_area.width = allocation.width - (2 * border_width);
restrict_area.height = widget->allocation.height - (2 * border_width); restrict_area.height = allocation.height - (2 * border_width);
if (gdk_rectangle_intersect (area, &restrict_area, &new_area)) if (gdk_rectangle_intersect (area, &restrict_area, &new_area))
{ {
gtk_paint_flat_box (widget->style, widget->window, GTK_STATE_PRELIGHT, gtk_paint_flat_box (style, window,
GTK_STATE_PRELIGHT,
GTK_SHADOW_ETCHED_OUT, GTK_SHADOW_ETCHED_OUT,
area, widget, "checkbutton", area, widget, "checkbutton",
new_area.x, new_area.y, new_area.x, new_area.y,
@ -889,7 +901,7 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
} }
} }
gtk_paint_option (widget->style, widget->window, gtk_paint_option (style, window,
state_type, shadow_type, state_type, shadow_type,
area, widget, "radiobutton", area, widget, "radiobutton",
x, y, indicator_size, indicator_size); x, y, indicator_size, indicator_size);