]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcellview.c
Don't do anything beyond clearing to the background if there is no active
[~andy/gtk] / gtk / gtkcellview.c
index 3ebd912a9d691bf44c5c2a18540b8f2119c2a60b..c0efb0c1b345d0031073c8bbc775cff6f25034ce 100644 (file)
@@ -17,6 +17,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include <config.h>
 #include "gtkcellview.h"
 #include "gtkcelllayout.h"
 #include "gtkintl.h"
@@ -436,9 +437,11 @@ gtk_cell_view_expose (GtkWidget      *widget,
       g_object_unref (G_OBJECT (gc));
     }
 
-  /* set cell data (if applicable) */
-  if (cellview->priv->displayed_row)
-    gtk_cell_view_set_cell_data (cellview);
+  if (!cellview->priv->displayed_row)
+    return FALSE;
+    
+  /* set cell data */
+  gtk_cell_view_set_cell_data (cellview);
 
   /* render cells */
   area = widget->allocation;
@@ -635,17 +638,16 @@ gtk_cell_view_cell_layout_clear (GtkCellLayout *layout)
 
   g_return_if_fail (GTK_IS_CELL_VIEW (cellview));
 
-  for (i = cellview->priv->cell_list; i; i = i->next)
+  while (cellview->priv->cell_list)
     {
-      GtkCellViewCellInfo *info = (GtkCellViewCellInfo *)i->data;
+      GtkCellViewCellInfo *info = (GtkCellViewCellInfo *)cellview->priv->cell_list->data;
 
       gtk_cell_view_cell_layout_clear_attributes (layout, info->cell);
       g_object_unref (G_OBJECT (info->cell));
       g_free (info);
+      cellview->priv->cell_list = g_list_delete_link (cellview->priv->cell_list, 
+                                                     cellview->priv->cell_list);
     }
-
-  g_list_free (cellview->priv->cell_list);
-  cellview->priv->cell_list = NULL;
 }
 
 static void
@@ -691,14 +693,13 @@ gtk_cell_view_cell_layout_clear_attributes (GtkCellLayout   *layout,
   g_return_if_fail (info != NULL);
 
   list = info->attributes;
-
   while (list && list->next)
     {
       g_free (list->data);
       list = list->next->next;
     }
-  g_slist_free (list);
 
+  g_slist_free (info->attributes);
   info->attributes = NULL;
 }
 
@@ -878,19 +879,35 @@ gtk_cell_view_set_model (GtkCellView  *cell_view,
     g_object_ref (G_OBJECT (cell_view->priv->model));
 }
 
+/**
+ * gtk_cell_view_set_displayed_row:
+ * @cell_view: a #GtkCellView
+ * @path: a #GtkTreePath or %NULL to unset.
+ * 
+ * Sets the row of the model that is currently displayed
+ * by the #GtkCellView. If the path is unset, then the
+ * contents of the cellview "stick" at their last value;
+ * this is not normally a desired result, but may be
+ * a needed intermediate state if say, the model for
+ * the #GtkCellView becomes temporarily empty.
+ **/
 void
 gtk_cell_view_set_displayed_row (GtkCellView *cell_view,
                                  GtkTreePath *path)
 {
   g_return_if_fail (GTK_IS_CELL_VIEW (cell_view));
   g_return_if_fail (GTK_IS_TREE_MODEL (cell_view->priv->model));
-  g_return_if_fail (path != NULL);
 
   if (cell_view->priv->displayed_row)
     gtk_tree_row_reference_free (cell_view->priv->displayed_row);
 
-  cell_view->priv->displayed_row =
-    gtk_tree_row_reference_new (cell_view->priv->model, path);
+  if (path)
+    {
+      cell_view->priv->displayed_row =
+       gtk_tree_row_reference_new (cell_view->priv->model, path);
+    }
+  else
+    cell_view->priv->displayed_row = NULL;
 
   /* force resize and redraw */
   gtk_widget_queue_resize (GTK_WIDGET (cell_view));