[gtk+/nth-child: 4/22] API: Add gtk_widget_path_set_region_flags()



commit 665d1a18588646f3f878076c5b68a2102fe589d8
Author: Benjamin Otte <otte redhat com>
Date:   Wed May 25 19:58:43 2011 +0200

    API: Add gtk_widget_path_set_region_flags()
    
    And gtk_widget_path_get_region_flags(). This is needed to make
    nth-child(first) etc work for widgets and not just for regions.

 docs/reference/gtk/gtk3-sections.txt |    2 +
 gtk/gtk.symbols                      |    2 +
 gtk/gtkwidgetpath.c                  |   57 ++++++++++++++++++++++++++++++++++
 gtk/gtkwidgetpath.h                  |   15 ++++++---
 4 files changed, 71 insertions(+), 5 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 291b219..465f8fb 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -5427,6 +5427,7 @@ gtk_widget_path_iter_clear_classes
 gtk_widget_path_iter_clear_regions
 gtk_widget_path_iter_get_name
 gtk_widget_path_iter_get_object_type
+gtk_widget_path_iter_get_region_flags
 gtk_widget_path_iter_has_class
 gtk_widget_path_iter_has_name
 gtk_widget_path_iter_has_qclass
@@ -5439,6 +5440,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_region_flags
 gtk_widget_path_length
 gtk_widget_path_new
 gtk_widget_path_prepend_type
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 51e07da..e09dac4 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -3589,6 +3589,7 @@ gtk_widget_path_iter_clear_classes
 gtk_widget_path_iter_clear_regions
 gtk_widget_path_iter_get_name
 gtk_widget_path_iter_get_object_type
+gtk_widget_path_iter_get_region_flags
 gtk_widget_path_iter_has_class
 gtk_widget_path_iter_has_name
 gtk_widget_path_iter_has_qclass
@@ -3601,6 +3602,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_region_flags
 gtk_widget_path_length
 gtk_widget_path_new
 gtk_widget_path_prepend_type
diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c
index 384cd5f..12abc99 100644
--- a/gtk/gtkwidgetpath.c
+++ b/gtk/gtkwidgetpath.c
@@ -91,6 +91,7 @@ struct GtkPathElement
 {
   GType type;
   GQuark name;
+  GtkRegionFlags flags;
   GHashTable *regions;
   GArray *classes;
 };
@@ -147,6 +148,7 @@ gtk_widget_path_copy (const GtkWidgetPath *path)
       elem = &g_array_index (path->elems, GtkPathElement, i);
 
       new.type = elem->type;
+      new.flags = elem->flags;
       new.name = elem->name;
 
       if (elem->regions)
@@ -413,6 +415,61 @@ gtk_widget_path_iter_set_object_type (GtkWidgetPath *path,
 }
 
 /**
+ * gtk_widget_path_iter_get_region_flags:
+ * @path: a #GtkWidgetPath
+ * @pos: position to get the flags for, -1 for the path head
+ *
+ * Returns the region flags at position @pos in the widget hierarchy
+ * defined in @path.
+ *
+ * Returns: the flags used
+ *
+ * Since: 3.0
+ **/
+GtkRegionFlags
+gtk_widget_path_iter_get_region_flags (const GtkWidgetPath *path,
+                                       gint                 pos)
+{
+  GtkPathElement *elem;
+
+  g_return_val_if_fail (path != NULL, G_TYPE_INVALID);
+  g_return_val_if_fail (path->elems->len != 0, G_TYPE_INVALID);
+
+  if (pos < 0 || pos >= path->elems->len)
+    pos = path->elems->len - 1;
+
+  elem = &g_array_index (path->elems, GtkPathElement, pos);
+  return elem->flags;
+}
+
+/**
+ * gtk_widget_path_iter_set_region_flags:
+ * @path: a #GtkWidgetPath
+ * @pos: position to modify, -1 for the path head
+ * @flags: flags to use
+ *
+ * Sets the region flags at @pos in the widget hierarchy at @path.
+ *
+ * Since: 3.2
+ **/
+void
+gtk_widget_path_iter_set_region_flags (GtkWidgetPath  *path,
+                                       gint            pos,
+                                       GtkRegionFlags  flags)
+{
+  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->flags = flags;
+}
+
+/**
  * 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 c33b059..5f626f4 100644
--- a/gtk/gtkwidgetpath.h
+++ b/gtk/gtkwidgetpath.h
@@ -47,11 +47,16 @@ gint            gtk_widget_path_append_type         (GtkWidgetPath       *path,
 void            gtk_widget_path_prepend_type        (GtkWidgetPath       *path,
                                                      GType                type);
 
-GType               gtk_widget_path_iter_get_object_type (const GtkWidgetPath *path,
-                                                          gint                 pos);
-void                gtk_widget_path_iter_set_object_type (GtkWidgetPath       *path,
-                                                          gint                 pos,
-                                                          GType                type);
+GType               gtk_widget_path_iter_get_object_type  (const GtkWidgetPath *path,
+                                                           gint                 pos);
+void                gtk_widget_path_iter_set_object_type  (GtkWidgetPath       *path,
+                                                           gint                 pos,
+                                                           GType                type);
+GtkRegionFlags      gtk_widget_path_iter_get_region_flags (const GtkWidgetPath *path,
+                                                           gint                 pos);
+void                gtk_widget_path_iter_set_region_flags (GtkWidgetPath       *path,
+                                                           gint                 pos,
+                                                           GtkRegionFlags       flags);
 
 G_CONST_RETURN gchar * gtk_widget_path_iter_get_name  (const GtkWidgetPath *path,
                                                        gint                 pos);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]