summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2004-03-25 21:36:02 +0000
committerFederico Mena Quintero <federico@src.gnome.org>2004-03-25 21:36:02 +0000
commitcd486d396fb0f85cdfa462ba6538564535f99825 (patch)
treec7c52f01de8465a80f8cb3cca73c501f3bddf9a8
parentc30e3b222c76285e3f7699580b73ebb4cec363f4 (diff)
downloadgtk+-cd486d396fb0f85cdfa462ba6538564535f99825.tar.gz
Fill the location entry with the display name of the file under the cursor
2004-03-25 Federico Mena Quintero <federico@ximian.com> * gtk/gtkfilechooserdefault.c (location_entry_create): Fill the location entry with the display name of the file under the cursor for Open mode, or the typed filename in Save mode.
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.pre-2-106
-rw-r--r--ChangeLog.pre-2-46
-rw-r--r--ChangeLog.pre-2-66
-rw-r--r--ChangeLog.pre-2-86
-rw-r--r--gtk/gtkfilechooserdefault.c50
6 files changed, 80 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 78733c133d..f96283ed17 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-03-25 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilechooserdefault.c (location_entry_create): Fill the
+ location entry with the display name of the file under the cursor
+ for Open mode, or the typed filename in Save mode.
+
2004-03-24 J. Ali Harlow <ali@juiblex.co.uk>
* gtk/gtkfilesystemwin32.c
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 78733c133d..f96283ed17 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,9 @@
+2004-03-25 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilechooserdefault.c (location_entry_create): Fill the
+ location entry with the display name of the file under the cursor
+ for Open mode, or the typed filename in Save mode.
+
2004-03-24 J. Ali Harlow <ali@juiblex.co.uk>
* gtk/gtkfilesystemwin32.c
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 78733c133d..f96283ed17 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,9 @@
+2004-03-25 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilechooserdefault.c (location_entry_create): Fill the
+ location entry with the display name of the file under the cursor
+ for Open mode, or the typed filename in Save mode.
+
2004-03-24 J. Ali Harlow <ali@juiblex.co.uk>
* gtk/gtkfilesystemwin32.c
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 78733c133d..f96283ed17 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,9 @@
+2004-03-25 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilechooserdefault.c (location_entry_create): Fill the
+ location entry with the display name of the file under the cursor
+ for Open mode, or the typed filename in Save mode.
+
2004-03-24 J. Ali Harlow <ali@juiblex.co.uk>
* gtk/gtkfilesystemwin32.c
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 78733c133d..f96283ed17 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,9 @@
+2004-03-25 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilechooserdefault.c (location_entry_create): Fill the
+ location entry with the display name of the file under the cursor
+ for Open mode, or the typed filename in Save mode.
+
2004-03-24 J. Ali Harlow <ali@juiblex.co.uk>
* gtk/gtkfilesystemwin32.c
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index bc50bfe1b9..0a74308caf 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -4867,6 +4867,47 @@ _gtk_file_chooser_default_new (const char *file_system)
NULL);
}
+/* Sets the file part of a file chooser entry from the file under the cursor */
+static void
+location_entry_set_from_list (GtkFileChooserDefault *impl,
+ GtkFileChooserEntry *entry)
+{
+ GtkTreePath *tree_path;
+ GtkTreeIter iter, child_iter;
+ const GtkFileInfo *info;
+ const char *name;
+
+ g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
+ || impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+
+ gtk_tree_view_get_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), &tree_path, NULL);
+ if (!tree_path)
+ return;
+
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->sort_model), &iter, tree_path);
+ gtk_tree_path_free (tree_path);
+
+ gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model, &child_iter, &iter);
+
+ info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
+ if (!info)
+ return;
+
+ name = gtk_file_info_get_display_name (info);
+ _gtk_file_chooser_entry_set_file_part (entry, name);
+}
+
+/* Sets the file part of a file chooser entry from the Name entry in save mode */
+static void
+location_entry_set_from_save_name (GtkFileChooserDefault *impl,
+ GtkFileChooserEntry *entry)
+{
+ g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+ || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
+
+ _gtk_file_chooser_entry_set_file_part (entry, gtk_entry_get_text (GTK_ENTRY (impl->save_file_name_entry)));
+}
+
static GtkWidget *
location_entry_create (GtkFileChooserDefault *impl)
{
@@ -4879,6 +4920,15 @@ location_entry_create (GtkFileChooserDefault *impl)
_gtk_file_chooser_entry_set_file_system (GTK_FILE_CHOOSER_ENTRY (entry), impl->file_system);
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (entry), impl->current_folder);
+ if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
+ || impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
+ location_entry_set_from_list (impl, GTK_FILE_CHOOSER_ENTRY (entry));
+ else if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+ || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+ location_entry_set_from_save_name (impl, GTK_FILE_CHOOSER_ENTRY (entry));
+ else
+ g_assert_not_reached ();
+
return GTK_WIDGET (entry);
}