gimp r24767 - in trunk: . libgimpconfig



Author: mitch
Date: Fri Feb  1 11:44:45 2008
New Revision: 24767
URL: http://svn.gnome.org/viewvc/gimp?rev=24767&view=rev

Log:
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.



Modified:
   trunk/ChangeLog
   trunk/libgimpconfig/gimpconfig-iface.c
   trunk/libgimpconfig/gimpconfig-iface.h
   trunk/libgimpconfig/gimpconfig-utils.c

Modified: trunk/libgimpconfig/gimpconfig-iface.c
==============================================================================
--- trunk/libgimpconfig/gimpconfig-iface.c	(original)
+++ trunk/libgimpconfig/gimpconfig-iface.c	Fri Feb  1 11:44:45 2008
@@ -58,6 +58,9 @@
 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 @@
       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 @@
 
   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_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_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 @@
   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 @@
 
   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 @@
 {
   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;
 }

Modified: trunk/libgimpconfig/gimpconfig-iface.h
==============================================================================
--- trunk/libgimpconfig/gimpconfig-iface.h	(original)
+++ trunk/libgimpconfig/gimpconfig-iface.h	Fri Feb  1 11:44:45 2008
@@ -62,6 +62,9 @@
   gboolean     (* equal)                (GimpConfig       *a,
                                          GimpConfig       *b);
   void         (* reset)                (GimpConfig       *config);
+  gboolean     (* copy)                 (GimpConfig       *src,
+                                         GimpConfig       *dest,
+                                         GParamFlags       flags);
 };
 
 
@@ -95,6 +98,9 @@
 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

Modified: trunk/libgimpconfig/gimpconfig-utils.c
==============================================================================
--- trunk/libgimpconfig/gimpconfig-utils.c	(original)
+++ trunk/libgimpconfig/gimpconfig-utils.c	Fri Feb  1 11:44:45 2008
@@ -216,6 +216,8 @@
   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 @@
         }
     }
 
+  g_object_thaw_notify (G_OBJECT (dest));
+
   g_list_free (diff);
 
   return TRUE;
@@ -306,9 +310,9 @@
         }
     }
 
-  g_free (property_specs);
-
   g_object_thaw_notify (object);
+
+  g_free (property_specs);
 }
 
 



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