GtkCellArea: allow finding attributes at runtime

This will allow e.g. GtkInspector to display attribute mappings.

http://bugzilla.gnome.org/show_bug.cgi?id=729817
This commit is contained in:
Matthias Clasen 2014-05-08 14:06:03 -04:00
parent c813765430
commit f4d02bd9c1
2 changed files with 45 additions and 0 deletions

View File

@ -2318,6 +2318,46 @@ gtk_cell_area_attribute_disconnect (GtkCellArea *area,
}
}
/**
* gtk_cell_area_attribute_get_column:
* @cell_layout: a #GtkCellLayout
* @cell: a #GtkCellRenderer
* @attribute: an attribute on the renderer
*
* Returns the model column that an attribute has been mapped to,
* or -1 if the attribute is not mapped.
*
* Returns: the model column, or -1
*
* Since: 3.14
*/
gint
gtk_cell_area_attribute_get_column (GtkCellArea *area,
GtkCellRenderer *renderer,
const gchar *attribute)
{
GtkCellAreaPrivate *priv;
CellInfo *info;
CellAttribute *cell_attribute;
GSList *node;
priv = area->priv;
info = g_hash_table_lookup (priv->cell_info, renderer);
if (info)
{
node = g_slist_find_custom (info->attributes, attribute,
(GCompareFunc)cell_attribute_find);
if (node)
{
cell_attribute = node->data;
return cell_attribute->column;
}
}
return -1;
}
/**
* gtk_cell_area_apply_attributes:
* @area: a #GtkCellArea

View File

@ -388,6 +388,11 @@ GDK_AVAILABLE_IN_ALL
void gtk_cell_area_attribute_disconnect (GtkCellArea *area,
GtkCellRenderer *renderer,
const gchar *attribute);
GDK_AVAILABLE_IN_3_14
gint gtk_cell_area_attribute_get_column (GtkCellArea *area,
GtkCellRenderer *renderer,
const gchar *attribute);
/* Cell Properties */
GDK_AVAILABLE_IN_ALL