mirror of https://github.com/GNOME/gimp.git
libgimpbase, libgimpconfig: new GIMP_PARAM_DONT_SERIALIZE flag.
The purpose of this flag is to have some procedure arguments for which you wish to ignore last values, or restored values. This may be needed for arguments which are really volatile and likely won't survive a session (or even from a run to another). This will be used in my next commit. Note: this is very close to GIMP_CONFIG_PARAM_IGNORE, except that this latter is used for obsolete properties instead, so I felt that it may not have been the best idea to mix these semantically different flag. Also GIMP_CONFIG_PARAM_IGNORE properties are not serialized but they are deserialized, which is not exactly what we want (in most case, it would work the same, but it also means that if last-used values were to contain some deprecated value for a property for which we added this flag, there would be at least one run where a buggy behavior would happen).
This commit is contained in:
parent
f7aaba9fc9
commit
9b5463b5c5
|
@ -37,13 +37,24 @@ G_BEGIN_DECLS
|
||||||
*/
|
*/
|
||||||
#define GIMP_PARAM_NO_VALIDATE (1 << (0 + G_PARAM_USER_SHIFT))
|
#define GIMP_PARAM_NO_VALIDATE (1 << (0 + G_PARAM_USER_SHIFT))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GIMP_PARAM_DONT_SERIALIZE:
|
||||||
|
*
|
||||||
|
* This property will be ignored when serializing and deserializing.
|
||||||
|
* This is useful for GimpProcedure arguments for which you never want
|
||||||
|
* the last run values to be restored.
|
||||||
|
*
|
||||||
|
* Since 3.0
|
||||||
|
*/
|
||||||
|
#define GIMP_PARAM_DONT_SERIALIZE (1 << (1 + G_PARAM_USER_SHIFT))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GIMP_PARAM_FLAG_SHIFT:
|
* GIMP_PARAM_FLAG_SHIFT:
|
||||||
*
|
*
|
||||||
* Minimum shift count to be used for libgimpconfig defined
|
* Minimum shift count to be used for libgimpconfig defined
|
||||||
* [flags@GObject.ParamFlags] (see libgimpconfig/gimpconfig-params.h).
|
* [flags@GObject.ParamFlags] (see libgimpconfig/gimpconfig-params.h).
|
||||||
*/
|
*/
|
||||||
#define GIMP_PARAM_FLAG_SHIFT (1 + G_PARAM_USER_SHIFT)
|
#define GIMP_PARAM_FLAG_SHIFT (2 + G_PARAM_USER_SHIFT)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GIMP_PARAM_STATIC_STRINGS:
|
* GIMP_PARAM_STATIC_STRINGS:
|
||||||
|
|
|
@ -325,9 +325,10 @@ gimp_config_deserialize_property (GimpConfig *config,
|
||||||
if (token == G_TOKEN_RIGHT_PAREN &&
|
if (token == G_TOKEN_RIGHT_PAREN &&
|
||||||
g_scanner_peek_next_token (scanner) == token)
|
g_scanner_peek_next_token (scanner) == token)
|
||||||
{
|
{
|
||||||
if (GIMP_VALUE_HOLDS_COLOR (&value) ||
|
if (! (prop_spec->flags & GIMP_PARAM_DONT_SERIALIZE) &&
|
||||||
|
(GIMP_VALUE_HOLDS_COLOR (&value) ||
|
||||||
! (G_VALUE_HOLDS_OBJECT (&value) &&
|
! (G_VALUE_HOLDS_OBJECT (&value) &&
|
||||||
(prop_spec->flags & GIMP_CONFIG_PARAM_AGGREGATE)))
|
(prop_spec->flags & GIMP_CONFIG_PARAM_AGGREGATE))))
|
||||||
g_object_set_property (G_OBJECT (config), prop_spec->name, &value);
|
g_object_set_property (G_OBJECT (config), prop_spec->name, &value);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
|
|
|
@ -182,7 +182,8 @@ gimp_config_serialize_property (GimpConfig *config,
|
||||||
if (! (param_spec->flags & GIMP_CONFIG_PARAM_SERIALIZE))
|
if (! (param_spec->flags & GIMP_CONFIG_PARAM_SERIALIZE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (param_spec->flags & GIMP_CONFIG_PARAM_IGNORE)
|
if (param_spec->flags & GIMP_CONFIG_PARAM_IGNORE ||
|
||||||
|
param_spec->flags & GIMP_PARAM_DONT_SERIALIZE)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
g_value_init (&value, param_spec->value_type);
|
g_value_init (&value, param_spec->value_type);
|
||||||
|
|
Loading…
Reference in New Issue