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 /gtk/gtkwidgetpath.c | |
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().
Diffstat (limited to 'gtk/gtkwidgetpath.c')
-rw-r--r-- | gtk/gtkwidgetpath.c | 75 |
1 files changed, 75 insertions, 0 deletions
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 |