summaryrefslogtreecommitdiff
path: root/gtk/gtkfilechooserentry.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2004-09-17 18:13:26 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-09-17 18:13:26 +0000
commit350559dea8f48114796c2c895dab0d0cb66413d2 (patch)
treec74d1f188236d749701d1fc8b910e15dbdcabf2b /gtk/gtkfilechooserentry.c
parent4e7e40493853047d2bc91d1b4c4bd00ba8405d19 (diff)
downloadgdk-pixbuf-350559dea8f48114796c2c895dab0d0cb66413d2.tar.gz
Remove leftover debug code.
2004-09-17 Matthias Clasen <mclasen@redhat.com> * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render): Remove leftover debug code. Improve the behaviour of the file chooser in save mode. Fixes bugs #151031, #151608, #151994 reported by Owen Taylor and Alexander Larsson. * gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_set_property): (location_entry_create): Propagate the action to the file chooser entries. (gtk_file_chooser_default_should_respond): Switch folders if the user enters a directory name in the entry and clear the entry after switching folders. (gtk_file_chooser_default_should_respond, shortcuts_row_activated_cb): Move focus to the file list when activating a shortcut. (gtk_file_chooser_default_should_respond): Handle the case where the user clicks on "Save" after selecting a folder in the file list. * gtk/gtkfilechooserbutton.c (gtk_file_chooser_button_set_property): Propagate the action to the file chooser entries. * gtk/gtkfilechooserentry.h: * gtk/gtkfilechooserentry.c (_gtk_file_chooser_entry_set_action): (_gtk_file_chooser_entry_get_action): New functions to propagate the GtkFileChooserAction of the file chooser to the file chooser entry. (check_completion_callback): If we are in save mode, only do inline completion for directories.
Diffstat (limited to 'gtk/gtkfilechooserentry.c')
-rw-r--r--gtk/gtkfilechooserentry.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 1d942a099..4d9a09856 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -43,6 +43,8 @@ struct _GtkFileChooserEntry
{
GtkEntry parent_instance;
+ GtkFileChooserAction action;
+
GtkFileSystem *file_system;
GtkFilePath *base_folder;
GtkFilePath *current_folder_path;
@@ -175,6 +177,7 @@ gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry)
GtkCellRenderer *cell;
comp = gtk_entry_completion_new ();
+
gtk_entry_completion_set_match_func (comp,
completion_match_func,
chooser_entry,
@@ -451,6 +454,19 @@ check_completion_callback (GtkFileChooserEntry *chooser_entry)
gtk_file_path_free (unique_path);
}
+ switch (chooser_entry->action)
+ {
+ case GTK_FILE_CHOOSER_ACTION_SAVE:
+ case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
+ if (common_prefix && !g_str_has_suffix (common_prefix, "/"))
+ {
+ g_free (common_prefix);
+ common_prefix = NULL;
+ }
+ break;
+ default: ;
+ }
+
if (common_prefix)
{
gint file_part_len;
@@ -874,6 +890,11 @@ _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry,
const GtkFilePath *
_gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry)
{
+ if (chooser_entry->has_completion)
+ {
+ gtk_editable_set_position (GTK_EDITABLE (chooser_entry),
+ GTK_ENTRY (chooser_entry)->text_length);
+ }
return chooser_entry->current_folder_path;
}
@@ -892,6 +913,11 @@ _gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry)
const gchar *
_gtk_file_chooser_entry_get_file_part (GtkFileChooserEntry *chooser_entry)
{
+ if (chooser_entry->has_completion)
+ {
+ gtk_editable_set_position (GTK_EDITABLE (chooser_entry),
+ GTK_ENTRY (chooser_entry)->text_length);
+ }
return chooser_entry->file_part;
}
@@ -910,3 +936,43 @@ _gtk_file_chooser_entry_set_file_part (GtkFileChooserEntry *chooser_entry,
gtk_entry_set_text (GTK_ENTRY (chooser_entry), file_part);
}
+
+
+/**
+ * _gtk_file_chooser_entry_set_action:
+ * @chooser_entry: a #GtkFileChooserEntry
+ * @action: the action which is performed by the file selector using this entry
+ *
+ * Sets action which is performed by the file selector using this entry.
+ * The #GtkFileChooserEntry will use different completion strategies for
+ * different actions.
+ **/
+void
+_gtk_file_chooser_entry_set_action (GtkFileChooserEntry *chooser_entry,
+ GtkFileChooserAction action)
+{
+ g_return_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry));
+
+ if ( chooser_entry->action != action)
+ {
+ chooser_entry->action = action;
+ }
+}
+
+
+/**
+ * _gtk_file_chooser_entry_get_action:
+ * @chooser_entry: a #GtkFileChooserEntry
+ *
+ * Gets the action for this entry.
+ *
+ * Returns: the action
+ **/
+GtkFileChooserAction
+_gtk_file_chooser_entry_get_action (GtkFileChooserEntry *chooser_entry)
+{
+ g_return_val_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry),
+ GTK_FILE_CHOOSER_ACTION_OPEN);
+
+ return chooser_entry->action;
+}