add new method GimpConfigInterface::copy() which by default calls
2008-02-01 Michael Natterer <mitch@gimp.org> * libgimpconfig/gimpconfig-iface.[ch]: add new method GimpConfigInterface::copy() which by default calls gimp_config_sync() but is overridable for objects which are not entirely property-defined or otherwise evil. Freeze/thaw property notifications in deserialize() and reset(). * libgimpconfig/gimpconfig-utils.c (gimp_config_sync): freeze/thaw property notifications on the dest object. svn path=/trunk/; revision=24767
This commit is contained in:

committed by
Michael Natterer

parent
44cf4587a7
commit
69d2abcb29
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
||||
2008-02-01 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimpconfig/gimpconfig-iface.[ch]: add new method
|
||||
GimpConfigInterface::copy() which by default calls
|
||||
gimp_config_sync() but is overridable for objects which are not
|
||||
entirely property-defined or otherwise evil.
|
||||
|
||||
Freeze/thaw property notifications in deserialize() and reset().
|
||||
|
||||
* libgimpconfig/gimpconfig-utils.c (gimp_config_sync): freeze/thaw
|
||||
property notifications on the dest object.
|
||||
|
||||
2008-02-01 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/print/print.c: some minor cleanups and preparation for
|
||||
|
@ -58,6 +58,9 @@ static GimpConfig * gimp_config_iface_duplicate (GimpConfig *config);
|
||||
static gboolean gimp_config_iface_equal (GimpConfig *a,
|
||||
GimpConfig *b);
|
||||
static void gimp_config_iface_reset (GimpConfig *config);
|
||||
static gboolean gimp_config_iface_copy (GimpConfig *src,
|
||||
GimpConfig *dest,
|
||||
GParamFlags flags);
|
||||
|
||||
|
||||
GType
|
||||
@ -95,6 +98,7 @@ gimp_config_iface_base_init (GimpConfigInterface *config_iface)
|
||||
config_iface->duplicate = gimp_config_iface_duplicate;
|
||||
config_iface->equal = gimp_config_iface_equal;
|
||||
config_iface->reset = gimp_config_iface_reset;
|
||||
config_iface->copy = gimp_config_iface_copy;
|
||||
}
|
||||
|
||||
/* always set these to NULL since we don't want to inherit them
|
||||
@ -167,7 +171,7 @@ gimp_config_iface_duplicate (GimpConfig *config)
|
||||
|
||||
g_free (construct_params);
|
||||
|
||||
gimp_config_sync (object, dup, 0);
|
||||
gimp_config_copy (config, GIMP_CONFIG (dup), 0);
|
||||
|
||||
return GIMP_CONFIG (dup);
|
||||
}
|
||||
@ -236,6 +240,14 @@ gimp_config_iface_reset (GimpConfig *config)
|
||||
gimp_config_reset_properties (G_OBJECT (config));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_config_iface_copy (GimpConfig *src,
|
||||
GimpConfig *dest,
|
||||
GParamFlags flags)
|
||||
{
|
||||
return gimp_config_sync (G_OBJECT (src), G_OBJECT (dest), flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_config_serialize_to_file:
|
||||
* @config: a #GObject that implements the #GimpConfigInterface.
|
||||
@ -340,7 +352,7 @@ gimp_config_serialize_to_string (GimpConfig *config,
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_config_deserialize:
|
||||
* gimp_config_deserialize_file:
|
||||
* @config: a #GObject that implements the #GimpConfigInterface.
|
||||
* @filename: the name of the file to read configuration from.
|
||||
* @data: user data passed to the deserialize implementation.
|
||||
@ -372,9 +384,13 @@ gimp_config_deserialize_file (GimpConfig *config,
|
||||
if (! scanner)
|
||||
return FALSE;
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (config));
|
||||
|
||||
success = GIMP_CONFIG_GET_INTERFACE (config)->deserialize (config,
|
||||
scanner, 0, data);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (config));
|
||||
|
||||
gimp_scanner_destroy (scanner);
|
||||
|
||||
if (! success)
|
||||
@ -415,9 +431,13 @@ gimp_config_deserialize_string (GimpConfig *config,
|
||||
|
||||
scanner = gimp_scanner_new_string (text, text_len, error);
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (config));
|
||||
|
||||
success = GIMP_CONFIG_GET_INTERFACE (config)->deserialize (config,
|
||||
scanner, 0, data);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (config));
|
||||
|
||||
gimp_scanner_destroy (scanner);
|
||||
|
||||
if (! success)
|
||||
@ -535,5 +555,46 @@ gimp_config_reset (GimpConfig *config)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_CONFIG (config));
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (config));
|
||||
|
||||
GIMP_CONFIG_GET_INTERFACE (config)->reset (config);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (config));
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_config_copy:
|
||||
* @src: a #GObject that implements the #GimpConfigInterface.
|
||||
* @dest: another #GObject of the same type as @a.
|
||||
* @flags: a mask of GParamFlags
|
||||
*
|
||||
* Compares all read- and write-able properties from @src and @dest
|
||||
* that have all @flags set. Differing values are then copied from
|
||||
* @src to @dest. If @flags is 0, all differing read/write properties.
|
||||
*
|
||||
* Properties marked as "construct-only" are not touched.
|
||||
*
|
||||
* Return value: %TRUE if @dest was modified, %FALSE otherwise
|
||||
*
|
||||
* Since: GIMP 2.6
|
||||
**/
|
||||
gboolean
|
||||
gimp_config_copy (GimpConfig *src,
|
||||
GimpConfig *dest,
|
||||
GParamFlags flags)
|
||||
{
|
||||
gboolean changed;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_CONFIG (src), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_CONFIG (dest), FALSE);
|
||||
g_return_val_if_fail (G_TYPE_FROM_INSTANCE (src) == G_TYPE_FROM_INSTANCE (dest),
|
||||
FALSE);
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (dest));
|
||||
|
||||
changed = GIMP_CONFIG_GET_INTERFACE (src)->copy (src, dest, flags);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (dest));
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
@ -62,6 +62,9 @@ struct _GimpConfigInterface
|
||||
gboolean (* equal) (GimpConfig *a,
|
||||
GimpConfig *b);
|
||||
void (* reset) (GimpConfig *config);
|
||||
gboolean (* copy) (GimpConfig *src,
|
||||
GimpConfig *dest,
|
||||
GParamFlags flags);
|
||||
};
|
||||
|
||||
|
||||
@ -95,6 +98,9 @@ gpointer gimp_config_duplicate (GimpConfig *config);
|
||||
gboolean gimp_config_is_equal_to (GimpConfig *a,
|
||||
GimpConfig *b);
|
||||
void gimp_config_reset (GimpConfig *config);
|
||||
gboolean gimp_config_copy (GimpConfig *src,
|
||||
GimpConfig *dest,
|
||||
GParamFlags flags);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -216,6 +216,8 @@ gimp_config_sync (GObject *src,
|
||||
if (!diff)
|
||||
return FALSE;
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (dest));
|
||||
|
||||
for (list = diff; list; list = list->next)
|
||||
{
|
||||
GParamSpec *prop_spec = list->data;
|
||||
@ -233,6 +235,8 @@ gimp_config_sync (GObject *src,
|
||||
}
|
||||
}
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (dest));
|
||||
|
||||
g_list_free (diff);
|
||||
|
||||
return TRUE;
|
||||
@ -306,9 +310,9 @@ gimp_config_reset_properties (GObject *object)
|
||||
}
|
||||
}
|
||||
|
||||
g_free (property_specs);
|
||||
|
||||
g_object_thaw_notify (object);
|
||||
|
||||
g_free (property_specs);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user