[gtk+/nth-child: 8/22] box: Add pseudo-classes to widgets



commit af3f352d93e2967d9f2518f35e71cf0d17f60769
Author: Benjamin Otte <otte redhat com>
Date:   Wed May 25 23:38:59 2011 +0200

    box: Add pseudo-classes to widgets

 gtk/gtkbox.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index 9a20579..2f08cf4 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -182,6 +182,9 @@ static void gtk_box_get_child_property (GtkContainer   *container,
                                         GValue         *value,
                                         GParamSpec     *pspec);
 static GType gtk_box_child_type        (GtkContainer   *container);
+static GtkWidgetPath * gtk_box_get_path_for_child
+                                       (GtkContainer   *container,
+                                        GtkWidget      *child);
 
 
 static void               gtk_box_get_preferred_width            (GtkWidget           *widget,
@@ -226,6 +229,7 @@ gtk_box_class_init (GtkBoxClass *class)
   container_class->child_type = gtk_box_child_type;
   container_class->set_child_property = gtk_box_set_child_property;
   container_class->get_child_property = gtk_box_get_child_property;
+  container_class->get_path_for_child = gtk_box_get_path_for_child;
   gtk_container_class_handle_border_width (container_class);
 
   g_object_class_override_property (object_class,
@@ -831,6 +835,42 @@ gtk_box_get_child_property (GtkContainer *container,
     }
 }
 
+static GtkWidgetPath *
+gtk_box_get_path_for_child (GtkContainer *container,
+                            GtkWidget    *child)
+{
+  GtkWidgetPath *path;
+  gboolean even;
+  GtkBox *box;
+  GList *l;
+
+  box = GTK_BOX (container);
+
+  path = GTK_CONTAINER_CLASS (gtk_box_parent_class)->get_path_for_child (container, child);
+
+  even = TRUE;
+  for (l = box->priv->children; l; l = l->next)
+    {
+      GtkBoxChild *child_entry;
+
+      child_entry = l->data;
+      even = !even;
+
+      if (child_entry->widget == child)
+        {
+          GtkRegionFlags flags = even ? GTK_REGION_EVEN : GTK_REGION_ODD;
+          if (l->prev == NULL)
+            flags |= GTK_REGION_FIRST;
+          if (l->next == NULL)
+            flags |= GTK_REGION_LAST;
+
+          gtk_widget_path_iter_set_region_flags (path, -1, flags);
+        }
+    }
+
+  return path;
+}
+
 static void
 gtk_box_pack (GtkBox      *box,
               GtkWidget   *child,



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