[aravis] Add arv_gc_enumeration_get_available_string_values.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] Add arv_gc_enumeration_get_available_string_values.
- Date: Mon, 9 Jul 2012 08:54:35 +0000 (UTC)
commit d7afe190150fe116cad662d81ff9d027b8253307
Author: Jure Varlec <jure varlec ad-vega si>
Date: Sun Jul 1 18:41:12 2012 +0200
Add arv_gc_enumeration_get_available_string_values.
src/arvgcenumeration.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++
src/arvgcenumeration.h | 1 +
2 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/src/arvgcenumeration.c b/src/arvgcenumeration.c
index 7c4b35e..971dc69 100644
--- a/src/arvgcenumeration.c
+++ b/src/arvgcenumeration.c
@@ -286,6 +286,84 @@ arv_gc_enumeration_get_available_int_values (ArvGcEnumeration *enumeration, guin
return values;
}
+const char **
+arv_gc_enumeration_get_available_string_values (ArvGcEnumeration *enumeration, guint *n_values, GError **error)
+{
+ const char ** strings;
+ const GSList *entries, *iter;
+ GSList *available_entries = NULL;
+ unsigned int i;
+ GError *local_error = NULL;
+
+ g_return_val_if_fail (n_values != NULL, NULL);
+
+ *n_values = 0;
+
+ g_return_val_if_fail (ARV_IS_GC_ENUMERATION (enumeration), NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ entries = arv_gc_enumeration_get_entries (enumeration);
+
+ *n_values = 0;
+ for (iter = entries; iter != NULL; iter = iter->next) {
+ gboolean is_available;
+
+ is_available = arv_gc_feature_node_is_available (iter->data, &local_error);
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ *n_values = 0;
+ g_slist_free (available_entries);
+
+ return NULL;
+ }
+
+ if (is_available) {
+ gboolean is_implemented;
+
+ is_implemented = arv_gc_feature_node_is_implemented (iter->data, &local_error);
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ *n_values = 0;
+ g_slist_free (available_entries);
+
+ return NULL;
+ }
+
+ if (is_implemented) {
+ (*n_values)++;
+ available_entries = g_slist_prepend (available_entries, iter->data);
+ }
+ }
+ }
+
+ if (*n_values == 0) {
+ g_slist_free (available_entries);
+ return NULL;
+ }
+
+ strings = g_new (const char*, *n_values);
+ for (iter = available_entries, i = 0; iter != NULL; iter = iter->next) {
+
+ strings[i] = arv_gc_enum_entry_get_string (iter->data, &local_error);
+
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
+ *n_values = 0;
+ g_slist_free (available_entries);
+ g_free (strings);
+
+ return NULL;
+ }
+ i++;
+ }
+
+ g_slist_free (available_entries);
+
+ return strings;
+}
+
void
arv_gc_enumeration_set_int_value (ArvGcEnumeration *enumeration, gint64 value, GError **error)
{
diff --git a/src/arvgcenumeration.h b/src/arvgcenumeration.h
index aa0c093..754b528 100644
--- a/src/arvgcenumeration.h
+++ b/src/arvgcenumeration.h
@@ -59,6 +59,7 @@ void arv_gc_enumeration_set_string_value (ArvGcEnumeration *enumeration, const
gint64 arv_gc_enumeration_get_int_value (ArvGcEnumeration *enumeration, GError **error);
void arv_gc_enumeration_set_int_value (ArvGcEnumeration *enumeration, gint64 value, GError **error);
gint64 * arv_gc_enumeration_get_available_int_values (ArvGcEnumeration *enumeration, guint *n_values, GError **error);
+const char ** arv_gc_enumeration_get_available_string_values (ArvGcEnumeration *enumeration, guint *n_values, GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]