[gtk+] API: Add gtk_widget_path_iter_set_state()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] API: Add gtk_widget_path_iter_set_state()
- Date: Sat, 19 Jul 2014 22:31:58 +0000 (UTC)
commit 09dd0ffcd0db95c657f125aa5efbba1d95efd26d
Author: Benjamin Otte <otte redhat com>
Date: Fri Jul 18 20:07:27 2014 +0200
API: Add gtk_widget_path_iter_set_state()
And the corresponding gtk_widget_path_iter_get_state().
docs/reference/gtk/gtk3-sections.txt | 2 +
gtk/gtkwidgetpath.c | 75 ++++++++++++++++++++++++++++++++++
gtk/gtkwidgetpath.h | 7 +++
3 files changed, 84 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index daada85..b2a773a 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -5871,6 +5871,7 @@ gtk_widget_path_iter_get_name
gtk_widget_path_iter_get_object_type
gtk_widget_path_iter_get_siblings
gtk_widget_path_iter_get_sibling_index
+gtk_widget_path_iter_get_state
gtk_widget_path_iter_has_class
gtk_widget_path_iter_has_name
gtk_widget_path_iter_has_qclass
@@ -5883,6 +5884,7 @@ gtk_widget_path_iter_remove_class
gtk_widget_path_iter_remove_region
gtk_widget_path_iter_set_name
gtk_widget_path_iter_set_object_type
+gtk_widget_path_iter_set_state
gtk_widget_path_length
gtk_widget_path_new
gtk_widget_path_prepend_type
diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c
index 221e93c..40d2972 100644
--- a/gtk/gtkwidgetpath.c
+++ b/gtk/gtkwidgetpath.c
@@ -88,6 +88,7 @@ struct GtkPathElement
{
GType type;
GQuark name;
+ GtkStateFlags state;
guint sibling_index;
GHashTable *regions;
GArray *classes;
@@ -573,6 +574,80 @@ gtk_widget_path_iter_set_object_type (GtkWidgetPath *path,
}
/**
+ * gtk_widget_path_iter_get_state:
+ * @path: a #GtkWidgetPath
+ * @pos: position to get the state for, -1 for the path head
+ *
+ * Returns the state flags corresponding to the widget found at
+ * the position @pos in the widget hierarchy defined by
+ * @path
+ *
+ * Returns: The state flags
+ *
+ * Since: 3.14
+ **/
+GtkStateFlags
+gtk_widget_path_iter_get_state (const GtkWidgetPath *path,
+ gint pos)
+{
+ GtkPathElement *elem;
+
+ g_return_val_if_fail (path != NULL, 0);
+ g_return_val_if_fail (path->elems->len != 0, 0);
+
+ if (pos < 0 || pos >= path->elems->len)
+ pos = path->elems->len - 1;
+
+ elem = &g_array_index (path->elems, GtkPathElement, pos);
+ return elem->state;
+}
+
+/**
+ * gtk_widget_path_iter_set_state:
+ * @path: a #GtkWidgetPath
+ * @pos: position to modify, -1 for the path head
+ * @state: state flags
+ *
+ * Sets the widget name for the widget found at position @pos
+ * in the widget hierarchy defined by @path.
+ *
+ * If you want to update just a single state flag, you need to do
+ * this manually, as this function updates all state flags.
+ *
+ * ## Setting a flag
+ *
+ * |[<!-- language="C" -->
+ * gtk_widget_path_iter_set_state (path, pos, gtk_widget_path_iter_get_state (path, pos) | flag);
+ * ]|
+ *
+ * ## Unsetting a flag
+ *
+ * |[<!-- language="C" -->
+ * gtk_widget_path_iter_set_state (path, pos, gtk_widget_path_iter_get_state (path, pos) & ~flag);
+ * ]|
+ *
+ *
+ * Since: 3.14
+ **/
+void
+gtk_widget_path_iter_set_state (GtkWidgetPath *path,
+ gint pos,
+ GtkStateFlags state)
+{
+ GtkPathElement *elem;
+
+ g_return_if_fail (path != NULL);
+ g_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);
+
+ elem->state = state;
+}
+
+/**
* gtk_widget_path_iter_get_name:
* @path: a #GtkWidgetPath
* @pos: position to get the widget name for, -1 for the path head
diff --git a/gtk/gtkwidgetpath.h b/gtk/gtkwidgetpath.h
index 7a70557..f1f7ad7 100644
--- a/gtk/gtkwidgetpath.h
+++ b/gtk/gtkwidgetpath.h
@@ -95,6 +95,13 @@ GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_path_iter_has_qname (const GtkWidgetPath *path,
gint pos,
GQuark qname);
+GDK_AVAILABLE_IN_3_14
+GtkStateFlags gtk_widget_path_iter_get_state (const GtkWidgetPath *path,
+ gint pos);
+GDK_AVAILABLE_IN_3_14
+void gtk_widget_path_iter_set_state (GtkWidgetPath *path,
+ gint pos,
+ GtkStateFlags state);
GDK_AVAILABLE_IN_ALL
void gtk_widget_path_iter_add_class (GtkWidgetPath *path,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]