diff options
author | Richard Purdie <richard@openedhand.com> | 2006-10-17 11:04:43 +0000 |
---|---|---|
committer | Richard Purdie <richard@openedhand.com> | 2006-10-17 11:04:43 +0000 |
commit | 09f13534bdffe20734cb9d24171e7d04334ad24c (patch) | |
tree | 75d62cf9a1d5cfcd2a72602ec68dc90c61041699 /meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkrange.c.diff | |
parent | b6959cf8d390ded754f9a4ab5ce746313663a510 (diff) | |
download | poky-09f13534bdffe20734cb9d24171e7d04334ad24c.tar.gz |
gtk+: remove outdated maemo version
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@804 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkrange.c.diff')
-rw-r--r-- | meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkrange.c.diff | 845 |
1 files changed, 0 insertions, 845 deletions
diff --git a/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkrange.c.diff b/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkrange.c.diff deleted file mode 100644 index 867d2b1d46..0000000000 --- a/meta/packages/gtk+/gtk+-2.6.4-1.osso7/gtkrange.c.diff +++ /dev/null | |||
@@ -1,845 +0,0 @@ | |||
1 | --- gtk+-2.6.4/gtk/gtkrange.c 2004-11-10 05:20:11.000000000 +0200 | ||
2 | +++ gtk+-2.6.4/gtk/gtkrange.c 2005-04-06 16:19:37.788793592 +0300 | ||
3 | @@ -25,6 +25,10 @@ | ||
4 | * GTK+ at ftp://ftp.gtk.org/pub/gtk/. | ||
5 | */ | ||
6 | |||
7 | +/* Modified for Nokia Oyj during 2002-2005. See CHANGES file for list | ||
8 | + * of changes. | ||
9 | + */ | ||
10 | + | ||
11 | #include <config.h> | ||
12 | #include <stdio.h> | ||
13 | #include <math.h> | ||
14 | @@ -44,7 +48,10 @@ | ||
15 | PROP_0, | ||
16 | PROP_UPDATE_POLICY, | ||
17 | PROP_ADJUSTMENT, | ||
18 | - PROP_INVERTED | ||
19 | + PROP_INVERTED, | ||
20 | + PROP_STREAM_INDICATOR, | ||
21 | + PROP_MINIMUM_VISIBLE_BARS, | ||
22 | + PROP_STREAM_POSITION | ||
23 | }; | ||
24 | |||
25 | enum { | ||
26 | @@ -88,8 +95,20 @@ | ||
27 | /* "grabbed" mouse location, OUTSIDE for no grab */ | ||
28 | MouseLocation grab_location; | ||
29 | gint grab_button; /* 0 if none */ | ||
30 | + | ||
31 | + /* OSSO hack: stream trough split position */ | ||
32 | + gint stream_pixel_position; | ||
33 | + gint minimum_visible_bars; | ||
34 | }; | ||
35 | |||
36 | +#define OSSO_GTK_RANGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_RANGE, OssoGtkRangePrivate)) | ||
37 | +typedef struct _OssoGtkRangePrivate OssoGtkRangePrivate; | ||
38 | + | ||
39 | +struct _OssoGtkRangePrivate | ||
40 | +{ | ||
41 | + gboolean stream_indicator; | ||
42 | + gdouble stream_position; | ||
43 | +}; | ||
44 | |||
45 | static void gtk_range_class_init (GtkRangeClass *klass); | ||
46 | static void gtk_range_init (GtkRange *range); | ||
47 | @@ -135,6 +154,7 @@ | ||
48 | gint mouse_x, | ||
49 | gint mouse_y); | ||
50 | |||
51 | +static gint osso_gtk_range_focus_out (GtkWidget *widget, GdkEventFocus *event); | ||
52 | |||
53 | /* Range methods */ | ||
54 | |||
55 | @@ -247,6 +267,9 @@ | ||
56 | widget_class->state_changed = gtk_range_state_changed; | ||
57 | widget_class->style_set = gtk_range_style_set; | ||
58 | |||
59 | + /* OSSO addition (see bug #1653) */ | ||
60 | + widget_class->focus_out_event = osso_gtk_range_focus_out; | ||
61 | + | ||
62 | class->move_slider = gtk_range_move_slider; | ||
63 | class->change_value = gtk_range_real_change_value; | ||
64 | |||
65 | @@ -344,6 +367,34 @@ | ||
66 | FALSE, | ||
67 | G_PARAM_READWRITE)); | ||
68 | |||
69 | + g_object_class_install_property (gobject_class, | ||
70 | + PROP_STREAM_INDICATOR, | ||
71 | + g_param_spec_boolean ("stream_indicator", | ||
72 | + P_("Stream Indicator"), | ||
73 | + P_("Whether to display a stream indicator graphics on trough."), | ||
74 | + FALSE, | ||
75 | + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); | ||
76 | + | ||
77 | + g_object_class_install_property (gobject_class, | ||
78 | + PROP_MINIMUM_VISIBLE_BARS, | ||
79 | + g_param_spec_int ("minimum_visible_bars", | ||
80 | + P_("Minimum visible bars"), | ||
81 | + P_("The minimum number of visible bars in a HildonControlBar"), | ||
82 | + 0, | ||
83 | + G_MAXINT, | ||
84 | + 0, | ||
85 | + G_PARAM_READWRITE)); | ||
86 | + | ||
87 | + g_object_class_install_property (gobject_class, | ||
88 | + PROP_STREAM_POSITION, | ||
89 | + g_param_spec_double ("stream_position", | ||
90 | + P_("Stream Position"), | ||
91 | + P_("The position of the streaming."), | ||
92 | + -G_MAXDOUBLE, | ||
93 | + G_MAXDOUBLE, | ||
94 | + 0.0, | ||
95 | + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); | ||
96 | + | ||
97 | gtk_widget_class_install_style_property (widget_class, | ||
98 | g_param_spec_int ("slider_width", | ||
99 | P_("Slider Width"), | ||
100 | @@ -392,6 +443,52 @@ | ||
101 | G_MAXINT, | ||
102 | 0, | ||
103 | G_PARAM_READABLE)); | ||
104 | + | ||
105 | + gtk_widget_class_install_style_property (widget_class, | ||
106 | + g_param_spec_boolean ("hildonlike", | ||
107 | + _("hildonlike"), | ||
108 | + _("Change focus out behaviour, 1/0"), | ||
109 | + FALSE, | ||
110 | + G_PARAM_READABLE)); | ||
111 | + | ||
112 | + gtk_widget_class_install_style_property (widget_class, | ||
113 | + g_param_spec_boolean ("two_part_trough", | ||
114 | + _("Two-part trough"), | ||
115 | + _("Allow different trough graphics on different sides of the slider, 1/0"), | ||
116 | + FALSE, | ||
117 | + G_PARAM_READABLE)); | ||
118 | + | ||
119 | + gtk_widget_class_install_style_property (widget_class, | ||
120 | + g_param_spec_int ("stream_indicator_padding", | ||
121 | + P_("Stream Indicator Padding"), | ||
122 | + P_("How many pixels smallerthan the trough the stream indicator is drawn from both ends ."), | ||
123 | + 0, | ||
124 | + G_MAXINT, | ||
125 | + 1, | ||
126 | + G_PARAM_READABLE)); | ||
127 | + | ||
128 | + gtk_widget_class_install_style_property (widget_class, | ||
129 | + g_param_spec_boolean ("autodimmed_steppers", | ||
130 | + _("Autodimmed steppers"), | ||
131 | + _("Automatically dim steppers when maximum or minimum value has been reached"), | ||
132 | + FALSE, | ||
133 | + G_PARAM_READABLE)); | ||
134 | + | ||
135 | + gtk_widget_class_install_style_property (widget_class, | ||
136 | + g_param_spec_boolean ("arrow_paint_box_layout", | ||
137 | + _("Arrow paint box layout"), | ||
138 | + _("Allows to use images instead of normal arrows."), | ||
139 | + FALSE, | ||
140 | + G_PARAM_READABLE)); | ||
141 | + | ||
142 | + gtk_widget_class_install_style_property (widget_class, | ||
143 | + g_param_spec_boolean ("draw_trough_under_steppers", | ||
144 | + _("Draw trough under steppers"), | ||
145 | + _("Whether to draw trought for full length of range or exclude the steppers and spacing"), | ||
146 | + TRUE, | ||
147 | + G_PARAM_READABLE)); | ||
148 | + | ||
149 | + g_type_class_add_private (gobject_class, sizeof (OssoGtkRangePrivate)); | ||
150 | } | ||
151 | |||
152 | static void | ||
153 | @@ -415,6 +512,15 @@ | ||
154 | case PROP_INVERTED: | ||
155 | gtk_range_set_inverted (range, g_value_get_boolean (value)); | ||
156 | break; | ||
157 | + case PROP_STREAM_INDICATOR: | ||
158 | + osso_gtk_range_set_stream_indicator (range, g_value_get_boolean (value)); | ||
159 | + break; | ||
160 | + case PROP_STREAM_POSITION: | ||
161 | + osso_gtk_range_set_stream_position (range, g_value_get_double (value)); | ||
162 | + break; | ||
163 | + case PROP_MINIMUM_VISIBLE_BARS: | ||
164 | + range->layout->minimum_visible_bars = g_value_get_int(value); | ||
165 | + break; | ||
166 | default: | ||
167 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
168 | break; | ||
169 | @@ -442,6 +548,15 @@ | ||
170 | case PROP_INVERTED: | ||
171 | g_value_set_boolean (value, range->inverted); | ||
172 | break; | ||
173 | + case PROP_STREAM_INDICATOR: | ||
174 | + g_value_set_boolean (value, osso_gtk_range_get_stream_indicator (range)); | ||
175 | + break; | ||
176 | + case PROP_STREAM_POSITION: | ||
177 | + g_value_set_double (value, osso_gtk_range_get_stream_indicator (range)); | ||
178 | + break; | ||
179 | + case PROP_MINIMUM_VISIBLE_BARS: | ||
180 | + g_value_set_int (value, range->layout->minimum_visible_bars); | ||
181 | + break; | ||
182 | default: | ||
183 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
184 | break; | ||
185 | @@ -451,6 +566,7 @@ | ||
186 | static void | ||
187 | gtk_range_init (GtkRange *range) | ||
188 | { | ||
189 | + OssoGtkRangePrivate *priv = OSSO_GTK_RANGE_GET_PRIVATE (range); | ||
190 | GTK_WIDGET_SET_FLAGS (range, GTK_NO_WINDOW); | ||
191 | |||
192 | range->adjustment = NULL; | ||
193 | @@ -471,6 +587,9 @@ | ||
194 | range->layout->grab_location = MOUSE_OUTSIDE; | ||
195 | range->layout->grab_button = 0; | ||
196 | range->timer = NULL; | ||
197 | + | ||
198 | + priv->stream_indicator = FALSE; | ||
199 | + priv->stream_position = 0.0; | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | @@ -584,7 +703,10 @@ | ||
204 | g_signal_connect (adjustment, "changed", | ||
205 | G_CALLBACK (gtk_range_adjustment_changed), | ||
206 | range); | ||
207 | - g_signal_connect (adjustment, "value_changed", | ||
208 | + /* OSSO modification : Changed for controlbar. | ||
209 | + * There we intercept this signal and put forth | ||
210 | + * our own, with modified parameters. */ | ||
211 | + g_signal_connect_after (adjustment, "value_changed", | ||
212 | G_CALLBACK (gtk_range_adjustment_value_changed), | ||
213 | range); | ||
214 | |||
215 | @@ -677,16 +799,21 @@ | ||
216 | gdouble max) | ||
217 | { | ||
218 | gdouble value; | ||
219 | + OssoGtkRangePrivate *priv; | ||
220 | |||
221 | g_return_if_fail (GTK_IS_RANGE (range)); | ||
222 | g_return_if_fail (min < max); | ||
223 | |||
224 | + priv = OSSO_GTK_RANGE_GET_PRIVATE (range); | ||
225 | + | ||
226 | range->adjustment->lower = min; | ||
227 | range->adjustment->upper = max; | ||
228 | |||
229 | value = CLAMP (range->adjustment->value, | ||
230 | range->adjustment->lower, | ||
231 | (range->adjustment->upper - range->adjustment->page_size)); | ||
232 | + if (priv->stream_indicator && value > priv->stream_position) | ||
233 | + value = (gdouble)priv->stream_position; | ||
234 | |||
235 | gtk_adjustment_set_value (range->adjustment, value); | ||
236 | gtk_adjustment_changed (range->adjustment); | ||
237 | @@ -707,10 +834,16 @@ | ||
238 | gtk_range_set_value (GtkRange *range, | ||
239 | gdouble value) | ||
240 | { | ||
241 | + OssoGtkRangePrivate *priv; | ||
242 | + | ||
243 | g_return_if_fail (GTK_IS_RANGE (range)); | ||
244 | |||
245 | + priv = OSSO_GTK_RANGE_GET_PRIVATE (range); | ||
246 | + | ||
247 | value = CLAMP (value, range->adjustment->lower, | ||
248 | (range->adjustment->upper - range->adjustment->page_size)); | ||
249 | + if (priv->stream_indicator && value > priv->stream_position) | ||
250 | + value = (gdouble)priv->stream_position; | ||
251 | |||
252 | gtk_adjustment_set_value (range->adjustment, value); | ||
253 | } | ||
254 | @@ -913,6 +1046,10 @@ | ||
255 | gint arrow_width; | ||
256 | gint arrow_height; | ||
257 | |||
258 | + /* OSSO modification: state of our style properties */ | ||
259 | + gboolean autodimmed_steppers = FALSE; | ||
260 | + gboolean arrow_paint_box_layout = FALSE; | ||
261 | + | ||
262 | /* More to get the right clip region than for efficiency */ | ||
263 | if (!gdk_rectangle_intersect (area, rect, &intersection)) | ||
264 | return; | ||
265 | @@ -929,6 +1066,37 @@ | ||
266 | else | ||
267 | state_type = GTK_STATE_NORMAL; | ||
268 | |||
269 | + /* OSSO modification : read all of our style properties needed in this func */ | ||
270 | + gtk_widget_style_get (widget, | ||
271 | + "autodimmed_steppers", &autodimmed_steppers, | ||
272 | + "arrow_paint_box_layout", &arrow_paint_box_layout, | ||
273 | + NULL); | ||
274 | + | ||
275 | + /* OSSO modification : dim the stepper if maximum or minimum value has been reached */ | ||
276 | + if (autodimmed_steppers) | ||
277 | + { | ||
278 | + OssoGtkRangePrivate *priv = OSSO_GTK_RANGE_GET_PRIVATE (range); | ||
279 | + if (((!range->inverted && (arrow_type == GTK_ARROW_DOWN || | ||
280 | + arrow_type == GTK_ARROW_RIGHT)) || | ||
281 | + (range->inverted && (arrow_type == GTK_ARROW_UP || | ||
282 | + arrow_type == GTK_ARROW_LEFT))) && | ||
283 | + range->adjustment->value >= | ||
284 | + (priv->stream_indicator | ||
285 | + ? priv->stream_position | ||
286 | + : range->adjustment->upper - range->adjustment->page_size)) | ||
287 | + { | ||
288 | + state_type = GTK_STATE_INSENSITIVE; | ||
289 | + } | ||
290 | + else if (((!range->inverted && (arrow_type == GTK_ARROW_UP || | ||
291 | + arrow_type == GTK_ARROW_LEFT)) || | ||
292 | + (range->inverted && (arrow_type == GTK_ARROW_DOWN || | ||
293 | + arrow_type == GTK_ARROW_RIGHT))) && | ||
294 | + range->adjustment->value <= range->adjustment->lower) | ||
295 | + { | ||
296 | + state_type = GTK_STATE_INSENSITIVE; | ||
297 | + } | ||
298 | + } | ||
299 | + | ||
300 | if (clicked) | ||
301 | shadow_type = GTK_SHADOW_IN; | ||
302 | else | ||
303 | @@ -944,10 +1112,20 @@ | ||
304 | rect->width, | ||
305 | rect->height); | ||
306 | |||
307 | - arrow_width = rect->width / 2; | ||
308 | - arrow_height = rect->height / 2; | ||
309 | - arrow_x = widget->allocation.x + rect->x + (rect->width - arrow_width) / 2; | ||
310 | - arrow_y = widget->allocation.y + rect->y + (rect->height - arrow_height) / 2; | ||
311 | + if (arrow_paint_box_layout) | ||
312 | + { | ||
313 | + arrow_width = rect->width; | ||
314 | + arrow_height = rect->height; | ||
315 | + arrow_x = widget->allocation.x + rect->x; | ||
316 | + arrow_y = widget->allocation.y + rect->y; | ||
317 | + } | ||
318 | + else | ||
319 | + { | ||
320 | + arrow_width = rect->width / 2; | ||
321 | + arrow_height = rect->height / 2; | ||
322 | + arrow_x = widget->allocation.x + rect->x + (rect->width - arrow_width) / 2; | ||
323 | + arrow_y = widget->allocation.y + rect->y + (rect->height - arrow_height) / 2; | ||
324 | + } | ||
325 | |||
326 | if (clicked) | ||
327 | { | ||
328 | @@ -982,8 +1160,11 @@ | ||
329 | GdkRectangle area; | ||
330 | gint focus_line_width = 0; | ||
331 | gint focus_padding = 0; | ||
332 | + OssoGtkRangePrivate *priv; | ||
333 | |||
334 | range = GTK_RANGE (widget); | ||
335 | + | ||
336 | + priv = OSSO_GTK_RANGE_GET_PRIVATE (range); | ||
337 | |||
338 | if (GTK_WIDGET_CAN_FOCUS (range)) | ||
339 | { | ||
340 | @@ -1011,18 +1192,118 @@ | ||
341 | if (gdk_rectangle_intersect (&expose_area, &range->range_rect, | ||
342 | &area)) | ||
343 | { | ||
344 | + gint x = widget->allocation.x + range->range_rect.x + focus_line_width + focus_padding; | ||
345 | + gint y = widget->allocation.y + range->range_rect.y + focus_line_width + focus_padding; | ||
346 | + gint width = range->range_rect.width - 2 * (focus_line_width + focus_padding); | ||
347 | + gint height = range->range_rect.height - 2 * (focus_line_width + focus_padding); | ||
348 | + gint *virtual_position, *virtual_size; | ||
349 | + gboolean two_part_trough = 0; | ||
350 | + gint stepper_size = 0; | ||
351 | + gint stepper_spacing = 0; | ||
352 | + gboolean draw_trough_under_steppers = TRUE; | ||
353 | + | ||
354 | area.x += widget->allocation.x; | ||
355 | area.y += widget->allocation.y; | ||
356 | + | ||
357 | + gtk_widget_style_get (GTK_WIDGET (range), | ||
358 | + "two_part_trough", &two_part_trough, | ||
359 | + "stepper_size", &stepper_size, | ||
360 | + "stepper_spacing", &stepper_spacing, | ||
361 | + "draw_trough_under_steppers", &draw_trough_under_steppers, | ||
362 | + NULL); | ||
363 | + | ||
364 | + if (range->orientation == GTK_ORIENTATION_HORIZONTAL) | ||
365 | + { | ||
366 | + virtual_position = &x; | ||
367 | + virtual_size = &width; | ||
368 | + } | ||
369 | + else | ||
370 | + { | ||
371 | + virtual_position = &y; | ||
372 | + virtual_size = &height; | ||
373 | + } | ||
374 | + | ||
375 | + if (draw_trough_under_steppers == FALSE) | ||
376 | + { | ||
377 | + *virtual_position += stepper_size + stepper_spacing; | ||
378 | + *virtual_size -= 2 * (stepper_size + stepper_spacing); | ||
379 | + } | ||
380 | |||
381 | - gtk_paint_box (widget->style, | ||
382 | - widget->window, | ||
383 | - sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, | ||
384 | - GTK_SHADOW_IN, | ||
385 | - &area, GTK_WIDGET(range), "trough", | ||
386 | - widget->allocation.x + range->range_rect.x + focus_line_width + focus_padding, | ||
387 | - widget->allocation.y + range->range_rect.y + focus_line_width + focus_padding, | ||
388 | - range->range_rect.width - 2 * (focus_line_width + focus_padding), | ||
389 | - range->range_rect.height - 2 * (focus_line_width + focus_padding)); | ||
390 | + if (two_part_trough == FALSE) | ||
391 | + { | ||
392 | + gtk_paint_box (widget->style, | ||
393 | + widget->window, | ||
394 | + sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, | ||
395 | + GTK_SHADOW_IN, | ||
396 | + &area, GTK_WIDGET(range), "trough", | ||
397 | + x, y, | ||
398 | + width, height); | ||
399 | + } | ||
400 | + else | ||
401 | + { | ||
402 | + gint trough_change_pos_x = width; | ||
403 | + gint trough_change_pos_y = height; | ||
404 | + | ||
405 | + if (range->orientation == GTK_ORIENTATION_HORIZONTAL) | ||
406 | + trough_change_pos_x = range->layout->slider.x + (range->layout->slider.width / 2) - stepper_size - stepper_spacing; | ||
407 | + else | ||
408 | + trough_change_pos_y = range->layout->slider.y + (range->layout->slider.height / 2) - stepper_size - stepper_spacing; | ||
409 | + | ||
410 | + gtk_paint_box (widget->style, | ||
411 | + widget->window, | ||
412 | + sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, | ||
413 | + GTK_SHADOW_IN, | ||
414 | + &area, GTK_WIDGET(range), "trough_northwest", | ||
415 | + x, y, | ||
416 | + trough_change_pos_x, trough_change_pos_y); | ||
417 | + | ||
418 | + if (range->orientation == GTK_ORIENTATION_HORIZONTAL) | ||
419 | + trough_change_pos_y = 0; | ||
420 | + else | ||
421 | + trough_change_pos_x = 0; | ||
422 | + | ||
423 | + gtk_paint_box (widget->style, | ||
424 | + widget->window, | ||
425 | + sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, | ||
426 | + GTK_SHADOW_IN, | ||
427 | + &area, GTK_WIDGET(range), "trough_southeast", | ||
428 | + x + trough_change_pos_x, y + trough_change_pos_y, | ||
429 | + width - trough_change_pos_x, height - trough_change_pos_y); | ||
430 | + } | ||
431 | + | ||
432 | + /* Stream indicator drawing does not support inverted state. */ | ||
433 | + if (priv->stream_indicator) | ||
434 | + { | ||
435 | + gchar *used_detail; | ||
436 | + gint stream_start_pos_x = 0; | ||
437 | + gint stream_start_pos_y = 0; | ||
438 | + gint stream_width = width; | ||
439 | + gint stream_height = height; | ||
440 | + | ||
441 | + if (range->orientation == GTK_ORIENTATION_HORIZONTAL) | ||
442 | + { | ||
443 | + stream_start_pos_x = range->layout->slider.x; | ||
444 | + stream_width = range->layout->stream_pixel_position - stream_start_pos_x; | ||
445 | + } | ||
446 | + else | ||
447 | + { | ||
448 | + stream_start_pos_y = range->layout->slider.y; | ||
449 | + stream_height = range->layout->stream_pixel_position - stream_start_pos_y; | ||
450 | + } | ||
451 | + | ||
452 | + if (priv->stream_position == range->adjustment->upper) | ||
453 | + used_detail = "trough_stream_complete"; | ||
454 | + else | ||
455 | + used_detail = "trough_stream"; | ||
456 | + | ||
457 | + gtk_paint_box (widget->style, | ||
458 | + widget->window, | ||
459 | + sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, | ||
460 | + GTK_SHADOW_IN, | ||
461 | + &area, GTK_WIDGET(range), used_detail, | ||
462 | + widget->allocation.x + stream_start_pos_x, widget->allocation.y + stream_start_pos_y, | ||
463 | + stream_width, stream_height); | ||
464 | + } | ||
465 | |||
466 | |||
467 | if (sensitive && | ||
468 | @@ -1189,19 +1470,41 @@ | ||
469 | { | ||
470 | gdouble frac; | ||
471 | gdouble value; | ||
472 | - | ||
473 | - if (range->orientation == GTK_ORIENTATION_VERTICAL) | ||
474 | + gint stepper_spacing = 0; | ||
475 | + gint minimum_visible_blocks = 0; | ||
476 | + gint magic_value = 0; | ||
477 | + | ||
478 | + g_object_get(range, "minimum_visible_bars", &minimum_visible_blocks, NULL); | ||
479 | + | ||
480 | + g_print("coord = %d\n", coord); | ||
481 | + gtk_widget_style_get (GTK_WIDGET (range), | ||
482 | + "stepper_spacing", &stepper_spacing, | ||
483 | + NULL); | ||
484 | + | ||
485 | + if (range->orientation == GTK_ORIENTATION_VERTICAL) { | ||
486 | + if (minimum_visible_blocks > 0) | ||
487 | + magic_value = ((range->layout->trough.height -(2*stepper_spacing)) / (range->adjustment->upper - range->adjustment->lower + 1)) * minimum_visible_blocks; | ||
488 | if (range->layout->trough.height == range->layout->slider.height) | ||
489 | frac = 1.0; | ||
490 | else | ||
491 | - frac = ((coord - range->layout->trough.y) / | ||
492 | - (gdouble) (range->layout->trough.height - range->layout->slider.height)); | ||
493 | - else | ||
494 | + frac = ((coord - range->layout->trough.y - magic_value - stepper_spacing) / | ||
495 | + (gdouble) (range->layout->trough.height - magic_value - range->layout->slider.height - (2 * stepper_spacing))); | ||
496 | + } | ||
497 | + else { | ||
498 | + if (minimum_visible_blocks > 0) | ||
499 | + magic_value = ((range->layout->trough.width -(2*stepper_spacing)) / (range->adjustment->upper - range->adjustment->lower + 1)) * minimum_visible_blocks; | ||
500 | if (range->layout->trough.width == range->layout->slider.width) | ||
501 | frac = 1.0; | ||
502 | else | ||
503 | - frac = ((coord - range->layout->trough.x) / | ||
504 | - (gdouble) (range->layout->trough.width - range->layout->slider.width)); | ||
505 | + frac = ((coord - range->layout->trough.x - magic_value - stepper_spacing) / | ||
506 | + (gdouble) (range->layout->trough.width - magic_value - range->layout->slider.width - (2 * stepper_spacing))); | ||
507 | + } | ||
508 | + | ||
509 | + if (frac < 0.0) | ||
510 | + frac = 0.0; | ||
511 | + else | ||
512 | + if (frac > 1.0) | ||
513 | + frac = 1.0; | ||
514 | |||
515 | if (should_invert (range)) | ||
516 | frac = 1.0 - frac; | ||
517 | @@ -1242,6 +1545,8 @@ | ||
518 | range->orientation == GTK_ORIENTATION_VERTICAL ? | ||
519 | event->y : event->x); | ||
520 | |||
521 | + g_print("button_press: calling coord_to_value with %d, click value = %d\n", event->x, click_value); | ||
522 | + | ||
523 | range->trough_click_forward = click_value > range->adjustment->value; | ||
524 | range_grab_add (range, MOUSE_TROUGH, event->button); | ||
525 | |||
526 | @@ -1286,7 +1591,9 @@ | ||
527 | * On button 2 press, we warp the slider to mouse position, | ||
528 | * then begin the slider drag. | ||
529 | */ | ||
530 | - if (event->button == 2) | ||
531 | + /* OSSO modification : We want this to be | ||
532 | + * the default behaviour. */ | ||
533 | + if (range->layout->mouse_location == MOUSE_TROUGH) | ||
534 | { | ||
535 | gdouble slider_low_value, slider_high_value, new_value; | ||
536 | |||
537 | @@ -1299,7 +1606,10 @@ | ||
538 | range->orientation == GTK_ORIENTATION_VERTICAL ? | ||
539 | event->y - range->layout->slider.height : | ||
540 | event->x - range->layout->slider.width); | ||
541 | - | ||
542 | + | ||
543 | + g_print("calling coord_to_value with %d\n", event->x); | ||
544 | + g_print("calling coord_to_value with %d\n", range->orientation == GTK_ORIENTATION_VERTICAL? event->y-range->layout->slider.height:event->x-range->layout->slider.width); | ||
545 | + | ||
546 | /* compute new value for warped slider */ | ||
547 | new_value = slider_low_value + (slider_high_value - slider_low_value) / 2; | ||
548 | |||
549 | @@ -1353,8 +1663,10 @@ | ||
550 | else | ||
551 | delta = mouse_x - range->slide_initial_coordinate; | ||
552 | |||
553 | + delta += -4; | ||
554 | c = range->slide_initial_slider_position + delta; | ||
555 | |||
556 | + g_print("delta = %d, calling coord_to_value with %d + delta = %d\n", delta, range->slide_initial_slider_position, c); | ||
557 | new_value = coord_to_value (range, c); | ||
558 | |||
559 | g_signal_emit (range, signals[CHANGE_VALUE], 0, GTK_SCROLL_JUMP, new_value, | ||
560 | @@ -1395,9 +1707,12 @@ | ||
561 | |||
562 | if (range->layout->grab_button == event->button) | ||
563 | { | ||
564 | + /* OSSO modification : Commented out. | ||
565 | + * Not sure about the reason unfortunately. */ | ||
566 | +/* | ||
567 | if (range->layout->grab_location == MOUSE_SLIDER) | ||
568 | update_slider_position (range, range->layout->mouse_x, range->layout->mouse_y); | ||
569 | - | ||
570 | +*/ | ||
571 | stop_scrolling (range); | ||
572 | |||
573 | return TRUE; | ||
574 | @@ -2026,6 +2341,7 @@ | ||
575 | GdkRectangle range_rect; | ||
576 | GtkRangeLayout *layout; | ||
577 | GtkWidget *widget; | ||
578 | + gint minimum_visible_bars = 0; | ||
579 | |||
580 | if (!range->need_recalc) | ||
581 | return; | ||
582 | @@ -2047,6 +2363,8 @@ | ||
583 | &slider_width, &stepper_size, &trough_border, &stepper_spacing, | ||
584 | NULL, NULL); | ||
585 | |||
586 | + g_object_get(range, "minimum_visible_bars", &minimum_visible_bars, NULL); | ||
587 | + | ||
588 | gtk_range_calc_request (range, | ||
589 | slider_width, stepper_size, trough_border, stepper_spacing, | ||
590 | &range_rect, &border, &n_steppers, &slider_length); | ||
591 | @@ -2167,10 +2485,13 @@ | ||
592 | /* Compute slider position/length */ | ||
593 | { | ||
594 | gint y, bottom, top, height; | ||
595 | - | ||
596 | - top = layout->trough.y + stepper_spacing; | ||
597 | - bottom = layout->trough.y + layout->trough.height - stepper_spacing; | ||
598 | - | ||
599 | + gint magic_value; | ||
600 | + | ||
601 | + magic_value = (layout->trough.height / (range->adjustment->upper - range->adjustment->lower + 1)); | ||
602 | + | ||
603 | + top = layout->trough.y + stepper_spacing + (minimum_visible_bars * magic_value); | ||
604 | + bottom = layout->trough.y + layout->trough.height - stepper_spacing; | ||
605 | + | ||
606 | /* slider height is the fraction (page_size / | ||
607 | * total_adjustment_range) times the trough height in pixels | ||
608 | */ | ||
609 | @@ -2307,8 +2628,11 @@ | ||
610 | /* Compute slider position/length */ | ||
611 | { | ||
612 | gint x, left, right, width; | ||
613 | + gint magic_value; | ||
614 | + | ||
615 | + magic_value = (layout->trough.width / (range->adjustment->upper - range->adjustment->lower + 1)); | ||
616 | |||
617 | - left = layout->trough.x + stepper_spacing; | ||
618 | + left = layout->trough.x + stepper_spacing + (minimum_visible_bars * magic_value); | ||
619 | right = layout->trough.x + layout->trough.width - stepper_spacing; | ||
620 | |||
621 | /* slider width is the fraction (page_size / | ||
622 | @@ -2340,6 +2664,32 @@ | ||
623 | |||
624 | layout->slider.x = x; | ||
625 | layout->slider.width = width; | ||
626 | + | ||
627 | + /* Hildon modification : Calculate the x point of streaming | ||
628 | + * indicator. | ||
629 | + */ | ||
630 | + { | ||
631 | + gint stream_indicator_padding = 0; | ||
632 | + OssoGtkRangePrivate *priv = OSSO_GTK_RANGE_GET_PRIVATE (range); | ||
633 | + gtk_widget_style_get (widget, | ||
634 | + "stream_indicator_padding", &stream_indicator_padding, | ||
635 | + NULL); | ||
636 | + | ||
637 | + if (priv->stream_indicator == TRUE) | ||
638 | + { | ||
639 | + if (range->adjustment->upper - range->adjustment->lower != 0) | ||
640 | + layout->stream_pixel_position = | ||
641 | + (right - left - (2 * stream_indicator_padding)) * | ||
642 | + ((priv->stream_position - range->adjustment->lower) / | ||
643 | + (range->adjustment->upper - range->adjustment->lower)) + | ||
644 | + left + stream_indicator_padding; | ||
645 | + else | ||
646 | + layout->stream_pixel_position = left + stream_indicator_padding; | ||
647 | + | ||
648 | + if (layout->stream_pixel_position < left + stream_indicator_padding) | ||
649 | + layout->stream_pixel_position = left + stream_indicator_padding; | ||
650 | + } | ||
651 | + } | ||
652 | |||
653 | /* These are publically exported */ | ||
654 | range->slider_start = layout->slider.x; | ||
655 | @@ -2382,12 +2732,17 @@ | ||
656 | GtkScrollType scroll, | ||
657 | gdouble value) | ||
658 | { | ||
659 | + OssoGtkRangePrivate *priv = OSSO_GTK_RANGE_GET_PRIVATE (range); | ||
660 | + | ||
661 | /* potentially adjust the bounds _before we clamp */ | ||
662 | g_signal_emit (range, signals[ADJUST_BOUNDS], 0, value); | ||
663 | |||
664 | value = CLAMP (value, range->adjustment->lower, | ||
665 | (range->adjustment->upper - range->adjustment->page_size)); | ||
666 | |||
667 | + if (priv->stream_indicator && value > priv->stream_position) | ||
668 | + value = (gdouble)priv->stream_position; | ||
669 | + | ||
670 | if (range->round_digits >= 0) | ||
671 | { | ||
672 | gdouble power; | ||
673 | @@ -2465,11 +2820,16 @@ | ||
674 | initial_timeout (gpointer data) | ||
675 | { | ||
676 | GtkRange *range; | ||
677 | + GtkSettings *settings; | ||
678 | + guint timeout = SCROLL_LATER_DELAY; | ||
679 | + | ||
680 | + settings = gtk_settings_get_default (); | ||
681 | + g_object_get (settings, "gtk-update-timeout", &timeout, NULL); | ||
682 | |||
683 | GDK_THREADS_ENTER (); | ||
684 | range = GTK_RANGE (data); | ||
685 | range->timer->timeout_id = | ||
686 | - g_timeout_add (SCROLL_LATER_DELAY, | ||
687 | + g_timeout_add (/*SCROLL_LATER_DELAY*/timeout, | ||
688 | second_timeout, | ||
689 | range); | ||
690 | GDK_THREADS_LEAVE (); | ||
691 | @@ -2482,13 +2842,19 @@ | ||
692 | gtk_range_add_step_timer (GtkRange *range, | ||
693 | GtkScrollType step) | ||
694 | { | ||
695 | + GtkSettings *settings; | ||
696 | + guint timeout = SCROLL_INITIAL_DELAY; | ||
697 | + | ||
698 | g_return_if_fail (range->timer == NULL); | ||
699 | g_return_if_fail (step != GTK_SCROLL_NONE); | ||
700 | |||
701 | + settings = gtk_settings_get_default (); | ||
702 | + g_object_get (settings, "gtk-initial-timeout", &timeout, NULL); | ||
703 | + | ||
704 | range->timer = g_new (GtkRangeStepTimer, 1); | ||
705 | |||
706 | range->timer->timeout_id = | ||
707 | - g_timeout_add (SCROLL_INITIAL_DELAY, | ||
708 | + g_timeout_add (/*SCROLL_INITIAL_DELAY*/timeout, | ||
709 | initial_timeout, | ||
710 | range); | ||
711 | range->timer->step = step; | ||
712 | @@ -2528,9 +2894,15 @@ | ||
713 | static void | ||
714 | gtk_range_reset_update_timer (GtkRange *range) | ||
715 | { | ||
716 | + /*GtkSettings *settings; | ||
717 | + guint timeout = UPDATE_DELAY; | ||
718 | + | ||
719 | + settings = gtk_settings_get_default (); | ||
720 | + g_object_get (settings, "gtk-update-timeout", &timeout, NULL);*/ | ||
721 | + | ||
722 | gtk_range_remove_update_timer (range); | ||
723 | |||
724 | - range->update_timeout_id = g_timeout_add (UPDATE_DELAY, | ||
725 | + range->update_timeout_id = g_timeout_add (/*timeout*/UPDATE_DELAY, | ||
726 | update_timeout, | ||
727 | range); | ||
728 | } | ||
729 | @@ -2544,3 +2916,116 @@ | ||
730 | range->update_timeout_id = 0; | ||
731 | } | ||
732 | } | ||
733 | + | ||
734 | +/** | ||
735 | + * osso_gtk_range_set_stream_indicator: | ||
736 | + * @range: A GtkRange | ||
737 | + * @stream_indicator: Whether stream indicator graphics is shown and restricts slider. | ||
738 | + * | ||
739 | + * Sets whether a graphical stream indicator | ||
740 | + * is show on the trough and the slider is restricted | ||
741 | + * to streamed area. | ||
742 | + **/ | ||
743 | +void | ||
744 | +osso_gtk_range_set_stream_indicator (GtkRange *range, gboolean stream_indicator) | ||
745 | +{ | ||
746 | + OssoGtkRangePrivate *priv; | ||
747 | + | ||
748 | + g_return_if_fail (GTK_IS_RANGE (range)); | ||
749 | + | ||
750 | + priv = OSSO_GTK_RANGE_GET_PRIVATE (range); | ||
751 | + | ||
752 | + if (stream_indicator == priv->stream_indicator) | ||
753 | + return; | ||
754 | + | ||
755 | + priv->stream_indicator = stream_indicator; | ||
756 | + g_signal_emit_by_name (G_OBJECT (range), "value_changed", NULL); | ||
757 | +} | ||
758 | + | ||
759 | +/** | ||
760 | + * osso_gtk_range_get_stream_indicator: | ||
761 | + * @range: A GtkRange | ||
762 | + * | ||
763 | + * Return value: Whether GtkRange displays an | ||
764 | + * stream indicator graphics and slider is restricted | ||
765 | + * to streamed area | ||
766 | + **/ | ||
767 | +gboolean | ||
768 | +osso_gtk_range_get_stream_indicator (GtkRange *range) | ||
769 | +{ | ||
770 | + OssoGtkRangePrivate *priv; | ||
771 | + | ||
772 | + g_return_val_if_fail (GTK_IS_RANGE (range), FALSE); | ||
773 | + | ||
774 | + priv = OSSO_GTK_RANGE_GET_PRIVATE (range); | ||
775 | + | ||
776 | + return priv->stream_indicator; | ||
777 | +} | ||
778 | + | ||
779 | +/** | ||
780 | + * osso_gtk_range_set_stream_position: | ||
781 | + * @range : A GtkRange | ||
782 | + * @position : The new position of the stream indicator | ||
783 | + * | ||
784 | + * Sets the new position of the stream indicator. | ||
785 | + * It is automatically clamped between lower and upper. | ||
786 | + * Note that you need to enable stream_indicator | ||
787 | + * before any stream-functionality is active. | ||
788 | + **/ | ||
789 | +void | ||
790 | +osso_gtk_range_set_stream_position (GtkRange *range, | ||
791 | + gdouble position) | ||
792 | +{ | ||
793 | + OssoGtkRangePrivate *priv; | ||
794 | + gdouble new_pos; | ||
795 | + | ||
796 | + g_return_if_fail (GTK_IS_RANGE (range)); | ||
797 | + | ||
798 | + new_pos = CLAMP (position, | ||
799 | + range->adjustment->lower, | ||
800 | + range->adjustment->upper); | ||
801 | + priv = OSSO_GTK_RANGE_GET_PRIVATE (range); | ||
802 | + | ||
803 | + priv->stream_position = new_pos; | ||
804 | + /* Reset the value to clamp it with the stream_position. */ | ||
805 | + if (priv->stream_indicator == TRUE) | ||
806 | + gtk_range_set_value (range, gtk_range_get_value (range)); | ||
807 | + | ||
808 | + g_object_notify (G_OBJECT (range), "stream_position"); | ||
809 | +} | ||
810 | +/** | ||
811 | + * osso_gtk_range_get_stream_position: | ||
812 | + * @range : A GtkRange | ||
813 | + * | ||
814 | + * Return value: The current position of the stream | ||
815 | + * indicator. Note that this value is undefined | ||
816 | + * when stream indicator is not enabled. | ||
817 | + **/ | ||
818 | +gdouble | ||
819 | +osso_gtk_range_get_stream_position (GtkRange *range) | ||
820 | +{ | ||
821 | + OssoGtkRangePrivate *priv; | ||
822 | + | ||
823 | + g_return_if_fail (GTK_IS_RANGE (range)); | ||
824 | + | ||
825 | + priv = OSSO_GTK_RANGE_GET_PRIVATE (range); | ||
826 | + | ||
827 | + return priv->stream_position; | ||
828 | +} | ||
829 | + | ||
830 | +/* OSSO addition : A function to ensure that | ||
831 | + * scrolling stops if widget loses focus (example: | ||
832 | + * dialog pops up) */ | ||
833 | +static gint | ||
834 | +osso_gtk_range_focus_out (GtkWidget *widget, GdkEventFocus *event) | ||
835 | +{ | ||
836 | + gboolean hildonlike; | ||
837 | + | ||
838 | + gtk_widget_style_get (widget, "hildonlike", &hildonlike, NULL); | ||
839 | + | ||
840 | + if (hildonlike) | ||
841 | + { | ||
842 | + stop_scrolling (GTK_RANGE (widget)); | ||
843 | + } | ||
844 | + return GTK_WIDGET_CLASS (parent_class)->focus_out_event (widget, event); | ||
845 | +} | ||