About all my projects
Gnome::Gtk3::StyleContext

Gnome::Gtk3::StyleContext

Rendering UI elements

Description

Gnome::Gtk3::StyleContext is an object that stores styling information affecting a widget.

In order to construct the final style information, Gnome::Gtk3::StyleContext queries information from all attached Gnome::Gtk3::StyleProviders. Style providers can be either attached explicitly to the context through add-provider(), or to the screen through add-provider-for-screen(). The resulting style is a combination of all providers’ information in priority order.

For GTK+ widgets, any Gnome::Gtk3::StyleContext returned by Gnome::Gtk3::Widget.get-style-context() will already have a Gnome::Gtk3::WidgetPath, a Gnome::Gdk3::Screen 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 set_path() and set_screen().

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.

Custom styling in UI libraries and applications

If you are developing a library with custom Gnome::Gtk3::Widgets that render differently than standard components, you may need to add a Gnome::Gtk3::StyleProvider yourself with the GTK_STYLE_PROVIDER_PRIORITY_FALLBACK priority, either a Gnome::Gtk3::CssProvider or a custom object implementing the Gnome::Gtk3::StyleProvider 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 application, you probably want then to make your style information prevail to the theme’s, so you must use a Gnome::Gtk3::StyleProvider 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.

Synopsis

Declaration

unit class Gnome::Gtk3::StyleContext;
also is Gnome::GObject::Object;

Inheriting this class

Inheriting is done in a special way in that it needs a call from new() to get the native object created by the class you are inheriting from.

use Gnome::Gtk3::StyleContext:api<1>;

unit class MyGuiClass;
also is Gnome::Gtk3::StyleContext;

submethod new ( |c ) {
  # let the Gnome::Gtk3::StyleContext class process the options
  self.bless( :GtkStyleContext, |c);
}

submethod BUILD ( ... ) {
  ...
}

Example

Types

GtkStyleContextPrintFlags

Flags that modify the behavior of gtk_style_context_to_string(). New values may be added to this enumeration.

  • GTK_STYLE_CONTEXT_PRINT_NONE;

  • GTK_STYLE_CONTEXT_PRINT_RECURSE; Print the entire tree of CSS nodes starting at the style context's node

  • GTK_STYLE_CONTEXT_PRINT_SHOW_STYLE; Show the values of the CSS properties for each node

Methods

new

default, no options

Create a new plain object. The value doesn't have to be True nor False. The name only will suffice.

multi method new ( )

:native-object

Create a StyleContext object using a native object from elsewhere. See also Gnome::N::TopLevelClassSupport.

multi method new ( N-GObject :$native-object! )

:build-id

Create a StyleContext object using a native object returned from a builder. See also Gnome::GObject::Object.

multi method new ( Str :$build-id! )

add-class

Adds a style class to context, so posterior calls to get() or any of the gtk-render-*() functions will make use of this new class for styling.

In the CSS file format, a Gnome::Gtk3::Entry defining a “search” class, would be matched by:

entry.search { … }

While any widget defining a “search” class would be matched by:

  .search { … }
  method add-class ( Str $class_name )
  • Str $class_name; class name to use in styling

add-provider

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 which context belongs. If you want to affect the style of all widgets, use add-provider-for-screen().

Note: If both priorities are the same, a Gnome::Gtk3::StyleProvider added through this function takes precedence over another added through add-provider-for-screen().

method add-provider ( N-GObject $provider, UInt $priority )
  • N-GObject $provider; a Gnome::Gtk3::StyleProvider

  • UInt $priority; the priority of the style provider. The lower it is, the earlier it will be used in the style construction. Typically this will be in the range between GTK-STYLE-PROVIDER-PRIORITY-FALLBACK and GTK-STYLE-PROVIDER-PRIORITY-USER

add-provider-for-screen

Adds a global style provider to screen, which will be used in style construction for all Gnome::Gtk3::StyleContexts under screen.

GTK+ uses this to make styling information from Gnome::Gtk3::Settings available.

Note: If both priorities are the same, A Gnome::Gtk3::StyleProvider added through add-provider() takes precedence over another added through this function.

method add-provider-for-screen ( N-GObject $screen, N-GObject $provider, UInt $priority )
  • N-GObject $screen; a Gnome::Gtk3::Screen

  • N-GObject $provider; a Gnome::Gtk3::StyleProvider

  • UInt $priority; the priority of the style provider. The lower it is, the earlier it will be used in the style construction. Typically this will be in the range between GTK-STYLE-PROVIDER-PRIORITY-FALLBACK and GTK-STYLE-PROVIDER-PRIORITY-USER

get

Retrieves several style property values from context for a given state.

See get-property() for details.

method get ( UInt $state, List $properties --> List )
  • UInt $state; state to retrieve the property values for @...: property name /return value pairs, followed by undefined GtkStateFlags

get-border, get-border-rk

Returns the border for a given state as a Gnome::Gtk3::Border.

method get-border ( UInt $state --> N-GtkBorder )
method get-border-rk ( UInt $state --> Gnome::Gtk3::Border )
  • UInt $state; state flags from GtkStateFlags to retrieve the border for

get-color, get-color-rk

Returns the foreground color for a given state.

method get-color ( Uint $state --> N-GdkRGBA )
method get-color-rk ( UInt $state --> Gnome::Gdk3::RGBA )
  • UInt $state; state flags from GtkStateFlags to retrieve the color for

get-frame-clock

Returns the Gnome::Gtk3::FrameClock to which context is attached.

Returns: a Gnome::Gtk3::FrameClock, or undefined if context does not have an attached frame clock.

method get-frame-clock ( --> N-GObject )

get-junction-sides

Returns the sides where rendered elements connect visually with others.

Returns: the junction sides mask. Bits are from GtkJunctionSides.

method get-junction-sides ( --> UInt )

get-margin, get-margin-rk

Returns the margin for a given state as a Gnome::Gtk3::Border.

method get-margin ( UInt $state --> N-GtkBorder )
method get-margin-rk ( UInt $state --> Gnome::Gtk3::Border )
  • UInt $state; state flags from GtkStateFlags to retrieve the border for

get-padding, get-padding-rk

Returns the padding for a given state as a Gnome::Gtk3::Border.

method get-padding ( UInt $state --> N-GtkBorder )
method get-padding-rk ( UInt $state --> Gnome::Gtk3::Border )
  • UInt $state; state flags from GtkStateFlagsto retrieve the padding for

get-parent, get-parent-rk

Gets the parent context set via set-parent(). See that function for details.

Returns: the parent context or undefined

method get-parent ( --> N-GObject )
method get-parent-rk ( --> Gnome::Gtk3::StyleContext )

get-path, get-path-rk

Returns the widget path used for style matching.

Returns: A Gnome::Gtk3::WidgetPath

method get-path ( --> N-GObject )
method get-path-rk ( --> Gnome::Gtk3::WidgetPath )

get-property

Gets a style property from context for 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 Gnome::Gtk3::Value. 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 context is not recommended unless the style context has been saved with save().

When value is no longer needed, clear-object() must be called to free any allocated memory.

method get-property ( Str $property, UInt $state --> N-GValue )
method get-property-rk (
  Str $property, UInt $state --> Gnome::GObject::Value
)
  • Str $property; style property name

  • UInt $state; state flags from GtkStateFlags to retrieve the property value for

  • N-GObject $value; return location for the style property value

get-scale

Returns the scale used for assets.

Returns: the scale

method get-scale ( --> Int )

get-screen, get-screen-rk

Returns the Gnome::Gtk3::Screen to which context is attached.

Returns: a Gnome::Gtk3::Screen.

method get-screen ( --> N-GObject )
method get-screen-rk ( --> Gnome::Gdk3::Screen )

get-section, get-section-rk

Queries the location in the CSS where $property was defined for the current context. Note that the state to be queried is taken from get-state().

If the location is not available, undefined will be returned. The location might not be available for various reasons, such as the property being overridden, $property not 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 undefined.

Returns: undefined or the section where a value for $property was defined

method get-section ( Str $property --> N-GObject )
method get-section-rk ( Str $property --> Gnome::Gtk3::CssSection )
  • $property; style property name

get-state

Returns the state used for style matching.

This method should only be used to retrieve the bit mask of GtkStateFlags to pass to Gnome::Gtk3::StyleContext methods, like get-padding(). If you need to retrieve the current state of a Gnome::Gtk3::Widget, use Gnome::Gtk3::Widget.get-state-flags().

Returns: the state flags bit mask from GtkStateFlags

method get-state ( --> UInt )

get-style

Retrieves several widget style properties from context according to the current style.

method get-style ( )

get-style-property, get-style-property-rk

Gets the value for a widget style property.

When value is no longer needed, g-value-unset() must be called to free any allocated memory.

method get-style-property ( Str $property_name --> N-GValue )
method get-style-property-rk ( Str $property_name --> Gnome::GObject::Value )
  • Str $property_name; the name of the widget style property

  • N-GObject $value; Return location for the property value

get-style-valist

Retrieves several widget style properties from context according to the current style.

method get-style-valist ( va_list $args )
  • va_list $args; va-list of property name/return location pairs, followed by undefined

get-valist

Retrieves several style property values from context for a given state.

See get-property() for details.

method get-valist ( UInt $state, va_list $args )
  • UInt $state; state flags from GtkStateFlags to retrieve the property values for

  • va_list $args; va-list of property name/return location pairs, followed by undefined

gtk-render-insertion-cursor

Draws a text caret on cr at the specified index of layout.

method gtk-render-insertion-cursor ( cairo_t $cr, Num() $x, Num() $y, N-GObject $layout, Int() $index, PangoDirection $direction )
  • cairo_t $cr; a cairo-t

  • Num() $x; X origin

  • Num() $y; Y origin

  • N-GObject $layout; the PangoLayout of the text

  • Int() $index; the index in the PangoLayout

  • PangoDirection $direction; the PangoDirection of the text

has-class

Returns True if context currently has defined the given class name.

Returns: True if context has class-name defined

method has-class ( Str $class_name --> Bool )
  • Str $class_name; a class name

list-classes, list-classes-rk

Returns the list of classes currently defined in context.

Returns: a Gnome::Gtk3::List of strings with the currently defined classes. The contents of the list are owned by GTK+, but you must free the list itself with clear-object() when you are done with it.

method list-classes ( --> N-GList )
method list-classes-rk ( --> Gnome::Glib::List )

lookup-color, lookup-color-rk

Looks up and resolves a color name in the context color map.

Returns: N-GdkRGBA color if color-name was found and resolved, undefined or invalid otherwise

method lookup-color ( Str $color_name --> N-GdkRGBA )
method lookup-color-rk ( Str $color_name --> Gnome::Gdk3::RGBA )
  • Str $color_name; color name to lookup

remove-class

Removes class-name from context.

method remove-class ( Str $class_name )
  • Str $class_name; class name to remove

remove-provider

Removes provider from the style providers list in context.

method remove-provider ( N-GObject $provider )
  • N-GObject $provider; a Gnome::Gtk3::StyleProvider

remove-provider-for-screen

Removes provider from the global style providers list in screen.

method remove-provider-for-screen ( N-GObject $screen, N-GObject $provider )
  • N-GObject $screen; a Gnome::Gtk3::Screen

  • N-GObject $provider; a Gnome::Gtk3::StyleProvider

render-activity

Renders an activity indicator (such as in Gnome::Gtk3::Spinner). The state GTK-STATE-FLAG-CHECKED determines whether there is activity going on.

method render-activity (
  cairo_t $cr, Num() $x, Num() $y, Num() $width, Num() $height
)
  • cairo_t $cr; a cairo-t

  • Num() $x; X origin of the rectangle

  • Num() $y; Y origin of the rectangle

  • Num() $width; rectangle width

  • Num() $height; rectangle height

render-arrow

Renders an arrow pointing to angle.

Typical arrow rendering at 0, 1⁄2 π;, π; and 3⁄2 π:

No caption
method render-arrow (
  cairo_t $cr, Num() $angle, Num() $x, Num() $y, Num() $size
)
  • cairo_t $cr; a cairo-t

  • Num() $angle; arrow angle from 0 to 2 * G-PI, being 0 the arrow pointing to the north

  • Num() $x; X origin of the render area

  • Num() $y; Y origin of the render area

  • Num() $size; square side for render area

render-background

Renders the background of an element.

Typical background rendering, showing the effect of `background-image`, `border-width` and `border-radius`:

No caption
method render-background (
  cairo_t $cr, Num() $x, Num() $y, Num() $width, Num() $height
)
  • cairo_t $cr; a cairo-t

  • Num() $x; X origin of the rectangle

  • Num() $y; Y origin of the rectangle

  • Num() $width; rectangle width

  • Num() $height; rectangle height

render-background-get-clip

Returns the area that will be affected (i.e. drawn to) when calling background() for the given context and rectangle. Returns a N-GdkRectangle (defined in Gnome::Gdk3::Types).

method render-background-get-clip (
  Num() $x, Num() $y, Num() $width, Num() $height --> N-GdkRectangle
)
  • Num() $x; X origin of the rectangle

  • Num() $y; Y origin of the rectangle

  • Num() $width; rectangle width

  • Num() $height; rectangle height

render-check

Renders a checkmark (as in a Gnome::Gtk3::CheckButton).

The GTK-STATE-FLAG-CHECKED state determines whether the check is on or off, and GTK-STATE-FLAG-INCONSISTENT determines whether it should be marked as undefined.

Typical checkmark rendering:

No caption
method render-check (
  cairo_t $cr, Num() $x, Num() $y, Num() $width, Num() $height
)
  • cairo_t $cr; a cairo-t

  • Num() $x; X origin of the rectangle

  • Num() $y; Y origin of the rectangle

  • Num() $width; rectangle width

  • Num() $height; rectangle height

render-expander

Renders an expander (as used in Gnome::Gtk3::TreeView and Gnome::Gtk3::Expander) in the area defined by x, y, width, height. The state GTK-STATE-FLAG-CHECKED determines whether the expander is collapsed or expanded.

Typical expander rendering:

No caption
method render-expander (
  cairo_t $cr, Num() $x, Num() $y, Num() $width, Num() $height
)
  • cairo_t $cr; a cairo-t

  • Num() $x; X origin of the rectangle

  • Num() $y; Y origin of the rectangle

  • Num() $width; rectangle width

  • Num() $height; rectangle height

render-extension

Renders a extension (as in a Gnome::Gtk3::Notebook tab) in the rectangle defined by x, y, width, height. The side where the extension connects to is defined by gap-side.

Typical extension rendering:

No caption
method render-extension (
  cairo_t $cr, Num() $x, Num() $y, Num() $width, Num() $height,
  GtkPositionType $gap_side
)
  • cairo_t $cr; a cairo-t

  • Num() $x; X origin of the rectangle

  • Num() $y; Y origin of the rectangle

  • Num() $width; rectangle width

  • Num() $height; rectangle height

  • GtkPositionType $gap_side; side where the gap is

render-focus

Renders a focus indicator on the rectangle determined by x, y, width, height.

Typical focus rendering:

No caption
method render-focus (
  cairo_t $cr, Num() $x, Num() $y, Num() $width, Num() $height
)
  • cairo_t $cr; a cairo-t

  • Num() $x; X origin of the rectangle

  • Num() $y; Y origin of the rectangle

  • Num() $width; rectangle width

  • Num() $height; rectangle height

render-frame

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-radius` and junctions:

No caption
method render-frame (
  cairo_t $cr, Num() $x, Num() $y, Num() $width, Num() $height
)
  • cairo_t $cr; a cairo-t

  • Num() $x; X origin of the rectangle

  • Num() $y; Y origin of the rectangle

  • Num() $width; rectangle width

  • Num() $height; rectangle height

render-handle

Renders a handle (as in Gnome::Gtk3::HandleBox, Gnome::Gtk3::Paned and Gnome::Gtk3::Window’s resize grip), in the rectangle determined by x, y, width, height.

Handles rendered for the paned and grip classes:

No caption
method render-handle (
  cairo_t $cr, Num() $x, Num() $y, Num() $width, Num() $height
)
  • cairo_t $cr; a cairo-t

  • Num() $x; X origin of the rectangle

  • Num() $y; Y origin of the rectangle

  • Num() $width; rectangle width

  • Num() $height; rectangle height

render-icon

Renders the icon in pixbuf at the specified x and y coordinates.

This function will render the icon in pixbuf at 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 icon-surface() instead, if you already have a Cairo surface.

method render-icon (
  cairo_t $cr, N-GPixbuf $pixbuf, Num() $x, Num() $y
)
  • cairo_t $cr; a cairo-t

  • N-GObject $pixbuf; a Gnome::Gtk3::Pixbuf containing the icon to draw

  • Num() $x; X position for the pixbuf

  • Num() $y; Y position for the pixbuf

render-icon-surface

Renders the icon in surface at the specified x and y coordinates.

method render-icon-surface (
  cairo_t $cr, cairo_surface_t $surface, Num() $x, Num() $y
)
  • cairo_t $cr; a cairo-t

  • cairo_surface_t $surface; a cairo-surface-t containing the icon to draw

  • Num() $x; X position for the icon

  • Num() $y; Y position for the incon

render-layout

Renders layout on the coordinates x, y

method render-layout (
  cairo_t $cr, Num() $x, Num() $y, N-GObject $layout
)
  • cairo_t $cr; a cairo-t

  • Num() $x; X origin

  • Num() $y; Y origin

  • N-GObject $layout; the PangoLayout to render

render-line

Renders a line from (x0, y0) to (x1, y1).

method render-line (
  cairo_t $cr, Num() $x0, Num() $y0, Num() $x1, Num() $y1
)
  • cairo_t $cr; a cairo-t

  • Num() $x0; X coordinate for the origin of the line

  • Num() $y0; Y coordinate for the origin of the line

  • Num() $x1; X coordinate for the end of the line

  • Num() $y1; Y coordinate for the end of the line

render-option

Renders an option mark (as in a Gnome::Gtk3::RadioButton), the GTK-STATE-FLAG-CHECKED state will determine whether the option is on or off, and GTK-STATE-FLAG-INCONSISTENT whether it should be marked as undefined.

Typical option mark rendering:

No caption
method render-option (
  cairo_t $cr, Num() $x, Num() $y, Num() $width, Num() $height
)
  • cairo_t $cr; a cairo-t

  • Num() $x; X origin of the rectangle

  • Num() $y; Y origin of the rectangle

  • Num() $width; rectangle width

  • Num() $height; rectangle height

render-slider

Renders a slider (as in Gnome::Gtk3::Scale) in the rectangle defined by x, y, width, height. orientation defines whether the slider is vertical or horizontal.

Typical slider rendering:

No caption
method render-slider (
  cairo_t $cr, Num() $x, Num() $y, Num() $width, Num() $height,
  GtkOrientation $orientation
)
  • cairo_t $cr; a cairo-t

  • Num() $x; X origin of the rectangle

  • Num() $y; Y origin of the rectangle

  • Num() $width; rectangle width

  • Num() $height; rectangle height

  • GtkOrientation $orientation; orientation of the slider

reset-widgets

This function recomputes the styles for all widgets under a particular Gnome::Gtk3::Screen. This is useful when some global parameter has changed that affects the appearance of all widgets, because when a widget gets a new style, it will both redraw and recompute any cached information about its appearance. As an example, it is used when the color scheme changes in the related Gnome::Gtk3::Settings object.

method reset-widgets ( N-GObject $screen )
  • N-GObject $screen; a Gnome::Gtk3::Screen

restore

Restores context state to a previous stage. See save().

method restore ( )

save

Saves the context state, so temporary modifications done through add-class(), remove-class(), set-state(), etc. can quickly be reverted in one go through gtk-style-context-restore().

The matching call to gtk-style-context-restore() must be done before GTK returns to the main loop.

method save ( )

set-frame-clock

Attaches context to the given frame clock.

The frame clock is used for the timing of animations.

If you are using a Gnome::Gtk3::StyleContext returned from gtk-widget-get-style-context(), you do not need to call this yourself.

method set-frame-clock ( N-GObject $frame-clock )
  • N-GObject $frame-clock; a Gnome::Gtk3::FrameClock

set-junction-sides

Sets the sides where rendered elements (mostly through 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.

method set-junction-sides ( UInt $sides )
  • UInt $sides; sides where rendered elements are visually connected to other elements. Bits ae from GtkJunctionSides.

set-parent

Sets the parent style context for context. The parent style context is used to implement [inheritance](http://www.w3.org/TR/css3-cascade/inheritance) of properties.

If you are using a Gnome::Gtk3::StyleContext returned from gtk-widget-get-style-context(), the parent will be set for you.

method set-parent ( N-GObject $parent )
  • N-GObject $parent; the new parent or undefined

set-path

Sets the Gnome::Gtk3::WidgetPath used for style matching. As a consequence, the style will be regenerated to match the new given path.

If you are using a Gnome::Gtk3::StyleContext returned from Gnome::Gtk3::Widget.get-style-context(), you do not need to call this yourself.

method set-path ( N-GObject $path )
  • N-GObject $path; a Gnome::Gtk3::WidgetPath

set-scale

Sets the scale to use when getting image assets for the style.

method set-scale ( Int() $scale )
  • Int() $scale; scale

set-screen

Attaches context to the given screen.

The screen is used to add style information from “global” style providers, such as the screen’s Gnome::Gtk3::Settings instance.

If you are using a Gnome::Gtk3::StyleContext returned from gtk-widget-get-style-context(), you do not need to call this yourself.

method set-screen ( N-GObject $screen )
  • N-GObject $screen; a Gnome::Gtk3::Screen

set-state

Sets the state bit mask to be used for style matching.

method set-state ( UInt $flags )
  • UInt $flags; state to represent using bits from GtkStateFlags

to-string

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.

Returns: a newly allocated string representing context

method to-string ( Uint $flags --> Str )
  • UInt $flags; Flags that determine what to print. Nits are from GtkStyleContextPrintFlags

_gtk_style_context_new

Creates a standalone Gnome::Gtk3::StyleContext, this style context won’t be attached to any widget, so you may want to call set-path() yourself.

This function is only useful when using the theming layer separated from GTK+, if you are using Gnome::Gtk3::StyleContext to theme Gnome::Gtk3::Widgets, use gtk-widget-get-style-context() in order to get a style context ready to theme the widget.

Returns: A newly created Gnome::Gtk3::StyleContext.

method _gtk_style_context_new ( --> N-GObject )

Signals

There are two ways to connect to a signal. The first option you have is to use register-signal() from Gnome::GObject::Object. The second option is to use connect-object() directly from Gnome::GObject::Signal.

First method

The positional arguments of the signal handler are all obligatory as well as their types. The named attributes :$widget and user data are optional.

# handler method
method mouse-event ( GdkEvent $event, :$widget ) { ... }

# connect a signal on window object
my Gnome::Gtk3::Window $w .= new( ... );
$w.register-signal( self, 'mouse-event', 'button-press-event');

Second method

my Gnome::Gtk3::Window $w .= new( ... );
my Callable $handler = sub (
  N-GObject $native, GdkEvent $event, OpaquePointer $data
) {
  ...
}

$w.connect-object( 'button-press-event', $handler);

Also here, the types of positional arguments in the signal handler are important. This is because both methods register-signal() and connect-object() are using the signatures of the handler routines to setup the native call interface.

Supported signals

changed

The changed signal is emitted when there is a change in the Gnome::Gtk3::StyleContext.

For a Gnome::Gtk3::StyleContext returned by Gnome::Gtk3::Widget.get-style-context(), the style-updated signal might be more convenient to use.

This signal is useful when using the theming layer standalone.

method handler (
  Int :$_handle_id,
  Gnome::Gtk3::StyleContext() :$_native_object,
  *%user-options
);
  • $_handle_id; the registered event handler id=item $_widget; the object which received the signal.

  • $_native-object; The native object provided by the caller wrapped in the Raku object which registered the signal.

  • %user-options; A list of named arguments provided at the register-signal() method

Properties

An example of using a string type property of a Gnome::Gtk3::Label object. This is just showing how to set/read a property, not that it is the best way to do it. This is because a) The class initialization often provides some options to set some of the properties and b) the classes provide many methods to modify just those properties. In the case below one can use new(:label('my text label')) or .set-text('my text label').

my Gnome::Gtk3::Label $label .= new;
my Gnome::GObject::Value $gv .= new(:init(G_TYPE_STRING));
$label.get-property( 'label', $gv);
$gv.set-string('my text label');

Supported properties

Direction: direction

Text direction Default value: False

The Gnome::GObject::Value type of property direction is G_TYPE_ENUM.

FrameClock: paint-clock

The associated GdkFrameClock Widget type: GDK-TYPE-FRAME-CLOCK

The Gnome::GObject::Value type of property paint-clock is G_TYPE_OBJECT.

Parent: parent

Sets or gets the style context’s parent. See set-parent() for details.

Widget type: GTK_TYPE_STYLE_CONTEXT

The Gnome::GObject::Value type of property parent is G_TYPE_OBJECT.

Screen: screen

The associated GdkScreen Widget type: GDK-TYPE-SCREEN

The Gnome::GObject::Value type of property screen is G_TYPE_OBJECT.

[gtk_] style_context_new

Creates a standalone Gnome::Gtk3::StyleContext, this style context won’t be attached to any widget, so you may want to call gtk_style_context_set_path() yourself.

This function is only useful when using the theming layer separated from GTK+, if you are using Gnome::Gtk3::StyleContext to theme Gnome::Gtk3::Widgets, use gtk_widget_get_style_context() in order to get a style context ready to theme the widget.

Returns: A newly created Gnome::Gtk3::StyleContext.

method gtk_style_context_new ( --> N-GObject  )

[[gtk_] style_context_] add_provider_for_screen

Adds a global style provider to Gnome::Gdk3::Screen, which will be used in style construction for all Gnome::Gtk3::StyleContexts under Gnome::Gdk3::Screen.

GTK+ uses this to make styling information from Gnome::Gtk3::Settings available.

Note: If both priorities are the same, A Gnome::Gtk3::StyleProvider added through gtk_style_context_add_provider() takes precedence over another added through this function.

Note: Priorities are unsigned integers renaging from 1 to lets say 1000. An enumeration GtkStyleProviderPriority in StyleProvider is defined for specific priorities such as GTK_STYLE_PROVIDER_PRIORITY_SETTINGS and GTK_STYLE_PROVIDER_PRIORITY_USER.

Since: 3.0

method gtk_style_context_add_provider_for_screen (
  N-GObject $screen, N-GObject $provider, UInt $priority
)
  • N-GObject $screen; a Gnome::Gdk3::Screen.

  • N-GObject $provider; a Gnome::Gtk3::StyleProvider.

  • UInt $priority; the priority of the style provider. The lower it is, the earlier it will be used in the style construction. Typically this will be in the range between GTK_STYLE_PROVIDER_PRIORITY_FALLBACK (= 1) and GTK_STYLE_PROVIDER_PRIORITY_USER (= 800).

my Gnome::Gdk3::Screen $screen .= new;
my Gnome::Gtk3::StyleContext $sc .= new;
my Gnome::Gtk3::CssProvider $cp .= new;

$sc.add-provider-for-screen(
  $screen, $cp, GTK_STYLE_PROVIDER_PRIORITY_FALLBACK
);

[[gtk_] style_context_] remove_provider_for_screen

Removes a Gnome::Gtk3::StyleProvider from the global style providers list in Gnome::Gdk3::Screen.

Since: 3.0

method gtk_style_context_remove_provider_for_screen ( N-GObject $screen, N-GObject $provider )
  • N-GObject $screen; a Gnome::Gdk3::Screen

  • N-GObject $provider; a Gnome::Gtk3::StyleProvider

[[gtk_] style_context_] add_provider

Adds a style provider to the context, to be used in style construction. Note that a style provider added by this function only affects the style of the widget to which context belongs. If you want to affect the style of all widgets, use gtk_style_context_add_provider_for_screen().

Note: If both priorities are the same, a Gnome::Gtk3::StyleProvider added through this function takes precedence over another added through gtk_style_context_add_provider_for_screen().

Since: 3.0

method gtk_style_context_add_provider ( N-GObject $provider, UInt $priority )
  • N-GObject $provider; a Gnome::Gtk3::StyleProvider

  • UInt $priority; the priority of the style provider. The lower it is, the earlier it will be used in the style construction. Typically this will be in the range between GTK_STYLE_PROVIDER_PRIORITY_FALLBACK and GTK_STYLE_PROVIDER_PRIORITY_USER

my Gnome::Gtk3::StyleContext $sc .= new;
my Gnome::Gtk3::CssProvider $cp .= new;

$sc.add-provider( $cp, 234);

[[gtk_] style_context_] remove_provider

Removes a Gnome::Gtk3::StyleProvider from the style providers list in context.

Since: 3.0

method gtk_style_context_remove_provider ( N-GObject $provider )
  • N-GObject $provider; a Gnome::Gtk3::StyleProvider

[gtk_] style_context_save

Saves the context state, so temporary modifications done through gtk_style_context_add_class(), gtk_style_context_remove_class(), gtk_style_context_set_state(), etc. can quickly be reverted in one go through gtk_style_context_restore().

The matching call to gtk_style_context_restore() must be done before GTK returns to the main loop.

Since: 3.0

method gtk_style_context_save ( )

[gtk_] style_context_restore

Restores context state to a previous stage. See gtk_style_context_save().

Since: 3.0

method gtk_style_context_restore ( )

[[gtk_] style_context_] get_section

Queries the location in the CSS where property was defined for the current context. Note that the state to be queried is taken from gtk_style_context_get_state().

If the location is not available, Any will be returned. The location might not be available for various reasons, such as the property being overridden, property not 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 Any.

Returns: (nullable) (transfer none): Any or the section where a value for property was defined

method gtk_style_context_get_section ( Str $property --> N-GObject  )
  • Str $property; style property name

[[gtk_] style_context_] get_property

Gets a style property from context for 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 context is not recommended unless the style context has been saved with gtk_style_context_save().

When value is no longer needed, clear-object() must be called to free any allocated memory.

Since: 3.0

method gtk_style_context_get_property ( Str $property, GtkStateFlags $state, N-GObject $value )
  • Str $property; style property name

  • GtkStateFlags $state; state to retrieve the property value for

  • N-GObject $value; (out) (transfer full): return location for the style property value

[[gtk_] style_context_] get_valist

Retrieves several style property values from context for a given state.

See gtk_style_context_get_property() for details.

Since: 3.0

method gtk_style_context_get_valist ( GtkStateFlags $state, va_list $args )
  • GtkStateFlags $state; state to retrieve the property values for

  • va_list $args; va_list of property name/return location pairs, followed by Any

[gtk_] style_context_get

Retrieves several style property values from context for a given state.

See gtk_style_context_get_property() for details.

Since: 3.0

method gtk_style_context_get ( GtkStateFlags $state )
  • GtkStateFlags $state; state to retrieve the property values for @...: property name /return value pairs, followed by Any

[[gtk_] style_context_] set_state

Sets the state to be used for style matching.

Since: 3.0

method gtk_style_context_set_state ( GtkStateFlags $flags )
  • GtkStateFlags $flags; state to represent

[[gtk_] style_context_] get_state

Returns the state used for style matching.

This method should only be used to retrieve the Gnome::Gtk3::StateFlags to pass to Gnome::Gtk3::StyleContext methods, like gtk_style_context_get_padding(). If you need to retrieve the current state of a Gnome::Gtk3::Widget, use gtk_widget_get_state_flags().

Returns: the state flags

Since: 3.0

method gtk_style_context_get_state ( --> GtkStateFlags  )

[[gtk_] style_context_] set_scale

Sets the scale to use when getting image assets for the style.

Since: 3.10

method gtk_style_context_set_scale ( Int $scale )
  • Int $scale; scale

[[gtk_] style_context_] get_scale

Returns the scale used for assets.

Returns: the scale

Since: 3.10

method gtk_style_context_get_scale ( --> Int  )

[[gtk_] style_context_] set_path

Sets the Gnome::Gtk3::WidgetPath used for style matching. As a consequence, the style will be regenerated to match the new given path.

If you are using a Gnome::Gtk3::StyleContext returned from gtk_widget_get_style_context(), you do not need to call this yourself.

Since: 3.0

method gtk_style_context_set_path ( N-GObject $path )
  • N-GObject $path; a Gnome::Gtk3::WidgetPath

[[gtk_] style_context_] get_path

method gtk_style_context_get_path ( --> N-GObject )

Returns the widget path

[[gtk_] style_context_] set_parent

Sets the parent style context for context. The parent style context is used to implement [inheritance](https://www.w3.org/TR/css3-cascade/#inheritance) of properties.

If you are using a Gnome::Gtk3::StyleContext returned from gtk_widget_get_style_context(), the parent will be set for you.

Since: 3.4

method gtk_style_context_set_parent ( N-GObject $parent )
  • N-GObject $parent; (allow-none): the new parent or Any

[[gtk_] style_context_] get_parent

Gets the parent context set via gtk_style_context_set_parent(). See that function for details.

Returns: (nullable) (transfer none): the parent context or Any

Since: 3.4

method gtk_style_context_get_parent ( --> N-GObject  )

[[gtk_] style_context_] list_classes

Returns the list of classes currently defined in context.

Returns: (transfer container) (element-type utf8): a GList of strings with the currently defined classes. The contents of the list are owned by GTK+, but you must free the list itself with g_list_free() when you are done with it.

Since: 3.0

method gtk_style_context_list_classes ( --> N-GObject  )

[[gtk_] style_context_] add_class

Adds a style class to context, so posterior calls to gtk_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 Gnome::Gtk3::Entry defining a “search” class, would be matched by:

entry.search { ... }

While any widget defining a “search” class would be matched by:

.search { ... }

Since: 3.0

method gtk_style_context_add_class ( Str $class_name )
  • Str $class_name; class name to use in styling

[[gtk_] style_context_] remove_class

Removes class_name from context.

Since: 3.0

method gtk_style_context_remove_class ( Str $class_name )
  • Str $class_name; class name to remove

[[gtk_] style_context_] has_class

Returns 1 if context currently has defined the given class name.

Returns: 1 if context has class_name defined

Since: 3.0

method gtk_style_context_has_class ( Str $class_name --> Int  )
  • Str $class_name; a class name

[[gtk_] style_context_] get_style_property

Gets the value for a widget style property.

When value is no longer needed, clear-object() must be called to free any allocated memory.

method gtk_style_context_get_style_property (
  Str $property_name, N-GObject $value
)
  • Str $property_name; the name of the widget style property

  • N-GObject $value; Return location for the property value

[[gtk_] style_context_] get_style_valist

Retrieves several widget style properties from context according to the current style.

Since: 3.0

method gtk_style_context_get_style_valist ( va_list $args )
  • va_list $args; va_list of property name/return location pairs, followed by Any

[[gtk_] style_context_] get_style

Retrieves several widget style properties from context according to the current style.

Since: 3.0

method gtk_style_context_get_style ( )

[[gtk_] style_context_] set_screen

Attaches context to the given screen.

The screen is used to add style information from “global” style providers, such as the screens Gnome::Gtk3::Settings instance.

If you are using a Gnome::Gtk3::StyleContext returned from gtk_widget_get_style_context(), you do not need to call this yourself.

Since: 3.0

method gtk_style_context_set_screen ( N-GObject $screen )
  • N-GObject $screen; a Gnome::Gdk3::Screen

[[gtk_] style_context_] get_screen

Returns the Gnome::Gdk3::Screen to which context is attached.

Returns: (transfer none): a Gnome::Gdk3::Screen.

method gtk_style_context_get_screen ( --> N-GObject  )

[[gtk_] style_context_] set_frame_clock

Attaches context to the given frame clock.

The frame clock is used for the timing of animations.

If you are using a Gnome::Gtk3::StyleContext returned from gtk_widget_get_style_context(), you do not need to call this yourself.

Since: 3.8

method gtk_style_context_set_frame_clock ( N-GObject $frame-clock )
  • N-GObject $frame-clock; a Gnome::Gdk3::FrameClock

[[gtk_] style_context_] get_frame_clock

Returns the Gnome::Gdk3::FrameClock to which context is attached.

Returns: (nullable) (transfer none): a Gnome::Gdk3::FrameClock, or Any if context does not have an attached frame clock.

Since: 3.8

method gtk_style_context_get_frame_clock ( --> N-GObject  )

[[gtk_] style_context_] set_junction_sides

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.

Since: 3.0

method gtk_style_context_set_junction_sides ( GtkJunctionSides $sides )
  • GtkJunctionSides $sides; sides where rendered elements are visually connected to other elements

[[gtk_] style_context_] get_junction_sides

Returns the sides where rendered elements connect visually with others.

Returns: the junction sides

Since: 3.0

method gtk_style_context_get_junction_sides ( --> GtkJunctionSides  )

[[gtk_] style_context_] lookup_color

Looks up and resolves a color name in the context color map.

Returns: 1 if color_name was found and resolved, 0 otherwise

method gtk_style_context_lookup_color ( Str $color_name, N-GObject $color --> Int  )
  • Str $color_name; color name to lookup

  • N-GObject $color; (out): Return location for the looked up color

[[gtk_] style_context_] get_color

Gets the foreground color for a given state.

See gtk_style_context_get_property() and GTK_STYLE_PROPERTY_COLOR for details.

Since: 3.0

method gtk_style_context_get_color ( GtkStateFlags $state, N-GdkRGBA $color )
  • GtkStateFlags $state; state to retrieve the color for

  • N-GObject $color; (out): return value for the foreground color

[[gtk_] style_context_] get_border

Gets the border for a given state as a Gnome::Gtk3::Border.

See gtk_style_context_get_property() and GTK_STYLE_PROPERTY_BORDER_WIDTH for details.

Since: 3.0

method gtk_style_context_get_border ( GtkStateFlags $state, N-GObject $border )
  • GtkStateFlags $state; state to retrieve the border for

  • N-GObject $border; (out): return value for the border settings

[[gtk_] style_context_] get_padding

Gets the padding for a given state as a Gnome::Gtk3::Border. See gtk_style_context_get() and GTK_STYLE_PROPERTY_PADDING for details.

Since: 3.0

method gtk_style_context_get_padding ( GtkStateFlags $state, N-GObject $padding )
  • GtkStateFlags $state; state to retrieve the padding for

  • N-GObject $padding; (out): return value for the padding settings

[[gtk_] style_context_] get_margin

Gets the margin for a given state as a Gnome::Gtk3::Border. See gtk_style_property_get() and GTK_STYLE_PROPERTY_MARGIN for details.

Since: 3.0

method gtk_style_context_get_margin ( GtkStateFlags $state, N-GObject $margin )
  • GtkStateFlags $state; state to retrieve the border for

  • N-GObject $margin; (out): return value for the margin settings

[[gtk_] style_context_] reset_widgets

This function recomputes the styles for all widgets under a particular Gnome::Gdk3::Screen. This is useful when some global parameter has changed that affects the appearance of all widgets, because when a widget gets a new style, it will both redraw and recompute any cached information about its appearance. As an example, it is used when the color scheme changes in the related Gnome::Gtk3::Settings object.

Since: 3.0

method gtk_style_context_reset_widgets ( N-GObject $screen )
  • N-GObject $screen; a Gnome::Gdk3::Screen

[[gtk_] style_context_] to_string

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.

Returns: a newly allocated string representing context

Since: 3.20

method gtk_style_context_to_string (
  GtkStyleContextPrintFlags $flags --> Str
)
  • GtkStyleContextPrintFlags $flags; Flags that determine what to print

[gtk_] render_check

Renders a checkmark (as in a Gnome::Gtk3::CheckButton).

The GTK_STATE_FLAG_CHECKED state determines whether the check is on or off, and GTK_STATE_FLAG_INCONSISTENT determines whether it should be marked as undefined.

Typical checkmark rendering:

No caption

Since: 3.0

method gtk_render_check ( N-GObject $context, cairo_t $cr, Num $x, Num $y, Num $width, Num $height )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • Num $x; X origin of the rectangle

  • Num $y; Y origin of the rectangle

  • Num $width; rectangle width

  • Num $height; rectangle height

[gtk_] render_option

Renders an option mark (as in a Gnome::Gtk3::RadioButton), the GTK_STATE_FLAG_CHECKED state will determine whether the option is on or off, and GTK_STATE_FLAG_INCONSISTENT whether it should be marked as undefined.

Typical option mark rendering:

No caption

Since: 3.0

method gtk_render_option ( N-GObject $context, cairo_t $cr, Num $x, Num $y, Num $width, Num $height )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • Num $x; X origin of the rectangle

  • Num $y; Y origin of the rectangle

  • Num $width; rectangle width

  • Num $height; rectangle height

[gtk_] render_arrow

Renders an arrow pointing to angle.

Typical arrow rendering at 0, 1⁄2 π;, π; and 3⁄2 π:

No caption

Since: 3.0

method gtk_render_arrow ( N-GObject $context, cairo_t $cr, Num $angle, Num $x, Num $y, Num $size )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • Num $angle; arrow angle from 0 to 2 * G_PI, being 0 the arrow pointing to the north

  • Num $x; X origin of the render area

  • Num $y; Y origin of the render area

  • Num $size; square side for render area

[gtk_] render_background

Renders the background of an element.

Typical background rendering, showing the effect of `background-image`, `border-width` and `border-radius`:

No caption
method gtk_render_background ( N-GObject $context, cairo_t $cr, Num $x, Num $y, Num $width, Num $height )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • Num $x; X origin of the rectangle

  • Num $y; Y origin of the rectangle

  • Num $width; rectangle width

  • Num $height; rectangle height

[[gtk_] render_] background_get_clip

Returns the area that will be affected (i.e. drawn to) when calling gtk_render_background() for the given context and rectangle.

Since: 3.20

method gtk_render_background_get_clip ( N-GObject $context, Num $x, Num $y, Num $width, Num $height, N-GObject $out_clip )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • Num $x; X origin of the rectangle

  • Num $y; Y origin of the rectangle

  • Num $width; rectangle width

  • Num $height; rectangle height

  • N-GObject $out_clip; (out): return location for the clip

[gtk_] render_frame

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-radius` and junctions:

No caption

Since: 3.0

method gtk_render_frame ( N-GObject $context, cairo_t $cr, Num $x, Num $y, Num $width, Num $height )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • Num $x; X origin of the rectangle

  • Num $y; Y origin of the rectangle

  • Num $width; rectangle width

  • Num $height; rectangle height

[gtk_] render_expander

Renders an expander (as used in Gnome::Gtk3::TreeView and Gnome::Gtk3::Expander) in the area defined by x, y, width, height. The state GTK_STATE_FLAG_CHECKED determines whether the expander is collapsed or expanded.

Typical expander rendering:

No caption

Since: 3.0

method gtk_render_expander ( N-GObject $context, cairo_t $cr, Num $x, Num $y, Num $width, Num $height )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • Num $x; X origin of the rectangle

  • Num $y; Y origin of the rectangle

  • Num $width; rectangle width

  • Num $height; rectangle height

[gtk_] render_focus

Renders a focus indicator on the rectangle determined by x, y, width, height.

Typical focus rendering:

No caption

Since: 3.0

method gtk_render_focus ( N-GObject $context, cairo_t $cr, Num $x, Num $y, Num $width, Num $height )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • Num $x; X origin of the rectangle

  • Num $y; Y origin of the rectangle

  • Num $width; rectangle width

  • Num $height; rectangle height

[gtk_] render_layout

Renders layout on the coordinates x, y

Since: 3.0

method gtk_render_layout ( N-GObject $context, cairo_t $cr, Num $x, Num $y, PangoLayout $layout )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • Num $x; X origin

  • Num $y; Y origin

  • PangoLayout $layout; the PangoLayout to render

[gtk_] render_line

Renders a line from (x0, y0) to (x1, y1).

Since: 3.0

method gtk_render_line ( N-GObject $context, cairo_t $cr, Num $x0, Num $y0, Num $x1, Num $y1 )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • Num $x0; X coordinate for the origin of the line

  • Num $y0; Y coordinate for the origin of the line

  • Num $x1; X coordinate for the end of the line

  • Num $y1; Y coordinate for the end of the line

[gtk_] render_slider

Renders a slider (as in Gnome::Gtk3::Scale) in the rectangle defined by x, y, width, height. orientation defines whether the slider is vertical or horizontal.

Typical slider rendering:

No caption

Since: 3.0

method gtk_render_slider ( N-GObject $context, cairo_t $cr, Num $x, Num $y, Num $width, Num $height, GtkOrientation $orientation )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • Num $x; X origin of the rectangle

  • Num $y; Y origin of the rectangle

  • Num $width; rectangle width

  • Num $height; rectangle height

  • GtkOrientation $orientation; orientation of the slider

[gtk_] render_extension

Renders a extension (as in a Gnome::Gtk3::Notebook tab) in the rectangle defined by x, y, width, height. The side where the extension connects to is defined by gap_side.

Typical extension rendering:

No caption

Since: 3.0

method gtk_render_extension ( N-GObject $context, cairo_t $cr, Num $x, Num $y, Num $width, Num $height, GtkPositionType $gap_side )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • Num $x; X origin of the rectangle

  • Num $y; Y origin of the rectangle

  • Num $width; rectangle width

  • Num $height; rectangle height

  • GtkPositionType $gap_side; side where the gap is

[gtk_] render_handle

Renders a handle (as in Gnome::Gtk3::HandleBox, Gnome::Gtk3::Paned and Gnome::Gtk3::Window’s resize grip), in the rectangle determined by x, y, width, height.

Handles rendered for the paned and grip classes:

No caption

Since: 3.0

method gtk_render_handle ( N-GObject $context, cairo_t $cr, Num $x, Num $y, Num $width, Num $height )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • Num $x; X origin of the rectangle

  • Num $y; Y origin of the rectangle

  • Num $width; rectangle width

  • Num $height; rectangle height

[gtk_] render_activity

Renders an activity indicator (such as in Gnome::Gtk3::Spinner). The state GTK_STATE_FLAG_CHECKED determines whether there is activity going on.

Since: 3.0

method gtk_render_activity ( N-GObject $context, cairo_t $cr, Num $x, Num $y, Num $width, Num $height )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • Num $x; X origin of the rectangle

  • Num $y; Y origin of the rectangle

  • Num $width; rectangle width

  • Num $height; rectangle height

[gtk_] render_icon

Renders the icon in pixbuf at the specified x and y coordinates.

This function will render the icon in pixbuf at 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.

Since: 3.2

method gtk_render_icon ( N-GObject $context, cairo_t $cr, N-GObject $pixbuf, Num $x, Num $y )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • N-GObject $pixbuf; a Gnome::Gdk3::Pixbuf containing the icon to draw

  • Num $x; X position for the pixbuf

  • Num $y; Y position for the pixbuf

[[gtk_] render_] icon_surface

Renders the icon in surface at the specified x and y coordinates.

Since: 3.10

method gtk_render_icon_surface ( N-GObject $context, cairo_t $cr, cairo_surface_t $surface, Num $x, Num $y )
  • N-GObject $context; a Gnome::Gtk3::StyleContext

  • cairo_t $cr; a cairo_t

  • cairo_surface_t $surface; a cairo_surface_t containing the icon to draw

  • Num $x; X position for the icon

  • Num $y; Y position for the incon

[gtk_] render_insertion_cursor

Draws a text caret on cr at the specified index of layout.

Since: 3.4

method gtk_render_insertion_cursor ( cairo_t $cr, Num $x, Num $y, PangoLayout $layout, int32 $index, PangoDirection $direction )
  • cairo_t $cr; a cairo_t

  • Num $x; X origin

  • Num $y; Y origin

  • PangoLayout $layout; the PangoLayout of the text

  • int32 $index; the index in the PangoLayout

  • PangoDirection $direction; the PangoDirection of the text

List of deprecated (not implemented!) methods

Since 3.4

method gtk_draw_insertion_cursor ( ... )

Since 3.6

method gtk_style_context_state_is_running ( ... )

method gtk_style_context_notify_state_change ( ... )

method gtk_style_context_cancel_animations ( ... )

method gtk_style_context_scroll_animations ( ... )

method gtk_style_context_push_animatable_region ( ... )

method gtk_style_context_pop_animatable_region ( ... )

Since 3.8.

method gtk_style_context_set_direction ( ... )

method gtk_style_context_get_direction ( ... )

method PangoFontDescription ( ... )

Since 3.10

method gtk_icon_set_render_icon_pixbuf ( ... )

method gtk_icon_set_render_icon_surface ( ... )

method gtk_style_context_lookup_icon_set ( ... )

method gtk_render_icon_pixbuf ( ... )

Since 3.12

method gtk_style_context_invalidate ( ... )

Since 3.14

method gtk_style_context_list_regions ( ... )

method gtk_style_context_add_region ( ... )

method gtk_style_context_remove_region ( ... )

method gtk_style_context_has_region ( ... )

Since 3.16.

method gtk_style_context_get_background_color ( ... )

method gtk_style_context_get_border_color ( ... )

Since 3.18.

method gtk_style_context_set_background ( ... )

Since 3.24.

method gtk_render_frame_gap ( ... )

Signals

Register any signal as follows. See also Gnome::GObject::Object.

my Bool $is-registered = $my-widget.register-signal (
  $handler-object, $handler-name, $signal-name,
  :$user-option1, ..., :$user-optionN
)

Not yet supported signals

changed

The sig changed signal is emitted when there is a change in the Gnome::Gtk3::StyleContext.

For a Gnome::Gtk3::StyleContext returned by gtk_widget_get_style_context(), the sig style-updated signal/vfunc might be more convenient to use.

This signal is useful when using the theming layer standalone.

Since: 3.0

method handler (
  :$user-option1, ..., :$user-optionN
);

Properties

An example of using a string type property of a Gnome::Gtk3::Label object. This is just showing how to set/read a property, not that it is the best way to do it. This is because a) The class initialization often provides some options to set some of the properties and b) the classes provide many methods to modify just those properties. In the case below one can use new(:label('my text label')) or gtk_label_set_text('my text label').

my Gnome::Gtk3::Label $label .= new;
my Gnome::GObject::Value $gv .= new(:init(G_TYPE_STRING));
$label.g-object-get-property( 'label', $gv);
$gv.g-value-set-string('my text label');

Not yet supported properties

parent

The Gnome::GObject::Value type of property parent is G_TYPE_OBJECT.

Sets or gets the style context’s parent. See gtk_style_context_set_parent() for details.

Since: 3.4