StyleContextProtocol
public protocol StyleContextProtocol : ObjectProtocol
GtkStyleContext is an object that stores styling information affecting
a widget defined by GtkWidgetPath.
In order to construct the final style information, GtkStyleContext
queries information from all attached GtkStyleProviders. Style providers
can be either attached explicitly to the context through
gtk_style_context_add_provider(), or to the screen through
gtk_style_context_add_provider_for_screen(). The resulting style is a
combination of all providers’ information in priority order.
For GTK+ widgets, any GtkStyleContext returned by
gtk_widget_get_style_context() will already have a GtkWidgetPath, a
GdkScreen and RTL/LTR information set. The style context will also be
updated automatically if any of these settings change on the widget.
If you are using the theming layer standalone, you will need to set a
widget path and a screen yourself to the created style context through
gtk_style_context_set_path() and possibly gtk_style_context_set_screen(). See
the “Foreign drawing“ example in gtk3-demo.
Style Classes #
Widgets can add style classes to their context, which can be used to associate different styles by class. The documentation for individual widgets lists which style classes it uses itself, and which style classes may be added by applications to affect their appearance.
GTK+ defines macros for a number of style classes.
Style Regions
Widgets can also add regions with flags to their context. This feature is deprecated and will be removed in a future GTK+ update. Please use style classes instead.
GTK+ defines macros for a number of style regions.
Custom styling in UI libraries and applications
If you are developing a library with custom GtkWidgets that
render differently than standard components, you may need to add a
GtkStyleProvider yourself with the GTK_STYLE_PROVIDER_PRIORITY_FALLBACK
priority, either a GtkCssProvider or a custom object implementing the
GtkStyleProvider interface. This way themes may still attempt
to style your UI elements in a different way if needed so.
If you are using custom styling on an applications, you probably want then
to make your style information prevail to the theme’s, so you must use
a GtkStyleProvider with the GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
priority, keep in mind that the user settings in
XDG_CONFIG_HOME/gtk-3.0/gtk.css will
still take precedence over your changes, as it uses the
GTK_STYLE_PROVIDER_PRIORITY_USER priority.
The StyleContextProtocol protocol exposes the methods and properties of an underlying GtkStyleContext 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 StyleContext.
Alternatively, use StyleContextRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkStyleContextinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
style_context_ptrDefault implementationTyped pointer to the underlying
GtkStyleContextinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkStyleContextinstance.Declaration
Swift
var style_context_ptr: UnsafeMutablePointer<GtkStyleContext>! { get } -
Required Initialiser for types conforming to
StyleContextProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
StyleContextPropertyNamesource property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: StyleContextPropertyName, 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 StyleContext property
Declaration
Swift
@inlinable func get(property: StyleContextPropertyName) -> 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 StyleContext property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: StyleContextPropertyName, 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
StyleContextSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: StyleContextSignalName, 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
StyleContextSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: StyleContextSignalName, 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)
-
onChanged(flags:Extension methodhandler: ) The
changedsignal is emitted when there is a change in theGtkStyleContext.For a
GtkStyleContextreturned bygtk_widget_get_style_context(), theGtkWidget::style-updatedsignal/vfunc might be more convenient to use.This signal is useful when using the theming layer standalone.
Note
This represents the underlyingchangedsignalDeclaration
Swift
@discardableResult @inlinable func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: StyleContextRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
handlerThe signal handler to call Run the given callback whenever the
changedsignal is emitted -
changedSignalExtension methodTyped
changedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var changedSignal: StyleContextSignalName { get } -
onNotifyDirection(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::directionsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyDirection(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: StyleContextRef, _ 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
notifyDirectionsignal is emitted -
notifyDirectionSignalExtension methodTyped
notify::directionsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyDirectionSignal: StyleContextSignalName { get } -
onNotifyPaintClock(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::paint-clocksignalDeclaration
Swift
@discardableResult @inlinable func onNotifyPaintClock(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: StyleContextRef, _ 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
notifyPaintClocksignal is emitted -
notifyPaintClockSignalExtension methodTyped
notify::paint-clocksignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyPaintClockSignal: StyleContextSignalName { get } -
onNotifyParent(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::parentsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyParent(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: StyleContextRef, _ 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
notifyParentsignal is emitted -
notifyParentSignalExtension methodTyped
notify::parentsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyParentSignal: StyleContextSignalName { get } -
onNotifyScreen(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::screensignalDeclaration
Swift
@discardableResult @inlinable func onNotifyScreen(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: StyleContextRef, _ 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
notifyScreensignal is emitted -
notifyScreenSignalExtension methodTyped
notify::screensignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyScreenSignal: StyleContextSignalName { get }
-
addClass(className:Extension method) Adds a style class to
context, so posterior calls togtk_style_context_get()or any of the gtk_render_*() functions will make use of this new class for styling.In the CSS file format, a
GtkEntrydefining a “search” class, would be matched by:(CSS Language Example):
entry.search { ... }While any widget defining a “search” class would be matched by: (CSS Language Example):
.search { ... }Declaration
Swift
@inlinable func addClass(className: UnsafePointer<gchar>!) -
add(provider:Extension methodpriority: ) Adds a style provider to
context, to be used in style construction. Note that a style provider added by this function only affects the style of the widget to whichcontextbelongs. If you want to affect the style of all widgets, usegtk_style_context_add_provider_for_screen().Note: If both priorities are the same, a
GtkStyleProvideradded through this function takes precedence over another added throughgtk_style_context_add_provider_for_screen().Declaration
Swift
@inlinable func add<StyleProviderT>(provider: StyleProviderT, priority: Int) where StyleProviderT : StyleProviderProtocol -
addRegion(regionName:Extension methodflags: ) Adds a region to
context, so posterior calls togtk_style_context_get()or any of the gtk_render_*() functions will make use of this new region for styling.In the CSS file format, a
GtkTreeViewdefining a “row” region, would be matched by:(CSS Language Example):
treeview row { ... }Pseudo-classes are used for matching
flags, so the two following rules: (CSS Language Example):treeview row:nth-child(even) { ... } treeview row:nth-child(odd) { ... }would apply to even and odd rows, respectively.
Region names must only contain lowercase letters and “-”, starting always with a lowercase letter.
add_region is deprecated: This method is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func addRegion(regionName: UnsafePointer<gchar>!, flags: RegionFlags) -
cancelAnimations(regionID:Extension method) Stops all running animations for
region_idand all animatable regions underneath.A
nilregion_idwill stop all ongoing animations incontext, when dealing with aGtkStyleContextobtained throughgtk_widget_get_style_context(), this is normally done for you in all circumstances you would expect all widget to be stopped, so this should be only used in complex widgets with different animatable regions.cancel_animations is deprecated: This function does nothing.
Declaration
Swift
@available(*, deprecated) @inlinable func cancelAnimations(regionID: gpointer! = nil) -
getBackgroundColor(state:Extension methodcolor: ) Gets the background color for a given state.
This function is far less useful than it seems, and it should not be used in newly written code. CSS has no concept of “background color”, as a background can be an image, or a gradient, or any other pattern including solid colors.
The only reason why you would call
gtk_style_context_get_background_color()is to use the returned value to draw the background with it; the correct way to achieve this result is to usegtk_render_background()instead, along with CSS style classes to modify the color to be rendered.get_background_color is deprecated: Use gtk_render_background() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getBackgroundColor<RGBAT>(state: StateFlags, color: RGBAT) where RGBAT : RGBAProtocol -
getBorder(state:Extension methodborder: ) Gets the border for a given state as a
GtkBorder.See
gtk_style_context_get_property()andGTK_STYLE_PROPERTY_BORDER_WIDTHfor details.Declaration
Swift
@inlinable func getBorder<BorderT>(state: StateFlags, border: BorderT) where BorderT : BorderProtocol -
getBorderColor(state:Extension methodcolor: ) Gets the border color for a given state.
get_border_color is deprecated: Use gtk_render_frame() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getBorderColor<RGBAT>(state: StateFlags, color: RGBAT) where RGBAT : RGBAProtocol -
getColor(state:Extension methodcolor: ) Gets the foreground color for a given state.
See
gtk_style_context_get_property()andGTK_STYLE_PROPERTY_COLORfor details.Declaration
Swift
@inlinable func getColor<RGBAT>(state: StateFlags, color: RGBAT) where RGBAT : RGBAProtocol -
getDirection()Extension methodReturns the widget direction used for rendering.
get_direction is deprecated: Use gtk_style_context_get_state() and check for #GTK_STATE_FLAG_DIR_LTR and #GTK_STATE_FLAG_DIR_RTL instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getDirection() -> GtkTextDirection -
getFont(state:Extension method) Returns the font description for a given state. The returned object is const and will remain valid until the
GtkStyleContext::changedsignal happens.get_font is deprecated: Use gtk_style_context_get() for “font” or subproperties instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getFont(state: StateFlags) -> Pango.FontDescriptionRef! -
getFrameClock()Extension methodReturns the
GdkFrameClockto whichcontextis attached.Declaration
Swift
@inlinable func getFrameClock() -> Gdk.FrameClockRef! -
getJunctionSides()Extension methodReturns the sides where rendered elements connect visually with others.
Declaration
Swift
@inlinable func getJunctionSides() -> JunctionSides -
getMargin(state:Extension methodmargin: ) Gets the margin for a given state as a
GtkBorder. Seegtk_style_property_get()andGTK_STYLE_PROPERTY_MARGINfor details.Declaration
Swift
@inlinable func getMargin<BorderT>(state: StateFlags, margin: BorderT) where BorderT : BorderProtocol -
getPadding(state:Extension methodpadding: ) Gets the padding for a given state as a
GtkBorder. Seegtk_style_context_get()andGTK_STYLE_PROPERTY_PADDINGfor details.Declaration
Swift
@inlinable func getPadding<BorderT>(state: StateFlags, padding: BorderT) where BorderT : BorderProtocol -
getParent()Extension methodGets the parent context set via
gtk_style_context_set_parent(). See that function for details.Declaration
Swift
@inlinable func getParent() -> StyleContextRef! -
getPath()Extension methodReturns the widget path used for style matching.
Declaration
Swift
@inlinable func getPath() -> WidgetPathRef! -
get(property:Extension methodstate: value: ) Gets a style property from
contextfor the given state.Note that not all CSS properties that are supported by GTK+ can be retrieved in this way, since they may not be representable as
GValue. GTK+ defines macros for a number of properties that can be used with this function.Note that passing a state other than the current state of
contextis not recommended unless the style context has been saved withgtk_style_context_save().When
valueis no longer needed,g_value_unset()must be called to free any allocated memory.Declaration
Swift
@inlinable func get<ValueT>(property: UnsafePointer<gchar>!, state: StateFlags, value: ValueT) where ValueT : ValueProtocol -
getScale()Extension methodReturns the scale used for assets.
Declaration
Swift
@inlinable func getScale() -> Int -
getScreen()Extension methodReturns the
GdkScreento whichcontextis attached.Declaration
Swift
@inlinable func getScreen() -> Gdk.ScreenRef! -
getSection(property:Extension method) Queries the location in the CSS where
propertywas defined for the currentcontext. Note that the state to be queried is taken fromgtk_style_context_get_state().If the location is not available,
nilwill be returned. The location might not be available for various reasons, such as the property being overridden,propertynot naming a supported CSS property or tracking of definitions being disabled for performance reasons.Shorthand CSS properties cannot be queried for a location and will always return
nil.Declaration
Swift
@inlinable func getSection(property: UnsafePointer<gchar>!) -> CssSectionRef! -
getState()Extension methodReturns the state used for style matching.
This method should only be used to retrieve the
GtkStateFlagsto pass toGtkStyleContextmethods, likegtk_style_context_get_padding(). If you need to retrieve the current state of aGtkWidget, usegtk_widget_get_state_flags().Declaration
Swift
@inlinable func getState() -> StateFlags -
getStyleProperty(propertyName:Extension methodvalue: ) Gets the value for a widget style property.
When
valueis no longer needed,g_value_unset()must be called to free any allocated memory.Declaration
Swift
@inlinable func getStyleProperty<ValueT>(propertyName: UnsafePointer<gchar>!, value: ValueT) where ValueT : ValueProtocol -
getStyleValist(args:Extension method) Retrieves several widget style properties from
contextaccording to the current style.Declaration
Swift
@inlinable func getStyleValist(args: CVaListPointer) -
getValist(state:Extension methodargs: ) Retrieves several style property values from
contextfor a given state.See
gtk_style_context_get_property()for details.Declaration
Swift
@inlinable func getValist(state: StateFlags, args: CVaListPointer) -
hasClass(className:Extension method) Returns
trueifcontextcurrently has defined the given class name.Declaration
Swift
@inlinable func hasClass(className: UnsafePointer<gchar>!) -> Bool -
hasRegion(regionName:Extension methodflagsReturn: ) Returns
trueifcontexthas the region defined. Ifflags_returnis notnil, it is set to the flags affecting the region.has_region is deprecated: This method is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func hasRegion(regionName: UnsafePointer<gchar>!, flagsReturn: UnsafeMutablePointer<GtkRegionFlags>! = nil) -> Bool -
invalidate()Extension methodInvalidates
contextstyle information, so it will be reconstructed again. It is useful if you modify thecontextand need the new information immediately.invalidate is deprecated: Style contexts are invalidated automatically.
Declaration
Swift
@available(*, deprecated) @inlinable func invalidate() -
listClasses()Extension methodReturns the list of classes currently defined in
context.Declaration
Swift
@inlinable func listClasses() -> GLib.ListRef! -
listRegions()Extension methodReturns the list of regions currently defined in
context.list_regions is deprecated: This method is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func listRegions() -> GLib.ListRef! -
lookupColor(colorName:Extension methodcolor: ) Looks up and resolves a color name in the
contextcolor map.Declaration
Swift
@inlinable func lookupColor<RGBAT>(colorName: UnsafePointer<gchar>!, color: RGBAT) -> Bool where RGBAT : RGBAProtocol -
lookupIconSet(stockID:Extension method) Looks up
stock_idin the icon factories associated tocontextand the default icon factory, returning an icon set if found, otherwisenil.lookup_icon_set is deprecated: Use gtk_icon_theme_lookup_icon() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func lookupIconSet(stockID: UnsafePointer<gchar>!) -> IconSetRef! -
notifyStateChange(window:Extension methodregionID: state: stateValue: ) Notifies a state change on
context, so if the current style makes use of transition animations, one will be started so all rendered elements underregion_idare animated for statestatebeing set to valuestate_value.The
windowparameter is used in order to invalidate the rendered area as the animation runs, so make sure it is the same window that is being rendered on by the gtk_render_*() functions.If
region_idisnil, all rendered elements usingcontextwill be affected by this state transition.As a practical example, a
GtkButtonnotifying a state transition on the prelight state: (C Language Example):gtk_style_context_notify_state_change (context, gtk_widget_get_window (widget), NULL, GTK_STATE_PRELIGHT, button->in_button);Can be handled in the CSS file like this: (CSS Language Example):
button { background-color: #f00 } button:hover { background-color: #fff; transition: 200ms linear }This combination will animate the button background from red to white if a pointer enters the button, and back to red if the pointer leaves the button.
Note that
stateis used when finding the transition parameters, which is why the style places the transition under the :hover pseudo-class.notify_state_change is deprecated: This function does nothing.
Declaration
Swift
@available(*, deprecated) @inlinable func notifyStateChange<WindowT>(window: WindowT, regionID: gpointer! = nil, state: GtkStateType, stateValue: Bool) where WindowT : WindowProtocol -
popAnimatableRegion()Extension methodPops an animatable region from
context. Seegtk_style_context_push_animatable_region().pop_animatable_region is deprecated: This function does nothing.
Declaration
Swift
@available(*, deprecated) @inlinable func popAnimatableRegion() -
pushAnimatableRegion(regionID:Extension method) Pushes an animatable region, so all further gtk_render_*() calls between this call and the following
gtk_style_context_pop_animatable_region()will potentially show transition animations for this region ifgtk_style_context_notify_state_change()is called for a given state, and the current theme/style defines transition animations for state changes.The
region_idused must be unique incontextso the themes can uniquely identify rendered elements subject to a state transition.push_animatable_region is deprecated: This function does nothing.
Declaration
Swift
@available(*, deprecated) @inlinable func pushAnimatableRegion(regionID: gpointer! = nil) -
removeClass(className:Extension method) Removes
class_namefromcontext.Declaration
Swift
@inlinable func removeClass(className: UnsafePointer<gchar>!) -
remove(provider:Extension method) Removes
providerfrom the style providers list incontext.Declaration
Swift
@inlinable func remove<StyleProviderT>(provider: StyleProviderT) where StyleProviderT : StyleProviderProtocol -
removeRegion(regionName:Extension method) Removes a region from
context.remove_region is deprecated: This method is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func removeRegion(regionName: UnsafePointer<gchar>!) -
restore()Extension methodRestores
contextstate to a previous stage. Seegtk_style_context_save().Declaration
Swift
@inlinable func restore() -
save()Extension methodSaves the
contextstate, so temporary modifications done throughgtk_style_context_add_class(),gtk_style_context_remove_class(),gtk_style_context_set_state(), etc. can quickly be reverted in one go throughgtk_style_context_restore().The matching call to
gtk_style_context_restore()must be done before GTK returns to the main loop.Declaration
Swift
@inlinable func save() -
scrollAnimations(window:Extension methoddx: dy: ) This function is analogous to
gdk_window_scroll(), and should be called together with it so the invalidation areas for any ongoing animation are scrolled together with it.scroll_animations is deprecated: This function does nothing.
Declaration
Swift
@available(*, deprecated) @inlinable func scrollAnimations<WindowT>(window: WindowT, dx: Int, dy: Int) where WindowT : WindowProtocol -
setBackground(window:Extension method) Sets the background of
windowto the background pattern or color specified incontextfor its current state.set_background is deprecated: Use gtk_render_background() instead. Note that clients still using this function are now responsible for calling this function again whenever @context is invalidated.
Declaration
Swift
@available(*, deprecated) @inlinable func setBackground<WindowT>(window: WindowT) where WindowT : WindowProtocol -
set(direction:Extension method) Sets the reading direction for rendering purposes.
If you are using a
GtkStyleContextreturned fromgtk_widget_get_style_context(), you do not need to call this yourself.set_direction is deprecated: Use gtk_style_context_set_state() with #GTK_STATE_FLAG_DIR_LTR and #GTK_STATE_FLAG_DIR_RTL instead.
Declaration
Swift
@available(*, deprecated) @inlinable func set(direction: GtkTextDirection) -
set(frameClock:Extension method) Attaches
contextto the given frame clock.The frame clock is used for the timing of animations.
If you are using a
GtkStyleContextreturned fromgtk_widget_get_style_context(), you do not need to call this yourself.Declaration
Swift
@inlinable func set<FrameClockT>(frameClock: FrameClockT) where FrameClockT : FrameClockProtocol -
setJunction(sides:Extension method) Sets the sides where rendered elements (mostly through
gtk_render_frame()) will visually connect with other visual elements.This is merely a hint that may or may not be honored by themes.
Container widgets are expected to set junction hints as appropriate for their children, so it should not normally be necessary to call this function manually.
Declaration
Swift
@inlinable func setJunction(sides: JunctionSides) -
set(parent:Extension method) Sets the parent style context for
context. The parent style context is used to implement inheritance of properties.If you are using a
GtkStyleContextreturned fromgtk_widget_get_style_context(), the parent will be set for you.Declaration
Swift
@inlinable func set(parent: StyleContextRef? = nil) -
set(parent:Extension method) Sets the parent style context for
context. The parent style context is used to implement inheritance of properties.If you are using a
GtkStyleContextreturned fromgtk_widget_get_style_context(), the parent will be set for you.Declaration
Swift
@inlinable func set<StyleContextT>(parent: StyleContextT?) where StyleContextT : StyleContextProtocol -
set(path:Extension method) Sets the
GtkWidgetPathused for style matching. As a consequence, the style will be regenerated to match the new given path.If you are using a
GtkStyleContextreturned fromgtk_widget_get_style_context(), you do not need to call this yourself.Declaration
Swift
@inlinable func set<WidgetPathT>(path: WidgetPathT) where WidgetPathT : WidgetPathProtocol -
set(scale:Extension method) Sets the scale to use when getting image assets for the style.
Declaration
Swift
@inlinable func set(scale: Int) -
set(screen:Extension method) Attaches
contextto the given screen.The screen is used to add style information from “global” style providers, such as the screen’s
GtkSettingsinstance.If you are using a
GtkStyleContextreturned fromgtk_widget_get_style_context(), you do not need to call this yourself.Declaration
Swift
@inlinable func set<ScreenT>(screen: ScreenT) where ScreenT : ScreenProtocol -
setState(flags:Extension method) Sets the state to be used for style matching.
Declaration
Swift
@inlinable func setState(flags: StateFlags) -
stateIsRunning(state:Extension methodprogress: ) Returns
trueif there is a transition animation running for the current region (seegtk_style_context_push_animatable_region()).If
progressis notnil, the animation progress will be returned there, 0.0 means the state is closest to being unset, while 1.0 means it’s closest to being set. This means transition animation will run from 0 to 1 whenstateis being set and from 1 to 0 when it’s being unset.state_is_running is deprecated: This function always returns %FALSE
Declaration
Swift
@available(*, deprecated) @inlinable func stateIsRunning(state: GtkStateType, progress: UnsafeMutablePointer<gdouble>!) -> Bool -
toString(flags:Extension method) Converts the style context into a string representation.
The string representation always includes information about the name, state, id, visibility and style classes of the CSS node that is backing
context. Depending on the flags, more information may be included.This function is intended for testing and debugging of the CSS implementation in GTK+. There are no guarantees about the format of the returned string, it may change.
Declaration
Swift
@inlinable func toString(flags: StyleContextPrintFlags) -> String! -
renderActivity(cr:Extension methodx: y: width: height: ) Renders an activity indicator (such as in
GtkSpinner). The stateGTK_STATE_FLAG_CHECKEDdetermines whether there is activity going on.Declaration
Swift
@inlinable func renderActivity<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol -
renderArrow(cr:Extension methodangle: x: y: size: ) Renders an arrow pointing to
angle.Typical arrow rendering at 0, 1⁄2 π;, π; and 3⁄2 π:

Declaration
Swift
@inlinable func renderArrow<ContextT>(cr: ContextT, angle: Double, x: Double, y: Double, size: Double) where ContextT : ContextProtocol -
renderBackground(cr:Extension methodx: y: width: height: ) Renders the background of an element.
Typical background rendering, showing the effect of
background-image,border-widthandborder-radius:
Declaration
Swift
@inlinable func renderBackground<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol -
renderBackgroundGetClip(x:Extension methody: width: height: outClip: ) Returns the area that will be affected (i.e. drawn to) when calling
gtk_render_background()for the givencontextand rectangle.Declaration
Swift
@inlinable func renderBackgroundGetClip<RectangleT>(x: Double, y: Double, width: Double, height: Double, outClip: RectangleT) where RectangleT : RectangleProtocol -
renderCheck(cr:Extension methodx: y: width: height: ) Renders a checkmark (as in a
GtkCheckButton).The
GTK_STATE_FLAG_CHECKEDstate determines whether the check is on or off, andGTK_STATE_FLAG_INCONSISTENTdetermines whether it should be marked as undefined.Typical checkmark rendering:

Declaration
Swift
@inlinable func renderCheck<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol -
renderExpander(cr:Extension methodx: y: width: height: ) Renders an expander (as used in
GtkTreeViewandGtkExpander) in the area defined byx,y,width,height. The stateGTK_STATE_FLAG_CHECKEDdetermines whether the expander is collapsed or expanded.Typical expander rendering:

Declaration
Swift
@inlinable func renderExpander<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol -
renderExtension(cr:Extension methodx: y: width: height: gapSide: ) Renders a extension (as in a
GtkNotebooktab) in the rectangle defined byx,y,width,height. The side where the extension connects to is defined bygap_side.Typical extension rendering:

Declaration
Swift
@inlinable func renderExtension<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double, gapSide: GtkPositionType) where ContextT : ContextProtocol -
renderFocus(cr:Extension methodx: y: width: height: ) Renders a focus indicator on the rectangle determined by
x,y,width,height.Typical focus rendering:

Declaration
Swift
@inlinable func renderFocus<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol -
renderFrame(cr:Extension methodx: y: width: height: ) Renders a frame around the rectangle defined by
x,y,width,height.Examples of frame rendering, showing the effect of
border-image,border-color,border-width,border-radiusand junctions:
Declaration
Swift
@inlinable func renderFrame<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol -
renderFrameGap(cr:Extension methodx: y: width: height: gapSide: xy0Gap: xy1Gap: ) Renders a frame around the rectangle defined by (
x,y,width,height), leaving a gap on one side.xy0_gapandxy1_gapwill mean X coordinates forGTK_POS_TOPandGTK_POS_BOTTOMgap sides, and Y coordinates forGTK_POS_LEFTandGTK_POS_RIGHT.Typical rendering of a frame with a gap:

render_frame_gap is deprecated: Use gtk_render_frame() instead. Themes can create gaps by omitting borders via CSS.
Declaration
Swift
@available(*, deprecated) @inlinable func renderFrameGap<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double, gapSide: GtkPositionType, xy0Gap: Double, xy1Gap: Double) where ContextT : ContextProtocol -
renderHandle(cr:Extension methodx: y: width: height: ) Renders a handle (as in
GtkHandleBox,GtkPanedandGtkWindow’s resize grip), in the rectangle determined byx,y,width,height.Handles rendered for the paned and grip classes:

Declaration
Swift
@inlinable func renderHandle<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol -
renderIcon(cr:Extension methodpixbuf: x: y: ) Renders the icon in
pixbufat the specifiedxandycoordinates.This function will render the icon in
pixbufat exactly its size, regardless of scaling factors, which may not be appropriate when drawing on displays with high pixel densities.You probably want to use
gtk_render_icon_surface()instead, if you already have a Cairo surface.Declaration
Swift
@inlinable func renderIcon<ContextT, PixbufT>(cr: ContextT, pixbuf: PixbufT, x: Double, y: Double) where ContextT : ContextProtocol, PixbufT : PixbufProtocol -
renderIconPixbuf(source:Extension methodsize: ) Renders the icon specified by
sourceat the givensize, returning the result in a pixbuf.render_icon_pixbuf is deprecated: Use gtk_icon_theme_load_icon() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func renderIconPixbuf<IconSourceT>(source: IconSourceT, size: GtkIconSize) -> PixbufRef! where IconSourceT : IconSourceProtocol -
renderIconSurface(cr:Extension methodsurface: x: y: ) Renders the icon in
surfaceat the specifiedxandycoordinates.Declaration
Swift
@inlinable func renderIconSurface<ContextT, SurfaceT>(cr: ContextT, surface: SurfaceT, x: Double, y: Double) where ContextT : ContextProtocol, SurfaceT : SurfaceProtocol -
renderInsertionCursor(cr:Extension methodx: y: layout: index: direction: ) Draws a text caret on
crat the specified index oflayout.Declaration
Swift
@inlinable func renderInsertionCursor<ContextT, LayoutT>(cr: ContextT, x: Double, y: Double, layout: LayoutT, index: Int, direction: PangoDirection) where ContextT : ContextProtocol, LayoutT : LayoutProtocol -
renderLayout(cr:Extension methodx: y: layout: ) Renders
layouton the coordinatesx,yDeclaration
Swift
@inlinable func renderLayout<ContextT, LayoutT>(cr: ContextT, x: Double, y: Double, layout: LayoutT) where ContextT : ContextProtocol, LayoutT : LayoutProtocol -
renderLine(cr:Extension methodx0: y0: x1: y1: ) Renders a line from (x0, y0) to (x1, y1).
Declaration
Swift
@inlinable func renderLine<ContextT>(cr: ContextT, x0: Double, y0: Double, x1: Double, y1: Double) where ContextT : ContextProtocol -
renderOption(cr:Extension methodx: y: width: height: ) Renders an option mark (as in a
GtkRadioButton), theGTK_STATE_FLAG_CHECKEDstate will determine whether the option is on or off, andGTK_STATE_FLAG_INCONSISTENTwhether it should be marked as undefined.Typical option mark rendering:

Declaration
Swift
@inlinable func renderOption<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double) where ContextT : ContextProtocol -
renderSlider(cr:Extension methodx: y: width: height: orientation: ) Renders a slider (as in
GtkScale) in the rectangle defined byx,y,width,height.orientationdefines whether the slider is vertical or horizontal.Typical slider rendering:

Declaration
Swift
@inlinable func renderSlider<ContextT>(cr: ContextT, x: Double, y: Double, width: Double, height: Double, orientation: GtkOrientation) where ContextT : ContextProtocol -
directionExtension methodUndocumented
Declaration
Swift
@inlinable var direction: GtkTextDirection { get nonmutating set } -
frameClockExtension methodReturns the
GdkFrameClockto whichcontextis attached.Declaration
Swift
@inlinable var frameClock: Gdk.FrameClockRef! { get nonmutating set } -
junctionSidesExtension methodReturns the sides where rendered elements connect visually with others.
Declaration
Swift
@inlinable var junctionSides: JunctionSides { get nonmutating set } -
parentExtension methodSets or gets the style context’s parent. See
gtk_style_context_set_parent()for details.Declaration
Swift
@inlinable var parent: StyleContextRef! { get nonmutating set } -
pathExtension methodReturns the widget path used for style matching.
Declaration
Swift
@inlinable var path: WidgetPathRef! { get nonmutating set } -
scaleExtension methodReturns the scale used for assets.
Declaration
Swift
@inlinable var scale: Int { get nonmutating set } -
screenExtension methodUndocumented
Declaration
Swift
@inlinable var screen: Gdk.ScreenRef! { get nonmutating set } -
stateExtension methodReturns the state used for style matching.
This method should only be used to retrieve the
GtkStateFlagsto pass toGtkStyleContextmethods, likegtk_style_context_get_padding(). If you need to retrieve the current state of aGtkWidget, usegtk_widget_get_state_flags().Declaration
Swift
@inlinable var state: StateFlags { get nonmutating set } -
parentObjectExtension methodUndocumented
Declaration
Swift
@inlinable var parentObject: GObject { get }
View on GitHub
Install in Dash
StyleContextProtocol Protocol Reference