Commit c06c90b5 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

add gimp_tagged_set_tags() which takes a GList of tags.

2009-03-02  Michael Natterer  <mitch@gimp.org>

	* app/core/gimptagged.[ch]: add gimp_tagged_set_tags() which
	takes a GList of tags.

	* app/widgets/gimptagentry.c (gimp_tag_entry_assign_tags): use it.

	(gimp_tag_entry_item_set_tags): remove.


svn path=/trunk/; revision=28094
parent 56198ec7
2009-03-02 Michael Natterer <mitch@gimp.org>
* app/core/gimptagged.[ch]: add gimp_tagged_set_tags() which
takes a GList of tags.
* app/widgets/gimptagentry.c (gimp_tag_entry_assign_tags): use it.
(gimp_tag_entry_item_set_tags): remove.
2009-03-02 Michael Natterer <mitch@gimp.org> 2009-03-02 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcombotagentry.c * app/widgets/gimpcombotagentry.c
......
...@@ -36,6 +36,7 @@ enum ...@@ -36,6 +36,7 @@ enum
LAST_SIGNAL LAST_SIGNAL
}; };
static void gimp_tagged_base_init (gpointer klass); static void gimp_tagged_base_init (gpointer klass);
static guint gimp_tagged_signals[LAST_SIGNAL] = { 0, }; static guint gimp_tagged_signals[LAST_SIGNAL] = { 0, };
...@@ -80,6 +81,7 @@ gimp_tagged_base_init (gpointer klass) ...@@ -80,6 +81,7 @@ gimp_tagged_base_init (gpointer klass)
g_cclosure_marshal_VOID__OBJECT, g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
GIMP_TYPE_TAG); GIMP_TYPE_TAG);
gimp_tagged_signals[TAG_REMOVED] = gimp_tagged_signals[TAG_REMOVED] =
g_signal_new ("tag-removed", g_signal_new ("tag-removed",
GIMP_TYPE_TAGGED, GIMP_TYPE_TAGGED,
...@@ -104,8 +106,8 @@ gimp_tagged_base_init (gpointer klass) ...@@ -104,8 +106,8 @@ gimp_tagged_base_init (gpointer klass)
* object. * object.
**/ **/
void void
gimp_tagged_add_tag (GimpTagged *tagged, gimp_tagged_add_tag (GimpTagged *tagged,
GimpTag *tag) GimpTag *tag)
{ {
g_return_if_fail (GIMP_IS_TAGGED (tagged)); g_return_if_fail (GIMP_IS_TAGGED (tagged));
...@@ -136,6 +138,40 @@ gimp_tagged_remove_tag (GimpTagged *tagged, ...@@ -136,6 +138,40 @@ gimp_tagged_remove_tag (GimpTagged *tagged,
} }
} }
/**
* gimp_tagged_set_tags:
* @tagged: an object that implements the %GimpTagged interface
* @tags: a list of tags
*
* Sets the list of tags assigned to this object. The passed list of
* tags is copied and should be freed by the caller.
**/
void
gimp_tagged_set_tags (GimpTagged *tagged,
GList *tags)
{
GList *old_tags;
GList *list;
g_return_if_fail (GIMP_IS_TAGGED (tagged));
old_tags = g_list_copy (gimp_tagged_get_tags (tagged));
for (list = old_tags; list; list = g_list_next (list))
{
gimp_tagged_remove_tag (tagged, list->data);
}
g_list_free (old_tags);
for (list = tags; list; list = g_list_next (list))
{
g_return_if_fail (GIMP_IS_TAG (list->data));
gimp_tagged_add_tag (tagged, list->data);
}
}
/** /**
* gimp_tagged_get_tags: * gimp_tagged_get_tags:
* @tagged: an object that implements the %GimpTagged interface * @tagged: an object that implements the %GimpTagged interface
......
...@@ -57,7 +57,11 @@ void gimp_tagged_add_tag (GimpTagged *tagged, ...@@ -57,7 +57,11 @@ void gimp_tagged_add_tag (GimpTagged *tagged,
GimpTag *tag); GimpTag *tag);
void gimp_tagged_remove_tag (GimpTagged *tagged, void gimp_tagged_remove_tag (GimpTagged *tagged,
GimpTag *tag); GimpTag *tag);
void gimp_tagged_set_tags (GimpTagged *tagged,
GList *tags);
GList * gimp_tagged_get_tags (GimpTagged *tagged); GList * gimp_tagged_get_tags (GimpTagged *tagged);
gchar * gimp_tagged_get_identifier (GimpTagged *tagged); gchar * gimp_tagged_get_identifier (GimpTagged *tagged);
gchar * gimp_tagged_get_checksum (GimpTagged *tagged); gchar * gimp_tagged_get_checksum (GimpTagged *tagged);
......
...@@ -93,8 +93,6 @@ static gboolean gimp_tag_entry_key_press (GtkWidget *widg ...@@ -93,8 +93,6 @@ static gboolean gimp_tag_entry_key_press (GtkWidget *widg
static gboolean gimp_tag_entry_query_tag (GimpTagEntry *entry); static gboolean gimp_tag_entry_query_tag (GimpTagEntry *entry);
static void gimp_tag_entry_assign_tags (GimpTagEntry *entry); static void gimp_tag_entry_assign_tags (GimpTagEntry *entry);
static void gimp_tag_entry_item_set_tags (GimpTagged *entry,
GList *tags);
static void gimp_tag_entry_load_selection (GimpTagEntry *entry, static void gimp_tag_entry_load_selection (GimpTagEntry *entry,
gboolean sort); gboolean sort);
...@@ -720,15 +718,15 @@ gimp_tag_entry_auto_complete (GimpTagEntry *tag_entry) ...@@ -720,15 +718,15 @@ gimp_tag_entry_auto_complete (GimpTagEntry *tag_entry)
static void static void
gimp_tag_entry_assign_tags (GimpTagEntry *tag_entry) gimp_tag_entry_assign_tags (GimpTagEntry *tag_entry)
{ {
GList *selected_iterator = NULL; GList *selected_iterator = NULL;
GimpTagged *selected_item; gchar **parsed_tags;
gchar **parsed_tags; gint count;
gint count; gint i;
gint i; GimpTag *tag;
GimpTag *tag; GList *tag_list = NULL;
GList *tag_list = NULL;
parsed_tags = gimp_tag_entry_parse_tags (tag_entry); parsed_tags = gimp_tag_entry_parse_tags (tag_entry);
count = g_strv_length (parsed_tags); count = g_strv_length (parsed_tags);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
...@@ -744,34 +742,10 @@ gimp_tag_entry_assign_tags (GimpTagEntry *tag_entry) ...@@ -744,34 +742,10 @@ gimp_tag_entry_assign_tags (GimpTagEntry *tag_entry)
selected_iterator; selected_iterator;
selected_iterator = g_list_next (selected_iterator)) selected_iterator = g_list_next (selected_iterator))
{ {
selected_item = GIMP_TAGGED (selected_iterator->data); gimp_tagged_set_tags (selected_iterator->data, tag_list);
gimp_tag_entry_item_set_tags (selected_item, tag_list);
}
g_list_free (tag_list);
}
static void
gimp_tag_entry_item_set_tags (GimpTagged *tagged,
GList *tags)
{
GList *old_tags;
GList *tags_iterator;
old_tags = g_list_copy (gimp_tagged_get_tags (tagged));
for (tags_iterator = old_tags;
tags_iterator;
tags_iterator = g_list_next (tags_iterator))
{
gimp_tagged_remove_tag (tagged, tags_iterator->data);
} }
g_list_free (old_tags);
for (tags_iterator = tags; g_list_free (tag_list);
tags_iterator;
tags_iterator = g_list_next (tags_iterator))
{
gimp_tagged_add_tag (tagged, tags_iterator->data);
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment