[gtk+/nth-child: 3/33] API: Change semantics of gtk_container_get_child_path()



commit 62d035b776bf780ecfeb8eb3f25939ce13c672a0
Author: Benjamin Otte <otte redhat com>
Date:   Wed May 25 22:21:15 2011 +0200

    API: Change semantics of gtk_container_get_child_path()
    
    Include the child widget path in the returned path now. This allows
    customizing the path of the current widgets - like adding flags to child
    widgets (and maybe siblings in the future).

 gtk/gtkcontainer.c |    4 +++-
 gtk/gtkframe.c     |    4 +++-
 gtk/gtknotebook.c  |    7 ++++---
 gtk/gtktreeview.c  |    2 ++
 gtk/gtkwidget.c    |    4 ++--
 5 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 50a4514..4b27fd6 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -2334,6 +2334,8 @@ gtk_container_real_get_path_for_child (GtkContainer *container,
       g_list_free_1 (cur);
     }
 
+  gtk_widget_path_append_for_widget (path, child);
+
   return path;
 }
 
@@ -3362,7 +3364,7 @@ _gtk_container_get_reallocate_redraws (GtkContainer *container)
  * @child: a child of @container
  *
  * Returns a newly created widget path representing all the widget hierarchy
- * from the toplevel down to @child (this one not being included).
+ * from the toplevel down to and including @child.
  *
  * Returns: A newly created #GtkWidgetPath
  **/
diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c
index 5f201cc..f0a42ed 100644
--- a/gtk/gtkframe.c
+++ b/gtk/gtkframe.c
@@ -384,7 +384,9 @@ gtk_frame_get_path_for_child (GtkContainer *container,
   path = GTK_CONTAINER_CLASS (gtk_frame_parent_class)->get_path_for_child (container, child);
 
   if (child == priv->label_widget)
-    gtk_widget_path_iter_add_class (path, -1, GTK_STYLE_CLASS_FRAME);
+    gtk_widget_path_iter_add_class (path,
+                                    gtk_widget_path_length (path) - 2,
+                                    GTK_STYLE_CLASS_FRAME);
 
   return path;
 }
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index b6ebff4..5954e92 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -4361,7 +4361,6 @@ gtk_notebook_get_path_for_child (GtkContainer *container,
   GtkNotebook *notebook;
   GtkNotebookPage *page;
   GtkWidgetPath *path;
-  GtkRegionFlags flags;
   GList *c;
 
   path = GTK_CONTAINER_CLASS (gtk_notebook_parent_class)->get_path_for_child (container, widget);
@@ -4381,8 +4380,10 @@ gtk_notebook_get_path_for_child (GtkContainer *container,
   if (!c)
     return path;
 
-  flags = _gtk_notebook_get_tab_flags (notebook, page);
-  gtk_widget_path_iter_add_region (path, -1, GTK_STYLE_REGION_TAB, flags);
+  gtk_widget_path_iter_add_region (path, 
+                                   gtk_widget_path_length (path) - 2,
+                                   GTK_STYLE_REGION_TAB,
+                                   _gtk_notebook_get_tab_flags (notebook, page));
 
   return path;
 }
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 912b0fb..3a003b7 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -8540,6 +8540,8 @@ gtk_tree_view_get_path_for_child (GtkContainer *container,
       break;
     }
 
+  gtk_widget_path_append_for_widget (path, child);
+
   return path;
 }
 
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 7b2d4ef..8805640 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -14316,10 +14316,10 @@ gtk_widget_get_path (GtkWidget *widget)
            * situation.
            */
           widget->priv->path = gtk_widget_path_new ();
+    
+          gtk_widget_path_append_for_widget (widget->priv->path, widget);
         }
 
-      gtk_widget_path_append_for_widget (widget->priv->path, widget);
-
       if (widget->priv->context)
         gtk_style_context_set_path (widget->priv->context,
                                     widget->priv->path);



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