forked from AuroraMiddleware/gtk
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).
This commit is contained in:
parent
73e45cef9d
commit
832c123fd2
@ -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);
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user