CtkRange

CtkRange — Base class for widgets which visualize an adjustment

Functions

Properties

CtkAdjustment * adjustment Read / Write / Construct
double fill-level Read / Write
gboolean inverted Read / Write
CtkSensitivityType lower-stepper-sensitivity Read / Write
gboolean restrict-to-fill-level Read / Write
int round-digits Read / Write
gboolean show-fill-level Read / Write
CtkSensitivityType upper-stepper-sensitivity Read / Write

Signals

void adjust-bounds Run Last
gboolean change-value Run Last
void move-slider Action
void value-changed Run Last

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── CtkWidget
            ╰── CtkRange
                ├── CtkScale
                ╰── CtkScrollbar

Implemented Interfaces

CtkRange implements AtkImplementorIface, CtkBuildable and CtkOrientable.

Includes

#include <ctk/ctk.h>

Description

CtkRange is the common base class for widgets which visualize an adjustment, e.g CtkScale or CtkScrollbar.

Apart from signals for monitoring the parameters of the adjustment, CtkRange provides properties and methods for influencing the sensitivity of the “steppers”. It also provides properties and methods for setting a “fill level” on range widgets. See ctk_range_set_fill_level().

Functions

ctk_range_get_fill_level ()

gdouble
ctk_range_get_fill_level (CtkRange *range);

Gets the current position of the fill level indicator.

Parameters

range

A CtkRange

 

Returns

The current fill level

Since: 2.12


ctk_range_get_restrict_to_fill_level ()

gboolean
ctk_range_get_restrict_to_fill_level (CtkRange *range);

Gets whether the range is restricted to the fill level.

Parameters

range

A CtkRange

 

Returns

TRUE if range is restricted to the fill level.

Since: 2.12


ctk_range_get_show_fill_level ()

gboolean
ctk_range_get_show_fill_level (CtkRange *range);

Gets whether the range displays the fill level graphically.

Parameters

range

A CtkRange

 

Returns

TRUE if range shows the fill level.

Since: 2.12


ctk_range_set_fill_level ()

void
ctk_range_set_fill_level (CtkRange *range,
                          gdouble fill_level);

Set the new position of the fill level indicator.

The “fill level” is probably best described by its most prominent use case, which is an indicator for the amount of pre-buffering in a streaming media player. In that use case, the value of the range would indicate the current play position, and the fill level would be the position up to which the file/stream has been downloaded.

This amount of prebuffering can be displayed on the range’s trough and is themeable separately from the trough. To enable fill level display, use ctk_range_set_show_fill_level(). The range defaults to not showing the fill level.

Additionally, it’s possible to restrict the range’s slider position to values which are smaller than the fill level. This is controller by ctk_range_set_restrict_to_fill_level() and is by default enabled.

Parameters

range

a CtkRange

 

fill_level

the new position of the fill level indicator

 

Since: 2.12


ctk_range_set_restrict_to_fill_level ()

void
ctk_range_set_restrict_to_fill_level (CtkRange *range,
                                      gboolean restrict_to_fill_level);

Sets whether the slider is restricted to the fill level. See ctk_range_set_fill_level() for a general description of the fill level concept.

Parameters

range

A CtkRange

 

restrict_to_fill_level

Whether the fill level restricts slider movement.

 

Since: 2.12


ctk_range_set_show_fill_level ()

void
ctk_range_set_show_fill_level (CtkRange *range,
                               gboolean show_fill_level);

Sets whether a graphical fill level is show on the trough. See ctk_range_set_fill_level() for a general description of the fill level concept.

Parameters

range

A CtkRange

 

show_fill_level

Whether a fill level indicator graphics is shown.

 

Since: 2.12


ctk_range_get_adjustment ()

CtkAdjustment *
ctk_range_get_adjustment (CtkRange *range);

Get the CtkAdjustment which is the “model” object for CtkRange. See ctk_range_set_adjustment() for details. The return value does not have a reference added, so should not be unreferenced.

Parameters

range

a CtkRange

 

Returns

a CtkAdjustment.

[transfer none]


ctk_range_set_adjustment ()

void
ctk_range_set_adjustment (CtkRange *range,
                          CtkAdjustment *adjustment);

Sets the adjustment to be used as the “model” object for this range widget. The adjustment indicates the current range value, the minimum and maximum range values, the step/page increments used for keybindings and scrolling, and the page size. The page size is normally 0 for CtkScale and nonzero for CtkScrollbar, and indicates the size of the visible area of the widget being scrolled. The page size affects the size of the scrollbar slider.

Parameters

range

a CtkRange

 

adjustment

a CtkAdjustment

 

ctk_range_get_inverted ()

gboolean
ctk_range_get_inverted (CtkRange *range);

Gets the value set by ctk_range_set_inverted().

Parameters

range

a CtkRange

 

Returns

TRUE if the range is inverted


ctk_range_set_inverted ()

void
ctk_range_set_inverted (CtkRange *range,
                        gboolean setting);

Ranges normally move from lower to higher values as the slider moves from top to bottom or left to right. Inverted ranges have higher values at the top or on the right rather than on the bottom or left.

Parameters

range

a CtkRange

 

setting

TRUE to invert the range

 

ctk_range_get_value ()

gdouble
ctk_range_get_value (CtkRange *range);

Gets the current value of the range.

Parameters

range

a CtkRange

 

Returns

current value of the range.


ctk_range_set_value ()

void
ctk_range_set_value (CtkRange *range,
                     gdouble value);

Sets the current value of the range; if the value is outside the minimum or maximum range values, it will be clamped to fit inside them. The range emits the “value-changed” signal if the value changes.

Parameters

range

a CtkRange

 

value

new value of the range

 

ctk_range_set_increments ()

void
ctk_range_set_increments (CtkRange *range,
                          gdouble step,
                          gdouble page);

Sets the step and page sizes for the range. The step size is used when the user clicks the CtkScrollbar arrows or moves CtkScale via arrow keys. The page size is used for example when moving via Page Up or Page Down keys.

Parameters

range

a CtkRange

 

step

step size

 

page

page size

 

ctk_range_set_range ()

void
ctk_range_set_range (CtkRange *range,
                     gdouble min,
                     gdouble max);

Sets the allowable values in the CtkRange, and clamps the range value to be between min and max . (If the range has a non-zero page size, it is clamped between min and max - page-size.)

Parameters

range

a CtkRange

 

min

minimum range value

 

max

maximum range value

 

ctk_range_get_round_digits ()

gint
ctk_range_get_round_digits (CtkRange *range);

Gets the number of digits to round the value to when it changes. See “change-value”.

Parameters

range

a CtkRange

 

Returns

the number of digits to round to

Since: 2.24


ctk_range_set_round_digits ()

void
ctk_range_set_round_digits (CtkRange *range,
                            gint round_digits);

Sets the number of digits to round the value to when it changes. See “change-value”.

Parameters

range

a CtkRange

 

round_digits

the precision in digits, or -1

 

Since: 2.24


ctk_range_set_lower_stepper_sensitivity ()

void
ctk_range_set_lower_stepper_sensitivity
                               (CtkRange *range,
                                CtkSensitivityType sensitivity);

Sets the sensitivity policy for the stepper that points to the 'lower' end of the CtkRange’s adjustment.

Parameters

range

a CtkRange

 

sensitivity

the lower stepper’s sensitivity policy.

 

Since: 2.10


ctk_range_get_lower_stepper_sensitivity ()

CtkSensitivityType
ctk_range_get_lower_stepper_sensitivity
                               (CtkRange *range);

Gets the sensitivity policy for the stepper that points to the 'lower' end of the CtkRange’s adjustment.

Parameters

range

a CtkRange

 

Returns

The lower stepper’s sensitivity policy.

Since: 2.10


ctk_range_set_upper_stepper_sensitivity ()

void
ctk_range_set_upper_stepper_sensitivity
                               (CtkRange *range,
                                CtkSensitivityType sensitivity);

Sets the sensitivity policy for the stepper that points to the 'upper' end of the CtkRange’s adjustment.

Parameters

range

a CtkRange

 

sensitivity

the upper stepper’s sensitivity policy.

 

Since: 2.10


ctk_range_get_upper_stepper_sensitivity ()

CtkSensitivityType
ctk_range_get_upper_stepper_sensitivity
                               (CtkRange *range);

Gets the sensitivity policy for the stepper that points to the 'upper' end of the CtkRange’s adjustment.

Parameters

range

a CtkRange

 

Returns

The upper stepper’s sensitivity policy.

Since: 2.10


ctk_range_get_flippable ()

gboolean
ctk_range_get_flippable (CtkRange *range);

Gets the value set by ctk_range_set_flippable().

Parameters

range

a CtkRange

 

Returns

TRUE if the range is flippable

Since: 2.18


ctk_range_set_flippable ()

void
ctk_range_set_flippable (CtkRange *range,
                         gboolean flippable);

If a range is flippable, it will switch its direction if it is horizontal and its direction is CTK_TEXT_DIR_RTL.

See ctk_widget_get_direction().

Parameters

range

a CtkRange

 

flippable

TRUE to make the range flippable

 

Since: 2.18


ctk_range_get_min_slider_size ()

gint
ctk_range_get_min_slider_size (CtkRange *range);

ctk_range_get_min_slider_size has been deprecated since version 3.20 and should not be used in newly-written code.

Use the min-height/min-width CSS properties on the slider node.

This function is useful mainly for CtkRange subclasses.

See ctk_range_set_min_slider_size().

Parameters

range

a CtkRange

 

Returns

The minimum size of the range’s slider.

Since: 2.20


ctk_range_get_range_rect ()

void
ctk_range_get_range_rect (CtkRange *range,
                          CdkRectangle *range_rect);

This function returns the area that contains the range’s trough and its steppers, in widget->window coordinates.

This function is useful mainly for CtkRange subclasses.

Parameters

range

a CtkRange

 

range_rect

return location for the range rectangle.

[out]

Since: 2.20


ctk_range_get_slider_range ()

void
ctk_range_get_slider_range (CtkRange *range,
                            gint *slider_start,
                            gint *slider_end);

This function returns sliders range along the long dimension, in widget->window coordinates.

This function is useful mainly for CtkRange subclasses.

Parameters

range

a CtkRange

 

slider_start

return location for the slider's start, or NULL.

[out][allow-none]

slider_end

return location for the slider's end, or NULL.

[out][allow-none]

Since: 2.20


ctk_range_get_slider_size_fixed ()

gboolean
ctk_range_get_slider_size_fixed (CtkRange *range);

This function is useful mainly for CtkRange subclasses.

See ctk_range_set_slider_size_fixed().

Parameters

range

a CtkRange

 

Returns

whether the range’s slider has a fixed size.

Since: 2.20


ctk_range_set_min_slider_size ()

void
ctk_range_set_min_slider_size (CtkRange *range,
                               gint min_size);

ctk_range_set_min_slider_size has been deprecated since version 3.20 and should not be used in newly-written code.

Use the min-height/min-width CSS properties on the slider node.

Sets the minimum size of the range’s slider.

This function is useful mainly for CtkRange subclasses.

Parameters

range

a CtkRange

 

min_size

The slider’s minimum size

 

Since: 2.20


ctk_range_set_slider_size_fixed ()

void
ctk_range_set_slider_size_fixed (CtkRange *range,
                                 gboolean size_fixed);

Sets whether the range’s slider has a fixed size, or a size that depends on its adjustment’s page size.

This function is useful mainly for CtkRange subclasses.

Parameters

range

a CtkRange

 

size_fixed

TRUE to make the slider size constant

 

Since: 2.20

Types and Values

struct CtkRange

struct CtkRange;

enum CtkSensitivityType

Determines how CTK+ handles the sensitivity of stepper arrows at the end of range widgets.

Members

CTK_SENSITIVITY_AUTO

The arrow is made insensitive if the thumb is at the end

 

CTK_SENSITIVITY_ON

The arrow is always sensitive

 

CTK_SENSITIVITY_OFF

The arrow is always insensitive

 

Property Details

The “adjustment” property

  “adjustment”               CtkAdjustment *

The CtkAdjustment that contains the current value of this range object.

Owner: CtkRange

Flags: Read / Write / Construct


The “fill-level” property

  “fill-level”               double

The fill level (e.g. prebuffering of a network stream). See ctk_range_set_fill_level().

Owner: CtkRange

Flags: Read / Write

Default value: 1.79769e+308

Since: 2.12


The “inverted” property

  “inverted”                 gboolean

Invert direction slider moves to increase range value.

Owner: CtkRange

Flags: Read / Write

Default value: FALSE


The “lower-stepper-sensitivity” property

  “lower-stepper-sensitivity” CtkSensitivityType

The sensitivity policy for the stepper that points to the adjustment's lower side.

Owner: CtkRange

Flags: Read / Write

Default value: CTK_SENSITIVITY_AUTO


The “restrict-to-fill-level” property

  “restrict-to-fill-level”   gboolean

The restrict-to-fill-level property controls whether slider movement is restricted to an upper boundary set by the fill level. See ctk_range_set_restrict_to_fill_level().

Owner: CtkRange

Flags: Read / Write

Default value: TRUE

Since: 2.12


The “round-digits” property

  “round-digits”             int

The number of digits to round the value to when it changes, or -1. See “change-value”.

Owner: CtkRange

Flags: Read / Write

Allowed values: >= -1

Default value: -1

Since: 2.24


The “show-fill-level” property

  “show-fill-level”          gboolean

The show-fill-level property controls whether fill level indicator graphics are displayed on the trough. See ctk_range_set_show_fill_level().

Owner: CtkRange

Flags: Read / Write

Default value: FALSE

Since: 2.12


The “upper-stepper-sensitivity” property

  “upper-stepper-sensitivity” CtkSensitivityType

The sensitivity policy for the stepper that points to the adjustment's upper side.

Owner: CtkRange

Flags: Read / Write

Default value: CTK_SENSITIVITY_AUTO

Signal Details

The “adjust-bounds” signal

void
user_function (CtkRange *range,
               double    value,
               gpointer  user_data)

Emitted before clamping a value, to give the application a chance to adjust the bounds.

Parameters

range

the CtkRange that received the signal

 

value

the value before we clamp

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “change-value” signal

gboolean
user_function (CtkRange     *range,
               CtkScrollType scroll,
               double        value,
               gpointer      user_data)

The “change-value” signal is emitted when a scroll action is performed on a range. It allows an application to determine the type of scroll event that occurred and the resultant new value. The application can handle the event itself and return TRUE to prevent further processing. Or, by returning FALSE, it can pass the event to other handlers until the default CTK+ handler is reached.

The value parameter is unrounded. An application that overrides the CtkRange::change-value signal is responsible for clamping the value to the desired number of decimal digits; the default CTK+ handler clamps the value based on “round-digits”.

Parameters

range

the CtkRange that received the signal

 

scroll

the type of scroll action that was performed

 

value

the new value resulting from the scroll action

 

user_data

user data set when the signal handler was connected.

 

Returns

TRUE to prevent other handlers from being invoked for the signal, FALSE to propagate the signal further

Flags: Run Last

Since: 2.6


The “move-slider” signal

void
user_function (CtkRange     *range,
               CtkScrollType step,
               gpointer      user_data)

Virtual function that moves the slider. Used for keybindings.

Parameters

range

the CtkRange that received the signal

 

step

how to move the slider

 

user_data

user data set when the signal handler was connected.

 

Flags: Action


The “value-changed” signal

void
user_function (CtkRange *range,
               gpointer  user_data)

Emitted when the range value changes.

Parameters

range

the CtkRange that received the signal

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last