app, libgimpconfig: move gimp_param_spec_duplicate() to libgimpconfig

This commit is contained in:
Michael Natterer 2019-09-14 17:34:06 +02:00
parent f73f813e1f
commit 8cdab31393
11 changed files with 62 additions and 63 deletions

View File

@ -413,8 +413,6 @@ libappcore_a_sources = \
gimpparamspecs.h \ gimpparamspecs.h \
gimpparamspecs-desc.c \ gimpparamspecs-desc.c \
gimpparamspecs-desc.h \ gimpparamspecs-desc.h \
gimpparamspecs-duplicate.c \
gimpparamspecs-duplicate.h \
gimpparasitelist.c \ gimpparasitelist.c \
gimpparasitelist.h \ gimpparasitelist.h \
gimppdbprogress.c \ gimppdbprogress.c \

View File

@ -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 <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 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 <https://www.gnu.org/licenses/>.
*/
#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__ */

View File

@ -193,7 +193,6 @@ libappcore_sources = [
'gimppalette.c', 'gimppalette.c',
'gimppalettemru.c', 'gimppalettemru.c',
'gimpparamspecs-desc.c', 'gimpparamspecs-desc.c',
'gimpparamspecs-duplicate.c',
'gimpparamspecs.c', 'gimpparamspecs.c',
'gimpparasitelist.c', 'gimpparasitelist.c',
'gimppattern-load.c', 'gimppattern-load.c',

View File

@ -32,7 +32,6 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimplist.h" #include "core/gimplist.h"
#include "core/gimpparamspecs-duplicate.h"
#include "core/gimpviewable.h" #include "core/gimpviewable.h"
#include "gegl/gimp-gegl-utils.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, "input") &&
strcmp (pspec->name, "output")) strcmp (pspec->name, "output"))
{ {
GParamSpec *copy = gimp_param_spec_duplicate (pspec); GParamSpec *copy = gimp_config_param_spec_duplicate (pspec);
if (copy) if (copy)
{ {

View File

@ -38,7 +38,6 @@
#include "core/gimperror.h" #include "core/gimperror.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimplist.h" #include "core/gimplist.h"
#include "core/gimpparamspecs-duplicate.h"
#include "core/gimppickable.h" #include "core/gimppickable.h"
#include "core/gimpsettings.h" #include "core/gimpsettings.h"

View File

@ -67,6 +67,7 @@ GIMP_CONFIG_PROP_STRING
GIMP_CONFIG_PROP_UINT64 GIMP_CONFIG_PROP_UINT64
GIMP_CONFIG_PROP_UINT GIMP_CONFIG_PROP_UINT
GIMP_CONFIG_PROP_UNIT GIMP_CONFIG_PROP_UNIT
gimp_config_param_spec_duplicate
</SECTION> </SECTION>
<SECTION> <SECTION>

View File

@ -19,6 +19,7 @@ libgimpconfig_introspectable = \
../libgimpconfig/gimpconfig-deserialize.c \ ../libgimpconfig/gimpconfig-deserialize.c \
../libgimpconfig/gimpconfig-error.c \ ../libgimpconfig/gimpconfig-error.c \
../libgimpconfig/gimpconfig-path.c \ ../libgimpconfig/gimpconfig-path.c \
../libgimpconfig/gimpconfig-params.c \
../libgimpconfig/gimpconfig-serialize.c \ ../libgimpconfig/gimpconfig-serialize.c \
../libgimpconfig/gimpconfig-utils.c \ ../libgimpconfig/gimpconfig-utils.c \
../libgimpconfig/gimpconfigwriter.c \ ../libgimpconfig/gimpconfigwriter.c \

View File

@ -1,45 +1,65 @@
/* GIMP - The GNU Image Manipulation Program /* LIBGIMP - The GIMP Library
* Copyright (C) 1995 Spencer Kimball and Peter Mattis * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
* *
* gimpparamspecs-duplicate.c * gimpconfig-params.c
* Copyright (C) 2008-2014 Michael Natterer <mitch@gimp.org> * Copyright (C) 2008-2019 Michael Natterer <mitch@gimp.org>
* *
* This program is free software: you can redistribute it and/or modify * This library is free software: you can redistribute it and/or
* it under the terms of the GNU General Public License as published by * modify it under the terms of the GNU Lesser General Public
* the Free Software Foundation; either version 3 of the License, or * License as published by the Free Software Foundation; either
* (at your option) any later version. * 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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* GNU General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU Lesser General Public
* along with this program. If not, see <https://www.gnu.org/licenses/>. * License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/ */
#include "config.h" #include "config.h"
#include <cairo.h> #include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h> #include <gegl.h>
#include <gegl-paramspecs.h> #include <gegl-paramspecs.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpcolor/gimpcolor.h" #include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.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"
/* 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 * GParamSpec *
gimp_param_spec_duplicate (GParamSpec *pspec) gimp_config_param_spec_duplicate (GParamSpec *pspec)
{ {
GParamSpec *copy = NULL; GParamSpec *copy = NULL;
GParamFlags flags; GParamFlags flags;
@ -48,6 +68,9 @@ gimp_param_spec_duplicate (GParamSpec *pspec)
flags = pspec->flags; 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")) if (! gimp_gegl_param_spec_has_key (pspec, "role", "output-extent"))
flags |= GIMP_CONFIG_PARAM_SERIALIZE; flags |= GIMP_CONFIG_PARAM_SERIALIZE;
@ -166,8 +189,7 @@ gimp_param_spec_duplicate (GParamSpec *pspec)
copy = gegl_param_spec_seed (pspec->name, copy = gegl_param_spec_seed (pspec->name,
g_param_spec_get_nick (pspec), g_param_spec_get_nick (pspec),
g_param_spec_get_blurb (pspec), g_param_spec_get_blurb (pspec),
pspec->flags | flags);
GIMP_CONFIG_PARAM_SERIALIZE);
G_PARAM_SPEC_UINT (copy)->minimum = spec->minimum; G_PARAM_SPEC_UINT (copy)->minimum = spec->minimum;
G_PARAM_SPEC_UINT (copy)->maximum = spec->maximum; G_PARAM_SPEC_UINT (copy)->maximum = spec->maximum;

View File

@ -3,6 +3,7 @@
* *
* ParamSpecs for config objects * 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 * This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -184,6 +185,11 @@ G_BEGIN_DECLS
GIMP_CONFIG_PARAM_SERIALIZE)) GIMP_CONFIG_PARAM_SERIALIZE))
/* create a copy of a GParamSpec */
GParamSpec * gimp_config_param_spec_duplicate (GParamSpec *pspec);
G_END_DECLS G_END_DECLS
#endif /* __GIMP_CONFIG_PARAMS_H__ */ #endif /* __GIMP_CONFIG_PARAMS_H__ */

View File

@ -39,6 +39,7 @@ EXPORTS
gimp_config_path_expand_to_files gimp_config_path_expand_to_files
gimp_config_path_get_type gimp_config_path_get_type
gimp_config_path_unexpand gimp_config_path_unexpand
gimp_config_param_spec_duplicate
gimp_config_reset gimp_config_reset
gimp_config_reset_properties gimp_config_reset_properties
gimp_config_reset_property gimp_config_reset_property

View File

@ -20,6 +20,7 @@ libgimpconfig_sources_introspectable = files(
'gimpconfig-error.c', 'gimpconfig-error.c',
'gimpconfig-iface.c', 'gimpconfig-iface.c',
'gimpconfig-path.c', 'gimpconfig-path.c',
'gimpconfig-params.c',
'gimpconfig-serialize.c', 'gimpconfig-serialize.c',
'gimpconfig-utils.c', 'gimpconfig-utils.c',
'gimpconfigwriter.c', 'gimpconfigwriter.c',