[gimp] pdb, libgimp: remove _gimp_register_load_handler()



commit 0745043ddbf0a38cb94edf69fa149709488ca68c
Author: Michael Natterer <mitch gimp org>
Date:   Tue Sep 10 12:29:17 2019 +0200

    pdb, libgimp: remove _gimp_register_load_handler()
    
    and rename _gimp_register_magic_load_handler() to
    _gimp_register_load_handler().

 app/pdb/fileops-cmds.c      | 80 ++++-----------------------------------------
 app/pdb/internal-procs.c    |  2 +-
 libgimp/gimpfileops_pdb.c   | 48 +++------------------------
 libgimp/gimpfileops_pdb.h   |  5 +--
 libgimp/gimploadprocedure.c | 17 +++-------
 pdb/groups/fileops.pdb      | 42 ++----------------------
 6 files changed, 18 insertions(+), 176 deletions(-)
---
diff --git a/app/pdb/fileops-cmds.c b/app/pdb/fileops-cmds.c
index 1403a4ad9a..4731bd4589 100644
--- a/app/pdb/fileops-cmds.c
+++ b/app/pdb/fileops-cmds.c
@@ -401,38 +401,6 @@ file_save_thumbnail_invoker (GimpProcedure         *procedure,
                                            error ? *error : NULL);
 }
 
-static GimpValueArray *
-register_magic_load_handler_invoker (GimpProcedure         *procedure,
-                                     Gimp                  *gimp,
-                                     GimpContext           *context,
-                                     GimpProgress          *progress,
-                                     const GimpValueArray  *args,
-                                     GError               **error)
-{
-  gboolean success = TRUE;
-  const gchar *procedure_name;
-  const gchar *extensions;
-  const gchar *prefixes;
-  const gchar *magics;
-
-  procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
-  extensions = g_value_get_string (gimp_value_array_index (args, 1));
-  prefixes = g_value_get_string (gimp_value_array_index (args, 2));
-  magics = g_value_get_string (gimp_value_array_index (args, 3));
-
-  if (success)
-    {
-      success = (gimp_pdb_is_canonical_procedure (procedure_name, error) &&
-                 gimp_plug_in_manager_register_load_handler (gimp->plug_in_manager,
-                                                             procedure_name,
-                                                             extensions, prefixes,
-                                                             magics));
-    }
-
-  return gimp_procedure_get_return_values (procedure, success,
-                                           error ? *error : NULL);
-}
-
 static GimpValueArray *
 register_load_handler_invoker (GimpProcedure         *procedure,
                                Gimp                  *gimp,
@@ -445,10 +413,12 @@ register_load_handler_invoker (GimpProcedure         *procedure,
   const gchar *procedure_name;
   const gchar *extensions;
   const gchar *prefixes;
+  const gchar *magics;
 
   procedure_name = g_value_get_string (gimp_value_array_index (args, 0));
   extensions = g_value_get_string (gimp_value_array_index (args, 1));
   prefixes = g_value_get_string (gimp_value_array_index (args, 2));
+  magics = g_value_get_string (gimp_value_array_index (args, 3));
 
   if (success)
     {
@@ -456,7 +426,7 @@ register_load_handler_invoker (GimpProcedure         *procedure,
                  gimp_plug_in_manager_register_load_handler (gimp->plug_in_manager,
                                                              procedure_name,
                                                              extensions, prefixes,
-                                                             NULL));
+                                                             magics));
     }
 
   return gimp_procedure_get_return_values (procedure, success,
@@ -895,11 +865,11 @@ register_fileops_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
-   * gimp-register-magic-load-handler
+   * gimp-register-load-handler
    */
-  procedure = gimp_procedure_new (register_magic_load_handler_invoker);
+  procedure = gimp_procedure_new (register_load_handler_invoker);
   gimp_object_set_static_name (GIMP_OBJECT (procedure),
-                               "gimp-register-magic-load-handler");
+                               "gimp-register-load-handler");
   gimp_procedure_set_static_help (procedure,
                                   "Registers a file load handler procedure.",
                                   "Registers a procedural database procedure to be called to load files of a 
particular file format using magic file information.",
@@ -939,44 +909,6 @@ register_fileops_procs (GimpPDB *pdb)
   gimp_pdb_register_procedure (pdb, procedure);
   g_object_unref (procedure);
 
-  /*
-   * gimp-register-load-handler
-   */
-  procedure = gimp_procedure_new (register_load_handler_invoker);
-  gimp_object_set_static_name (GIMP_OBJECT (procedure),
-                               "gimp-register-load-handler");
-  gimp_procedure_set_static_help (procedure,
-                                  "Registers a file load handler procedure.",
-                                  "Registers a procedural database procedure to be called to load files of a 
particular file format.",
-                                  NULL);
-  gimp_procedure_set_static_attribution (procedure,
-                                         "Spencer Kimball & Peter Mattis",
-                                         "Spencer Kimball & Peter Mattis",
-                                         "1995-1996");
-  gimp_procedure_add_argument (procedure,
-                               gimp_param_spec_string ("procedure-name",
-                                                       "procedure name",
-                                                       "The name of the procedure to be used for loading",
-                                                       FALSE, FALSE, TRUE,
-                                                       NULL,
-                                                       GIMP_PARAM_READWRITE));
-  gimp_procedure_add_argument (procedure,
-                               gimp_param_spec_string ("extensions",
-                                                       "extensions",
-                                                       "comma separated list of extensions this handler can 
load (i.e. \"jpg,jpeg\")",
-                                                       FALSE, FALSE, FALSE,
-                                                       NULL,
-                                                       GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
-  gimp_procedure_add_argument (procedure,
-                               gimp_param_spec_string ("prefixes",
-                                                       "prefixes",
-                                                       "comma separated list of prefixes this handler can 
load (i.e. \"http:,ftp:\")",
-                                                       FALSE, FALSE, FALSE,
-                                                       NULL,
-                                                       GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
-  gimp_pdb_register_procedure (pdb, procedure);
-  g_object_unref (procedure);
-
   /*
    * gimp-register-save-handler
    */
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index ab84499432..9be183da70 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 753 procedures registered total */
+/* 752 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/libgimp/gimpfileops_pdb.c b/libgimp/gimpfileops_pdb.c
index c024ba08e3..059511ddd3 100644
--- a/libgimp/gimpfileops_pdb.c
+++ b/libgimp/gimpfileops_pdb.c
@@ -272,7 +272,7 @@ gimp_file_save_thumbnail (GimpImage   *image,
 }
 
 /**
- * _gimp_register_magic_load_handler:
+ * _gimp_register_load_handler:
  * @procedure_name: The name of the procedure to be used for loading.
  * @extensions: comma separated list of extensions this handler can load (i.e. \"jpg,jpeg\").
  * @prefixes: comma separated list of prefixes this handler can load (i.e. \"http:,ftp:\").
@@ -286,51 +286,10 @@ gimp_file_save_thumbnail (GimpImage   *image,
  * Returns: TRUE on success.
  **/
 gboolean
-_gimp_register_magic_load_handler (const gchar *procedure_name,
-                                   const gchar *extensions,
-                                   const gchar *prefixes,
-                                   const gchar *magics)
-{
-  GimpValueArray *args;
-  GimpValueArray *return_vals;
-  gboolean success = TRUE;
-
-  args = gimp_value_array_new_from_types (NULL,
-                                          G_TYPE_STRING, procedure_name,
-                                          G_TYPE_STRING, extensions,
-                                          G_TYPE_STRING, prefixes,
-                                          G_TYPE_STRING, magics,
-                                          G_TYPE_NONE);
-
-  return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
-                                              "gimp-register-magic-load-handler",
-                                              args);
-  gimp_value_array_unref (args);
-
-  success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
-
-  gimp_value_array_unref (return_vals);
-
-  return success;
-}
-
-/**
- * _gimp_register_load_handler:
- * @procedure_name: The name of the procedure to be used for loading.
- * @extensions: comma separated list of extensions this handler can load (i.e. \"jpg,jpeg\").
- * @prefixes: comma separated list of prefixes this handler can load (i.e. \"http:,ftp:\").
- *
- * Registers a file load handler procedure.
- *
- * Registers a procedural database procedure to be called to load files
- * of a particular file format.
- *
- * Returns: TRUE on success.
- **/
-gboolean
 _gimp_register_load_handler (const gchar *procedure_name,
                              const gchar *extensions,
-                             const gchar *prefixes)
+                             const gchar *prefixes,
+                             const gchar *magics)
 {
   GimpValueArray *args;
   GimpValueArray *return_vals;
@@ -340,6 +299,7 @@ _gimp_register_load_handler (const gchar *procedure_name,
                                           G_TYPE_STRING, procedure_name,
                                           G_TYPE_STRING, extensions,
                                           G_TYPE_STRING, prefixes,
+                                          G_TYPE_STRING, magics,
                                           G_TYPE_NONE);
 
   return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
diff --git a/libgimp/gimpfileops_pdb.h b/libgimp/gimpfileops_pdb.h
index d9d180f719..7f287cca9c 100644
--- a/libgimp/gimpfileops_pdb.h
+++ b/libgimp/gimpfileops_pdb.h
@@ -49,13 +49,10 @@ gboolean                 gimp_file_save                       (GimpRunMode   run
                                                                const gchar  *raw_filename);
 gboolean                 gimp_file_save_thumbnail             (GimpImage    *image,
                                                                const gchar  *filename);
-G_GNUC_INTERNAL gboolean _gimp_register_magic_load_handler    (const gchar  *procedure_name,
+G_GNUC_INTERNAL gboolean _gimp_register_load_handler          (const gchar  *procedure_name,
                                                                const gchar  *extensions,
                                                                const gchar  *prefixes,
                                                                const gchar  *magics);
-G_GNUC_INTERNAL gboolean _gimp_register_load_handler          (const gchar  *procedure_name,
-                                                               const gchar  *extensions,
-                                                               const gchar  *prefixes);
 G_GNUC_INTERNAL gboolean _gimp_register_save_handler          (const gchar  *procedure_name,
                                                                const gchar  *extensions,
                                                                const gchar  *prefixes);
diff --git a/libgimp/gimploadprocedure.c b/libgimp/gimploadprocedure.c
index fec6da2349..b9d91ccbf0 100644
--- a/libgimp/gimploadprocedure.c
+++ b/libgimp/gimploadprocedure.c
@@ -119,19 +119,10 @@ gimp_load_procedure_install (GimpProcedure *procedure)
 
   GIMP_PROCEDURE_CLASS (parent_class)->install (procedure);
 
-  if (gimp_file_procedure_get_magics (file_proc))
-    {
-      _gimp_register_magic_load_handler (gimp_procedure_get_name (procedure),
-                                         gimp_file_procedure_get_extensions (file_proc),
-                                         gimp_file_procedure_get_prefixes (file_proc),
-                                         gimp_file_procedure_get_magics (file_proc));
-    }
-  else
-    {
-      _gimp_register_load_handler (gimp_procedure_get_name (procedure),
-                                   gimp_file_procedure_get_extensions (file_proc),
-                                   gimp_file_procedure_get_prefixes (file_proc));
-    }
+  _gimp_register_load_handler (gimp_procedure_get_name (procedure),
+                               gimp_file_procedure_get_extensions (file_proc),
+                               gimp_file_procedure_get_prefixes (file_proc),
+                               gimp_file_procedure_get_magics (file_proc));
 
   if (gimp_file_procedure_get_handles_remote (file_proc))
     _gimp_register_file_handler_remote (gimp_procedure_get_name (procedure));
diff --git a/pdb/groups/fileops.pdb b/pdb/groups/fileops.pdb
index 9a63d08261..8776a3d623 100644
--- a/pdb/groups/fileops.pdb
+++ b/pdb/groups/fileops.pdb
@@ -436,7 +436,7 @@ CODE
     );
 }
 
-sub register_magic_load_handler {
+sub register_load_handler {
     $blurb = 'Registers a file load handler procedure.';
 
     $help = <<'HELP';
@@ -475,43 +475,6 @@ CODE
     );
 }
 
-sub register_load_handler {
-    $blurb = 'Registers a file load handler procedure.';
-
-    $help = <<'HELP';
-Registers a procedural database procedure to be called to load files of a
-particular file format.
-HELP
-
-    &std_pdb_misc;
-
-    $lib_private = 1;
-
-    @inargs = (
-        { name => 'procedure_name', type => 'string', non_empty => 1,
-          desc => 'The name of the procedure to be used for loading' },
-        { name => 'extensions', type => 'string', no_validate => 1,
-          desc => 'comma separated list of extensions this handler
-                   can load (i.e. "jpg,jpeg")' },
-        { name => 'prefixes', type => 'string', no_validate => 1,
-          desc => 'comma separated list of prefixes this handler
-                   can load (i.e. "http:,ftp:")' }
-    );
-
-
-    %invoke = (
-        code => <<'CODE'
-{
-  success = (gimp_pdb_is_canonical_procedure (procedure_name, error) &&
-             gimp_plug_in_manager_register_load_handler (gimp->plug_in_manager,
-                                                         procedure_name,
-                                                         extensions, prefixes,
-                                                         NULL));
-}
-CODE
-    );
-}
-
 sub register_save_handler {
     $blurb = 'Registers a file save handler procedure.';
 
@@ -724,7 +687,6 @@ CODE
             file_save
             file_load_thumbnail
             file_save_thumbnail
-            register_magic_load_handler
             register_load_handler
             register_save_handler
             register_file_handler_priority
@@ -733,7 +695,7 @@ CODE
             register_file_handler_raw
             register_thumbnail_loader);
 
-%exports = (app => [@procs], lib => [@procs[0..3,5..13]]);
+%exports = (app => [@procs], lib => [@procs[0..3,5..12]]);
 
 $desc = 'File Operations';
 $doc_title = 'gimpfileops';


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