mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
Add gtk_widget_get_style_color
There is a widespread need to access the CSS foreground color for custom drawing in snapshot functions, so make it available after gtk_style_context_get_color was deprecated with a new widget api.
This commit is contained in:
parent
f42fe500c9
commit
5627542d7c
@ -824,7 +824,7 @@ gtk_style_context_lookup_color (GtkStyleContext *context,
|
||||
*
|
||||
* Gets the foreground color for a given state.
|
||||
*
|
||||
* Deprecated: 4.10: This api will be removed in GTK 5
|
||||
* Deprecated: 4.10: Use [method@Gtk.Widget.get_style_color] instead
|
||||
*/
|
||||
void
|
||||
gtk_style_context_get_color (GtkStyleContext *context,
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "gtkconstraint.h"
|
||||
#include "gtkcssboxesprivate.h"
|
||||
#include "gtkcssfiltervalueprivate.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkcsstransformvalueprivate.h"
|
||||
#include "gtkcsspositionvalueprivate.h"
|
||||
#include "gtkcssfontvariationsvalueprivate.h"
|
||||
@ -12869,6 +12870,33 @@ gtk_widget_set_css_classes (GtkWidget *widget,
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CSS_CLASSES]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_get_css_style:
|
||||
* @widget: a `GtkWidget`
|
||||
* @color: (out): return location for the color
|
||||
*
|
||||
* Gets the current foreground color for the widgets
|
||||
* CSS style.
|
||||
*
|
||||
* This function should only be used in snapshot
|
||||
* implementations that need need to do custom
|
||||
* drawing with the foreground color.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_widget_get_style_color (GtkWidget *widget,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GtkCssStyle *style;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
style = gtk_css_node_get_style (priv->cssnode);
|
||||
*color = *gtk_css_color_value_get_rgba (style->core->color);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_widget_update_orientation:
|
||||
* @widget: a `GtkWidget` implementing `GtkOrientable`
|
||||
|
@ -928,7 +928,9 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_widget_set_css_classes (GtkWidget *widget,
|
||||
const char **classes);
|
||||
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_widget_get_style_color (GtkWidget *widget,
|
||||
GdkRGBA *rgba);
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user