summaryrefslogtreecommitdiff
path: root/gtk/gtkwidgetpath.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-10-27 01:26:20 +0100
committerBenjamin Otte <otte@redhat.com>2015-10-27 01:44:50 +0100
commit101df329ae7d4df779230ac565a7507fda44025d (patch)
tree18b8afca7878b4b29b6078d3cd598f7cba48adf5 /gtk/gtkwidgetpath.c
parentaedd193c69f5857917369c083be04bd24a1e770e (diff)
downloadgtk+-101df329ae7d4df779230ac565a7507fda44025d.tar.gz
API: Add gtk_widget_path_iter_set_object_name()
... and gtk_widget_path_iter_get_object_name(). This allows applications that still use widget paths to use the new object names to get the correct styling. Mutter and webkit-gtk are examples here.
Diffstat (limited to 'gtk/gtkwidgetpath.c')
-rw-r--r--gtk/gtkwidgetpath.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c
index 0c309d3d8d..f28ddc990d 100644
--- a/gtk/gtkwidgetpath.c
+++ b/gtk/gtkwidgetpath.c
@@ -512,6 +512,65 @@ gtk_widget_path_iter_get_sibling_index (const GtkWidgetPath *path,
}
/**
+ * gtk_widget_path_iter_get_object_name:
+ * @path: a #GtkWidgetPath
+ * @pos: position to get the object name for, -1 for the path head
+ *
+ * Returns the object name that is at position @pos in the widget
+ * hierarchy defined in @path.
+ *
+ * Returns: the name or %NULL
+ *
+ * Since: 3.20
+ **/
+const char *
+gtk_widget_path_iter_get_object_name (const GtkWidgetPath *path,
+ gint pos)
+{
+ GtkPathElement *elem;
+
+ gtk_internal_return_val_if_fail (path != NULL, NULL);
+ gtk_internal_return_val_if_fail (path->elems->len != 0, NULL);
+
+ if (pos < 0 || pos >= path->elems->len)
+ pos = path->elems->len - 1;
+
+ elem = &g_array_index (path->elems, GtkPathElement, pos);
+ return gtk_css_node_declaration_get_name (elem->decl);
+}
+
+/**
+ * gtk_widget_path_iter_set_object_name:
+ * @path: a #GtkWidgetPath
+ * @pos: position to modify, -1 for the path head
+ * @name: (allow-none): object name to set or %NULL to unset
+ *
+ * Sets the object name for a given position in the widget hierarchy
+ * defined by @path.
+ *
+ * When set, the object name overrides the object type when matching
+ * CSS.
+ *
+ * Since: 3.20
+ **/
+void
+gtk_widget_path_iter_set_object_name (GtkWidgetPath *path,
+ gint pos,
+ const char *name)
+{
+ GtkPathElement *elem;
+
+ gtk_internal_return_if_fail (path != NULL);
+ gtk_internal_return_if_fail (path->elems->len != 0);
+
+ if (pos < 0 || pos >= path->elems->len)
+ pos = path->elems->len - 1;
+
+ elem = &g_array_index (path->elems, GtkPathElement, pos);
+ gtk_css_node_declaration_set_name (&elem->decl, g_intern_string (name));
+}
+
+/**
* gtk_widget_path_iter_get_object_type:
* @path: a #GtkWidgetPath
* @pos: position to get the object type for, -1 for the path head