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
4 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
7 +/* Modified for Nokia Oyj during 2002-2005. See CHANGES file for list
20 + PROP_STREAM_INDICATOR,
21 + PROP_MINIMUM_VISIBLE_BARS,
22 + PROP_STREAM_POSITION
27 /* "grabbed" mouse location, OUTSIDE for no grab */
28 MouseLocation grab_location;
29 gint grab_button; /* 0 if none */
31 + /* OSSO hack: stream trough split position */
32 + gint stream_pixel_position;
33 + gint minimum_visible_bars;
36 +#define OSSO_GTK_RANGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_RANGE, OssoGtkRangePrivate))
37 +typedef struct _OssoGtkRangePrivate OssoGtkRangePrivate;
39 +struct _OssoGtkRangePrivate
41 + gboolean stream_indicator;
42 + gdouble stream_position;
45 static void gtk_range_class_init (GtkRangeClass *klass);
46 static void gtk_range_init (GtkRange *range);
51 +static gint osso_gtk_range_focus_out (GtkWidget *widget, GdkEventFocus *event);
56 widget_class->state_changed = gtk_range_state_changed;
57 widget_class->style_set = gtk_range_style_set;
59 + /* OSSO addition (see bug #1653) */
60 + widget_class->focus_out_event = osso_gtk_range_focus_out;
62 class->move_slider = gtk_range_move_slider;
63 class->change_value = gtk_range_real_change_value;
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."),
75 + G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
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"),
85 + G_PARAM_READWRITE));
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."),
95 + G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
97 gtk_widget_class_install_style_property (widget_class,
98 g_param_spec_int ("slider_width",
105 + gtk_widget_class_install_style_property (widget_class,
106 + g_param_spec_boolean ("hildonlike",
108 + _("Change focus out behaviour, 1/0"),
110 + G_PARAM_READABLE));
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"),
117 + G_PARAM_READABLE));
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 ."),
126 + G_PARAM_READABLE));
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"),
133 + G_PARAM_READABLE));
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."),
140 + G_PARAM_READABLE));
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"),
147 + G_PARAM_READABLE));
149 + g_type_class_add_private (gobject_class, sizeof (OssoGtkRangePrivate));
155 gtk_range_set_inverted (range, g_value_get_boolean (value));
157 + case PROP_STREAM_INDICATOR:
158 + osso_gtk_range_set_stream_indicator (range, g_value_get_boolean (value));
160 + case PROP_STREAM_POSITION:
161 + osso_gtk_range_set_stream_position (range, g_value_get_double (value));
163 + case PROP_MINIMUM_VISIBLE_BARS:
164 + range->layout->minimum_visible_bars = g_value_get_int(value);
167 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
171 g_value_set_boolean (value, range->inverted);
173 + case PROP_STREAM_INDICATOR:
174 + g_value_set_boolean (value, osso_gtk_range_get_stream_indicator (range));
176 + case PROP_STREAM_POSITION:
177 + g_value_set_double (value, osso_gtk_range_get_stream_indicator (range));
179 + case PROP_MINIMUM_VISIBLE_BARS:
180 + g_value_set_int (value, range->layout->minimum_visible_bars);
183 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
187 gtk_range_init (GtkRange *range)
189 + OssoGtkRangePrivate *priv = OSSO_GTK_RANGE_GET_PRIVATE (range);
190 GTK_WIDGET_SET_FLAGS (range, GTK_NO_WINDOW);
192 range->adjustment = NULL;
194 range->layout->grab_location = MOUSE_OUTSIDE;
195 range->layout->grab_button = 0;
198 + priv->stream_indicator = FALSE;
199 + priv->stream_position = 0.0;
204 g_signal_connect (adjustment, "changed",
205 G_CALLBACK (gtk_range_adjustment_changed),
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),
215 @@ -677,16 +799,21 @@
219 + OssoGtkRangePrivate *priv;
221 g_return_if_fail (GTK_IS_RANGE (range));
222 g_return_if_fail (min < max);
224 + priv = OSSO_GTK_RANGE_GET_PRIVATE (range);
226 range->adjustment->lower = min;
227 range->adjustment->upper = max;
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;
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,
241 + OssoGtkRangePrivate *priv;
243 g_return_if_fail (GTK_IS_RANGE (range));
245 + priv = OSSO_GTK_RANGE_GET_PRIVATE (range);
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;
252 gtk_adjustment_set_value (range->adjustment, value);
254 @@ -913,6 +1046,10 @@
258 + /* OSSO modification: state of our style properties */
259 + gboolean autodimmed_steppers = FALSE;
260 + gboolean arrow_paint_box_layout = FALSE;
262 /* More to get the right clip region than for efficiency */
263 if (!gdk_rectangle_intersect (area, rect, &intersection))
265 @@ -929,6 +1066,37 @@
267 state_type = GTK_STATE_NORMAL;
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,
275 + /* OSSO modification : dim the stepper if maximum or minimum value has been reached */
276 + if (autodimmed_steppers)
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))
288 + state_type = GTK_STATE_INSENSITIVE;
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)
296 + state_type = GTK_STATE_INSENSITIVE;
301 shadow_type = GTK_SHADOW_IN;
303 @@ -944,10 +1112,20 @@
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)
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;
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;
328 @@ -982,8 +1160,11 @@
330 gint focus_line_width = 0;
331 gint focus_padding = 0;
332 + OssoGtkRangePrivate *priv;
334 range = GTK_RANGE (widget);
336 + priv = OSSO_GTK_RANGE_GET_PRIVATE (range);
338 if (GTK_WIDGET_CAN_FOCUS (range))
340 @@ -1011,18 +1192,118 @@
341 if (gdk_rectangle_intersect (&expose_area, &range->range_rect,
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;
354 area.x += widget->allocation.x;
355 area.y += widget->allocation.y;
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,
364 + if (range->orientation == GTK_ORIENTATION_HORIZONTAL)
366 + virtual_position = &x;
367 + virtual_size = &width;
371 + virtual_position = &y;
372 + virtual_size = &height;
375 + if (draw_trough_under_steppers == FALSE)
377 + *virtual_position += stepper_size + stepper_spacing;
378 + *virtual_size -= 2 * (stepper_size + stepper_spacing);
381 - gtk_paint_box (widget->style,
383 - sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
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)
392 + gtk_paint_box (widget->style,
394 + sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
396 + &area, GTK_WIDGET(range), "trough",
402 + gint trough_change_pos_x = width;
403 + gint trough_change_pos_y = height;
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;
408 + trough_change_pos_y = range->layout->slider.y + (range->layout->slider.height / 2) - stepper_size - stepper_spacing;
410 + gtk_paint_box (widget->style,
412 + sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
414 + &area, GTK_WIDGET(range), "trough_northwest",
416 + trough_change_pos_x, trough_change_pos_y);
418 + if (range->orientation == GTK_ORIENTATION_HORIZONTAL)
419 + trough_change_pos_y = 0;
421 + trough_change_pos_x = 0;
423 + gtk_paint_box (widget->style,
425 + sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
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);
432 + /* Stream indicator drawing does not support inverted state. */
433 + if (priv->stream_indicator)
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;
441 + if (range->orientation == GTK_ORIENTATION_HORIZONTAL)
443 + stream_start_pos_x = range->layout->slider.x;
444 + stream_width = range->layout->stream_pixel_position - stream_start_pos_x;
448 + stream_start_pos_y = range->layout->slider.y;
449 + stream_height = range->layout->stream_pixel_position - stream_start_pos_y;
452 + if (priv->stream_position == range->adjustment->upper)
453 + used_detail = "trough_stream_complete";
455 + used_detail = "trough_stream";
457 + gtk_paint_box (widget->style,
459 + sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
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);
468 @@ -1189,19 +1470,41 @@
473 - if (range->orientation == GTK_ORIENTATION_VERTICAL)
474 + gint stepper_spacing = 0;
475 + gint minimum_visible_blocks = 0;
476 + gint magic_value = 0;
478 + g_object_get(range, "minimum_visible_bars", &minimum_visible_blocks, NULL);
480 + g_print("coord = %d\n", coord);
481 + gtk_widget_style_get (GTK_WIDGET (range),
482 + "stepper_spacing", &stepper_spacing,
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)
491 - frac = ((coord - range->layout->trough.y) /
492 - (gdouble) (range->layout->trough.height - range->layout->slider.height));
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)));
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)
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)));
515 if (should_invert (range))
517 @@ -1242,6 +1545,8 @@
518 range->orientation == GTK_ORIENTATION_VERTICAL ?
519 event->y : event->x);
521 + g_print("button_press: calling coord_to_value with %d, click value = %d\n", event->x, click_value);
523 range->trough_click_forward = click_value > range->adjustment->value;
524 range_grab_add (range, MOUSE_TROUGH, event->button);
526 @@ -1286,7 +1591,9 @@
527 * On button 2 press, we warp the slider to mouse position,
528 * then begin the slider drag.
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)
535 gdouble slider_low_value, slider_high_value, new_value;
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);
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);
546 /* compute new value for warped slider */
547 new_value = slider_low_value + (slider_high_value - slider_low_value) / 2;
549 @@ -1353,8 +1663,10 @@
551 delta = mouse_x - range->slide_initial_coordinate;
554 c = range->slide_initial_slider_position + delta;
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);
559 g_signal_emit (range, signals[CHANGE_VALUE], 0, GTK_SCROLL_JUMP, new_value,
560 @@ -1395,9 +1707,12 @@
562 if (range->layout->grab_button == event->button)
564 + /* OSSO modification : Commented out.
565 + * Not sure about the reason unfortunately. */
567 if (range->layout->grab_location == MOUSE_SLIDER)
568 update_slider_position (range, range->layout->mouse_x, range->layout->mouse_y);
571 stop_scrolling (range);
574 @@ -2026,6 +2341,7 @@
575 GdkRectangle range_rect;
576 GtkRangeLayout *layout;
578 + gint minimum_visible_bars = 0;
580 if (!range->need_recalc)
582 @@ -2047,6 +2363,8 @@
583 &slider_width, &stepper_size, &trough_border, &stepper_spacing,
586 + g_object_get(range, "minimum_visible_bars", &minimum_visible_bars, NULL);
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 */
594 gint y, bottom, top, height;
596 - top = layout->trough.y + stepper_spacing;
597 - bottom = layout->trough.y + layout->trough.height - stepper_spacing;
601 + magic_value = (layout->trough.height / (range->adjustment->upper - range->adjustment->lower + 1));
603 + top = layout->trough.y + stepper_spacing + (minimum_visible_bars * magic_value);
604 + bottom = layout->trough.y + layout->trough.height - stepper_spacing;
606 /* slider height is the fraction (page_size /
607 * total_adjustment_range) times the trough height in pixels
609 @@ -2307,8 +2628,11 @@
610 /* Compute slider position/length */
612 gint x, left, right, width;
615 + magic_value = (layout->trough.width / (range->adjustment->upper - range->adjustment->lower + 1));
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;
621 /* slider width is the fraction (page_size /
622 @@ -2340,6 +2664,32 @@
624 layout->slider.x = x;
625 layout->slider.width = width;
627 + /* Hildon modification : Calculate the x point of streaming
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,
637 + if (priv->stream_indicator == TRUE)
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;
646 + layout->stream_pixel_position = left + stream_indicator_padding;
648 + if (layout->stream_pixel_position < left + stream_indicator_padding)
649 + layout->stream_pixel_position = left + stream_indicator_padding;
653 /* These are publically exported */
654 range->slider_start = layout->slider.x;
655 @@ -2382,12 +2732,17 @@
656 GtkScrollType scroll,
659 + OssoGtkRangePrivate *priv = OSSO_GTK_RANGE_GET_PRIVATE (range);
661 /* potentially adjust the bounds _before we clamp */
662 g_signal_emit (range, signals[ADJUST_BOUNDS], 0, value);
664 value = CLAMP (value, range->adjustment->lower,
665 (range->adjustment->upper - range->adjustment->page_size));
667 + if (priv->stream_indicator && value > priv->stream_position)
668 + value = (gdouble)priv->stream_position;
670 if (range->round_digits >= 0)
673 @@ -2465,11 +2820,16 @@
674 initial_timeout (gpointer data)
677 + GtkSettings *settings;
678 + guint timeout = SCROLL_LATER_DELAY;
680 + settings = gtk_settings_get_default ();
681 + g_object_get (settings, "gtk-update-timeout", &timeout, NULL);
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,
690 GDK_THREADS_LEAVE ();
691 @@ -2482,13 +2842,19 @@
692 gtk_range_add_step_timer (GtkRange *range,
695 + GtkSettings *settings;
696 + guint timeout = SCROLL_INITIAL_DELAY;
698 g_return_if_fail (range->timer == NULL);
699 g_return_if_fail (step != GTK_SCROLL_NONE);
701 + settings = gtk_settings_get_default ();
702 + g_object_get (settings, "gtk-initial-timeout", &timeout, NULL);
704 range->timer = g_new (GtkRangeStepTimer, 1);
706 range->timer->timeout_id =
707 - g_timeout_add (SCROLL_INITIAL_DELAY,
708 + g_timeout_add (/*SCROLL_INITIAL_DELAY*/timeout,
711 range->timer->step = step;
712 @@ -2528,9 +2894,15 @@
714 gtk_range_reset_update_timer (GtkRange *range)
716 + /*GtkSettings *settings;
717 + guint timeout = UPDATE_DELAY;
719 + settings = gtk_settings_get_default ();
720 + g_object_get (settings, "gtk-update-timeout", &timeout, NULL);*/
722 gtk_range_remove_update_timer (range);
724 - range->update_timeout_id = g_timeout_add (UPDATE_DELAY,
725 + range->update_timeout_id = g_timeout_add (/*timeout*/UPDATE_DELAY,
729 @@ -2544,3 +2916,116 @@
730 range->update_timeout_id = 0;
735 + * osso_gtk_range_set_stream_indicator:
736 + * @range: A GtkRange
737 + * @stream_indicator: Whether stream indicator graphics is shown and restricts slider.
739 + * Sets whether a graphical stream indicator
740 + * is show on the trough and the slider is restricted
741 + * to streamed area.
744 +osso_gtk_range_set_stream_indicator (GtkRange *range, gboolean stream_indicator)
746 + OssoGtkRangePrivate *priv;
748 + g_return_if_fail (GTK_IS_RANGE (range));
750 + priv = OSSO_GTK_RANGE_GET_PRIVATE (range);
752 + if (stream_indicator == priv->stream_indicator)
755 + priv->stream_indicator = stream_indicator;
756 + g_signal_emit_by_name (G_OBJECT (range), "value_changed", NULL);
760 + * osso_gtk_range_get_stream_indicator:
761 + * @range: A GtkRange
763 + * Return value: Whether GtkRange displays an
764 + * stream indicator graphics and slider is restricted
768 +osso_gtk_range_get_stream_indicator (GtkRange *range)
770 + OssoGtkRangePrivate *priv;
772 + g_return_val_if_fail (GTK_IS_RANGE (range), FALSE);
774 + priv = OSSO_GTK_RANGE_GET_PRIVATE (range);
776 + return priv->stream_indicator;
780 + * osso_gtk_range_set_stream_position:
781 + * @range : A GtkRange
782 + * @position : The new position of the stream indicator
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.
790 +osso_gtk_range_set_stream_position (GtkRange *range,
793 + OssoGtkRangePrivate *priv;
796 + g_return_if_fail (GTK_IS_RANGE (range));
798 + new_pos = CLAMP (position,
799 + range->adjustment->lower,
800 + range->adjustment->upper);
801 + priv = OSSO_GTK_RANGE_GET_PRIVATE (range);
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));
808 + g_object_notify (G_OBJECT (range), "stream_position");
811 + * osso_gtk_range_get_stream_position:
812 + * @range : A GtkRange
814 + * Return value: The current position of the stream
815 + * indicator. Note that this value is undefined
816 + * when stream indicator is not enabled.
819 +osso_gtk_range_get_stream_position (GtkRange *range)
821 + OssoGtkRangePrivate *priv;
823 + g_return_if_fail (GTK_IS_RANGE (range));
825 + priv = OSSO_GTK_RANGE_GET_PRIVATE (range);
827 + return priv->stream_position;
830 +/* OSSO addition : A function to ensure that
831 + * scrolling stops if widget loses focus (example:
832 + * dialog pops up) */
834 +osso_gtk_range_focus_out (GtkWidget *widget, GdkEventFocus *event)
836 + gboolean hildonlike;
838 + gtk_widget_style_get (widget, "hildonlike", &hildonlike, NULL);
842 + stop_scrolling (GTK_RANGE (widget));
844 + return GTK_WIDGET_CLASS (parent_class)->focus_out_event (widget, event);