[gimp] pdb: fix gimp-file-open and gimp-file-save for GIO-ported file procedures



commit e47ded9420035fc5db707d066e3c0edd85bb654f
Author: Michael Natterer <mitch gimp org>
Date:   Sat Oct 18 01:14:58 2014 +0200

    pdb: fix gimp-file-open and gimp-file-save for GIO-ported file procedures
    
    Pass URIs instead of filenames to the procedures if they are ported to GIO.

 app/pdb/fileops-cmds.c       |   59 ++++++++++++++++++++++++++++++++----------
 tools/pdbgen/pdb/fileops.pdb |   59 ++++++++++++++++++++++++++++++++----------
 2 files changed, 90 insertions(+), 28 deletions(-)
---
diff --git a/app/pdb/fileops-cmds.c b/app/pdb/fileops-cmds.c
index 56ad266..df8ac4d 100644
--- a/app/pdb/fileops-cmds.c
+++ b/app/pdb/fileops-cmds.c
@@ -43,6 +43,7 @@
 #include "file/file-utils.h"
 #include "plug-in/gimppluginmanager-file.h"
 #include "plug-in/gimppluginmanager.h"
+#include "plug-in/gimppluginprocedure.h"
 
 #include "gimppdb.h"
 #include "gimpprocedure.h"
@@ -75,19 +76,30 @@ file_load_invoker (GimpProcedure         *procedure,
   file_proc = file_procedure_find (gimp->plug_in_manager->load_procs,
                                    file, error);
 
-  g_object_unref (file);
-
   if (! file_proc)
-    return gimp_procedure_get_return_values (procedure, FALSE,
-                                             error ? *error : NULL);
+    {
+      g_object_unref (file);
+
+      return gimp_procedure_get_return_values (procedure, FALSE,
+                                               error ? *error : NULL);
+    }
 
   proc = GIMP_PROCEDURE (file_proc);
 
   new_args = gimp_procedure_get_arguments (proc);
 
-  for (i = 0; i < 3; i++)
-    g_value_transform (gimp_value_array_index (args, i),
-                       gimp_value_array_index (new_args, i));
+  g_value_transform (gimp_value_array_index (args, 0),
+                     gimp_value_array_index (new_args, 0));
+
+  if (file_proc->handles_uri)
+    g_value_take_string (gimp_value_array_index (new_args, 1),
+                         g_file_get_uri (file));
+  else
+    g_value_transform (gimp_value_array_index (args, 1),
+                       gimp_value_array_index (new_args, 1));
+
+  g_value_transform (gimp_value_array_index (args, 2),
+                     gimp_value_array_index (new_args, 2));
 
   for (i = 3; i < proc->num_args; i++)
     if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
@@ -114,6 +126,8 @@ file_load_invoker (GimpProcedure         *procedure,
         }
     }
 
+  g_object_unref (file);
+
   return return_vals;
 }
 
@@ -272,19 +286,34 @@ file_save_invoker (GimpProcedure         *procedure,
     file_proc = file_procedure_find (gimp->plug_in_manager->export_procs,
                                      file, error);
 
-  g_object_unref (file);
-
   if (! file_proc)
-    return gimp_procedure_get_return_values (procedure, FALSE,
-                                             error ? *error : NULL);
+    {
+      g_object_unref (file);
+
+      return gimp_procedure_get_return_values (procedure, FALSE,
+                                               error ? *error : NULL);
+    }
 
   proc = GIMP_PROCEDURE (file_proc);
 
   new_args = gimp_procedure_get_arguments (proc);
 
-  for (i = 0; i < 5; i++)
-    g_value_transform (gimp_value_array_index (args, i),
-                       gimp_value_array_index (new_args, i));
+  g_value_transform (gimp_value_array_index (args, 0),
+                     gimp_value_array_index (new_args, 0));
+  g_value_transform (gimp_value_array_index (args, 1),
+                     gimp_value_array_index (new_args, 1));
+  g_value_transform (gimp_value_array_index (args, 2),
+                     gimp_value_array_index (new_args, 2));
+
+  if (file_proc->handles_uri)
+    g_value_take_string (gimp_value_array_index (new_args, 3),
+                         g_file_get_uri (file));
+  else
+    g_value_transform (gimp_value_array_index (args, 3),
+                       gimp_value_array_index (new_args, 3));
+
+  g_value_transform (gimp_value_array_index (args, 4),
+                     gimp_value_array_index (new_args, 4));
 
   for (i = 5; i < proc->num_args; i++)
     if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
@@ -298,6 +327,8 @@ file_save_invoker (GimpProcedure         *procedure,
 
   gimp_value_array_unref (new_args);
 
+  g_object_unref (file);
+
   return return_vals;
 }
 
diff --git a/tools/pdbgen/pdb/fileops.pdb b/tools/pdbgen/pdb/fileops.pdb
index 80a9990..5fa4a70 100644
--- a/tools/pdbgen/pdb/fileops.pdb
+++ b/tools/pdbgen/pdb/fileops.pdb
@@ -68,19 +68,30 @@ HELP
   file_proc = file_procedure_find (gimp->plug_in_manager->load_procs,
                                    file, error);
 
-  g_object_unref (file);
-
   if (! file_proc)
-    return gimp_procedure_get_return_values (procedure, FALSE,
-                                             error ? *error : NULL);
+    {
+      g_object_unref (file);
+
+      return gimp_procedure_get_return_values (procedure, FALSE,
+                                               error ? *error : NULL);
+    }
 
   proc = GIMP_PROCEDURE (file_proc);
 
   new_args = gimp_procedure_get_arguments (proc);
 
-  for (i = 0; i < 3; i++)
-    g_value_transform (gimp_value_array_index (args, i),
-                       gimp_value_array_index (new_args, i));
+  g_value_transform (gimp_value_array_index (args, 0),
+                    gimp_value_array_index (new_args, 0));
+
+  if (file_proc->handles_uri)
+    g_value_take_string (gimp_value_array_index (new_args, 1),
+                         g_file_get_uri (file));
+  else
+    g_value_transform (gimp_value_array_index (args, 1),
+                       gimp_value_array_index (new_args, 1));
+
+  g_value_transform (gimp_value_array_index (args, 2),
+                     gimp_value_array_index (new_args, 2));
 
   for (i = 3; i < proc->num_args; i++)
     if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
@@ -107,6 +118,8 @@ HELP
         }
     }
 
+  g_object_unref (file);
+
   return return_vals;
 }
 CODE
@@ -294,19 +307,34 @@ HELP
     file_proc = file_procedure_find (gimp->plug_in_manager->export_procs,
                                      file, error);
 
-  g_object_unref (file);
-
   if (! file_proc)
-    return gimp_procedure_get_return_values (procedure, FALSE,
-                                             error ? *error : NULL);
+    {
+      g_object_unref (file);
+
+      return gimp_procedure_get_return_values (procedure, FALSE,
+                                               error ? *error : NULL);
+    }
 
   proc = GIMP_PROCEDURE (file_proc);
 
   new_args = gimp_procedure_get_arguments (proc);
 
-  for (i = 0; i < 5; i++)
-    g_value_transform (gimp_value_array_index (args, i),
-                       gimp_value_array_index (new_args, i));
+  g_value_transform (gimp_value_array_index (args, 0),
+                     gimp_value_array_index (new_args, 0));
+  g_value_transform (gimp_value_array_index (args, 1),
+                     gimp_value_array_index (new_args, 1));
+  g_value_transform (gimp_value_array_index (args, 2),
+                     gimp_value_array_index (new_args, 2));
+
+  if (file_proc->handles_uri)
+    g_value_take_string (gimp_value_array_index (new_args, 3),
+                         g_file_get_uri (file));
+  else
+    g_value_transform (gimp_value_array_index (args, 3),
+                       gimp_value_array_index (new_args, 3));
+
+  g_value_transform (gimp_value_array_index (args, 4),
+                     gimp_value_array_index (new_args, 4));
 
   for (i = 5; i < proc->num_args; i++)
     if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
@@ -320,6 +348,8 @@ HELP
 
   gimp_value_array_unref (new_args);
 
+  g_object_unref (file);
+
   return return_vals;
 }
 CODE
@@ -660,6 +690,7 @@ CODE
               "core/gimp-utils.h"
               "plug-in/gimppluginmanager.h"
               "plug-in/gimppluginmanager-file.h"
+              "plug-in/gimppluginprocedure.h"
               "file/file-open.h"
               "file/file-save.h"
              "file/file-procedure.h"


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