diff options
author | Benjamin Otte <otte@redhat.com> | 2014-07-18 20:07:27 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2014-07-19 23:42:38 +0200 |
commit | 09dd0ffcd0db95c657f125aa5efbba1d95efd26d (patch) | |
tree | 739058ba8758fc63c63a3591e59fc57233884040 | |
parent | 71d47ef60713d5f274fdb13ee6cf9939a0b35984 (diff) | |
download | gtk+-09dd0ffcd0db95c657f125aa5efbba1d95efd26d.tar.gz |
API: Add gtk_widget_path_iter_set_state()
And the corresponding gtk_widget_path_iter_get_state().
-rw-r--r-- | docs/reference/gtk/gtk3-sections.txt | 2 | ||||
-rw-r--r-- | gtk/gtkwidgetpath.c | 75 | ||||
-rw-r--r-- | 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 daada859e4..b2a773adf1 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 221e93ce61..40d29721e0 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 7a705572aa..f1f7ad7a6a 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, |