summaryrefslogtreecommitdiff
path: root/gtk/gtkfilechooserentry.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-12-16 18:47:42 +0100
committerBenjamin Otte <otte@redhat.com>2011-12-16 20:09:14 +0100
commit640754e98b6a0a59fbfa9f35d03e0f096988a0a2 (patch)
tree67f67eece7a483d18d32c7e0365c4bedbf9cb52c /gtk/gtkfilechooserentry.c
parent351dd206bc024b1744d67f5849fd4e7c8f039dd1 (diff)
downloadgtk+-640754e98b6a0a59fbfa9f35d03e0f096988a0a2.tar.gz
filechooserentry: Do inline completion only when opening files
When saving files, using <tab> is required. We don't want the UI randomly changing filenames from below us. https://bugzilla.gnome.org/show_bug.cgi?id=663573
Diffstat (limited to 'gtk/gtkfilechooserentry.c')
-rw-r--r--gtk/gtkfilechooserentry.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 3010c94218..50d346263d 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -432,13 +432,37 @@ gtk_file_chooser_entry_focus_out_event (GtkWidget *widget,
}
static void
+update_inline_completion (GtkFileChooserEntry *chooser_entry)
+{
+ GtkEntryCompletion *completion = gtk_entry_get_completion (GTK_ENTRY (chooser_entry));
+
+ if (!chooser_entry->current_folder_loaded)
+ {
+ gtk_entry_completion_set_inline_completion (completion, FALSE);
+ return;
+ }
+
+ switch (chooser_entry->action)
+ {
+ case GTK_FILE_CHOOSER_ACTION_OPEN:
+ case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
+ gtk_entry_completion_set_inline_completion (completion, TRUE);
+ break;
+ case GTK_FILE_CHOOSER_ACTION_SAVE:
+ case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER:
+ gtk_entry_completion_set_inline_completion (completion, FALSE);
+ break;
+ }
+}
+
+static void
discard_completion_store (GtkFileChooserEntry *chooser_entry)
{
if (!chooser_entry->completion_store)
return;
gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)), NULL);
- gtk_entry_completion_set_inline_completion (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)), FALSE);
+ update_inline_completion (chooser_entry);
g_object_unref (chooser_entry->completion_store);
chooser_entry->completion_store = NULL;
}
@@ -529,7 +553,7 @@ finished_loading_cb (GtkFileSystemModel *model,
gtk_widget_set_tooltip_text (GTK_WIDGET (chooser_entry), NULL);
completion = gtk_entry_get_completion (GTK_ENTRY (chooser_entry));
- gtk_entry_completion_set_inline_completion (completion, TRUE);
+ update_inline_completion (chooser_entry);
gtk_entry_completion_complete (completion);
gtk_entry_completion_insert_prefix (completion);
}
@@ -822,6 +846,8 @@ _gtk_file_chooser_entry_set_action (GtkFileChooserEntry *chooser_entry,
_gtk_file_system_model_set_show_files (GTK_FILE_SYSTEM_MODEL (chooser_entry->completion_store),
action == GTK_FILE_CHOOSER_ACTION_OPEN ||
action == GTK_FILE_CHOOSER_ACTION_SAVE);
+
+ update_inline_completion (chooser_entry);
}
}