[][src]Trait gtk::StyleContextExt

pub trait StyleContextExt: 'static {
    fn add_class(&self, class_name: &str);
fn add_provider<P: IsA<StyleProvider>>(&self, provider: &P, priority: u32);
fn get_background_color(&self, state: StateFlags) -> RGBA;
fn get_border(&self, state: StateFlags) -> Border;
fn get_border_color(&self, state: StateFlags) -> RGBA;
fn get_color(&self, state: StateFlags) -> RGBA;
fn get_frame_clock(&self) -> Option<FrameClock>;
fn get_junction_sides(&self) -> JunctionSides;
fn get_margin(&self, state: StateFlags) -> Border;
fn get_padding(&self, state: StateFlags) -> Border;
fn get_parent(&self) -> Option<StyleContext>;
fn get_path(&self) -> Option<WidgetPath>;
fn get_property(&self, property: &str, state: StateFlags) -> Value;
fn get_scale(&self) -> i32;
fn get_screen(&self) -> Option<Screen>;
fn get_section(&self, property: &str) -> Option<CssSection>;
fn get_state(&self) -> StateFlags;
fn get_style_property(&self, property_name: &str) -> Value;
fn has_class(&self, class_name: &str) -> bool;
fn list_classes(&self) -> Vec<GString>;
fn lookup_color(&self, color_name: &str) -> Option<RGBA>;
fn remove_class(&self, class_name: &str);
fn remove_provider<P: IsA<StyleProvider>>(&self, provider: &P);
fn restore(&self);
fn save(&self);
fn set_background<P: IsA<Window>>(&self, window: &P);
fn set_frame_clock(&self, frame_clock: &FrameClock);
fn set_junction_sides(&self, sides: JunctionSides);
fn set_parent<P: IsA<StyleContext>>(&self, parent: Option<&P>);
fn set_path(&self, path: &WidgetPath);
fn set_scale(&self, scale: i32);
fn set_screen(&self, screen: &Screen);
fn set_state(&self, flags: StateFlags);
fn to_string(&self, flags: StyleContextPrintFlags) -> GString;
fn get_property_direction(&self) -> TextDirection;
fn set_property_direction(&self, direction: TextDirection);
fn get_property_paint_clock(&self) -> Option<FrameClock>;
fn set_property_paint_clock(&self, paint_clock: Option<&FrameClock>);
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_direction_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_paint_clock_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_parent_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_screen_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; }

Trait containing all StyleContext methods.

Implementors

StyleContext

Required methods

fn add_class(&self, class_name: &str)

Adds a style class to self, so posterior calls to StyleContextExt::get or any of the gtk_render_*() functions will make use of this new class for styling.

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

entry.search { ... }

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

.search { ... }

class_name

class name to use in styling

fn add_provider<P: IsA<StyleProvider>>(&self, provider: &P, priority: u32)

Adds a style provider to self, to be used in style construction. Note that a style provider added by this function only affects the style of the widget to which self belongs. If you want to affect the style of all widgets, use StyleContext::add_provider_for_screen.

Note: If both priorities are the same, a StyleProvider added through this function takes precedence over another added through StyleContext::add_provider_for_screen.

provider

a StyleProvider

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

fn get_background_color(&self, state: StateFlags) -> RGBA

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 StyleContextExt::get_background_color is to use the returned value to draw the background with it; the correct way to achieve this result is to use gtk_render_background instead, along with CSS style classes to modify the color to be rendered.

Deprecated since 3.16

Use gtk_render_background instead.

state

state to retrieve the color for

color

return value for the background color

fn get_border(&self, state: StateFlags) -> Border

Gets the border for a given state as a Border.

See StyleContextExt::get_property and GTK_STYLE_PROPERTY_BORDER_WIDTH for details.

state

state to retrieve the border for

border

return value for the border settings

fn get_border_color(&self, state: StateFlags) -> RGBA

Gets the border color for a given state.

Deprecated since 3.16

Use gtk_render_frame instead.

state

state to retrieve the color for

color

return value for the border color

fn get_color(&self, state: StateFlags) -> RGBA

Gets the foreground color for a given state.

See StyleContextExt::get_property and GTK_STYLE_PROPERTY_COLOR for details.

state

state to retrieve the color for

color

return value for the foreground color

fn get_frame_clock(&self) -> Option<FrameClock>

Returns the gdk::FrameClock to which self is attached.

Returns

a gdk::FrameClock, or None if self does not have an attached frame clock.

fn get_junction_sides(&self) -> JunctionSides

Returns the sides where rendered elements connect visually with others.

Returns

the junction sides

fn get_margin(&self, state: StateFlags) -> Border

Gets the margin for a given state as a Border. See gtk_style_property_get and GTK_STYLE_PROPERTY_MARGIN for details.

state

state to retrieve the border for

margin

return value for the margin settings

fn get_padding(&self, state: StateFlags) -> Border

Gets the padding for a given state as a Border. See StyleContextExt::get and GTK_STYLE_PROPERTY_PADDING for details.

state

state to retrieve the padding for

padding

return value for the padding settings

fn get_parent(&self) -> Option<StyleContext>

Gets the parent context set via StyleContextExt::set_parent. See that function for details.

Returns

the parent context or None

fn get_path(&self) -> Option<WidgetPath>

Returns the widget path used for style matching.

Returns

A WidgetPath

fn get_property(&self, property: &str, state: StateFlags) -> Value

Gets a style property from self 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 gobject::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 self is not recommended unless the style context has been saved with StyleContextExt::save.

When value is no longer needed, gobject::Value::unset must be called to free any allocated memory.

property

style property name

state

state to retrieve the property value for

value

return location for the style property value

fn get_scale(&self) -> i32

Returns the scale used for assets.

Returns

the scale

fn get_screen(&self) -> Option<Screen>

Returns the gdk::Screen to which self is attached.

Returns

a gdk::Screen.

fn get_section(&self, property: &str) -> Option<CssSection>

Queries the location in the CSS where property was defined for the current self. Note that the state to be queried is taken from StyleContextExt::get_state.

If the location is not available, None 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 None.

property

style property name

Returns

None or the section where a value for property was defined

fn get_state(&self) -> StateFlags

Returns the state used for style matching.

This method should only be used to retrieve the StateFlags to pass to StyleContext methods, like StyleContextExt::get_padding. If you need to retrieve the current state of a Widget, use WidgetExt::get_state_flags.

Returns

the state flags

fn get_style_property(&self, property_name: &str) -> Value

Gets the value for a widget style property.

When value is no longer needed, gobject::Value::unset must be called to free any allocated memory.

property_name

the name of the widget style property

value

Return location for the property value

fn has_class(&self, class_name: &str) -> bool

Returns true if self currently has defined the given class name.

class_name

a class name

Returns

true if self has class_name defined

fn list_classes(&self) -> Vec<GString>

Returns the list of classes currently defined in self.

Returns

a glib::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 glib::List::free when you are done with it.

fn lookup_color(&self, color_name: &str) -> Option<RGBA>

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

color_name

color name to lookup

color

Return location for the looked up color

Returns

true if color_name was found and resolved, false otherwise

fn remove_class(&self, class_name: &str)

Removes class_name from self.

class_name

class name to remove

fn remove_provider<P: IsA<StyleProvider>>(&self, provider: &P)

Removes provider from the style providers list in self.

provider

a StyleProvider

fn restore(&self)

Restores self state to a previous stage. See StyleContextExt::save.

fn save(&self)

Saves the self state, so temporary modifications done through StyleContextExt::add_class, StyleContextExt::remove_class, StyleContextExt::set_state, etc. can quickly be reverted in one go through StyleContextExt::restore.

The matching call to StyleContextExt::restore must be done before GTK returns to the main loop.

fn set_background<P: IsA<Window>>(&self, window: &P)

Sets the background of window to the background pattern or color specified in self for its current state.

Deprecated since 3.18

Use gtk_render_background instead. Note that clients still using this function are now responsible for calling this function again whenever self is invalidated.

window

a gdk::Window

fn set_frame_clock(&self, frame_clock: &FrameClock)

Attaches self to the given frame clock.

The frame clock is used for the timing of animations.

If you are using a StyleContext returned from WidgetExt::get_style_context, you do not need to call this yourself.

frame_clock

a gdk::FrameClock

fn set_junction_sides(&self, sides: JunctionSides)

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.

sides

sides where rendered elements are visually connected to other elements

fn set_parent<P: IsA<StyleContext>>(&self, parent: Option<&P>)

Sets the parent style context for self. The parent style context is used to implement inheritance of properties.

If you are using a StyleContext returned from WidgetExt::get_style_context, the parent will be set for you.

parent

the new parent or None

fn set_path(&self, path: &WidgetPath)

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

If you are using a StyleContext returned from WidgetExt::get_style_context, you do not need to call this yourself.

path

a WidgetPath

fn set_scale(&self, scale: i32)

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

scale

scale

fn set_screen(&self, screen: &Screen)

Attaches self to the given screen.

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

If you are using a StyleContext returned from WidgetExt::get_style_context, you do not need to call this yourself.

screen

a gdk::Screen

fn set_state(&self, flags: StateFlags)

Sets the state to be used for style matching.

flags

state to represent

fn to_string(&self, flags: StyleContextPrintFlags) -> GString

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 self. 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.

Feature: v3_20

flags

Flags that determine what to print

Returns

a newly allocated string representing self

fn get_property_direction(&self) -> TextDirection

fn set_property_direction(&self, direction: TextDirection)

fn get_property_paint_clock(&self) -> Option<FrameClock>

fn set_property_paint_clock(&self, paint_clock: Option<&FrameClock>)

fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

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

For a StyleContext returned by WidgetExt::get_style_context, the Widget::style-updated signal/vfunc might be more convenient to use.

This signal is useful when using the theming layer standalone.

fn connect_property_direction_notify<F: Fn(&Self) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

fn connect_property_paint_clock_notify<F: Fn(&Self) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

fn connect_property_parent_notify<F: Fn(&Self) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

fn connect_property_screen_notify<F: Fn(&Self) + 'static>(
    &self,
    f: F
) -> SignalHandlerId

Loading content...

Implementors

impl<O: IsA<StyleContext>> StyleContextExt for O[src]

Loading content...