[gthumb] add the file tags to the global tags when opening the metadata dialog
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] add the file tags to the global tags when opening the metadata dialog
- Date: Tue, 28 Dec 2010 17:23:45 +0000 (UTC)
commit 05ae4f8599a1f6c449d79b6c71ed308ffbb9b81e
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Dec 28 16:00:31 2010 +0100
add the file tags to the global tags when opening the metadata dialog
extensions/edit_metadata/gth-edit-comment-page.c | 4 +-
gthumb/gth-tags-entry.c | 26 +++++++++++++++++++--
gthumb/gth-tags-file.c | 15 +++++++++---
gthumb/gth-tags-file.h | 4 +-
4 files changed, 38 insertions(+), 11 deletions(-)
---
diff --git a/extensions/edit_metadata/gth-edit-comment-page.c b/extensions/edit_metadata/gth-edit-comment-page.c
index 6b4eae5..96b5180 100644
--- a/extensions/edit_metadata/gth-edit-comment-page.c
+++ b/extensions/edit_metadata/gth-edit-comment-page.c
@@ -112,13 +112,13 @@ gth_edit_comment_page_real_set_file_list (GthEditMetadataPage *base,
if (tags != NULL) {
char *value;
- value = gth_string_list_join (tags, ", ");
+ value = gth_string_list_join (tags, ",");
gth_tags_entry_set_text (GTH_TAGS_ENTRY (self->priv->tags_entry), value);
g_free (value);
}
else
- gth_tags_entry_set_text (GTH_TAGS_ENTRY (self->priv->tags_entry), "");
+ gth_tags_entry_set_text (GTH_TAGS_ENTRY (self->priv->tags_entry), NULL);
metadata = (GthMetadata *) g_file_info_get_attribute_object (self->priv->info, "general::rating");
if (metadata != NULL) {
diff --git a/gthumb/gth-tags-entry.c b/gthumb/gth-tags-entry.c
index 84d80d9..71ab4b6 100644
--- a/gthumb/gth-tags-entry.c
+++ b/gthumb/gth-tags-entry.c
@@ -866,14 +866,24 @@ void
gth_tags_entry_set_tags (GthTagsEntry *self,
char **tags)
{
- char *s;
+ GthTagsFile *tags_file;
+ int i;
+ gboolean global_tags_changed = FALSE;
+ char *s;
if ((tags == NULL) || (tags[0] == NULL)) {
gtk_entry_set_text (GTK_ENTRY (self->priv->entry), "");
return;
}
- s = g_strjoinv(", ", tags);
+ tags_file = gth_main_get_default_tag_file ();
+ for (i = 0; tags[i] != NULL; i++)
+ if (gth_tags_file_add (tags_file, tags[i]))
+ global_tags_changed = TRUE;
+ if (global_tags_changed)
+ gth_main_tags_changed ();
+
+ s = g_strjoinv (", ", tags);
gtk_entry_set_text (GTK_ENTRY (self->priv->entry), s);
g_free (s);
}
@@ -883,5 +893,15 @@ void
gth_tags_entry_set_text (GthTagsEntry *self,
const char *text)
{
- gtk_entry_set_text (GTK_ENTRY (self->priv->entry), text);
+ char **tags;
+
+ if ((text == NULL) || (strcmp (text, "") == 0)) {
+ gth_tags_entry_set_tags (self, NULL);
+ return;
+ }
+
+ tags = g_strsplit (text, ",", -1);
+ gth_tags_entry_set_tags (self, tags);
+
+ g_strfreev (tags);
}
diff --git a/gthumb/gth-tags-file.c b/gthumb/gth-tags-file.c
index e0e2666..b45601a 100644
--- a/gthumb/gth-tags-file.c
+++ b/gthumb/gth-tags-file.c
@@ -269,19 +269,23 @@ gth_tags_file_has_tag (GthTagsFile *tags,
}
-void
+gboolean
gth_tags_file_add (GthTagsFile *tags,
const char *tag)
{
GList *link;
link = g_list_find_custom (tags->items, tag, (GCompareFunc) strcmp);
- if (link == NULL)
+ if (link == NULL) {
tags->items = g_list_append (tags->items, g_strdup (tag));
+ return TRUE;
+ }
+
+ return FALSE;
}
-void
+gboolean
gth_tags_file_remove (GthTagsFile *tags,
const char *tag)
{
@@ -289,9 +293,12 @@ gth_tags_file_remove (GthTagsFile *tags,
link = g_list_find_custom (tags->items, tag, (GCompareFunc) strcmp);
if (link == NULL)
- return;
+ return FALSE;
+
tags->items = g_list_remove_link (tags->items, link);
_g_string_list_free (link);
+
+ return TRUE;
}
diff --git a/gthumb/gth-tags-file.h b/gthumb/gth-tags-file.h
index 9a46d23..807f1d2 100644
--- a/gthumb/gth-tags-file.h
+++ b/gthumb/gth-tags-file.h
@@ -47,9 +47,9 @@ gboolean gth_tags_file_to_file (GthTagsFile *tags,
char ** gth_tags_file_get_tags (GthTagsFile *tags);
gboolean gth_tags_file_has_tag (GthTagsFile *tags,
const char *tag);
-void gth_tags_file_add (GthTagsFile *tags,
+gboolean gth_tags_file_add (GthTagsFile *tags,
const char *tag);
-void gth_tags_file_remove (GthTagsFile *tags,
+gboolean gth_tags_file_remove (GthTagsFile *tags,
const char *tag);
void gth_tags_file_clear (GthTagsFile *tags);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]