gimp r25988 - in trunk: . app/tools



Author: mitch
Date: Wed Jun 25 08:16:48 2008
New Revision: 25988
URL: http://svn.gnome.org/viewvc/gimp?rev=25988&view=rev

Log:
2008-06-25  Michael Natterer  <mitch gimp org>

	* app/tools/gimpcurvestool.c (gimp_curves_tool_settings_import):
	parse the first line of the file manually and detect whether we
	are importing an old curves file or a GimpConfig one.



Modified:
   trunk/ChangeLog
   trunk/app/tools/gimpcurvestool.c

Modified: trunk/app/tools/gimpcurvestool.c
==============================================================================
--- trunk/app/tools/gimpcurvestool.c	(original)
+++ trunk/app/tools/gimpcurvestool.c	Wed Jun 25 08:16:48 2008
@@ -584,6 +584,7 @@
   GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
   FILE           *file;
   gboolean        success;
+  gchar           header[64];
 
   file = g_fopen (filename, "rt");
 
@@ -596,11 +597,32 @@
       return FALSE;
     }
 
-  success = gimp_curves_config_load_cruft (tool->config, file, error);
+  if (! fgets (header, sizeof (header), file))
+    {
+      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
+                   _("Could not read header from '%s': %s"),
+                   gimp_filename_to_utf8 (filename),
+                   g_strerror (errno));
+      fclose (file);
+      return FALSE;
+    }
+
+  if (g_str_has_prefix (header, "# GIMP Curves File\n"))
+    {
+      rewind (file);
+
+      success = gimp_curves_config_load_cruft (tool->config, file, error);
+
+      fclose (file);
+
+      return success;
+    }
 
   fclose (file);
 
-  return success;
+  return GIMP_IMAGE_MAP_TOOL_CLASS (parent_class)->settings_import (image_map_tool,
+                                                                    filename,
+                                                                    error);
 }
 
 static gboolean



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