[gimp] app: remove gimp_image_set_filename()



commit 597a438f0744896a672ec057132c6bf6e98976b6
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jul 13 22:43:22 2015 +0200

    app: remove gimp_image_set_filename()
    
    - gimp-image-set-filename PDB wrapper: implement the same there in
      a few lines
    - xcf-load.c: use gimp_image_set_file() instead, and get rid of the
      last use of filename in xcf/ in favor of GFile

 app/core/gimpimage.c       |   17 -----------------
 app/core/gimpimage.h       |    3 ---
 app/pdb/image-cmds.c       |   13 ++++++++++++-
 app/xcf/xcf-load.c         |    2 +-
 app/xcf/xcf-private.h      |    2 +-
 app/xcf/xcf.c              |   41 +++++++++++++++++++----------------------
 tools/pdbgen/pdb/image.pdb |   13 ++++++++++++-
 7 files changed, 45 insertions(+), 46 deletions(-)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index b1d9b60..fa25566 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -1937,23 +1937,6 @@ gimp_image_get_file (const GimpImage *image)
   return GIMP_IMAGE_GET_PRIVATE (image)->file;
 }
 
-void
-gimp_image_set_filename (GimpImage   *image,
-                         const gchar *filename)
-{
-  GFile *file = NULL;
-
-  g_return_if_fail (GIMP_IS_IMAGE (image));
-
-  if (filename && strlen (filename))
-    file = file_utils_filename_to_file (image->gimp, filename, NULL);
-
-  gimp_image_set_file (image, file);
-
-  if (file)
-    g_object_unref (file);
-}
-
 /**
  * gimp_image_get_imported_file:
  * @image: A #GimpImage.
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index a55e0f1..28d7554 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -149,9 +149,6 @@ void            gimp_image_set_exported_file     (GimpImage          *image,
 void            gimp_image_set_save_a_copy_file  (GimpImage          *image,
                                                   GFile              *file);
 
-void            gimp_image_set_filename          (GimpImage          *image,
-                                                  const gchar        *filename);
-
 const gchar   * gimp_image_get_display_name      (GimpImage          *image);
 const gchar   * gimp_image_get_display_path      (GimpImage          *image);
 
diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c
index 707fe91..9e3d874 100644
--- a/app/pdb/image-cmds.c
+++ b/app/pdb/image-cmds.c
@@ -53,6 +53,7 @@
 #include "core/gimpselection.h"
 #include "core/gimptempbuf.h"
 #include "core/gimpunit.h"
+#include "file/file-utils.h"
 #include "plug-in/gimpplugin.h"
 #include "plug-in/gimppluginmanager.h"
 #include "vectors/gimpvectors.h"
@@ -2078,7 +2079,17 @@ image_set_filename_invoker (GimpProcedure         *procedure,
         success = FALSE;
 
       if (success)
-        gimp_image_set_filename (image, filename);
+        {
+          GFile *file = NULL;
+
+          if (filename && strlen (filename))
+            file = file_utils_filename_to_file (image->gimp, filename, NULL);
+
+          gimp_image_set_file (image, file);
+
+          if (file)
+            g_object_unref (file);
+        }
     }
 
   return gimp_procedure_get_return_values (procedure, success,
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index a62b37c..71326e4 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -506,7 +506,7 @@ xcf_load_image (Gimp     *gimp,
   if (info->active_channel)
     gimp_image_set_active_channel (image, info->active_channel);
 
-  gimp_image_set_filename (image, info->filename);
+  gimp_image_set_file (image, info->file);
 
   if (info->tattoo_state > 0)
     gimp_image_set_tattoo_state (image, info->tattoo_state);
diff --git a/app/xcf/xcf-private.h b/app/xcf/xcf-private.h
index 5e77700..3c3edf6 100644
--- a/app/xcf/xcf-private.h
+++ b/app/xcf/xcf-private.h
@@ -94,7 +94,7 @@ struct _XcfInfo
   GOutputStream      *output;
   GSeekable          *seekable;
   guint               cp;
-  const gchar        *filename;
+  GFile              *file;
   GimpTattoo          tattoo_state;
   GimpLayer          *active_layer;
   GimpChannel        *active_channel;
diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c
index bbcf09d..a2f3449 100644
--- a/app/xcf/xcf.c
+++ b/app/xcf/xcf.c
@@ -255,7 +255,6 @@ xcf_load_invoker (GimpProcedure         *procedure,
   GimpValueArray *return_vals;
   GimpImage      *image   = NULL;
   const gchar    *uri;
-  gchar          *filename;
   GFile          *file;
   gboolean        success = FALSE;
   gchar           id[14];
@@ -263,9 +262,8 @@ xcf_load_invoker (GimpProcedure         *procedure,
 
   gimp_set_busy (gimp);
 
-  uri      = g_value_get_string (gimp_value_array_index (args, 1));
-  file     = g_file_new_for_uri (uri);
-  filename = g_file_get_parse_name (file);
+  uri  = g_value_get_string (gimp_value_array_index (args, 1));
+  file = g_file_new_for_uri (uri);
 
   info.input = G_INPUT_STREAM (g_file_read (file, NULL, &my_error));
 
@@ -274,11 +272,12 @@ xcf_load_invoker (GimpProcedure         *procedure,
       info.gimp        = gimp;
       info.seekable    = G_SEEKABLE (info.input);
       info.progress    = progress;
-      info.filename    = filename;
+      info.file        = file;
       info.compression = COMPRESS_NONE;
 
       if (progress)
-        gimp_progress_start (progress, FALSE, _("Opening '%s'"), filename);
+        gimp_progress_start (progress, FALSE, _("Opening '%s'"),
+                             gimp_file_get_utf8_name (file));
 
       success = TRUE;
 
@@ -329,10 +328,9 @@ xcf_load_invoker (GimpProcedure         *procedure,
     {
       g_propagate_prefixed_error (error, my_error,
                                   _("Could not open '%s' for reading: "),
-                                  filename);
+                                  gimp_file_get_utf8_name (file));
     }
 
-  g_free (filename);
   g_object_unref (file);
 
   return_vals = gimp_procedure_get_return_values (procedure, success,
@@ -358,17 +356,15 @@ xcf_save_invoker (GimpProcedure         *procedure,
   GimpValueArray *return_vals;
   GimpImage      *image;
   const gchar    *uri;
-  gchar          *filename;
   GFile          *file;
   gboolean        success  = FALSE;
   GError         *my_error = NULL;
 
   gimp_set_busy (gimp);
 
-  image    = gimp_value_get_image (gimp_value_array_index (args, 1), gimp);
-  uri      = g_value_get_string (gimp_value_array_index (args, 3));
-  file     = g_file_new_for_uri (uri);
-  filename = g_file_get_parse_name (file);
+  image = gimp_value_get_image (gimp_value_array_index (args, 1), gimp);
+  uri   = g_value_get_string (gimp_value_array_index (args, 3));
+  file  = g_file_new_for_uri (uri);
 
   info.output = G_OUTPUT_STREAM (g_file_replace (file,
                                                  NULL, FALSE, G_FILE_CREATE_NONE,
@@ -378,10 +374,10 @@ xcf_save_invoker (GimpProcedure         *procedure,
     {
       gboolean compat_mode = gimp_image_get_xcf_compat_mode (image);
 
-      info.gimp         = gimp;
-      info.seekable     = G_SEEKABLE (info.output);
-      info.progress     = progress;
-      info.filename     = filename;
+      info.gimp     = gimp;
+      info.seekable = G_SEEKABLE (info.output);
+      info.progress = progress;
+      info.file     = file;
 
       if (compat_mode)
         info.compression = COMPRESS_RLE;
@@ -394,14 +390,16 @@ xcf_save_invoker (GimpProcedure         *procedure,
                                                       NULL, NULL);
 
       if (progress)
-        gimp_progress_start (progress, FALSE, _("Saving '%s'"), filename);
+        gimp_progress_start (progress, FALSE, _("Saving '%s'"),
+                             gimp_file_get_utf8_name (file));
 
       success = xcf_save_image (&info, image, &my_error);
 
       if (success)
         {
           if (progress)
-            gimp_progress_set_text (progress, _("Closing '%s'"), filename);
+            gimp_progress_set_text (progress, _("Closing '%s'"),
+                                    gimp_file_get_utf8_name (file));
 
           success = g_output_stream_close (info.output, NULL, &my_error);
         }
@@ -409,7 +407,7 @@ xcf_save_invoker (GimpProcedure         *procedure,
       if (! success)
         g_propagate_prefixed_error (error, my_error,
                                     _("Error writing '%s': "),
-                                    filename);
+                                    gimp_file_get_utf8_name (file));
 
       g_object_unref (info.output);
 
@@ -420,10 +418,9 @@ xcf_save_invoker (GimpProcedure         *procedure,
     {
       g_propagate_prefixed_error (error, my_error,
                                   _("Error creating '%s': "),
-                                  filename);
+                                  gimp_file_get_utf8_name (file));
     }
 
-  g_free (filename);
   g_object_unref (file);
 
   return_vals = gimp_procedure_get_return_values (procedure, success,
diff --git a/tools/pdbgen/pdb/image.pdb b/tools/pdbgen/pdb/image.pdb
index cb5d4ca..de8125c 100644
--- a/tools/pdbgen/pdb/image.pdb
+++ b/tools/pdbgen/pdb/image.pdb
@@ -2049,7 +2049,17 @@ HELP
     success = FALSE;
 
   if (success)
-    gimp_image_set_filename (image, filename);
+    {
+      GFile *file = NULL;
+
+      if (filename && strlen (filename))
+        file = file_utils_filename_to_file (image->gimp, filename, NULL);
+
+      gimp_image_set_file (image, file);
+
+      if (file)
+        g_object_unref (file);
+    }
 }
 CODE
     );
@@ -2816,6 +2826,7 @@ CODE
               "core/gimpprogress.h"
               "core/gimptempbuf.h"
               "core/gimpunit.h"
+              "file/file-utils.h"
               "plug-in/gimpplugin.h"
               "plug-in/gimppluginmanager.h"
               "gimppdbcontext.h"


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