[gtk+/entry-css-cleanups: 6/11] treeview: add the CELL style class to editable children



commit 0720a448fd8d576da42989a48b1b83c6beb00ccd
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Jan 30 16:08:02 2012 -0500

    treeview: add the CELL style class to editable children
    
    GtkTreeView uses GtkContainer to put editable children over the rows.
    Modify gtk_tree_view_get_path_for_child() to add a CELL style class to
    those widgets.

 gtk/gtktreeview.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 96d9107..3d7f9e4 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -8504,11 +8504,13 @@ gtk_tree_view_get_path_for_child (GtkContainer *container,
   GtkTreeView *tree_view = GTK_TREE_VIEW (container);
   GtkWidgetPath *path;
   gboolean rtl;
+  gboolean found_header, found_child;
   GList *list;
   gint n_col = 0;
 
   path = GTK_CONTAINER_CLASS (gtk_tree_view_parent_class)->get_path_for_child (container, child);
   rtl = (gtk_widget_get_direction (GTK_WIDGET (container)) == GTK_TEXT_DIR_RTL);
+  found_header = found_child = FALSE;
 
   for (list = (rtl ? g_list_last (tree_view->priv->columns) : g_list_first (tree_view->priv->columns));
        list;
@@ -8526,6 +8528,8 @@ gtk_tree_view_get_path_for_child (GtkContainer *container,
           gtk_tree_view_column_get_button (column) != child)
         continue;
 
+      found_header = TRUE;
+
       if ((n_col % 2) == 0)
         flags |= GTK_REGION_EVEN;
       else
@@ -8542,7 +8546,29 @@ gtk_tree_view_get_path_for_child (GtkContainer *container,
       break;
     }
 
-  gtk_widget_path_append_for_widget (path, child);
+  if (!found_header)
+    {
+      GtkTreeViewChild *tree_child;
+      gint pos;
+
+      for (list = tree_view->priv->children; list; list = list->next)
+        {
+          tree_child = list->data;
+          if (tree_child->widget == child)
+            {
+              /* Add the "cell" style class to editable widgets we put into our 
+               * container.
+               */
+              found_child = TRUE;
+              pos = gtk_widget_path_append_for_widget (path, child);
+              gtk_widget_path_iter_add_class (path, pos, GTK_STYLE_CLASS_CELL);
+              break;
+            }
+        }
+    }
+
+  if (!found_child)
+    gtk_widget_path_append_for_widget (path, child);
 
   return path;
 }



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