[gtk+] GtkCellArea: allow finding attributes at runtime



commit f4d02bd9c18516e3ef4b32bae072e37822bdcd5e
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu May 8 14:06:03 2014 -0400

    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

 gtk/gtkcellarea.c |   40 ++++++++++++++++++++++++++++++++++++++++
 gtk/gtkcellarea.h |    5 +++++
 2 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcellarea.c b/gtk/gtkcellarea.c
index 09d7654..b27ad07 100644
--- a/gtk/gtkcellarea.c
+++ b/gtk/gtkcellarea.c
@@ -2319,6 +2319,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
  * @tree_model: the #GtkTreeModel to pull values from
diff --git a/gtk/gtkcellarea.h b/gtk/gtkcellarea.h
index eaa6373..854e32f 100644
--- a/gtk/gtkcellarea.h
+++ b/gtk/gtkcellarea.h
@@ -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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]