[gtk+/bgo593793-filechooser-recent-folders] Instruct the user to pick a folder when nothing is selected in the recent-folders list
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/bgo593793-filechooser-recent-folders] Instruct the user to pick a folder when nothing is selected in the recent-folders list
- Date: Wed, 29 Jun 2011 21:45:06 +0000 (UTC)
commit e6ceb4228958591f62fc96e3992c6d51447108c7
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Jun 29 16:42:01 2011 -0500
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>
gtk/gtkfilechooserdefault.c | 90 ++++++++++++++++++++++++++++++++++++-------
gtk/gtkfilechooserprivate.h | 1 +
2 files changed, 77 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index ac7d9d6..d4c0249 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -4992,6 +4992,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
@@ -5037,6 +5080,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);
@@ -9252,27 +9296,43 @@ recent_hide_entry (GtkFileChooserDefault *impl)
GtkWidget *image;
gchar *tmp;
+ /* Box for recent widgets */
impl->recent_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 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)
@@ -9771,6 +9831,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 74902ae..3e32d67 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]