ScaleProtocol
public protocol ScaleProtocol : RangeProtocol
A GtkScale is a slider control used to select a numeric value.
To use it, you’ll probably want to investigate the methods on
its base class, GtkRange, in addition to the methods for GtkScale itself.
To set the value of a scale, you would normally use gtk_range_set_value().
To detect changes to the value, you would normally use the
GtkRange::value-changed signal.
Note that using the same upper and lower bounds for the GtkScale (through
the GtkRange methods) will hide the slider itself. This is useful for
applications that want to show an undeterminate value on the scale, without
changing the layout of the application (such as movie or music players).
GtkScale as GtkBuildable
GtkScale supports a custom <marks> element, which can contain multiple
<mark> elements. The “value” and “position” attributes have the same
meaning as gtk_scale_add_mark() parameters of the same name. If the
element is not empty, its content is taken as the markup to show at
the mark. It can be translated with the usual ”translatable” and
“context” attributes.
CSS nodes
(plain Language Example):
scale[.fine-tune][.marks-before][.marks-after]
├── marks.top
│ ├── mark
│ ┊ ├── [label]
│ ┊ ╰── indicator
┊ ┊
│ ╰── mark
├── [value]
├── contents
│ ╰── trough
│ ├── slider
│ ├── [highlight]
│ ╰── [fill]
╰── marks.bottom
├── mark
┊ ├── indicator
┊ ╰── [label]
╰── mark
GtkScale has a main CSS node with name scale and a subnode for its contents, with subnodes named trough and slider.
The main node gets the style class .fine-tune added when the scale is in ‘fine-tuning’ mode.
If the scale has an origin (see gtk_scale_set_has_origin()), there is a
subnode with name highlight below the trough node that is used for rendering
the highlighted part of the trough.
If the scale is showing a fill level (see gtk_range_set_show_fill_level()),
there is a subnode with name fill below the trough node that is used for
rendering the filled in part of the trough.
If marks are present, there is a marks subnode before or after the contents node, below which each mark gets a node with name mark. The marks nodes get either the .top or .bottom style class.
The mark node has a subnode named indicator. If the mark has text, it also has a subnode named label. When the mark is either above or left of the scale, the label subnode is the first when present. Otherwise, the indicator subnode is the first.
The main CSS node gets the ‘marks-before’ and/or ‘marks-after’ style classes added depending on what marks are present.
If the scale is displaying the value (see GtkScale:draw-value), there is
subnode with name value.
The ScaleProtocol protocol exposes the methods and properties of an underlying GtkScale instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see Scale.
Alternatively, use ScaleRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkScaleinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
scale_ptrDefault implementationTyped pointer to the underlying
GtkScaleinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkScaleinstance.Declaration
Swift
var scale_ptr: UnsafeMutablePointer<GtkScale>! { get } -
Required Initialiser for types conforming to
ScaleProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
ScalePropertyNamesource property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: ScalePropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a Scale property
Declaration
Swift
@inlinable func get(property: ScalePropertyName) -> GLibObject.ValueParameters
propertythe property to get the value for
Return Value
the value of the named property
-
set(property:Extension methodvalue: ) Set the value of a Scale property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: ScalePropertyName, value v: GLibObject.Value)Parameters
propertythe property to get the value for
Return Value
the value of the named property
-
connect(signal:Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
ScaleSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ScaleSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatahandlerThe Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
ScaleSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ScaleSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatasignalHandlerThe C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onFormatValue(flags:Extension methodhandler: ) Signal which allows you to change how the scale value is displayed. Connect a signal handler which returns an allocated string representing
value. That string will then be used to display the scale’s value.If no user-provided handlers are installed, the value will be displayed on its own, rounded according to the value of the
GtkScale:digitsproperty.Here’s an example signal handler which displays a value 1.0 as with “–>1.0<–”. (C Language Example):
static gchar* format_value_callback (GtkScale *scale, gdouble value) { return g_strdup_printf ("-->\%0.*g<--", gtk_scale_get_digits (scale), value); }Note
This represents the underlyingformat-valuesignalDeclaration
Swift
@discardableResult @inlinable func onFormatValue(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ScaleRef, _ value: Double) -> String) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
valuethe value to format
handlerallocated string representing
valueRun the given callback whenever theformatValuesignal is emitted -
formatValueSignalExtension methodTyped
format-valuesignal for using theconnect(signal:)methodsDeclaration
Swift
static var formatValueSignal: ScaleSignalName { get } -
onNotifyDigits(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::digitssignalDeclaration
Swift
@discardableResult @inlinable func onNotifyDigits(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ScaleRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyDigitssignal is emitted -
notifyDigitsSignalExtension methodTyped
notify::digitssignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyDigitsSignal: ScaleSignalName { get } -
onNotifyDrawValue(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::draw-valuesignalDeclaration
Swift
@discardableResult @inlinable func onNotifyDrawValue(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ScaleRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyDrawValuesignal is emitted -
notifyDrawValueSignalExtension methodTyped
notify::draw-valuesignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyDrawValueSignal: ScaleSignalName { get } -
onNotifyHasOrigin(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::has-originsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyHasOrigin(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ScaleRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyHasOriginsignal is emitted -
notifyHasOriginSignalExtension methodTyped
notify::has-originsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyHasOriginSignal: ScaleSignalName { get } -
onNotifyValuePos(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::value-possignalDeclaration
Swift
@discardableResult @inlinable func onNotifyValuePos(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ScaleRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyValuePossignal is emitted -
notifyValuePosSignalExtension methodTyped
notify::value-possignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyValuePosSignal: ScaleSignalName { get }
-
addMark(value:Extension methodposition: markup: ) Adds a mark at
value.A mark is indicated visually by drawing a tick mark next to the scale, and GTK+ makes it easy for the user to position the scale exactly at the marks value.
If
markupis notnil, text is shown next to the tick mark.To remove marks from a scale, use
gtk_scale_clear_marks().Declaration
Swift
@inlinable func addMark(value: Double, position: GtkPositionType, markup: UnsafePointer<gchar>? = nil) -
clearMarks()Extension methodRemoves any marks that have been added with
gtk_scale_add_mark().Declaration
Swift
@inlinable func clearMarks() -
getDigits()Extension methodGets the number of decimal places that are displayed in the value.
Declaration
Swift
@inlinable func getDigits() -> Int -
getDrawValue()Extension methodReturns whether the current value is displayed as a string next to the slider.
Declaration
Swift
@inlinable func getDrawValue() -> Bool -
getHasOrigin()Extension methodReturns whether the scale has an origin.
Declaration
Swift
@inlinable func getHasOrigin() -> Bool -
getLayout()Extension methodGets the
PangoLayoutused to display the scale. The returned object is owned by the scale so does not need to be freed by the caller.Declaration
Swift
@inlinable func getLayout() -> Pango.LayoutRef! -
getLayoutOffsets(x:Extension methody: ) Obtains the coordinates where the scale will draw the
PangoLayoutrepresenting the text in the scale. Remember when using thePangoLayoutfunction you need to convert to and from pixels usingPANGO_PIXELS()orPANGO_SCALE.If the
GtkScale:draw-valueproperty isfalse, the return values are undefined.Declaration
Swift
@inlinable func getLayoutOffsets(x: UnsafeMutablePointer<gint>! = nil, y: UnsafeMutablePointer<gint>! = nil) -
getValuePos()Extension methodGets the position in which the current value is displayed.
Declaration
Swift
@inlinable func getValuePos() -> GtkPositionType -
set(digits:Extension method) Sets the number of decimal places that are displayed in the value. Also causes the value of the adjustment to be rounded to this number of digits, so the retrieved value matches the displayed one, if
GtkScale:draw-valueistruewhen the value changes. If you want to enforce rounding the value whenGtkScale:draw-valueisfalse, you can setGtkRange:round-digitsinstead.Note that rounding to a small number of digits can interfere with the smooth autoscrolling that is built into
GtkScale. As an alternative, you can use theGtkScale::format-valuesignal to format the displayed value yourself.Declaration
Swift
@inlinable func set(digits: Int) -
set(drawValue:Extension method) Specifies whether the current value is displayed as a string next to the slider.
Declaration
Swift
@inlinable func set(drawValue: Bool) -
set(hasOrigin:Extension method) If
GtkScale:has-originis set totrue(the default), the scale will highlight the part of the trough between the origin (bottom or left side) and the current value.Declaration
Swift
@inlinable func set(hasOrigin: Bool) -
setValue(pos:Extension method) Sets the position in which the current value is displayed.
Declaration
Swift
@inlinable func setValue(pos: GtkPositionType) -
digitsExtension methodUndocumented
Declaration
Swift
@inlinable var digits: Int { get nonmutating set } -
drawValueExtension methodReturns whether the current value is displayed as a string next to the slider.
Declaration
Swift
@inlinable var drawValue: Bool { get nonmutating set } -
hasOriginExtension methodReturns whether the scale has an origin.
Declaration
Swift
@inlinable var hasOrigin: Bool { get nonmutating set } -
layoutExtension methodGets the
PangoLayoutused to display the scale. The returned object is owned by the scale so does not need to be freed by the caller.Declaration
Swift
@inlinable var layout: Pango.LayoutRef! { get } -
valuePosExtension methodGets the position in which the current value is displayed.
Declaration
Swift
@inlinable var valuePos: GtkPositionType { get nonmutating set } -
rangeExtension methodUndocumented
Declaration
Swift
@inlinable var range: GtkRange { get }
View on GitHub
Install in Dash
ScaleProtocol Protocol Reference