Class: Gtk::StyleContext
- Inherits:
-
Object
- Object
- Gtk::StyleContext
- Defined in:
- (unknown)
Class Method Summary collapse
-
.add_provider_for_display(display, provider, priority) ⇒ nil
Adds a global style provider to display, which will be used in style construction for all
GtkStyleContextsunder display. -
.remove_provider_for_display(display, provider) ⇒ nil
Removes provider from the global style providers list in display.
Instance Method Summary collapse
-
#add_class(class_name) ⇒ nil
Adds a style class to context, so later uses of the style context will make use of this new class for styling.
-
#add_provider(provider, priority) ⇒ nil
Adds a style provider to context, to be used in style construction.
-
#display ⇒ Gdk::Display
Display.
- #display=(display) ⇒ Gdk::Display
-
#get_border(border) ⇒ nil
Gets the border for a given state as a
GtkBorder. -
#get_color(color) ⇒ nil
Gets the foreground color for a given state.
-
#get_margin(margin) ⇒ nil
Gets the margin for a given state as a
GtkBorder. -
#get_padding(padding) ⇒ nil
Gets the padding for a given state as a
GtkBorder. -
#has_class(class_name) ⇒ Boolean
Returns true if context currently has defined the given class name.
-
#lookup_color(color_name, color) ⇒ Boolean
Looks up and resolves a color name in the context color map.
-
#remove_class(class_name) ⇒ nil
Removes class_name from context.
-
#remove_provider(provider) ⇒ nil
Removes provider from the style providers list in context.
-
#restore ⇒ nil
Restores context state to a previous stage.
-
#save ⇒ nil
Saves the context state.
-
#scale ⇒ Integer
Returns the scale used for assets.
-
#scale=(scale) ⇒ nil
Sets the scale to use when getting image assets for the style.
-
#state ⇒ Gtk::StateFlags
Returns the state used for style matching.
-
#state=(flags) ⇒ nil
Sets the state to be used for style matching.
-
#to_string(flags) ⇒ String
Converts the style context into a string representation.
Class Method Details
.add_provider_for_display(display, provider, priority) ⇒ nil
Adds a global style provider to display, which will be used
in style construction for all GtkStyleContexts under display.
GTK uses this to make styling information from GtkSettings
available.
Note: If both priorities are the same, A GtkStyleProvider
added through [methodGtk.StyleContext.add_provider] takes
precedence over another added through this function.
.remove_provider_for_display(display, provider) ⇒ nil
Removes provider from the global style providers list in display.
Instance Method Details
#add_class(class_name) ⇒ nil
Adds a style class to context, so later uses of the style context will make use of this new class for styling.
In the CSS file format, a GtkEntry defining a “search”
class, would be matched by:
entry.search { ... }
While any widget defining a “search” class would be matched by:
.search { ... }
#add_provider(provider, priority) ⇒ nil
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 [funcGtk.StyleContext.add_provider_for_display].
Note: If both priorities are the same, a GtkStyleProvider
added through this function takes precedence over another added
through [funcGtk.StyleContext.add_provider_for_display].
#display ⇒ Gdk::Display
Returns display.
#display=(display) ⇒ Gdk::Display
#get_border(border) ⇒ nil
Gets the border for a given state as a GtkBorder.
#get_color(color) ⇒ nil
Gets the foreground color for a given state.
#get_margin(margin) ⇒ nil
Gets the margin for a given state as a GtkBorder.
#get_padding(padding) ⇒ nil
Gets the padding for a given state as a GtkBorder.
#has_class(class_name) ⇒ Boolean
Returns true if context currently has defined the given class name.
#lookup_color(color_name, color) ⇒ Boolean
Looks up and resolves a color name in the context color map.
#remove_class(class_name) ⇒ nil
Removes class_name from context.
#remove_provider(provider) ⇒ nil
Removes provider from the style providers list in context.
#restore ⇒ nil
Restores context state to a previous stage.
See [methodGtk.StyleContext.save].
#save ⇒ nil
Saves the context state.
This allows temporary modifications done through [methodGtk.StyleContext.add_class], [methodGtk.StyleContext.remove_class], [methodGtk.StyleContext.set_state] to be quickly reverted in one go through [methodGtk.StyleContext.restore].
The matching call to [methodGtk.StyleContext.restore] must be done before GTK returns to the main loop.
#scale ⇒ Integer
Returns the scale used for assets.
#scale=(scale) ⇒ nil
Sets the scale to use when getting image assets for the style.
#state ⇒ Gtk::StateFlags
Returns the state used for style matching.
This method should only be used to retrieve the GtkStateFlags
to pass to GtkStyleContext methods, like
[methodGtk.StyleContext.get_padding].
If you need to retrieve the current state of a GtkWidget, use
[methodGtk.Widget.get_state_flags].
#state=(flags) ⇒ nil
Sets the state to be used for style matching.
#to_string(flags) ⇒ 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.