[gtk/wip/otte/for-master: 4/12] widget: Add gtk_widget_get_css_name() API



commit 264967b7643388af64e86d6cc5aacae275358b40
Author: Benjamin Otte <otte redhat com>
Date:   Fri Feb 14 20:25:00 2020 +0100

    widget: Add gtk_widget_get_css_name() API

 docs/reference/gtk/gtk4-sections.txt |  1 +
 gtk/gtkwidget.c                      | 18 ++++++++++++++++++
 gtk/gtkwidget.h                      |  2 ++
 3 files changed, 21 insertions(+)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 73bba8e78c..76f703ec42 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -4189,6 +4189,7 @@ gtk_widget_insert_after
 gtk_widget_set_layout_manager
 gtk_widget_get_layout_manager
 gtk_widget_should_layout
+gtk_widget_get_css_name
 gtk_widget_add_css_class
 gtk_widget_remove_css_class
 gtk_widget_has_css_class
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 36baa66c3d..5ea1f97613 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13102,6 +13102,24 @@ gtk_widget_class_query_action (GtkWidgetClass      *widget_class,
   return FALSE;
 }
 
+/**
+ * gtk_widget_get_css_name:
+ * @self: a #GtkWidget
+ *
+ * Returns the CSS name that is used for @self.
+ *
+ * Returns: the CSS name
+ **/
+const char *
+gtk_widget_get_css_name (GtkWidget *self)
+{
+  GtkWidgetPrivate *priv = gtk_widget_get_instance_private (self);
+
+  g_return_val_if_fail (GTK_IS_WIDGET (self), NULL);
+
+  return g_quark_to_string (gtk_css_node_get_name (priv->cssnode));
+}
+
 /**
  * gtk_widget_add_css_class:
  * @widget: a #GtkWidget
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 5cbea4b35f..718b3be13b 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -971,6 +971,8 @@ void                    gtk_widget_snapshot_child       (GtkWidget   *widget,
 GDK_AVAILABLE_IN_ALL
 gboolean                gtk_widget_should_layout        (GtkWidget   *widget);
 GDK_AVAILABLE_IN_ALL
+const char *            gtk_widget_get_css_name         (GtkWidget   *self) G_GNUC_PURE;
+GDK_AVAILABLE_IN_ALL
 void                    gtk_widget_add_css_class        (GtkWidget   *widget,
                                                          const char  *css_class);
 GDK_AVAILABLE_IN_ALL


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]