Trait gtk4::prelude::StyleContextExt

source ·
pub trait StyleContextExt: IsA<StyleContext> + Sealed + 'static {
Show 20 methods // Provided methods fn add_class(&self, class_name: &str) { ... } fn add_provider(&self, provider: &impl IsA<StyleProvider>, priority: u32) { ... } fn border(&self) -> Border { ... } fn color(&self) -> RGBA { ... } fn display(&self) -> Display { ... } fn margin(&self) -> Border { ... } fn padding(&self) -> Border { ... } fn scale(&self) -> i32 { ... } fn state(&self) -> StateFlags { ... } fn has_class(&self, class_name: &str) -> bool { ... } fn lookup_color(&self, color_name: &str) -> Option<RGBA> { ... } fn remove_class(&self, class_name: &str) { ... } fn remove_provider(&self, provider: &impl IsA<StyleProvider>) { ... } fn restore(&self) { ... } fn save(&self) { ... } fn set_display(&self, display: &impl IsA<Display>) { ... } fn set_scale(&self, scale: i32) { ... } fn set_state(&self, flags: StateFlags) { ... } fn to_string(&self, flags: StyleContextPrintFlags) -> GString { ... } fn connect_display_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId { ... }
}
👎Deprecated: Since 4.10
Expand description

Trait containing all StyleContext methods.

§Implementors

StyleContext

Provided Methods§

source

fn add_class(&self, class_name: &str)

👎Deprecated: Since 4.10

Adds a style class to @self, so later uses of the style context 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 { ... }
§Deprecated since 4.10

Use WidgetExt::add_css_class() instead

§class_name

class name to use in styling

source

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

👎Deprecated: Since 4.10

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_display().

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

§Deprecated since 4.10

Use style classes instead

§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

source

fn border(&self) -> Border

👎Deprecated: Since 4.10

Gets the border for a given state as a Border.

§Deprecated since 4.10

This api will be removed in GTK 5

§Returns
§border

return value for the border settings

source

fn color(&self) -> RGBA

👎Deprecated: Since 4.10

Gets the foreground color for a given state.

§Deprecated since 4.10

Use WidgetExt::color() instead

§Returns
§color

return value for the foreground color

source

fn display(&self) -> Display

👎Deprecated: Since 4.10

Returns the gdk::Display to which @self is attached.

§Deprecated since 4.10

Use WidgetExt::display() instead

§Returns

a gdk::Display.

source

fn margin(&self) -> Border

👎Deprecated: Since 4.10

Gets the margin for a given state as a Border.

§Deprecated since 4.10

This api will be removed in GTK 5

§Returns
§margin

return value for the margin settings

source

fn padding(&self) -> Border

👎Deprecated: Since 4.10

Gets the padding for a given state as a Border.

§Deprecated since 4.10

This api will be removed in GTK 5

§Returns
§padding

return value for the padding settings

source

fn scale(&self) -> i32

👎Deprecated: Since 4.10

Returns the scale used for assets.

§Deprecated since 4.10

Use WidgetExt::scale_factor() instead

§Returns

the scale

source

fn state(&self) -> StateFlags

👎Deprecated: Since 4.10

Returns the state used for style matching.

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

§Deprecated since 4.10

Use WidgetExt::state_flags() instead

§Returns

the state flags

source

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

👎Deprecated: Since 4.10

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

§Deprecated since 4.10

Use WidgetExt::has_css_class() instead

§class_name

a class name

§Returns

true if @self has @class_name defined

source

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

👎Deprecated: Since 4.10

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

§Deprecated since 4.10

This api will be removed in GTK 5

§color_name

color name to lookup

§Returns

true if @color_name was found and resolved, false otherwise

§color

Return location for the looked up color

source

fn remove_class(&self, class_name: &str)

👎Deprecated: Since 4.10

Removes @class_name from @self.

§Deprecated since 4.10

Use WidgetExt::remove_css_class() instead

§class_name

class name to remove

source

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

👎Deprecated: Since 4.10

Removes @provider from the style providers list in @self.

§Deprecated since 4.10
§provider

a StyleProvider

source

fn restore(&self)

👎Deprecated: Since 4.10

Restores @self state to a previous stage.

See save().

§Deprecated since 4.10

This API will be removed in GTK 5

source

fn save(&self)

👎Deprecated: Since 4.10

Saves the @self state.

This allows temporary modifications done through add_class(), remove_class(), set_state() to be quickly reverted in one go through restore().

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

§Deprecated since 4.10

This API will be removed in GTK 5

source

fn set_display(&self, display: &impl IsA<Display>)

👎Deprecated: Since 4.10

Attaches @self to the given display.

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

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

§Deprecated since 4.10

You should not use this api

§display

a gdk::Display

source

fn set_scale(&self, scale: i32)

👎Deprecated: Since 4.10

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

§Deprecated since 4.10

You should not use this api

§scale

scale

source

fn set_state(&self, flags: StateFlags)

👎Deprecated: Since 4.10

Sets the state to be used for style matching.

§Deprecated since 4.10

You should not use this api

§flags

state to represent

source

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

👎Deprecated: Since 4.10

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.

§Deprecated since 4.10

This api will be removed in GTK 5

§flags

Flags that determine what to print

§Returns

a newly allocated string representing @self

source

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

👎Deprecated: Since 4.10

Object Safety§

This trait is not object safe.

Implementors§