mirror of https://github.com/GNOME/gimp.git
app/core/gimpdata.[ch] app/core/gimptagcache.c (gimp_tag_cache_update)
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. svn path=/branches/soc-2008-tagging/; revision=25970
This commit is contained in:
parent
f21a96629e
commit
ab0a63f8d4
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
|||
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.
|
||||
|
||||
|
||||
2008-06-17 Aurimas Juška <aurisj@svn.gnome.org>
|
||||
|
||||
* app/core/Makefile.am
|
||||
|
|
|
@ -88,7 +88,7 @@ gimp_gradients_add_gradient (Gimp *gimp,
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -598,14 +598,16 @@ gimp_real_initialize (Gimp *gimp,
|
|||
|
||||
/* 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);
|
||||
|
|
|
@ -380,7 +380,8 @@ gimp_brush_get_standard (void)
|
|||
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);
|
||||
|
|
|
@ -537,7 +537,8 @@ gimp_curve_get_standard (void)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -93,6 +93,9 @@ static gboolean gimp_data_add_tag (GimpTagged *tagged,
|
|||
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 @@ gimp_data_class_init (GimpDataClass *klass)
|
|||
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 @@ gimp_data_init (GimpData *data,
|
|||
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 @@ gimp_data_finalize (GObject *object)
|
|||
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 @@ gimp_data_get_tags (GimpTagged *tagged)
|
|||
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 @@ gimp_data_duplicate (GimpData *data)
|
|||
* 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 @@ gimp_data_make_internal (GimpData *data)
|
|||
data->filename = NULL;
|
||||
}
|
||||
|
||||
data->internal_name = g_strdup (internal_name);
|
||||
|
||||
data->internal = TRUE;
|
||||
data->writable = FALSE;
|
||||
data->deletable = FALSE;
|
||||
|
|
|
@ -60,6 +60,7 @@ struct _GimpData
|
|||
time_t mtime;
|
||||
|
||||
GList *tags;
|
||||
gchar *internal_name;
|
||||
};
|
||||
|
||||
struct _GimpDataClass
|
||||
|
@ -102,7 +103,8 @@ const gchar * gimp_data_get_mime_type (GimpData *data);
|
|||
|
||||
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);
|
||||
|
|
|
@ -285,7 +285,8 @@ gimp_gradient_get_standard (void)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -281,7 +281,8 @@ gimp_palette_get_standard (void)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -213,7 +213,8 @@ gimp_pattern_get_standard (void)
|
|||
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);
|
||||
|
|
|
@ -108,6 +108,5 @@ void
|
|||
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));
|
||||
}
|
||||
|
|
|
@ -152,3 +152,46 @@ gimp_tagged_get_get_tags (GimpTagged *tagged)
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,10 @@ struct _GimpTaggedInterface
|
|||
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 @@ void gimp_tagged_remove_tag (GimpTagged *tagged,
|
|||
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__ */
|
||||
|
|
Loading…
Reference in New Issue