[gimp] app: implement gimp_curve_load() and _save() in GIO



commit 77b6af2da864f7a4ee07e1ee7ce223bb668f78df
Author: Michael Natterer <mitch gimp org>
Date:   Thu Jul 3 13:22:10 2014 +0200

    app: implement gimp_curve_load() and _save() in GIO
    
    They are currently unused, but implementing them was a copy/paste
    no brainer.

 app/core/gimpcurve-load.c |   34 ++++++++--------------------------
 app/core/gimpcurve-save.c |   36 ++++++------------------------------
 2 files changed, 14 insertions(+), 56 deletions(-)
---
diff --git a/app/core/gimpcurve-load.c b/app/core/gimpcurve-load.c
index 243dfa7..86ea39e 100644
--- a/app/core/gimpcurve-load.c
+++ b/app/core/gimpcurve-load.c
@@ -17,54 +17,36 @@
 
 #include "config.h"
 
-#include <errno.h>
-
 #include <gdk-pixbuf/gdk-pixbuf.h>
-#include <glib/gstdio.h>
 #include <gegl.h>
 
-#include "libgimpbase/gimpbase.h"
-
-#ifdef G_OS_WIN32
-#include "libgimpbase/gimpwin32-io.h"
-#endif
+#include "libgimpconfig/gimpconfig.h"
 
 #include "core-types.h"
 
 #include "gimpcurve.h"
 #include "gimpcurve-load.h"
 
-#include "gimp-intl.h"
-
 
 GList *
 gimp_curve_load (GFile   *file,
                  GError **error)
 {
-  gchar *path;
-  FILE  *f;
+  GimpCurve *curve;
 
   g_return_val_if_fail (G_IS_FILE (file), NULL);
-
-  path = g_file_get_path (file);
-
-  g_return_val_if_fail (g_path_is_absolute (path), NULL);
   g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
-  f = g_fopen (path, "rb");
-  g_free (path);
+  curve = g_object_new (GIMP_TYPE_CURVE, NULL);
 
-  if (! f)
+  if (gimp_config_deserialize_gfile (GIMP_CONFIG (curve),
+                                     file,
+                                     NULL, error))
     {
-      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
-                   _("Could not open '%s' for reading: %s"),
-                   gimp_file_get_utf8_name (file), g_strerror (errno));
-      return NULL;
+      return g_list_prepend (NULL, curve);
     }
 
-  /* load curves */
-
-  fclose (f);
+  g_object_unref (curve);
 
   return NULL;
 }
diff --git a/app/core/gimpcurve-save.c b/app/core/gimpcurve-save.c
index 8f5f029..1790178 100644
--- a/app/core/gimpcurve-save.c
+++ b/app/core/gimpcurve-save.c
@@ -17,51 +17,27 @@
 
 #include "config.h"
 
-#include <errno.h>
-
 #include <gdk-pixbuf/gdk-pixbuf.h>
-#include <glib/gstdio.h>
 #include <gegl.h>
 
-#include "libgimpbase/gimpbase.h"
+#include "libgimpconfig/gimpconfig.h"
 
 #include "core-types.h"
 
 #include "gimpcurve.h"
 #include "gimpcurve-save.h"
 
-#include "gimp-intl.h"
-
 
 gboolean
 gimp_curve_save (GimpData  *data,
                  GError   **error)
 {
-  /* GimpCurve *curve; */
-  gchar     *path;
-  FILE      *file;
-
   g_return_val_if_fail (GIMP_IS_CURVE (data), FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-  /* curve = GIMP_CURVE (data); */
-
-  path = g_file_get_path (gimp_data_get_file (data));
-  file = g_fopen (path, "wb");
-  g_free (path);
-
-  if (! file)
-    {
-      g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_OPEN,
-                   _("Could not open '%s' for writing: %s"),
-                   gimp_file_get_utf8_name (gimp_data_get_file (data)),
-                   g_strerror (errno));
-      return FALSE;
-    }
-
-  /* FIXME: write curve */
-
-  fclose (file);
-
-  return TRUE;
+  return gimp_config_serialize_to_gfile (GIMP_CONFIG (data),
+                                         gimp_data_get_file (data),
+                                         "GIMP curve file",
+                                         "end of GIMP curve file",
+                                         NULL, error);
 }


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