[gimp] app, libgimpconfig: move gimp_param_spec_duplicate() to libgimpconfig



commit 8cdab31393831025f3c718e5354b1cf0f76f8d7e
Author: Michael Natterer <mitch gimp org>
Date:   Sat Sep 14 17:34:06 2019 +0200

    app, libgimpconfig: move gimp_param_spec_duplicate() to libgimpconfig

 app/core/Makefile.am                               |  2 -
 app/core/gimpparamspecs-duplicate.h                | 28 ---------
 app/core/meson.build                               |  1 -
 app/operations/gimp-operation-config.c             |  3 +-
 app/tools/gimpoperationtool.c                      |  1 -
 .../libgimpconfig/libgimpconfig3-sections.txt      |  1 +
 libgimpconfig/Makefile.gi                          |  9 +--
 .../gimpconfig-params.c                            | 66 ++++++++++++++--------
 libgimpconfig/gimpconfig-params.h                  |  8 ++-
 libgimpconfig/gimpconfig.def                       |  1 +
 libgimpconfig/meson.build                          |  1 +
 11 files changed, 60 insertions(+), 61 deletions(-)
---
diff --git a/app/core/Makefile.am b/app/core/Makefile.am
index edd736f5f4..dbd68a89bd 100644
--- a/app/core/Makefile.am
+++ b/app/core/Makefile.am
@@ -413,8 +413,6 @@ libappcore_a_sources = \
        gimpparamspecs.h                        \
        gimpparamspecs-desc.c                   \
        gimpparamspecs-desc.h                   \
-       gimpparamspecs-duplicate.c              \
-       gimpparamspecs-duplicate.h              \
        gimpparasitelist.c                      \
        gimpparasitelist.h                      \
        gimppdbprogress.c                       \
diff --git a/app/core/meson.build b/app/core/meson.build
index 007ec8c9e3..d65661f071 100644
--- a/app/core/meson.build
+++ b/app/core/meson.build
@@ -193,7 +193,6 @@ libappcore_sources = [
   'gimppalette.c',
   'gimppalettemru.c',
   'gimpparamspecs-desc.c',
-  'gimpparamspecs-duplicate.c',
   'gimpparamspecs.c',
   'gimpparasitelist.c',
   'gimppattern-load.c',
diff --git a/app/operations/gimp-operation-config.c b/app/operations/gimp-operation-config.c
index 2ffe858abc..f4ff88a095 100644
--- a/app/operations/gimp-operation-config.c
+++ b/app/operations/gimp-operation-config.c
@@ -32,7 +32,6 @@
 #include "core/gimp.h"
 
 #include "core/gimplist.h"
-#include "core/gimpparamspecs-duplicate.h"
 #include "core/gimpviewable.h"
 
 #include "gegl/gimp-gegl-utils.h"
@@ -186,7 +185,7 @@ gimp_operation_config_class_init (GObjectClass *klass,
           strcmp (pspec->name, "input")     &&
           strcmp (pspec->name, "output"))
         {
-          GParamSpec *copy = gimp_param_spec_duplicate (pspec);
+          GParamSpec *copy = gimp_config_param_spec_duplicate (pspec);
 
           if (copy)
             {
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index 3640014072..22bef367a3 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -38,7 +38,6 @@
 #include "core/gimperror.h"
 #include "core/gimpimage.h"
 #include "core/gimplist.h"
-#include "core/gimpparamspecs-duplicate.h"
 #include "core/gimppickable.h"
 #include "core/gimpsettings.h"
 
diff --git a/devel-docs/libgimpconfig/libgimpconfig3-sections.txt 
b/devel-docs/libgimpconfig/libgimpconfig3-sections.txt
index d2412a7880..f364380cfc 100644
--- a/devel-docs/libgimpconfig/libgimpconfig3-sections.txt
+++ b/devel-docs/libgimpconfig/libgimpconfig3-sections.txt
@@ -67,6 +67,7 @@ GIMP_CONFIG_PROP_STRING
 GIMP_CONFIG_PROP_UINT64
 GIMP_CONFIG_PROP_UINT
 GIMP_CONFIG_PROP_UNIT
+gimp_config_param_spec_duplicate
 </SECTION>
 
 <SECTION>
diff --git a/libgimpconfig/Makefile.gi b/libgimpconfig/Makefile.gi
index db9a9d4dee..bd83600014 100644
--- a/libgimpconfig/Makefile.gi
+++ b/libgimpconfig/Makefile.gi
@@ -8,10 +8,10 @@ libgimpconfig_introspectable_headers =        \
        ../libgimpconfig/gimpconfig-error.h             \
        ../libgimpconfig/gimpconfig-params.h            \
        ../libgimpconfig/gimpconfig-path.h              \
-       ../libgimpconfig/gimpconfig-serialize.h \
+       ../libgimpconfig/gimpconfig-serialize.h         \
        ../libgimpconfig/gimpconfig-utils.h             \
        ../libgimpconfig/gimpconfigwriter.h             \
-       ../libgimpconfig/gimpscanner.h          \
+       ../libgimpconfig/gimpscanner.h                  \
        ../libgimpconfig/gimpcolorconfig.h
 
 libgimpconfig_introspectable = \
@@ -19,9 +19,10 @@ libgimpconfig_introspectable =       \
        ../libgimpconfig/gimpconfig-deserialize.c       \
        ../libgimpconfig/gimpconfig-error.c             \
        ../libgimpconfig/gimpconfig-path.c              \
-       ../libgimpconfig/gimpconfig-serialize.c \
+       ../libgimpconfig/gimpconfig-params.c            \
+       ../libgimpconfig/gimpconfig-serialize.c         \
        ../libgimpconfig/gimpconfig-utils.c             \
        ../libgimpconfig/gimpconfigwriter.c             \
-       ../libgimpconfig/gimpscanner.c          \
+       ../libgimpconfig/gimpscanner.c                  \
        ../libgimpconfig/gimpcolorconfig.c              \
        $(libgimpconfig_introspectable_headers)
diff --git a/app/core/gimpparamspecs-duplicate.c b/libgimpconfig/gimpconfig-params.c
similarity index 84%
rename from app/core/gimpparamspecs-duplicate.c
rename to libgimpconfig/gimpconfig-params.c
index 69260f153c..fb242bf981 100644
--- a/app/core/gimpparamspecs-duplicate.c
+++ b/libgimpconfig/gimpconfig-params.c
@@ -1,45 +1,65 @@
-/* GIMP - The GNU Image Manipulation Program
- * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+/* LIBGIMP - The GIMP Library
+ * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
  *
- * gimpparamspecs-duplicate.c
- * Copyright (C) 2008-2014 Michael Natterer <mitch gimp org>
+ * gimpconfig-params.c
+ * Copyright (C) 2008-2019 Michael Natterer <mitch gimp org>
  *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * This library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <https://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
 
 #include <cairo.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
 #include <gegl.h>
 #include <gegl-paramspecs.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
 
 #include "libgimpcolor/gimpcolor.h"
 #include "libgimpconfig/gimpconfig.h"
 
-#include "core-types.h"
+#include "gimpconfig.h"
 
-#include "gegl/gimp-gegl-utils.h"
 
-#include "gimpparamspecs.h"
-#include "gimpparamspecs-duplicate.h"
+static gboolean
+gimp_gegl_param_spec_has_key (GParamSpec  *pspec,
+                              const gchar *key,
+                              const gchar *value)
+{
+  const gchar *v = gegl_param_spec_get_property_key (pspec, key);
+
+  if (v && ! strcmp (v, value))
+    return TRUE;
 
+  return FALSE;
+}
 
-/* FIXME: this code is not yet general as it should be (gegl tool only atm) */
 
+/**
+ * gimp_config_param_spec_duplicate:
+ * @pspec: the #GParamSpec to duplicate
+ *
+ * Creates an exact copy of @pspec, with all its properties, returns
+ * %NULL if @pspec is of an unknown type that can't be duplicated.
+ *
+ * Return: (transfer full): The new #GParamSpec, or %NULL.
+ *
+ * Since: 3.0
+ **/
 GParamSpec *
-gimp_param_spec_duplicate (GParamSpec *pspec)
+gimp_config_param_spec_duplicate (GParamSpec *pspec)
 {
   GParamSpec  *copy = NULL;
   GParamFlags  flags;
@@ -48,6 +68,9 @@ gimp_param_spec_duplicate (GParamSpec *pspec)
 
   flags = pspec->flags;
 
+  /*  this special case exists for the GEGL tool, we don't want this
+   *  property serialized
+   */
   if (! gimp_gegl_param_spec_has_key (pspec, "role", "output-extent"))
     flags |= GIMP_CONFIG_PARAM_SERIALIZE;
 
@@ -166,8 +189,7 @@ gimp_param_spec_duplicate (GParamSpec *pspec)
       copy = gegl_param_spec_seed (pspec->name,
                                    g_param_spec_get_nick (pspec),
                                    g_param_spec_get_blurb (pspec),
-                                   pspec->flags |
-                                   GIMP_CONFIG_PARAM_SERIALIZE);
+                                   flags);
 
       G_PARAM_SPEC_UINT (copy)->minimum = spec->minimum;
       G_PARAM_SPEC_UINT (copy)->maximum = spec->maximum;
diff --git a/libgimpconfig/gimpconfig-params.h b/libgimpconfig/gimpconfig-params.h
index 943b4d38d6..4c89a17965 100644
--- a/libgimpconfig/gimpconfig-params.h
+++ b/libgimpconfig/gimpconfig-params.h
@@ -2,7 +2,8 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * ParamSpecs for config objects
- * Copyright (C) 2001  Sven Neumann <sven gimp org>
+ * Copyright (C) 2001       Sven Neumann <sven gimp org>
+ *               2001-2019  Michael Natterer <mitch gimp org>
  *
  * This library is free software: you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -184,6 +185,11 @@ G_BEGIN_DECLS
                                    GIMP_CONFIG_PARAM_SERIALIZE))
 
 
+/*  create a copy of a GParamSpec  */
+
+GParamSpec * gimp_config_param_spec_duplicate (GParamSpec *pspec);
+
+
 G_END_DECLS
 
 #endif /* __GIMP_CONFIG_PARAMS_H__ */
diff --git a/libgimpconfig/gimpconfig.def b/libgimpconfig/gimpconfig.def
index 6320d1e4c6..d1d8d69363 100644
--- a/libgimpconfig/gimpconfig.def
+++ b/libgimpconfig/gimpconfig.def
@@ -39,6 +39,7 @@ EXPORTS
        gimp_config_path_expand_to_files
        gimp_config_path_get_type
        gimp_config_path_unexpand
+       gimp_config_param_spec_duplicate
        gimp_config_reset
        gimp_config_reset_properties
        gimp_config_reset_property
diff --git a/libgimpconfig/meson.build b/libgimpconfig/meson.build
index 8124a01203..e2af1f3dae 100644
--- a/libgimpconfig/meson.build
+++ b/libgimpconfig/meson.build
@@ -20,6 +20,7 @@ libgimpconfig_sources_introspectable = files(
   'gimpconfig-error.c',
   'gimpconfig-iface.c',
   'gimpconfig-path.c',
+  'gimpconfig-params.c',
   'gimpconfig-serialize.c',
   'gimpconfig-utils.c',
   'gimpconfigwriter.c',


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