* Boston, MA 02111-1307, USA.
*/
+#include <config.h>
#include "gtkcellview.h"
#include "gtkcelllayout.h"
#include "gtkintl.h"
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;
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
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;
}
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));