gimp r25970 - in branches/soc-2008-tagging: . app/core



Author: aurisj
Date: Fri Jun 20 21:35:44 2008
New Revision: 25970
URL: http://svn.gnome.org/viewvc/gimp?rev=25970&view=rev

Log:
2008-06-20  Aurimas JuÅka   <aurisj svn gnome org>
	* app/core/gimpdata.[ch]
	* app/core/gimptagcache.c (gimp_tag_cache_update)
	* app/core/gimptagged.[ch]: extended object identification
	  capabilities. Each tagged object now provides unique
	  identification string. In case it can change between sessions,
	  objects can provide digest calculation which would help to remap
	  to new identification string.
	* app/core/gimp-gradients.c
	* app/core/gimp.c
	* app/core/gimpbrush.c
	* app/core/gimpcurve.c
	* app/core/gimpgradient.c (gimp_gradient_get_standard)
	* app/core/gimppalette.c (gimp_palette_get_standard)
	* app/core/gimppattern.c (gimp_pattern_get_standard): provide
	  unique name for internal objects.


Modified:
   branches/soc-2008-tagging/ChangeLog
   branches/soc-2008-tagging/app/core/gimp-gradients.c
   branches/soc-2008-tagging/app/core/gimp.c
   branches/soc-2008-tagging/app/core/gimpbrush.c
   branches/soc-2008-tagging/app/core/gimpcurve.c
   branches/soc-2008-tagging/app/core/gimpdata.c
   branches/soc-2008-tagging/app/core/gimpdata.h
   branches/soc-2008-tagging/app/core/gimpgradient.c
   branches/soc-2008-tagging/app/core/gimppalette.c
   branches/soc-2008-tagging/app/core/gimppattern.c
   branches/soc-2008-tagging/app/core/gimptagcache.c
   branches/soc-2008-tagging/app/core/gimptagged.c
   branches/soc-2008-tagging/app/core/gimptagged.h

Modified: branches/soc-2008-tagging/app/core/gimp-gradients.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimp-gradients.c	(original)
+++ branches/soc-2008-tagging/app/core/gimp-gradients.c	Fri Jun 20 21:35:44 2008
@@ -88,7 +88,7 @@
 {
   GimpGradient *gradient = GIMP_GRADIENT (gimp_gradient_new (name));
 
-  gimp_data_make_internal (GIMP_DATA (gradient));
+  gimp_data_make_internal (GIMP_DATA (gradient), id);
 
   gradient->segments->left_color_type  = GIMP_GRADIENT_COLOR_FOREGROUND;
   gradient->segments->right_color_type = GIMP_GRADIENT_COLOR_BACKGROUND;

Modified: branches/soc-2008-tagging/app/core/gimp.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimp.c	(original)
+++ branches/soc-2008-tagging/app/core/gimp.c	Fri Jun 20 21:35:44 2008
@@ -598,14 +598,16 @@
 
   /*  add the clipboard brush  */
   clipboard_brush = gimp_brush_clipboard_new (gimp);
-  gimp_data_make_internal (GIMP_DATA (clipboard_brush));
+  gimp_data_make_internal (GIMP_DATA (clipboard_brush),
+                           "gimp-brush-clipboard");
   gimp_container_add (gimp->brush_factory->container,
                       GIMP_OBJECT (clipboard_brush));
   g_object_unref (clipboard_brush);
 
   /*  add the clipboard pattern  */
   clipboard_pattern = gimp_pattern_clipboard_new (gimp);
-  gimp_data_make_internal (GIMP_DATA (clipboard_pattern));
+  gimp_data_make_internal (GIMP_DATA (clipboard_pattern),
+                           "gimp-pattern-clipboard");
   gimp_container_add (gimp->pattern_factory->container,
                       GIMP_OBJECT (clipboard_pattern));
   g_object_unref (clipboard_pattern);

Modified: branches/soc-2008-tagging/app/core/gimpbrush.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimpbrush.c	(original)
+++ branches/soc-2008-tagging/app/core/gimpbrush.c	Fri Jun 20 21:35:44 2008
@@ -380,7 +380,8 @@
       standard_brush = gimp_brush_new ("Standard");
 
       standard_brush->dirty = FALSE;
-      gimp_data_make_internal (standard_brush);
+      gimp_data_make_internal (standard_brush,
+                               "gimp-brush-standard");
 
       /*  set ref_count to 2 --> never swap the standard brush  */
       g_object_ref (standard_brush);

Modified: branches/soc-2008-tagging/app/core/gimpcurve.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimpcurve.c	(original)
+++ branches/soc-2008-tagging/app/core/gimpcurve.c	Fri Jun 20 21:35:44 2008
@@ -537,7 +537,8 @@
       standard_curve = gimp_curve_new ("Standard");
 
       standard_curve->dirty = FALSE;
-      gimp_data_make_internal (standard_curve);
+      gimp_data_make_internal (standard_curve,
+                               "gimp-curve-standard");
 
       g_object_ref (standard_curve);
     }

Modified: branches/soc-2008-tagging/app/core/gimpdata.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimpdata.c	(original)
+++ branches/soc-2008-tagging/app/core/gimpdata.c	Fri Jun 20 21:35:44 2008
@@ -93,6 +93,9 @@
 static gboolean  gimp_data_remove_tag        (GimpTagged            *tagged,
                                               GimpTag                tag);
 static GList *   gimp_data_get_tags          (GimpTagged            *tagged);
+static gchar *   gimp_data_get_identifier    (GimpTagged            *tagged);
+static gboolean  gimp_data_get_digest        (GimpTagged            *tagged,
+                                              guchar                 digest[16]);
 
 
 static guint data_signals[LAST_SIGNAL] = { 0 };
@@ -191,9 +194,11 @@
 static void
 gimp_data_tagged_iface_init (GimpTaggedInterface *iface)
 {
-  iface->add_tag    = gimp_data_add_tag;
-  iface->remove_tag = gimp_data_remove_tag;
-  iface->get_tags   = gimp_data_get_tags;
+  iface->add_tag        = gimp_data_add_tag;
+  iface->remove_tag     = gimp_data_remove_tag;
+  iface->get_tags       = gimp_data_get_tags;
+  iface->get_identifier = gimp_data_get_identifier;
+  iface->get_digest     = gimp_data_get_digest;
 }
 
 static void
@@ -209,6 +214,7 @@
   data->freeze_count = 0;
   data->mtime        = 0;
   data->tags         = NULL;
+  data->internal_name = NULL;
 
   /*  look at the passed class pointer, not at GIMP_DATA_GET_CLASS(data)
    *  here, because the latter is always GimpDataClass itself
@@ -251,6 +257,12 @@
       data->tags = NULL;
     }
 
+  if (data->internal_name)
+    {
+      g_free (data->internal_name);
+      data->internal_name = NULL;
+    }
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -394,6 +406,28 @@
   return GIMP_DATA (tagged)->tags;
 }
 
+static gchar*
+gimp_data_get_identifier (GimpTagged *tagged)
+{
+  GimpData *data = GIMP_DATA (tagged);
+
+  if (data->internal)
+    {
+      return data->internal_name;
+    }
+  else
+    {
+      return data->filename;
+    }
+}
+
+static gboolean
+gimp_data_get_digest (GimpTagged *tagged,
+                      guchar      digest[16])
+{
+  return FALSE;
+}
+
 /**
  * gimp_data_save:
  * @data:  object whose contents are to be saved.
@@ -710,9 +744,13 @@
  * saved to disk.  Note that if you do this, later calls to
  * gimp_data_save() and gimp_data_delete_from_disk() will
  * automatically return successfully without giving any warning.
+ *
+ * Internal name should be untranslated globally unique string
+ * identifying internal object.
  **/
 void
-gimp_data_make_internal (GimpData *data)
+gimp_data_make_internal (GimpData      *data,
+                         const gchar   *internal_name)
 {
   g_return_if_fail (GIMP_IS_DATA (data));
 
@@ -722,6 +760,8 @@
       data->filename = NULL;
     }
 
+  data->internal_name = g_strdup (internal_name);
+
   data->internal  = TRUE;
   data->writable  = FALSE;
   data->deletable = FALSE;

Modified: branches/soc-2008-tagging/app/core/gimpdata.h
==============================================================================
--- branches/soc-2008-tagging/app/core/gimpdata.h	(original)
+++ branches/soc-2008-tagging/app/core/gimpdata.h	Fri Jun 20 21:35:44 2008
@@ -60,6 +60,7 @@
   time_t        mtime;
 
   GList        *tags;
+  gchar        *internal_name;
 };
 
 struct _GimpDataClass
@@ -102,7 +103,8 @@
 
 GimpData    * gimp_data_duplicate        (GimpData     *data);
 
-void          gimp_data_make_internal    (GimpData     *data);
+void          gimp_data_make_internal    (GimpData     *data,
+                                          const gchar  *internal_name);
 
 gint          gimp_data_name_compare     (GimpData     *data1,
                                           GimpData     *data2);

Modified: branches/soc-2008-tagging/app/core/gimpgradient.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimpgradient.c	(original)
+++ branches/soc-2008-tagging/app/core/gimpgradient.c	Fri Jun 20 21:35:44 2008
@@ -285,7 +285,8 @@
       standard_gradient = gimp_gradient_new ("Standard");
 
       standard_gradient->dirty = FALSE;
-      gimp_data_make_internal (standard_gradient);
+      gimp_data_make_internal (standard_gradient,
+                               "gimp-gradient-standard");
 
       g_object_ref (standard_gradient);
     }

Modified: branches/soc-2008-tagging/app/core/gimppalette.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimppalette.c	(original)
+++ branches/soc-2008-tagging/app/core/gimppalette.c	Fri Jun 20 21:35:44 2008
@@ -281,7 +281,8 @@
       standard_palette = gimp_palette_new ("Standard");
 
       standard_palette->dirty = FALSE;
-      gimp_data_make_internal (standard_palette);
+      gimp_data_make_internal (standard_palette,
+                               "gimp-palette-standard");
 
       g_object_ref (standard_palette);
     }

Modified: branches/soc-2008-tagging/app/core/gimppattern.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimppattern.c	(original)
+++ branches/soc-2008-tagging/app/core/gimppattern.c	Fri Jun 20 21:35:44 2008
@@ -213,7 +213,8 @@
       standard_pattern = gimp_pattern_new ("Standard");
 
       standard_pattern->dirty = FALSE;
-      gimp_data_make_internal (standard_pattern);
+      gimp_data_make_internal (standard_pattern,
+                               "gimp-pattern-standard");
 
       /*  set ref_count to 2 --> never swap the standard pattern  */
       g_object_ref (standard_pattern);

Modified: branches/soc-2008-tagging/app/core/gimptagcache.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimptagcache.c	(original)
+++ branches/soc-2008-tagging/app/core/gimptagcache.c	Fri Jun 20 21:35:44 2008
@@ -108,6 +108,5 @@
 gimp_tag_cache_update (GimpTaggedInterface *tagged,
                        GimpTagCache        *cache)
 {
-    GimpData *data = GIMP_DATA(tagged);
-    printf("resource received: %s\n", data->filename); 
+    printf("resource received: %s\n", gimp_tagged_get_identifier (tagged)); 
 }

Modified: branches/soc-2008-tagging/app/core/gimptagged.c
==============================================================================
--- branches/soc-2008-tagging/app/core/gimptagged.c	(original)
+++ branches/soc-2008-tagging/app/core/gimptagged.c	Fri Jun 20 21:35:44 2008
@@ -152,3 +152,46 @@
 
   return GIMP_TAGGED_GET_INTERFACE (tagged)->get_tags (tagged);
 }
+
+/**
+ * gimp_tagged_get_identifier:
+ * @tagged: an object that implements the %GimpTagged interface
+ *
+ * Returns an identifier string which uniquely identifies the object.
+ * The returned string is owned by @tagged object and must not be
+ * modified or destroyed.
+ *
+ * Return value: unique identifier of the object.
+ **/
+gchar *
+gimp_tagged_get_identifier (GimpTagged *tagged)
+{
+  g_return_val_if_fail (GIMP_IS_TAGGED (tagged), NULL);
+
+  return GIMP_TAGGED_GET_INTERFACE (tagged)->get_identifier (tagged);
+}
+
+/**
+ * gimp_tagged_get_digest:
+ * @tagged: an object that implements the %GimpTagged interface
+ *
+ * Returns an digest value of @tagged object. It is used to remap
+ * object identifier if it changed from the previous session.
+ * For example, when filename changes tags can be remapped to the
+ * proper objects by finding it using digest value.
+ *
+ * If the object does not want to support such remapping
+ * (object not stored in file, for example) it can return #FALSE
+ *
+ * Return value: TRUE if object needs identifier remapping and provides
+ * digest value, FALSE otherwise.
+ **/
+gboolean
+gimp_tagged_get_digest (GimpTagged *tagged,
+                        guchar      digest[16])
+{
+  g_return_val_if_fail (GIMP_IS_TAGGED (tagged), FALSE);
+
+  return GIMP_TAGGED_GET_INTERFACE (tagged)->get_digest (tagged, digest);
+}
+

Modified: branches/soc-2008-tagging/app/core/gimptagged.h
==============================================================================
--- branches/soc-2008-tagging/app/core/gimptagged.h	(original)
+++ branches/soc-2008-tagging/app/core/gimptagged.h	Fri Jun 20 21:35:44 2008
@@ -47,6 +47,10 @@
   gboolean   (* remove_tag)  (GimpTagged *tagged,
                               GimpTag     tag);
   GList    * (* get_tags)    (GimpTagged *tagged);
+
+  gchar    * (* get_identifier) (GimpTagged *tagged);
+  gboolean   (* get_digest)     (GimpTagged *tagged,
+                                 guchar      digest[16]);
 };
 
 
@@ -58,5 +62,8 @@
                                            GimpTag     tag);
 GList    * gimp_tagged_get_get_tags       (GimpTagged *tagged);
 
+gchar    * gimp_tagged_get_identifier     (GimpTagged *tagged);
+gboolean   gimp_tagged_get_digest         (GimpTagged *tagged,
+                                           guchar      digest[16]);
 
 #endif  /* __GIMP_TAGGED_H__ */



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