diff options
Diffstat (limited to 'meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkcheckbutton.c.diff')
-rw-r--r-- | meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkcheckbutton.c.diff | 520 |
1 files changed, 520 insertions, 0 deletions
diff --git a/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkcheckbutton.c.diff b/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkcheckbutton.c.diff new file mode 100644 index 0000000000..c6922ddc16 --- /dev/null +++ b/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkcheckbutton.c.diff | |||
@@ -0,0 +1,520 @@ | |||
1 | --- gtk+-2.6.4/gtk/gtkcheckbutton.c 2004-08-09 19:59:51.000000000 +0300 | ||
2 | +++ gtk+-2.6.4/gtk/gtkcheckbutton.c 2005-04-06 16:19:36.317017336 +0300 | ||
3 | @@ -31,27 +31,44 @@ | ||
4 | #include "gtklabel.h" | ||
5 | |||
6 | |||
7 | -#define INDICATOR_SIZE 13 | ||
8 | +#define INDICATOR_SIZE 24 | ||
9 | #define INDICATOR_SPACING 2 | ||
10 | |||
11 | +/* maJiK numbers for indicator */ | ||
12 | +#define INDICATOR_SIDE_PADDING 5 | ||
13 | +#define FOCUS_TOP_PADDING 7 | ||
14 | +#define FOCUS_DOWN_PADDING 1 | ||
15 | + | ||
16 | +/* spacing to take account of the 1 pixel | ||
17 | + transparency of the widgetfocus.png | ||
18 | +*/ | ||
19 | +#define HILDON_SPACING 1 | ||
20 | + | ||
21 | +#define TOGGLE_ON_CLICK "toggle-on-click" | ||
22 | |||
23 | -static void gtk_check_button_class_init (GtkCheckButtonClass *klass); | ||
24 | -static void gtk_check_button_init (GtkCheckButton *check_button); | ||
25 | -static void gtk_check_button_size_request (GtkWidget *widget, | ||
26 | - GtkRequisition *requisition); | ||
27 | -static void gtk_check_button_size_allocate (GtkWidget *widget, | ||
28 | - GtkAllocation *allocation); | ||
29 | -static gint gtk_check_button_expose (GtkWidget *widget, | ||
30 | - GdkEventExpose *event); | ||
31 | -static void gtk_check_button_paint (GtkWidget *widget, | ||
32 | - GdkRectangle *area); | ||
33 | -static void gtk_check_button_draw_indicator (GtkCheckButton *check_button, | ||
34 | - GdkRectangle *area); | ||
35 | -static void gtk_real_check_button_draw_indicator (GtkCheckButton *check_button, | ||
36 | - GdkRectangle *area); | ||
37 | +static void gtk_check_button_class_init (GtkCheckButtonClass *klass); | ||
38 | +static void gtk_check_button_init (GtkCheckButton *check_button); | ||
39 | +static void gtk_check_button_size_request (GtkWidget *widget, | ||
40 | + GtkRequisition *requisition); | ||
41 | +static void gtk_check_button_size_allocate (GtkWidget *widget, | ||
42 | + GtkAllocation *allocation); | ||
43 | +static gint gtk_check_button_expose (GtkWidget *widget, | ||
44 | + GdkEventExpose *event); | ||
45 | +static void gtk_check_button_paint (GtkWidget *widget, | ||
46 | + GdkRectangle *area); | ||
47 | +static void gtk_check_button_draw_indicator (GtkCheckButton *check_button, | ||
48 | + GdkRectangle *area); | ||
49 | +static void gtk_real_check_button_draw_indicator | ||
50 | + (GtkCheckButton *check_button, | ||
51 | + GdkRectangle *area); | ||
52 | |||
53 | -static GtkToggleButtonClass *parent_class = NULL; | ||
54 | +static void gtk_check_button_calc_indicator_size( GtkCheckButton *button, | ||
55 | + GdkRectangle *rect ); | ||
56 | + | ||
57 | +static void gtk_check_button_clicked (GtkButton *button); | ||
58 | +static void gtk_check_button_update_state (GtkButton *button); | ||
59 | |||
60 | +static GtkToggleButtonClass *parent_class = NULL; | ||
61 | |||
62 | GType | ||
63 | gtk_check_button_get_type (void) | ||
64 | @@ -85,32 +102,36 @@ | ||
65 | gtk_check_button_class_init (GtkCheckButtonClass *class) | ||
66 | { | ||
67 | GtkWidgetClass *widget_class; | ||
68 | - | ||
69 | + GtkButtonClass *button_class; | ||
70 | + | ||
71 | widget_class = (GtkWidgetClass*) class; | ||
72 | + button_class = (GtkButtonClass*) class; | ||
73 | parent_class = g_type_class_peek_parent (class); | ||
74 | |||
75 | widget_class->size_request = gtk_check_button_size_request; | ||
76 | widget_class->size_allocate = gtk_check_button_size_allocate; | ||
77 | widget_class->expose_event = gtk_check_button_expose; | ||
78 | |||
79 | + button_class->clicked = gtk_check_button_clicked; | ||
80 | + | ||
81 | class->draw_indicator = gtk_real_check_button_draw_indicator; | ||
82 | |||
83 | gtk_widget_class_install_style_property (widget_class, | ||
84 | g_param_spec_int ("indicator_size", | ||
85 | - P_("Indicator Size"), | ||
86 | - P_("Size of check or radio indicator"), | ||
87 | - 0, | ||
88 | - G_MAXINT, | ||
89 | - INDICATOR_SIZE, | ||
90 | - G_PARAM_READABLE)); | ||
91 | + P_("Indicator Size"), | ||
92 | + P_("Size of check or radio indicator"), | ||
93 | + 0, | ||
94 | + G_MAXINT, | ||
95 | + INDICATOR_SIZE, | ||
96 | + G_PARAM_READABLE)); | ||
97 | gtk_widget_class_install_style_property (widget_class, | ||
98 | g_param_spec_int ("indicator_spacing", | ||
99 | - P_("Indicator Spacing"), | ||
100 | - P_("Spacing around check or radio indicator"), | ||
101 | - 0, | ||
102 | - G_MAXINT, | ||
103 | - INDICATOR_SPACING, | ||
104 | - G_PARAM_READABLE)); | ||
105 | + P_("Indicator Spacing"), | ||
106 | + P_("Spacing around check or radio indicator"), | ||
107 | + 0, | ||
108 | + G_MAXINT, | ||
109 | + INDICATOR_SPACING, | ||
110 | + G_PARAM_READABLE)); | ||
111 | } | ||
112 | |||
113 | static void | ||
114 | @@ -148,7 +169,8 @@ | ||
115 | GtkWidget* | ||
116 | gtk_check_button_new_with_mnemonic (const gchar *label) | ||
117 | { | ||
118 | - return g_object_new (GTK_TYPE_CHECK_BUTTON, "label", label, "use_underline", TRUE, NULL); | ||
119 | + return g_object_new (GTK_TYPE_CHECK_BUTTON, "label", label, | ||
120 | + "use_underline", TRUE, NULL); | ||
121 | } | ||
122 | |||
123 | |||
124 | @@ -163,39 +185,70 @@ | ||
125 | |||
126 | if (GTK_WIDGET_DRAWABLE (widget)) | ||
127 | { | ||
128 | - gint border_width; | ||
129 | - gint interior_focus; | ||
130 | - gint focus_width; | ||
131 | - gint focus_pad; | ||
132 | - | ||
133 | + gint border_width = 0; | ||
134 | + gint interior_focus = 0; | ||
135 | + gint focus_width = 0; | ||
136 | + gint focus_pad = 0; | ||
137 | + gint indicator_size = 0; | ||
138 | + gint indicator_spacing = 0; | ||
139 | + | ||
140 | gtk_widget_style_get (widget, | ||
141 | "interior-focus", &interior_focus, | ||
142 | "focus-line-width", &focus_width, | ||
143 | "focus-padding", &focus_pad, | ||
144 | + "indicator-size", &indicator_size, | ||
145 | + "indicator-spacing", &indicator_spacing, | ||
146 | NULL); | ||
147 | - | ||
148 | - gtk_check_button_draw_indicator (check_button, area); | ||
149 | |||
150 | border_width = GTK_CONTAINER (widget)->border_width; | ||
151 | + | ||
152 | + /* Hildon: change the focus so that it draws around the entire | ||
153 | + * widget - including both the indicator *and* the label | ||
154 | + */ | ||
155 | if (GTK_WIDGET_HAS_FOCUS (widget)) | ||
156 | { | ||
157 | GtkWidget *child = GTK_BIN (widget)->child; | ||
158 | |||
159 | + int w = indicator_size + 2 * indicator_spacing + | ||
160 | + 2 * (focus_width + focus_pad); | ||
161 | + int h = indicator_size + 2 * indicator_spacing + | ||
162 | + 2 * (focus_width + focus_pad) + 2 * HILDON_SPACING | ||
163 | + - FOCUS_TOP_PADDING; | ||
164 | + int x = widget->allocation.x; | ||
165 | + int y = widget->allocation.y + (widget->allocation.height - h)/2 | ||
166 | + + FOCUS_DOWN_PADDING; | ||
167 | + | ||
168 | + if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL) | ||
169 | + x = widget->allocation.x + widget->allocation.width - | ||
170 | + (2 * HILDON_SPACING) - (indicator_size + 2) - | ||
171 | + (indicator_spacing + 2); | ||
172 | + | ||
173 | if (interior_focus && child && GTK_WIDGET_VISIBLE (child)) | ||
174 | - gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget), | ||
175 | - NULL, widget, "checkbutton", | ||
176 | - child->allocation.x - focus_width - focus_pad, | ||
177 | - child->allocation.y - focus_width - focus_pad, | ||
178 | - child->allocation.width + 2 * (focus_width + focus_pad), | ||
179 | - child->allocation.height + 2 * (focus_width + focus_pad)); | ||
180 | + { | ||
181 | + if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL) | ||
182 | + { | ||
183 | + /* Move the "x" to the left, and enlarge the width, | ||
184 | + both accounting for the child | ||
185 | + */ | ||
186 | + x += - child->allocation.width - HILDON_SPACING - | ||
187 | + (widget->style->xthickness); | ||
188 | + w += child->allocation.width + HILDON_SPACING + | ||
189 | + (widget->style->xthickness); | ||
190 | + } else { | ||
191 | + w = child->allocation.x + child->allocation.width + | ||
192 | + 2 * widget->style->xthickness - x; | ||
193 | + } | ||
194 | + | ||
195 | + gtk_paint_focus (widget->style, widget->window, | ||
196 | + GTK_WIDGET_STATE (widget), | ||
197 | + NULL, widget, "checkbutton", x, y, w, h); | ||
198 | + } | ||
199 | else | ||
200 | - gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget), | ||
201 | - NULL, widget, "checkbutton", | ||
202 | - border_width + widget->allocation.x, | ||
203 | - border_width + widget->allocation.y, | ||
204 | - widget->allocation.width - 2 * border_width, | ||
205 | - widget->allocation.height - 2 * border_width); | ||
206 | + gtk_paint_focus (widget->style, widget->window, | ||
207 | + GTK_WIDGET_STATE (widget), | ||
208 | + NULL, widget, "checkbutton", x, y, w, h); | ||
209 | } | ||
210 | + gtk_check_button_draw_indicator (check_button, area); | ||
211 | } | ||
212 | } | ||
213 | |||
214 | @@ -205,10 +258,10 @@ | ||
215 | gint *indicator_spacing) | ||
216 | { | ||
217 | GtkWidget *widget = GTK_WIDGET (check_button); | ||
218 | - | ||
219 | + | ||
220 | if (indicator_size) | ||
221 | gtk_widget_style_get (widget, "indicator_size", indicator_size, NULL); | ||
222 | - | ||
223 | + | ||
224 | if (indicator_spacing) | ||
225 | gtk_widget_style_get (widget, "indicator_spacing", indicator_spacing, NULL); | ||
226 | } | ||
227 | @@ -233,7 +286,7 @@ | ||
228 | "focus-line-width", &focus_width, | ||
229 | "focus-padding", &focus_pad, | ||
230 | NULL); | ||
231 | - | ||
232 | + | ||
233 | requisition->width = border_width * 2; | ||
234 | requisition->height = border_width * 2; | ||
235 | |||
236 | @@ -246,15 +299,19 @@ | ||
237 | GtkRequisition child_requisition; | ||
238 | |||
239 | gtk_widget_size_request (child, &child_requisition); | ||
240 | - | ||
241 | - requisition->width += child_requisition.width + indicator_spacing; | ||
242 | + | ||
243 | + requisition->width += child_requisition.width + | ||
244 | + 2 * widget->style->xthickness; | ||
245 | requisition->height += child_requisition.height; | ||
246 | + requisition->width += 2 * widget->style->xthickness; | ||
247 | } | ||
248 | |||
249 | - requisition->width += (indicator_size + indicator_spacing * 2 + 2 * (focus_width + focus_pad)); | ||
250 | + requisition->width += (indicator_size + indicator_spacing * 2 + | ||
251 | + 2 * (focus_width + focus_pad)); | ||
252 | |||
253 | temp = indicator_size + indicator_spacing * 2; | ||
254 | - requisition->height = MAX (requisition->height, temp) + 2 * (focus_width + focus_pad); | ||
255 | + requisition->height = MAX (requisition->height, temp) + | ||
256 | + 2 * (focus_width + focus_pad); | ||
257 | } | ||
258 | else | ||
259 | (* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition); | ||
260 | @@ -280,45 +337,59 @@ | ||
261 | gint focus_width; | ||
262 | gint focus_pad; | ||
263 | |||
264 | - _gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing); | ||
265 | + _gtk_check_button_get_props (check_button, | ||
266 | + &indicator_size, &indicator_spacing); | ||
267 | gtk_widget_style_get (widget, | ||
268 | "focus-line-width", &focus_width, | ||
269 | "focus-padding", &focus_pad, | ||
270 | NULL); | ||
271 | - | ||
272 | + | ||
273 | widget->allocation = *allocation; | ||
274 | if (GTK_WIDGET_REALIZED (widget)) | ||
275 | gdk_window_move_resize (button->event_window, | ||
276 | allocation->x, allocation->y, | ||
277 | allocation->width, allocation->height); | ||
278 | |||
279 | - if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child)) | ||
280 | + if (GTK_BIN (button)->child && | ||
281 | + GTK_WIDGET_VISIBLE (GTK_BIN (button)->child)) | ||
282 | { | ||
283 | GtkRequisition child_requisition; | ||
284 | gint border_width = GTK_CONTAINER (widget)->border_width; | ||
285 | - | ||
286 | - gtk_widget_get_child_requisition (GTK_BIN (button)->child, &child_requisition); | ||
287 | + | ||
288 | + gtk_widget_get_child_requisition (GTK_BIN (button)->child, | ||
289 | + &child_requisition); | ||
290 | |||
291 | - child_allocation.width = MIN (child_requisition.width, | ||
292 | + child_allocation.width = MIN ( | ||
293 | + child_requisition.width, | ||
294 | allocation->width - | ||
295 | - ((border_width + focus_width + focus_pad) * 2 | ||
296 | - + indicator_size + indicator_spacing * 3)); | ||
297 | - child_allocation.width = MAX (child_allocation.width, 1); | ||
298 | + ((border_width + focus_width + | ||
299 | + focus_pad) * 2 | ||
300 | + - 2 * widget->style->xthickness + | ||
301 | + indicator_size + | ||
302 | + indicator_spacing * 2 ) ); | ||
303 | |||
304 | + child_allocation.width = MAX (child_allocation.width, 1); | ||
305 | + | ||
306 | child_allocation.height = MIN (child_requisition.height, | ||
307 | - allocation->height - (border_width + focus_width + focus_pad) * 2); | ||
308 | + allocation->height - | ||
309 | + (border_width + focus_width + | ||
310 | + focus_pad) * 2); | ||
311 | child_allocation.height = MAX (child_allocation.height, 1); | ||
312 | |||
313 | - child_allocation.x = (border_width + indicator_size + indicator_spacing * 3 + | ||
314 | - widget->allocation.x + focus_width + focus_pad); | ||
315 | + child_allocation.x = (border_width + indicator_size + | ||
316 | + indicator_spacing * 2 + | ||
317 | + widget->style->xthickness + | ||
318 | + widget->allocation.x + | ||
319 | + focus_width + focus_pad); | ||
320 | child_allocation.y = widget->allocation.y + | ||
321 | - (allocation->height - child_allocation.height) / 2; | ||
322 | - | ||
323 | + (allocation->height - child_allocation.height) / 2; | ||
324 | + | ||
325 | if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) | ||
326 | - child_allocation.x = allocation->x + allocation->width | ||
327 | - - (child_allocation.x - allocation->x + child_allocation.width); | ||
328 | + child_allocation.x = allocation->x + allocation->width - | ||
329 | + (child_allocation.x - allocation->x + child_allocation.width); | ||
330 | |||
331 | - gtk_widget_size_allocate (GTK_BIN (button)->child, &child_allocation); | ||
332 | + gtk_widget_size_allocate (GTK_BIN (button)->child, | ||
333 | + &child_allocation); | ||
334 | } | ||
335 | } | ||
336 | else | ||
337 | @@ -375,45 +446,33 @@ | ||
338 | GdkRectangle *area) | ||
339 | { | ||
340 | GtkWidget *widget; | ||
341 | - GtkWidget *child; | ||
342 | GtkButton *button; | ||
343 | GtkToggleButton *toggle_button; | ||
344 | GtkStateType state_type; | ||
345 | GtkShadowType shadow_type; | ||
346 | - gint x, y; | ||
347 | - gint indicator_size; | ||
348 | - gint indicator_spacing; | ||
349 | - gint focus_width; | ||
350 | - gint focus_pad; | ||
351 | - gboolean interior_focus; | ||
352 | + | ||
353 | + GdkRectangle indicator = {0, 0, 0, 0}; | ||
354 | |||
355 | if (GTK_WIDGET_DRAWABLE (check_button)) | ||
356 | { | ||
357 | widget = GTK_WIDGET (check_button); | ||
358 | button = GTK_BUTTON (check_button); | ||
359 | toggle_button = GTK_TOGGLE_BUTTON (check_button); | ||
360 | - | ||
361 | - gtk_widget_style_get (widget, "interior_focus", &interior_focus, | ||
362 | - "focus-line-width", &focus_width, | ||
363 | - "focus-padding", &focus_pad, NULL); | ||
364 | - | ||
365 | - _gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing); | ||
366 | - | ||
367 | - x = widget->allocation.x + indicator_spacing + GTK_CONTAINER (widget)->border_width; | ||
368 | - y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2; | ||
369 | - | ||
370 | - child = GTK_BIN (check_button)->child; | ||
371 | - if (!interior_focus || !(child && GTK_WIDGET_VISIBLE (child))) | ||
372 | - x += focus_width + focus_pad; | ||
373 | - | ||
374 | + gtk_check_button_calc_indicator_size( check_button, &indicator ); | ||
375 | + | ||
376 | + /* move indicator to root coordinates */ | ||
377 | + indicator.x += widget->allocation.x; | ||
378 | + indicator.y += widget->allocation.y; | ||
379 | + | ||
380 | if (toggle_button->inconsistent) | ||
381 | shadow_type = GTK_SHADOW_ETCHED_IN; | ||
382 | else if (toggle_button->active) | ||
383 | shadow_type = GTK_SHADOW_IN; | ||
384 | else | ||
385 | shadow_type = GTK_SHADOW_OUT; | ||
386 | - | ||
387 | - if (button->activate_timeout || (button->button_down && button->in_button)) | ||
388 | + | ||
389 | + if (button->activate_timeout || | ||
390 | + (button->button_down && button->in_button)) | ||
391 | state_type = GTK_STATE_ACTIVE; | ||
392 | else if (button->in_button) | ||
393 | state_type = GTK_STATE_PRELIGHT; | ||
394 | @@ -422,32 +481,107 @@ | ||
395 | else | ||
396 | state_type = GTK_STATE_NORMAL; | ||
397 | |||
398 | - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) | ||
399 | - x = widget->allocation.x + widget->allocation.width - (indicator_size + x - widget->allocation.x); | ||
400 | + /* Hildon change. We want to draw active image always when we have | ||
401 | + * focus. */ | ||
402 | + if (GTK_WIDGET_HAS_FOCUS (widget)) | ||
403 | + state_type = GTK_STATE_ACTIVE; | ||
404 | |||
405 | - if (GTK_WIDGET_STATE (toggle_button) == GTK_STATE_PRELIGHT) | ||
406 | + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) | ||
407 | { | ||
408 | - GdkRectangle restrict_area; | ||
409 | - GdkRectangle new_area; | ||
410 | - | ||
411 | - restrict_area.x = widget->allocation.x + GTK_CONTAINER (widget)->border_width; | ||
412 | - restrict_area.y = widget->allocation.y + GTK_CONTAINER (widget)->border_width; | ||
413 | - restrict_area.width = widget->allocation.width - (2 * GTK_CONTAINER (widget)->border_width); | ||
414 | - restrict_area.height = widget->allocation.height - (2 * GTK_CONTAINER (widget)->border_width); | ||
415 | + indicator.x = widget->allocation.x + widget->allocation.width | ||
416 | + - (indicator.width + indicator.x - widget->allocation.x); | ||
417 | |||
418 | - if (gdk_rectangle_intersect (area, &restrict_area, &new_area)) | ||
419 | - { | ||
420 | - gtk_paint_flat_box (widget->style, widget->window, GTK_STATE_PRELIGHT, | ||
421 | - GTK_SHADOW_ETCHED_OUT, | ||
422 | - area, widget, "checkbutton", | ||
423 | - new_area.x, new_area.y, | ||
424 | - new_area.width, new_area.height); | ||
425 | - } | ||
426 | } | ||
427 | |||
428 | gtk_paint_check (widget->style, widget->window, | ||
429 | state_type, shadow_type, | ||
430 | area, widget, "checkbutton", | ||
431 | - x, y, indicator_size, indicator_size); | ||
432 | + indicator.x, indicator.y, | ||
433 | + indicator.width, indicator.height); | ||
434 | + } | ||
435 | +} | ||
436 | + | ||
437 | + | ||
438 | +/* calculates the size and position of the indicator | ||
439 | + * relative to the origin of the check button. | ||
440 | + */ | ||
441 | +static void gtk_check_button_calc_indicator_size( GtkCheckButton *button, | ||
442 | + GdkRectangle *rect ) | ||
443 | +{ | ||
444 | + gint indicator_size; | ||
445 | + gint indicator_spacing; | ||
446 | + gint focus_width; | ||
447 | + gint focus_pad; | ||
448 | + gboolean interior_focus; | ||
449 | + GtkWidget *child; | ||
450 | + GtkWidget *widget = GTK_WIDGET(button); | ||
451 | + | ||
452 | + | ||
453 | + gtk_widget_style_get (widget, "interior_focus", &interior_focus, | ||
454 | + "focus-line-width", &focus_width, | ||
455 | + "focus-padding", &focus_pad, | ||
456 | + "indicator-size", &indicator_size, | ||
457 | + "indicator-spacing", &indicator_spacing, | ||
458 | + NULL | ||
459 | + ); | ||
460 | + | ||
461 | + | ||
462 | + /* HILDON: We want the indicator to be positioned according to the spec. | ||
463 | + * | ||
464 | + * NOTE: INDICATOR_SIDE_PADDING and INDICATOR_TOP_PADDING | ||
465 | + * are maJiKal numbers that make the indicator to be drawn | ||
466 | + * to correct coordinates, 1337 \o/ | ||
467 | + */ | ||
468 | + rect->x = INDICATOR_SIDE_PADDING; | ||
469 | + rect->y = ( widget->allocation.height - indicator_size ) / 2; | ||
470 | + | ||
471 | + /* Hildon: we always add space for the focus */ | ||
472 | + rect->x += focus_width + focus_pad; | ||
473 | + | ||
474 | + child = GTK_BIN (widget)->child; | ||
475 | + if (interior_focus && child && GTK_WIDGET_VISIBLE (child)) | ||
476 | + { | ||
477 | + rect->y += HILDON_SPACING; | ||
478 | } | ||
479 | + | ||
480 | + rect->width = indicator_size; | ||
481 | + rect->height = indicator_size; | ||
482 | } | ||
483 | + | ||
484 | +static void | ||
485 | +gtk_check_button_clicked (GtkButton *button) | ||
486 | +{ | ||
487 | + GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button); | ||
488 | + | ||
489 | + toggle_button->active = !toggle_button->active; | ||
490 | + gtk_toggle_button_toggled (toggle_button); | ||
491 | + | ||
492 | + gtk_check_button_update_state (button); | ||
493 | + | ||
494 | + g_object_notify (G_OBJECT (toggle_button), "active"); | ||
495 | +} | ||
496 | + | ||
497 | +static void | ||
498 | +gtk_check_button_update_state (GtkButton *button) | ||
499 | +{ | ||
500 | + GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button); | ||
501 | + gboolean depressed; | ||
502 | + GtkStateType new_state; | ||
503 | + | ||
504 | + if (toggle_button->inconsistent) | ||
505 | + depressed = FALSE; | ||
506 | + else if (button->in_button && button->button_down) | ||
507 | + depressed = TRUE; | ||
508 | + else | ||
509 | + depressed = toggle_button->active; | ||
510 | + | ||
511 | + if (button->in_button && | ||
512 | + (!button->button_down || toggle_button->draw_indicator)) | ||
513 | + new_state = GTK_STATE_PRELIGHT; | ||
514 | + else | ||
515 | + new_state = depressed ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL; | ||
516 | + | ||
517 | + _gtk_button_set_depressed (button, depressed); | ||
518 | + gtk_widget_set_state (GTK_WIDGET (toggle_button), new_state); | ||
519 | +} | ||
520 | + | ||