[gnome-photos/wip/rishi/double-buffering: 5/7] Add function to convert va_list of GEGL operation properties to GList



commit 297cabad338ce8ce88b4b9e3ef681fcd34d262be
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Jan 20 19:30:02 2017 +0100

    Add function to convert va_list of GEGL operation properties to GList
    
    Bump minimum GEGL version to 0.3.11.

 configure.ac       |    2 +-
 src/photos-utils.c |   36 ++++++++++++++++++++++++++++++++++++
 src/photos-utils.h |    4 ++++
 3 files changed, 41 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4251de9..9e16915 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,7 +32,7 @@ GLIB_GSETTINGS
 
 CAIRO_MIN_VERSION=1.14.0
 GDATA_MIN_VERSION=0.15.2
-GEGL_MIN_VERSION=0.3.5
+GEGL_MIN_VERSION=0.3.11
 GFBGRAPH_MIN_VERSION=0.2.1
 GLIB_MIN_VERSION=2.44.0
 GOA_MIN_VERSION=3.8.0
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 8814540..d00dc6b 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -32,6 +32,7 @@
 #include <string.h>
 
 #include <glib.h>
+#include <gobject/gvaluecollector.h>
 #include <libgnome-desktop/gnome-desktop-thumbnail.h>
 #include <tracker-sparql.h>
 #include <libgd/gd.h>
@@ -387,6 +388,41 @@ photos_utils_create_collection_icon (gint base_size, GList *pixbufs)
 }
 
 
+GList *
+photos_utils_create_operation_parameters_from_valist (const gchar *operation,
+                                                      const gchar *first_property_name,
+                                                      va_list ap)
+{
+  GList *parameters = NULL;
+  const gchar *property_name;
+
+  for (property_name = first_property_name; property_name != NULL; property_name = va_arg (ap, gchar *))
+    {
+      GParamSpec *pspec;
+      GParameter *parameter;
+      gchar *error;
+
+      pspec = gegl_operation_find_property (operation, property_name);
+      parameter = photos_utils_parameter_new (pspec, property_name);
+
+      error = NULL;
+      G_VALUE_COLLECT (&parameter->value, ap, 0, &error);
+      if (error != NULL)
+        {
+          g_warning ("Unable to set GValue: %s", error);
+          g_free (error);
+          photos_utils_parameter_free (parameter);
+          continue;
+        }
+
+      parameters = g_list_prepend (parameters, parameter);
+    }
+
+  parameters = g_list_reverse (parameters);
+  return parameters;
+}
+
+
 GeglNode *
 photos_utils_create_orientation_node (GeglNode *parent, GQuark orientation)
 {
diff --git a/src/photos-utils.h b/src/photos-utils.h
index ad4b5db..8305fde 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -84,6 +84,10 @@ gchar           *photos_utils_convert_path_to_uri         (const gchar *path);
 
 GIcon           *photos_utils_create_collection_icon      (gint base_size, GList *pixbufs);
 
+GList           *photos_utils_create_operation_parameters_from_valist (const gchar *operation,
+                                                                       const gchar *first_property_name,
+                                                                       va_list ap);
+
 GeglNode        *photos_utils_create_orientation_node     (GeglNode *parent, GQuark orientation);
 
 GdkPixbuf       *photos_utils_create_pixbuf_from_node     (GeglNode *node);


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