[gtk/wip/baedert/widget-add-style-class] widget: Add gtk_widget_add_style_class
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/widget-add-style-class] widget: Add gtk_widget_add_style_class
- Date: Wed, 29 Jan 2020 07:36:17 +0000 (UTC)
commit 81d62f10fe3a88714ce6a284bb25aa7d25ce63ce
Author: Timm Bäder <mail baedert org>
Date: Wed Jan 29 08:33:41 2020 +0100
widget: Add gtk_widget_add_style_class
As convenience for adding a style class to a widget's style context,
which just adds it to the widget's css node anyway. This is a
prerequisite for style contexts eventually going away.
docs/reference/gtk/gtk4-sections.txt | 1 +
gtk/gtkwidget.c | 20 ++++++++++++++++++++
gtk/gtkwidget.h | 3 +++
3 files changed, 24 insertions(+)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index b4a737d2f0..b90d4cd75e 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -4409,6 +4409,7 @@ gtk_widget_insert_after
gtk_widget_set_layout_manager
gtk_widget_get_layout_manager
gtk_widget_should_layout
+gtk_widget_add_style_class
<SUBSECTION>
gtk_widget_get_style_context
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index ba4f4b461c..6a03409017 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13175,3 +13175,23 @@ gtk_widget_class_query_action (GtkWidgetClass *widget_class,
return FALSE;
}
+
+/**
+ * gtk_widget_add_style_class:
+ * @widget: a #GtkWidget
+ * @style_class: The style class to add to @widget
+ *
+ * Adds @style_class to @widget. After calling this function, @widget's
+ * style will match for @style_class, after the CSS matching rules.
+ */
+void
+gtk_widget_add_style_class (GtkWidget *widget,
+ const char *style_class)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (style_class != NULL);
+ g_return_if_fail (style_class[0] != '\0');
+ g_return_if_fail (style_class[0] != '.');
+
+ gtk_style_context_add_class (gtk_widget_get_style_context (widget), style_class);
+}
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 1719f59487..9c68e03a90 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -967,6 +967,9 @@ void gtk_widget_snapshot_child (GtkWidget *widget,
GtkSnapshot *snapshot);
GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_should_layout (GtkWidget *widget);
+GDK_AVAILABLE_IN_ALL
+void gtk_widget_add_style_class (GtkWidget *widget,
+ const char *style_class);
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]