mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-18 09:00:34 +00:00
Switch to Recent Files or $CWD at startup
Signed-off-by: Federico Mena Quintero <federico@gnome.org>
This commit is contained in:
parent
ebb2977a54
commit
a591a15382
@ -5920,6 +5920,7 @@ settings_load (GtkFileChooserDefault *impl)
|
|||||||
gboolean show_size_column;
|
gboolean show_size_column;
|
||||||
gint sort_column;
|
gint sort_column;
|
||||||
GtkSortType sort_order;
|
GtkSortType sort_order;
|
||||||
|
StartupMode startup_mode;
|
||||||
|
|
||||||
settings = _gtk_file_chooser_settings_new ();
|
settings = _gtk_file_chooser_settings_new ();
|
||||||
|
|
||||||
@ -5928,6 +5929,7 @@ settings_load (GtkFileChooserDefault *impl)
|
|||||||
show_size_column = _gtk_file_chooser_settings_get_show_size_column (settings);
|
show_size_column = _gtk_file_chooser_settings_get_show_size_column (settings);
|
||||||
sort_column = _gtk_file_chooser_settings_get_sort_column (settings);
|
sort_column = _gtk_file_chooser_settings_get_sort_column (settings);
|
||||||
sort_order = _gtk_file_chooser_settings_get_sort_order (settings);
|
sort_order = _gtk_file_chooser_settings_get_sort_order (settings);
|
||||||
|
startup_mode = _gtk_file_chooser_settings_get_startup_mode (settings);
|
||||||
|
|
||||||
g_object_unref (settings);
|
g_object_unref (settings);
|
||||||
|
|
||||||
@ -5944,6 +5946,8 @@ settings_load (GtkFileChooserDefault *impl)
|
|||||||
* created yet. The individual functions that create and set the models will
|
* created yet. The individual functions that create and set the models will
|
||||||
* call set_sort_column() themselves.
|
* call set_sort_column() themselves.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
impl->startup_mode = startup_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -5990,6 +5994,7 @@ settings_save (GtkFileChooserDefault *impl)
|
|||||||
_gtk_file_chooser_settings_set_show_size_column (settings, impl->show_size_column);
|
_gtk_file_chooser_settings_set_show_size_column (settings, impl->show_size_column);
|
||||||
_gtk_file_chooser_settings_set_sort_column (settings, impl->sort_column);
|
_gtk_file_chooser_settings_set_sort_column (settings, impl->sort_column);
|
||||||
_gtk_file_chooser_settings_set_sort_order (settings, impl->sort_order);
|
_gtk_file_chooser_settings_set_sort_order (settings, impl->sort_order);
|
||||||
|
_gtk_file_chooser_settings_set_startup_mode (settings, impl->startup_mode);
|
||||||
|
|
||||||
save_dialog_geometry (impl, settings);
|
save_dialog_geometry (impl, settings);
|
||||||
|
|
||||||
@ -6036,6 +6041,38 @@ get_file_for_last_folder_opened (GtkFileChooserDefault *impl)
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Changes the current folder to $CWD */
|
||||||
|
static void
|
||||||
|
switch_to_cwd (GtkFileChooserDefault *impl)
|
||||||
|
{
|
||||||
|
char *current_working_dir;
|
||||||
|
|
||||||
|
current_working_dir = g_get_current_dir ();
|
||||||
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (impl), current_working_dir);
|
||||||
|
g_free (current_working_dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets the file chooser to showing Recent Files or $CWD, depending on the
|
||||||
|
* user's settings.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
set_startup_mode (GtkFileChooserDefault *impl)
|
||||||
|
{
|
||||||
|
switch (impl->startup_mode)
|
||||||
|
{
|
||||||
|
case STARTUP_MODE_RECENT:
|
||||||
|
recent_shortcut_handler (impl);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STARTUP_MODE_CWD:
|
||||||
|
switch_to_cwd (impl);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* GtkWidget::map method */
|
/* GtkWidget::map method */
|
||||||
static void
|
static void
|
||||||
gtk_file_chooser_default_map (GtkWidget *widget)
|
gtk_file_chooser_default_map (GtkWidget *widget)
|
||||||
@ -6048,12 +6085,14 @@ gtk_file_chooser_default_map (GtkWidget *widget)
|
|||||||
|
|
||||||
GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->map (widget);
|
GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->map (widget);
|
||||||
|
|
||||||
|
settings_load (impl);
|
||||||
|
|
||||||
if (impl->operation_mode == OPERATION_MODE_BROWSE)
|
if (impl->operation_mode == OPERATION_MODE_BROWSE)
|
||||||
{
|
{
|
||||||
switch (impl->reload_state)
|
switch (impl->reload_state)
|
||||||
{
|
{
|
||||||
case RELOAD_EMPTY:
|
case RELOAD_EMPTY:
|
||||||
recent_shortcut_handler (impl);
|
set_startup_mode (impl);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RELOAD_HAS_FOLDER:
|
case RELOAD_HAS_FOLDER:
|
||||||
@ -6069,8 +6108,6 @@ gtk_file_chooser_default_map (GtkWidget *widget)
|
|||||||
|
|
||||||
volumes_bookmarks_changed_cb (impl->file_system, impl);
|
volumes_bookmarks_changed_cb (impl->file_system, impl);
|
||||||
|
|
||||||
settings_load (impl);
|
|
||||||
|
|
||||||
profile_end ("end", NULL);
|
profile_end ("end", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user