[gimp] app: use the GParamSpec's name in gimp_pdb_dump()



commit 967cbb4fad499bfd3ee0e66949cbc97b85eef5a1
Author: Michael Natterer <mitch gimp org>
Date:   Fri Aug 30 11:42:14 2019 +0200

    app: use the GParamSpec's name in gimp_pdb_dump()
    
    and remove gimp_pdb_compat_arg_type_from_gtype(). The core is now free
    of PDB legacy code.

 app/Makefile.am           |  1 +
 app/config/Makefile.am    |  1 +
 app/pdb/gimp-pdb-compat.c | 80 -----------------------------------------------
 app/pdb/gimp-pdb-compat.h |  6 ++--
 app/pdb/gimppdb-query.c   | 42 ++++++-------------------
 app/tests/Makefile.am     |  1 +
 6 files changed, 15 insertions(+), 116 deletions(-)
---
diff --git a/app/Makefile.am b/app/Makefile.am
index 749e7a11f6..7c224291b6 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -148,6 +148,7 @@ AM_LDFLAGS = \
        -Wl,-u,$(SYMPREFIX)gimp_operations_init                 \
        -Wl,-u,$(SYMPREFIX)xcf_init                             \
        -Wl,-u,$(SYMPREFIX)internal_procs_init                  \
+       -Wl,-u,$(SYMPREFIX)gimp_pdb_compat_procs_register       \
        -Wl,-u,$(SYMPREFIX)gimp_plug_in_manager_restore         \
        -Wl,-u,$(SYMPREFIX)gimp_layer_mode_is_legacy            \
        -Wl,-u,$(SYMPREFIX)gimp_parallel_init                   \
diff --git a/app/config/Makefile.am b/app/config/Makefile.am
index 371b790321..b3196b54e5 100644
--- a/app/config/Makefile.am
+++ b/app/config/Makefile.am
@@ -90,6 +90,7 @@ test_config_LDFLAGS = \
        -Wl,-u,$(SYMPREFIX)gimp_param_spec_duplicate            \
        -Wl,-u,$(SYMPREFIX)xcf_init                             \
        -Wl,-u,$(SYMPREFIX)internal_procs_init                  \
+       -Wl,-u,$(SYMPREFIX)gimp_pdb_compat_procs_register       \
        -Wl,-u,$(SYMPREFIX)gimp_plug_in_manager_restore         \
        -Wl,-u,$(SYMPREFIX)gimp_layer_mode_is_legacy            \
        -Wl,-u,$(SYMPREFIX)gimp_async_set_new                   \
diff --git a/app/pdb/gimp-pdb-compat.c b/app/pdb/gimp-pdb-compat.c
index 24ab0e857b..77e0aaf364 100644
--- a/app/pdb/gimp-pdb-compat.c
+++ b/app/pdb/gimp-pdb-compat.c
@@ -21,94 +21,14 @@
 #include <gegl.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
-#include "libgimpbase/gimpbase.h"
-#include "libgimpcolor/gimpcolor.h"
-
 #include "pdb-types.h"
 
-#include "core/gimp.h"
-#include "core/gimpimage.h"
-#include "core/gimplayer.h"
-#include "core/gimplayermask.h"
-#include "core/gimpselection.h"
-#include "core/gimpparamspecs.h"
-
-#include "vectors/gimpvectors.h"
-
 #include "gimppdb.h"
 #include "gimp-pdb-compat.h"
 
 
 /*  public functions  */
 
-GimpPDBArgType
-gimp_pdb_compat_arg_type_from_gtype (GType type)
-{
-  static GQuark  pdb_type_quark = 0;
-  GimpPDBArgType pdb_type;
-
-  if (! pdb_type_quark)
-    {
-      struct
-      {
-        GType          g_type;
-        GimpPDBArgType pdb_type;
-      }
-      type_mapping[] =
-      {
-        { G_TYPE_INT,                GIMP_PDB_INT32       },
-        { G_TYPE_UINT,               GIMP_PDB_INT32       },
-        { G_TYPE_ENUM,               GIMP_PDB_INT32       },
-        { G_TYPE_BOOLEAN,            GIMP_PDB_INT32       },
-
-        { G_TYPE_UCHAR,              GIMP_PDB_INT8        },
-        { G_TYPE_DOUBLE,             GIMP_PDB_FLOAT       },
-
-        { G_TYPE_STRING,             GIMP_PDB_STRING      },
-
-        { GIMP_TYPE_RGB,             GIMP_PDB_COLOR       },
-
-        { GIMP_TYPE_INT32_ARRAY,     GIMP_PDB_INT32ARRAY  },
-        { GIMP_TYPE_INT16_ARRAY,     GIMP_PDB_INT16ARRAY  },
-        { GIMP_TYPE_UINT8_ARRAY,     GIMP_PDB_INT8ARRAY   },
-        { GIMP_TYPE_FLOAT_ARRAY,     GIMP_PDB_FLOATARRAY  },
-        { GIMP_TYPE_STRING_ARRAY,    GIMP_PDB_STRINGARRAY },
-        { GIMP_TYPE_RGB_ARRAY,       GIMP_PDB_COLORARRAY  },
-
-        { GIMP_TYPE_ITEM,            GIMP_PDB_ITEM        },
-        { GIMP_TYPE_IMAGE,           GIMP_PDB_IMAGE       },
-        { GIMP_TYPE_LAYER,           GIMP_PDB_LAYER       },
-        { GIMP_TYPE_CHANNEL,         GIMP_PDB_CHANNEL     },
-        { GIMP_TYPE_DRAWABLE,        GIMP_PDB_DRAWABLE    },
-        { GIMP_TYPE_SELECTION,       GIMP_PDB_SELECTION   },
-        { GIMP_TYPE_LAYER_MASK,      GIMP_PDB_CHANNEL     },
-        { GIMP_TYPE_VECTORS,         GIMP_PDB_VECTORS     },
-
-        { GIMP_TYPE_PARASITE,        GIMP_PDB_PARASITE    },
-
-        { GIMP_TYPE_PDB_STATUS_TYPE, GIMP_PDB_STATUS      }
-      };
-
-      GType type;
-      gint  i;
-
-      pdb_type_quark = g_quark_from_static_string ("gimp-pdb-type");
-
-      for (i = 0; i < G_N_ELEMENTS (type_mapping); i++)
-        g_type_set_qdata (type_mapping[i].g_type, pdb_type_quark,
-                          GINT_TO_POINTER (type_mapping[i].pdb_type));
-
-      type = g_type_from_name ("GimpDisplay");
-      if (type)
-        g_type_set_qdata (type, pdb_type_quark,
-                          GINT_TO_POINTER (GIMP_PDB_DISPLAY));
-    }
-
-  pdb_type = GPOINTER_TO_INT (g_type_get_qdata (type, pdb_type_quark));
-
-  return pdb_type;
-}
-
 void
 gimp_pdb_compat_procs_register (GimpPDB           *pdb,
                                 GimpPDBCompatMode  compat_mode)
diff --git a/app/pdb/gimp-pdb-compat.h b/app/pdb/gimp-pdb-compat.h
index e79881ba56..f2ccb03a09 100644
--- a/app/pdb/gimp-pdb-compat.h
+++ b/app/pdb/gimp-pdb-compat.h
@@ -19,10 +19,8 @@
 #define __GIMP_PDB_COMPAT_H__
 
 
-GimpPDBArgType   gimp_pdb_compat_arg_type_from_gtype (GType type);
-
-void             gimp_pdb_compat_procs_register (GimpPDB           *pdb,
-                                                 GimpPDBCompatMode  compat_mode);
+void   gimp_pdb_compat_procs_register (GimpPDB           *pdb,
+                                       GimpPDBCompatMode  compat_mode);
 
 
 #endif  /*  __GIMP_PDB_COMPAT_H__  */
diff --git a/app/pdb/gimppdb-query.c b/app/pdb/gimppdb-query.c
index b35cc584af..016e76bb04 100644
--- a/app/pdb/gimppdb-query.c
+++ b/app/pdb/gimppdb-query.c
@@ -32,7 +32,6 @@
 #include "gimppdb.h"
 #include "gimppdb-query.h"
 #include "gimppdberror.h"
-#include "gimp-pdb-compat.h"
 #include "gimpprocedure.h"
 
 #include "gimp-intl.h"
@@ -452,7 +451,6 @@ gimp_pdb_print_entry (gpointer key,
     {
       GimpProcedure      *procedure = list->data;
       PDBStrings          strings;
-      GEnumValue         *arg_value;
       const GimpEnumDesc *type_desc;
       gint                i;
 
@@ -484,34 +482,24 @@ gimp_pdb_print_entry (gpointer key,
 
       for (i = 0; i < procedure->num_args; i++)
         {
-          GParamSpec     *pspec = procedure->args[i];
-          GimpPDBArgType  arg_type;
-
-          arg_type = gimp_pdb_compat_arg_type_from_gtype (pspec->value_type);
-
-          arg_value = g_enum_get_value (arg_class, arg_type);
+          GParamSpec *pspec = procedure->args[i];
 
           if (i > 0)
             g_string_append_printf (string, " ");
 
-          output_string (string, arg_value->value_name);
+          output_string (string, G_PARAM_SPEC_TYPE_NAME (pspec));
         }
 
       g_string_append_printf (string, ") (");
 
       for (i = 0; i < procedure->num_values; i++)
         {
-          GParamSpec     *pspec = procedure->values[i];
-          GimpPDBArgType  arg_type;
-
-          arg_type = gimp_pdb_compat_arg_type_from_gtype (pspec->value_type);
-
-          arg_value = g_enum_get_value (arg_class, arg_type);
+          GParamSpec *pspec = procedure->values[i];
 
           if (i > 0)
             g_string_append_printf (string, " ");
 
-          output_string (string, arg_value->value_name);
+          output_string (string, G_PARAM_SPEC_TYPE_NAME (pspec))
         }
 
       g_string_append_printf (string, "))\n");
@@ -540,21 +528,16 @@ gimp_pdb_print_entry (gpointer key,
 
       for (i = 0; i < procedure->num_args; i++)
         {
-          GParamSpec     *pspec = procedure->args[i];
-          GimpPDBArgType  arg_type;
-          gchar          *desc  = gimp_param_spec_get_desc (pspec);
+          GParamSpec *pspec = procedure->args[i];
+          gchar      *desc  = gimp_param_spec_get_desc (pspec);
 
           g_string_append_printf (string, "\n    (\n");
 
-          arg_type = gimp_pdb_compat_arg_type_from_gtype (pspec->value_type);
-
-          arg_value = g_enum_get_value (arg_class, arg_type);
-
           g_string_append_printf (string, "      ");
           output_string (string, g_param_spec_get_name (pspec));
 
           g_string_append_printf (string, "      ");
-          output_string (string, arg_value->value_name);
+          output_string (string, G_PARAM_SPEC_TYPE_NAME (pspec));
 
           g_string_append_printf (string, "      ");
           output_string (string, desc);
@@ -570,21 +553,16 @@ gimp_pdb_print_entry (gpointer key,
 
       for (i = 0; i < procedure->num_values; i++)
         {
-          GParamSpec     *pspec = procedure->values[i];
-          GimpPDBArgType  arg_type;
-          gchar          *desc  = gimp_param_spec_get_desc (pspec);
+          GParamSpec *pspec = procedure->values[i];
+          gchar      *desc  = gimp_param_spec_get_desc (pspec);
 
           g_string_append_printf (string, "\n    (\n");
 
-          arg_type = gimp_pdb_compat_arg_type_from_gtype (pspec->value_type);
-
-          arg_value = g_enum_get_value (arg_class, arg_type);
-
           g_string_append_printf (string, "      ");
           output_string (string, g_param_spec_get_name (pspec));
 
           g_string_append_printf (string, "      ");
-          output_string (string, arg_value->value_name);
+          output_string (string, G_PARAM_SPEC_TYPE_NAME (pspec));
 
           g_string_append_printf (string, "      ");
           output_string (string, desc);
diff --git a/app/tests/Makefile.am b/app/tests/Makefile.am
index 3bb2097975..d828f310e6 100644
--- a/app/tests/Makefile.am
+++ b/app/tests/Makefile.am
@@ -86,6 +86,7 @@ AM_LDFLAGS = \
        -Wl,-u,$(SYMPREFIX)gimp_operations_init                 \
        -Wl,-u,$(SYMPREFIX)xcf_init                             \
        -Wl,-u,$(SYMPREFIX)internal_procs_init                  \
+       -Wl,-u,$(SYMPREFIX)gimp_pdb_compat_procs_register       \
        -Wl,-u,$(SYMPREFIX)gimp_plug_in_manager_restore         \
        -Wl,-u,$(SYMPREFIX)gimp_layer_mode_is_legacy            \
        -Wl,-u,$(SYMPREFIX)gui_init                             \


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