summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@gnome.org>2011-06-29 16:42:01 -0500
committerFederico Mena Quintero <federico@gnome.org>2011-07-12 17:52:08 -0500
commit03b50bd9a919f4818cc0ad682ff22873a9df5b11 (patch)
tree407ec497bf984406555380885d1a2903f9a14ac2
parentdacdb343db12cc2c7bce0d0a7cadfcc26dcdd690 (diff)
downloadgtk+-03b50bd9a919f4818cc0ad682ff22873a9df5b11.tar.gz
Instruct the user to pick a folder when nothing is selected in the recent-folders list
Signed-off-by: Federico Mena Quintero <federico@gnome.org>
-rw-r--r--gtk/gtkfilechooserdefault.c90
-rw-r--r--gtk/gtkfilechooserprivate.h1
2 files changed, 77 insertions, 14 deletions
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 825f80c8c1..6f16365b0b 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -4974,6 +4974,49 @@ restore_path_bar (GtkFileChooserDefault *impl)
g_object_unref (impl->browse_path_bar_hbox);
}
+/* Takes the folder stored in a row in the recent_model, and puts it in the pathbar */
+static void
+put_recent_folder_in_pathbar (GtkFileChooserDefault *impl, GtkTreeIter *iter)
+{
+ GFile *file;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (impl->recent_model), iter,
+ MODEL_COL_FILE, &file,
+ -1);
+ _gtk_path_bar_set_file (GTK_PATH_BAR (impl->browse_path_bar), file, FALSE, NULL); /* NULL-GError */
+ g_object_unref (file);
+}
+
+/* For recently-used mode, updates the path in the pathbar with the currently-selected item */
+static void
+update_path_bar (GtkFileChooserDefault *impl)
+{
+ if (impl->operation_mode == OPERATION_MODE_RECENT
+ && impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+ {
+ GtkTreeSelection *selection;
+ gboolean have_selected;
+ GtkTreeIter iter;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
+
+ /* Save mode means single-selection mode, so the following is valid */
+ have_selected = gtk_tree_selection_get_selected (selection, NULL, &iter);
+
+ if (have_selected)
+ {
+ put_recent_folder_in_pathbar (impl, &iter);
+ gtk_widget_show (impl->browse_path_bar);
+ gtk_widget_hide (impl->browse_select_a_folder_label);
+ }
+ else
+ {
+ gtk_widget_hide (impl->browse_path_bar);
+ gtk_widget_show (impl->browse_select_a_folder_label);
+ }
+ }
+}
+
/* This function is basically a do_all function.
*
* It sets the visibility on all the widgets based on the current state, and
@@ -5019,6 +5062,7 @@ update_appearance (GtkFileChooserDefault *impl)
_gtk_file_chooser_entry_set_action (GTK_FILE_CHOOSER_ENTRY (impl->location_entry), impl->action);
restore_path_bar (impl);
+ update_path_bar (impl);
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN || !impl->create_folders)
gtk_widget_hide (impl->browse_new_folder_button);
@@ -9230,27 +9274,43 @@ recent_hide_entry (GtkFileChooserDefault *impl)
GtkWidget *image;
gchar *tmp;
+ /* Box for recent widgets */
impl->recent_hbox = gtk_hbox_new (FALSE, 12);
- /* Image */
- image = gtk_image_new_from_icon_name ("document-open-recent", GTK_ICON_SIZE_BUTTON);
- gtk_box_pack_start (GTK_BOX (impl->recent_hbox), image, FALSE, FALSE, 5);
+ gtk_box_pack_start (GTK_BOX (impl->browse_path_bar_hbox), impl->recent_hbox, TRUE, TRUE, 0);
+ gtk_size_group_add_widget (impl->browse_path_bar_size_group, impl->recent_hbox);
+ gtk_widget_show (impl->recent_hbox);
- /* Label */
- label = gtk_label_new (NULL);
- tmp = g_strdup_printf ("<b>%s</b>", _("Recently Used"));
- gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), tmp);
- gtk_box_pack_start (GTK_BOX (impl->recent_hbox), label, FALSE, FALSE, 0);
- g_free (tmp);
+ /* For Save mode, we don't want this icon/label - we want update_path_bar() to do its thing instead */
+ if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+ {
+ char *str;
+
+ str = g_strconcat ("<i>", _("Please select a folder below"), "</i>", NULL);
+ impl->browse_select_a_folder_label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (impl->browse_select_a_folder_label), str);
+ g_free (str);
+ gtk_box_pack_start (GTK_BOX (impl->recent_hbox), impl->browse_select_a_folder_label, FALSE, FALSE, 0);
+ }
+ else
+ {
+ /* Image */
+ image = gtk_image_new_from_icon_name ("document-open-recent", GTK_ICON_SIZE_BUTTON);
+ gtk_box_pack_start (GTK_BOX (impl->recent_hbox), image, FALSE, FALSE, 5);
+ gtk_widget_show (image);
+
+ /* Label */
+ label = gtk_label_new (NULL);
+ tmp = g_strdup_printf ("<b>%s</b>", _("Recently Used"));
+ gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), tmp);
+ gtk_box_pack_start (GTK_BOX (impl->recent_hbox), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+ g_free (tmp);
+ }
gtk_widget_hide (impl->browse_path_bar);
gtk_widget_hide (impl->browse_new_folder_button);
- /* Box for recent widgets */
- gtk_box_pack_start (GTK_BOX (impl->browse_path_bar_hbox), impl->recent_hbox, TRUE, TRUE, 0);
- gtk_size_group_add_widget (impl->browse_path_bar_size_group, impl->recent_hbox);
- gtk_widget_show_all (impl->recent_hbox);
-
/* Hide the location widgets temporarily */
if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
@@ -9749,6 +9809,8 @@ list_selection_changed (GtkTreeSelection *selection,
if (impl->location_entry)
update_chooser_entry (impl);
+ update_path_bar (impl);
+
check_preview_change (impl);
bookmarks_check_add_sensitivity (impl);
diff --git a/gtk/gtkfilechooserprivate.h b/gtk/gtkfilechooserprivate.h
index ebecfcce71..625cd19e0d 100644
--- a/gtk/gtkfilechooserprivate.h
+++ b/gtk/gtkfilechooserprivate.h
@@ -183,6 +183,7 @@ struct _GtkFileChooserDefault
GtkWidget *browse_path_bar_hbox;
GtkSizeGroup *browse_path_bar_size_group;
GtkWidget *browse_path_bar;
+ GtkWidget *browse_select_a_folder_label;
GtkFileSystemModel *browse_files_model;
char *browse_files_last_selected_name;