gimp r26348 - in branches/soc-2008-tagging: . app/widgets
- From: aurisj svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26348 - in branches/soc-2008-tagging: . app/widgets
- Date: Fri, 1 Aug 2008 19:47:26 +0000 (UTC)
Author: aurisj
Date: Fri Aug 1 19:47:26 2008
New Revision: 26348
URL: http://svn.gnome.org/viewvc/gimp?rev=26348&view=rev
Log:
2008-08-01 Aurimas JuÅka <aurisj svn gnome org>
* app/widgets/gimptagentry.c: hide tags on assign tag entry when
selected item is not visible in the view.
Modified:
branches/soc-2008-tagging/ChangeLog
branches/soc-2008-tagging/app/widgets/gimptagentry.c
Modified: branches/soc-2008-tagging/app/widgets/gimptagentry.c
==============================================================================
--- branches/soc-2008-tagging/app/widgets/gimptagentry.c (original)
+++ branches/soc-2008-tagging/app/widgets/gimptagentry.c Fri Aug 1 19:47:26 2008
@@ -61,6 +61,9 @@
static gboolean gimp_tag_entry_focus_out (GtkWidget *widget,
GdkEventFocus *event,
gpointer user_data);
+static void gimp_tag_entry_container_changed (GimpContainer *container,
+ GimpObject *object,
+ GimpTagEntry *tag_entry);
static gboolean gimp_tag_entry_button_release (GtkWidget *widget,
GdkEventButton *event);
static void gimp_tag_entry_backspace (GtkEntry *entry);
@@ -171,6 +174,14 @@
tag_entry->recent_list = NULL;
}
+ if (tag_entry->tagged_container)
+ {
+ g_signal_handlers_disconnect_by_func (tag_entry->tagged_container,
+ gimp_tag_entry_container_changed, tag_entry);
+ g_object_unref (tag_entry->tagged_container);
+ tag_entry->tagged_container = NULL;
+ }
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -188,6 +199,12 @@
entry->tagged_container = tagged_container;
entry->mode = mode;
+ g_object_ref (tagged_container);
+ g_signal_connect (entry->tagged_container, "add",
+ G_CALLBACK (gimp_tag_entry_container_changed), entry);
+ g_signal_connect (entry->tagged_container, "remove",
+ G_CALLBACK (gimp_tag_entry_container_changed), entry);
+
gimp_tag_entry_toggle_desc (entry, TRUE);
return GTK_WIDGET (entry);
@@ -200,6 +217,7 @@
GimpTagEntry *tag_entry;
gint selection_start;
gint selection_end;
+ GList *iterator;
tag_entry = GIMP_TAG_ENTRY (entry);
@@ -211,10 +229,23 @@
{
gtk_editable_select_region (GTK_EDITABLE (entry),
selection_end, selection_end);
- return;
}
- if (tag_entry->mode == GIMP_TAG_ENTRY_MODE_ASSIGN)
+ iterator = tag_entry->selected_items;
+ while (iterator)
+ {
+ if (gimp_tagged_get_tags (GIMP_TAGGED (iterator->data))
+ && gimp_container_have (GIMP_CONTAINER (tag_entry->tagged_container),
+ GIMP_OBJECT(iterator->data)))
+ {
+ break;
+ }
+
+ iterator = g_list_next (iterator);
+ }
+
+ if (tag_entry->mode == GIMP_TAG_ENTRY_MODE_ASSIGN
+ && iterator)
{
gimp_tag_entry_assign_tags (GIMP_TAG_ENTRY (entry));
}
@@ -444,6 +475,8 @@
gimp_tag_entry_set_selected_items (GimpTagEntry *entry,
GList *items)
{
+ GList *iterator;
+
if (entry->selected_items)
{
g_list_free (entry->selected_items);
@@ -452,9 +485,30 @@
entry->selected_items = g_list_copy (items);
- if (! entry->description_shown)
+ iterator = entry->selected_items;
+ while (iterator)
+ {
+ if (gimp_tagged_get_tags (GIMP_TAGGED (iterator->data))
+ && gimp_container_have (GIMP_CONTAINER (entry->tagged_container),
+ GIMP_OBJECT(iterator->data)))
+ {
+ break;
+ }
+
+ iterator = g_list_next (iterator);
+ }
+
+ if (entry->mode == GIMP_TAG_ENTRY_MODE_ASSIGN
+ && iterator)
{
gimp_tag_entry_load_selection (entry);
+ gimp_tag_entry_toggle_desc (entry, FALSE);
+ }
+ else
+ {
+ entry->internal_change = TRUE;
+ gtk_editable_delete_text (GTK_EDITABLE (entry), 0, -1);
+ entry->internal_change = FALSE;
gimp_tag_entry_toggle_desc (entry, TRUE);
}
}
@@ -469,7 +523,9 @@
GimpTag *tag;
gchar *text;
+ tag_entry->internal_change = TRUE;
gtk_editable_delete_text (GTK_EDITABLE (tag_entry), 0, -1);
+ tag_entry->internal_change = FALSE;
if (! tag_entry->selected_items)
{
@@ -486,8 +542,10 @@
{
tag = GIMP_TAG (tag_iterator->data);
text = g_strdup_printf ("%s, ", gimp_tag_get_name (tag));
+ tag_entry->internal_change = TRUE;
gtk_editable_insert_text (GTK_EDITABLE (tag_entry), text, strlen (text),
&insert_pos);
+ tag_entry->internal_change = FALSE;
g_free (text);
tag_iterator = g_list_next (tag_iterator);
@@ -670,11 +728,8 @@
gpointer user_data)
{
GimpTagEntry *tag_entry = GIMP_TAG_ENTRY (widget);
+
gimp_tag_entry_toggle_desc (GIMP_TAG_ENTRY (widget), FALSE);
- if (tag_entry->mode == GIMP_TAG_ENTRY_MODE_ASSIGN)
- {
- gimp_tag_entry_load_selection (tag_entry);
- }
return FALSE;
}
@@ -695,6 +750,35 @@
return FALSE;
}
+
+static void
+gimp_tag_entry_container_changed (GimpContainer *container,
+ GimpObject *object,
+ GimpTagEntry *tag_entry)
+{
+ if (tag_entry->mode == GIMP_TAG_ENTRY_MODE_ASSIGN)
+ {
+ GList *selected_iterator = tag_entry->selected_items;
+
+ while (selected_iterator)
+ {
+ if (gimp_tagged_get_tags (GIMP_TAGGED (selected_iterator->data))
+ && gimp_container_have (GIMP_CONTAINER (tag_entry->tagged_container),
+ GIMP_OBJECT(selected_iterator->data)))
+ {
+ break;
+ }
+ selected_iterator = g_list_next (selected_iterator);
+ }
+ if (! selected_iterator)
+ {
+ tag_entry->internal_change = TRUE;
+ gtk_editable_delete_text (GTK_EDITABLE (tag_entry), 0, -1);
+ tag_entry->internal_change = FALSE;
+ }
+ }
+}
+
static void
gimp_tag_entry_toggle_desc (GimpTagEntry *tag_entry,
gboolean show)
@@ -718,28 +802,21 @@
if (show)
{
- gchar **tags;
- gint tag_count;
- gint i;
- gboolean has_valid_tag = FALSE;
-
- tags = gimp_tag_entry_parse_tags (tag_entry);
- tag_count = g_strv_length (tags);
- for (i = 0; i < tag_count; i++)
- {
- if (tags[i] && *tags[i])
- {
- has_valid_tag = TRUE;
- break;
- }
- }
- g_strfreev (tags);
+ gchar *current_text;
+ size_t len;
- if (! has_valid_tag)
+ current_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (tag_entry)));
+ current_text = g_strstrip (current_text);
+ len = strlen (current_text);
+ g_free (current_text);
+
+ if (len > 0)
{
- tag_entry->description_shown = TRUE;
- gtk_widget_queue_draw (widget);
+ return;
}
+
+ tag_entry->description_shown = TRUE;
+ gtk_widget_queue_draw (widget);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]