diff --git a/ChangeLog b/ChangeLog index 9eccc349bd..9d5421ef61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,13 @@ * gtk/gtkfilechooserdefault.c (location_mode_set): Just change the location_mode field if we are in SAVE/CREATE_FOLDER modes. + (gtk_file_chooser_default_get_paths): Get the path based on the + currently focused widget, or the last-focused widget. This is + what we should have been doing in the beginning, but it worked out + fine because we didn't have the possibility of a filename entry in + OPEN mode. + (gtk_file_chooser_default_should_respond): Handle the case where + the last focused widget is the location_entry. 2006-03-28 Federico Mena Quintero diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9eccc349bd..9d5421ef61 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -2,6 +2,13 @@ * gtk/gtkfilechooserdefault.c (location_mode_set): Just change the location_mode field if we are in SAVE/CREATE_FOLDER modes. + (gtk_file_chooser_default_get_paths): Get the path based on the + currently focused widget, or the last-focused widget. This is + what we should have been doing in the beginning, but it worked out + fine because we didn't have the possibility of a filename entry in + OPEN mode. + (gtk_file_chooser_default_should_respond): Handle the case where + the last focused widget is the location_entry. 2006-03-28 Federico Mena Quintero diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index 6a10c42770..63cbbeb065 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -6031,15 +6031,34 @@ gtk_file_chooser_default_get_paths (GtkFileChooser *chooser) { GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser); struct get_paths_closure info; + GtkWindow *toplevel; + GtkWidget *current_focus; info.impl = impl; info.result = NULL; info.path_from_entry = NULL; - if (impl->location_entry) + toplevel = get_toplevel (GTK_WIDGET (impl)); + if (toplevel) + current_focus = gtk_window_get_focus (toplevel); + else + current_focus = NULL; + + if (current_focus == impl->browse_files_tree_view) + { + GtkTreeSelection *selection; + + file_list: + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view)); + gtk_tree_selection_selected_foreach (selection, get_paths_foreach, &info); + } + else if (impl->location_entry && current_focus == impl->location_entry) { gboolean is_well_formed, is_empty, is_file_part_empty; + file_entry: + check_save_entry (impl, &info.path_from_entry, &is_well_formed, &is_empty, &is_file_part_empty); if (!is_well_formed) @@ -6053,19 +6072,23 @@ gtk_file_chooser_default_get_paths (GtkFileChooser *chooser) return NULL; } } - } - if (!info.path_from_entry || impl->select_multiple) + info.result = g_slist_prepend (info.result, info.path_from_entry); + } + else if (impl->toplevel_last_focus_widget == impl->browse_files_tree_view) + goto file_list; + else if (impl->location_entry && impl->toplevel_last_focus_widget == impl->location_entry) + goto file_entry; + else { - GtkTreeSelection *selection; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view)); - gtk_tree_selection_selected_foreach (selection, get_paths_foreach, &info); + /* The focus is on a dialog's action area button or something else */ + if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE + || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER) + goto file_entry; + else + goto file_list; } - if (info.path_from_entry) - info.result = g_slist_prepend (info.result, info.path_from_entry); - /* If there's no folder selected, and we're in SELECT_FOLDER mode, then we * fall back to the current directory */ if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER && @@ -6885,6 +6908,13 @@ gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed) */ goto file_list; } + else if (impl->location_entry && impl->toplevel_last_focus_widget == impl->location_entry) + { + /* The focus is on a dialog's action area button, *and* the widget that + * was focused immediately before it is the location entry. + */ + goto save_entry; + } else /* The focus is on a dialog's action area button or something else */ if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE