From 11a9457ee1f3ffe3066bd092ac62496325ea9159 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Thu, 13 Mar 2008 00:38:31 +0000 Subject: [PATCH] Clear pending completions thoroughly Signed-off-by: Federico Mena Quintero svn path=/trunk/; revision=19828 --- gtk/gtkfilechooserentry.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c index 03397c3f51..6ce875822b 100644 --- a/gtk/gtkfilechooserentry.c +++ b/gtk/gtkfilechooserentry.c @@ -594,6 +594,13 @@ gtk_file_chooser_entry_do_insert_text (GtkEditable *editable, install_start_autocompletion_idle (chooser_entry); } +static void +clear_completions (GtkFileChooserEntry *chooser_entry) +{ + chooser_entry->has_completion = FALSE; + chooser_entry->load_complete_action = LOAD_COMPLETE_NOTHING; +} + static void gtk_file_chooser_entry_do_delete_text (GtkEditable *editable, gint start_pos, @@ -606,7 +613,7 @@ gtk_file_chooser_entry_do_delete_text (GtkEditable *editable, if (chooser_entry->in_change) return; - chooser_entry->load_complete_action = LOAD_COMPLETE_NOTHING; + clear_completions (chooser_entry); } static void @@ -620,7 +627,7 @@ gtk_file_chooser_entry_set_position (GtkEditable *editable, if (chooser_entry->in_change) return; - chooser_entry->load_complete_action = LOAD_COMPLETE_NOTHING; + clear_completions (chooser_entry); } static void @@ -635,7 +642,7 @@ gtk_file_chooser_entry_set_selection_bounds (GtkEditable *editable, if (chooser_entry->in_change) return; - chooser_entry->load_complete_action = LOAD_COMPLETE_NOTHING; + clear_completions (chooser_entry); } static void @@ -680,10 +687,13 @@ gtk_file_chooser_entry_focus (GtkWidget *widget, if (chooser_entry->has_completion) { + gboolean has_selection; gint sel_end; - if (gtk_editable_get_selection_bounds (editable, NULL, &sel_end)) - gtk_editable_set_position (editable, sel_end); + has_selection = gtk_editable_get_selection_bounds (editable, NULL, &sel_end); + g_assert (has_selection && sel_end == GTK_ENTRY (entry)->text_length); + + gtk_editable_set_position (editable, sel_end); } else {