aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-29 00:05:01 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-07-02 22:34:09 +0800
commitd40e5a8ba1e7d362415be17d0ccde4477243839d (patch)
tree394a4672fd317d909a2ff2505a84a24a7a0e94ee /e-util
parent46b7a9961fc0606941dc0e2a2edf4a1383e3fa25 (diff)
downloadgsoc2013-evolution-d40e5a8ba1e7d362415be17d0ccde4477243839d.tar.gz
gsoc2013-evolution-d40e5a8ba1e7d362415be17d0ccde4477243839d.tar.zst
gsoc2013-evolution-d40e5a8ba1e7d362415be17d0ccde4477243839d.zip
Add e_table_specification_get_column_index().
Lookups up the column index of an ETableColumnSpecification, returns a negative value if no match found.
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-table-specification.c41
-rw-r--r--e-util/e-table-specification.h3
2 files changed, 44 insertions, 0 deletions
diff --git a/e-util/e-table-specification.c b/e-util/e-table-specification.c
index d6ca13bec4..40d4a54d63 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 79484aa92e..09b86c3791 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);