[gimp] app: implement GimpConfigInterface::equal() in gimp-gegl-config-proxy.c



commit 4f7cb8813297bdccdd0e38adad53bb8aaebf0468
Author: Michael Natterer <mitch gimp org>
Date:   Tue Mar 12 19:05:57 2013 +0100

    app: implement GimpConfigInterface::equal() in gimp-gegl-config-proxy.c
    
    so the automatically saved timestamped presets don't fill up with
    duplicates of identical settings. The default impl considers them
    different because of their timestamps.

 app/gegl/gimp-gegl-config-proxy.c |   43 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 42 insertions(+), 1 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-config-proxy.c b/app/gegl/gimp-gegl-config-proxy.c
index a0216fb..4981a7c 100644
--- a/app/gegl/gimp-gegl-config-proxy.c
+++ b/app/gegl/gimp-gegl-config-proxy.c
@@ -149,6 +149,47 @@ gimp_gegl_config_class_init (GObjectClass *klass,
   g_free (pspecs);
 }
 
+static gboolean
+gimp_gegl_config_equal (GimpConfig *a,
+                        GimpConfig *b)
+{
+  GList    *diff;
+  gboolean  equal = TRUE;
+
+  diff = gimp_config_diff (G_OBJECT (a), G_OBJECT (b),
+                           GIMP_CONFIG_PARAM_SERIALIZE);
+
+  if (G_TYPE_FROM_INSTANCE (a) == G_TYPE_FROM_INSTANCE (b))
+    {
+      GList *list;
+
+      for (list = diff; list; list = g_list_next (list))
+        {
+          GParamSpec *pspec = list->data;
+
+          if (pspec->owner_type == G_TYPE_FROM_INSTANCE (a))
+            {
+              equal = FALSE;
+              break;
+            }
+        }
+    }
+  else if (diff)
+    {
+      equal = FALSE;
+    }
+
+  g_list_free (diff);
+
+  return equal;
+}
+
+static void
+gimp_gegl_config_config_iface_init (GimpConfigInterface *iface)
+{
+  iface->equal = gimp_gegl_config_equal;
+}
+
 GimpObject *
 gimp_gegl_get_config_proxy (const gchar *operation,
                             GType        parent_type)
@@ -188,7 +229,7 @@ gimp_gegl_get_config_proxy (const gchar *operation,
 
         const GInterfaceInfo config_info =
           {
-            NULL, /* interface_init     */
+            (GInterfaceInitFunc) gimp_gegl_config_config_iface_init,
             NULL, /* interface_finalize */
             NULL  /* interface_data     */
           };


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