From 832c123fd27e0439343699673ad865e86065b22d Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Tue, 2 Nov 2010 18:01:03 +0900 Subject: [PATCH] Extended gtk_cell_area_apply_attributes() to account for expander/expanded cells The state of expanded cells must come from the view, since these states can vary across views accessing the same model (also "finished up" the applying of attributes code). --- gtk/gtkcellarea.c | 31 ++++++++++++++++++++++++++++++- gtk/gtkcellarea.h | 4 +++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/gtk/gtkcellarea.c b/gtk/gtkcellarea.c index e77c2280ce..634ff4906c 100644 --- a/gtk/gtkcellarea.c +++ b/gtk/gtkcellarea.c @@ -117,6 +117,8 @@ typedef struct { GtkCellArea *area; GtkTreeModel *model; GtkTreeIter *iter; + gboolean is_expander; + gboolean is_expanded; } AttributeData; struct _GtkCellAreaPrivate @@ -926,6 +928,22 @@ apply_cell_attributes (GtkCellRenderer *renderer, CellAttribute *attribute; GSList *list; GValue value = { 0, }; + gboolean is_expander; + gboolean is_expanded; + + g_object_freeze_notify (G_OBJECT (renderer)); + + /* Whether a row expands or is presently expanded can only be + * provided by the view (as these states can vary across views + * accessing the same model). + */ + g_object_get (renderer, "is-expander", &is_expander, NULL); + if (is_expander != data->is_expander) + g_object_set (renderer, "is-expander", data->is_expander, NULL); + + g_object_get (renderer, "is-expanded", &is_expanded, NULL); + if (is_expanded != data->is_expanded) + g_object_set (renderer, "is-expanded", data->is_expanded, NULL); /* Apply the attributes directly to the renderer */ for (list = info->attributes; list; list = list->next) @@ -942,12 +960,16 @@ apply_cell_attributes (GtkCellRenderer *renderer, if (info->func) info->func (GTK_CELL_LAYOUT (data->area), renderer, data->model, data->iter, info->data); + + g_object_thaw_notify (G_OBJECT (renderer)); } void gtk_cell_area_apply_attributes (GtkCellArea *area, GtkTreeModel *tree_model, - GtkTreeIter *iter) + GtkTreeIter *iter, + gboolean is_expander, + gboolean is_expanded) { GtkCellAreaPrivate *priv; AttributeData data; @@ -958,6 +980,13 @@ gtk_cell_area_apply_attributes (GtkCellArea *area, priv = area->priv; + /* Feed in data needed to apply to every renderer */ + data.area = area; + data.model = tree_model; + data.iter = iter; + data.is_expander = is_expander; + data.is_expanded = is_expanded; + /* Go over any cells that have attributes or custom GtkCellLayoutDataFuncs and * apply the data from the treemodel */ g_hash_table_foreach (priv->cell_info, (GHFunc)apply_cell_attributes, &data); diff --git a/gtk/gtkcellarea.h b/gtk/gtkcellarea.h index c45977fb29..2e804714c5 100644 --- a/gtk/gtkcellarea.h +++ b/gtk/gtkcellarea.h @@ -197,7 +197,9 @@ void gtk_cell_area_get_preferred_width_for_height (GtkCellArea /* Attributes */ void gtk_cell_area_apply_attributes (GtkCellArea *area, GtkTreeModel *tree_model, - GtkTreeIter *iter); + GtkTreeIter *iter, + gboolean is_expander, + gboolean is_expanded); void gtk_cell_area_attribute_connect (GtkCellArea *area, GtkCellRenderer *renderer, const gchar *attribute,