[evolution] Add e_table_specification_get_column_index().



commit d40e5a8ba1e7d362415be17d0ccde4477243839d
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Jun 28 12:05:01 2013 -0400

    Add e_table_specification_get_column_index().
    
    Lookups up the column index of an ETableColumnSpecification, returns a
    negative value if no match found.

 .../evolution-util/evolution-util-sections.txt     |    1 +
 e-util/e-table-specification.c                     |   41 ++++++++++++++++++++
 e-util/e-table-specification.h                     |    3 +
 3 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/doc/reference/evolution-util/evolution-util-sections.txt 
b/doc/reference/evolution-util/evolution-util-sections.txt
index 039667a..6555f5b 100644
--- a/doc/reference/evolution-util/evolution-util-sections.txt
+++ b/doc/reference/evolution-util/evolution-util-sections.txt
@@ -3915,6 +3915,7 @@ e_table_sorting_utils_lookup_cmp_cache
 ETableSpecification
 e_table_specification_new
 e_table_specification_ref_columns
+e_table_specification_get_column_index
 e_table_specification_load_from_file
 e_table_specification_load_from_string
 e_table_specification_load_from_node
diff --git a/e-util/e-table-specification.c b/e-util/e-table-specification.c
index d6ca13b..40d4a54 100644
--- a/e-util/e-table-specification.c
+++ b/e-util/e-table-specification.c
@@ -143,6 +143,47 @@ e_table_specification_ref_columns (ETableSpecification *specification)
 }
 
 /**
+ * e_table_specification_get_column_index:
+ * @specification: an #ETableSpecification
+ * @column_spec: an #ETableColumnSpecification
+ *
+ * Returns the zero-based index of @column_spec within @specification,
+ * or a negative value if @column_spec is not defined by @specification.
+ *
+ * Returns: the column index of @column_spec, or a negative value
+ **/
+gint
+e_table_specification_get_column_index (ETableSpecification *specification,
+                                        ETableColumnSpecification *column_spec)
+{
+       GPtrArray *columns;
+       gint column_index = -1;
+       guint ii;
+
+       g_return_val_if_fail (E_IS_TABLE_SPECIFICATION (specification), -1);
+       g_return_val_if_fail (E_IS_TABLE_COLUMN_SPECIFICATION (column_spec), -1);
+
+       columns = e_table_specification_ref_columns (specification);
+
+       for (ii = 0; ii < columns->len; ii++) {
+               gboolean column_specs_equal;
+
+               column_specs_equal =
+                       e_table_column_specification_equal (
+                       column_spec, columns->pdata[ii]);
+
+               if (column_specs_equal) {
+                       column_index = (gint) ii;
+                       break;
+               }
+       }
+
+       g_ptr_array_unref (columns);
+
+       return column_index;
+}
+
+/**
  * e_table_specification_load_from_file:
  * @specification: an #ETableSpecification
  * @filename: the name of a file containing an #ETable specification
diff --git a/e-util/e-table-specification.h b/e-util/e-table-specification.h
index 79484aa..09b86c3 100644
--- a/e-util/e-table-specification.h
+++ b/e-util/e-table-specification.h
@@ -87,6 +87,9 @@ ETableSpecification *
                e_table_specification_new       (void);
 GPtrArray *    e_table_specification_ref_columns
                                                (ETableSpecification *specification);
+gint           e_table_specification_get_column_index
+                                               (ETableSpecification *specification,
+                                                ETableColumnSpecification *column_spec);
 gboolean       e_table_specification_load_from_file
                                                (ETableSpecification *specification,
                                                 const gchar *filename);


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