API: Add gtk_widget_path_iter_set_state()

And the corresponding gtk_widget_path_iter_get_state().
This commit is contained in:
Benjamin Otte 2014-07-18 20:07:27 +02:00
parent 71d47ef607
commit 09dd0ffcd0
3 changed files with 84 additions and 0 deletions

View File

@ -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

View File

@ -88,6 +88,7 @@ struct GtkPathElement
{
GType type;
GQuark name;
GtkStateFlags state;
guint sibling_index;
GHashTable *regions;
GArray *classes;
@ -572,6 +573,80 @@ gtk_widget_path_iter_set_object_type (GtkWidgetPath *path,
elem->type = type;
}
/**
* 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

View File

@ -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,