From 8cdab31393831025f3c718e5354b1cf0f76f8d7e Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sat, 14 Sep 2019 17:34:06 +0200 Subject: [PATCH] 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 | 70 ++++++++++++------- libgimpconfig/gimpconfig-params.h | 8 ++- libgimpconfig/gimpconfig.def | 1 + libgimpconfig/meson.build | 1 + 11 files changed, 62 insertions(+), 63 deletions(-) delete mode 100644 app/core/gimpparamspecs-duplicate.h rename app/core/gimpparamspecs-duplicate.c => libgimpconfig/gimpconfig-params.c (84%) 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/gimpparamspecs-duplicate.h b/app/core/gimpparamspecs-duplicate.h deleted file mode 100644 index 2bb1432ede..0000000000 --- a/app/core/gimpparamspecs-duplicate.h +++ /dev/null @@ -1,28 +0,0 @@ -/* GIMP - The GNU Image Manipulation Program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimpparamspecs-duplicate.h - * Copyright (C) 2008-2009 Michael Natterer - * - * 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 program 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. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __GIMP_PARAM_SPECS_DUPLICATE_H__ -#define __GIMP_PARAM_SPECS_DUPLICATE_H__ - - -GParamSpec * gimp_param_spec_duplicate (GParamSpec *pspec); - - -#endif /* __GIMP_PARAM_SPECS_DUPLICATE_H__ */ 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
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 + * gimpconfig-params.c + * Copyright (C) 2008-2019 Michael Natterer * - * 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 . + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . */ #include "config.h" #include +#include + #include #include -#include #include "libgimpcolor/gimpcolor.h" #include "libgimpconfig/gimpconfig.h" -#include "core-types.h" - -#include "gegl/gimp-gegl-utils.h" - -#include "gimpparamspecs.h" -#include "gimpparamspecs-duplicate.h" +#include "gimpconfig.h" -/* FIXME: this code is not yet general as it should be (gegl tool only atm) */ +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; +} + + +/** + * 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 + * Copyright (C) 2001 Sven Neumann + * 2001-2019 Michael Natterer * * 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',