mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-08 17:50:10 +00:00
filechooser: Save and restore view type
With this, the filechooser comes up with the same view (grid or list) that it had the last time you used it.
This commit is contained in:
parent
10338a5237
commit
ee5324359d
@ -46,6 +46,7 @@ G_BEGIN_DECLS
|
||||
#define SETTINGS_KEY_CLOCK_FORMAT "clock-format"
|
||||
#define SETTINGS_KEY_DATE_FORMAT "date-format"
|
||||
#define SETTINGS_KEY_TYPE_FORMAT "type-format"
|
||||
#define SETTINGS_KEY_VIEW_TYPE "view-type"
|
||||
|
||||
#define GTK_FILE_CHOOSER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_CHOOSER, GtkFileChooserIface))
|
||||
|
||||
|
@ -3224,6 +3224,7 @@ settings_load (GtkFileChooserWidget *impl)
|
||||
gboolean sort_directories_first;
|
||||
DateFormat date_format;
|
||||
TypeFormat type_format;
|
||||
ViewType view_type;
|
||||
int sort_column;
|
||||
GtkSortType sort_order;
|
||||
StartupMode startup_mode;
|
||||
@ -3242,6 +3243,7 @@ settings_load (GtkFileChooserWidget *impl)
|
||||
sort_directories_first = g_settings_get_boolean (settings, SETTINGS_KEY_SORT_DIRECTORIES_FIRST);
|
||||
date_format = g_settings_get_enum (settings, SETTINGS_KEY_DATE_FORMAT);
|
||||
type_format = g_settings_get_enum (settings, SETTINGS_KEY_TYPE_FORMAT);
|
||||
view_type = g_settings_get_enum (settings, SETTINGS_KEY_VIEW_TYPE);
|
||||
|
||||
set_show_hidden (impl, show_hidden);
|
||||
|
||||
@ -3258,6 +3260,8 @@ settings_load (GtkFileChooserWidget *impl)
|
||||
impl->clock_format = g_settings_get_enum (settings, "clock-format");
|
||||
impl->type_format = type_format;
|
||||
|
||||
set_view_type (impl, view_type);
|
||||
|
||||
/* We don't call set_sort_column() here as the models may not have been
|
||||
* created yet. The individual functions that create and set the models will
|
||||
* call set_sort_column() themselves.
|
||||
@ -3294,6 +3298,7 @@ settings_save (GtkFileChooserWidget *impl)
|
||||
gtk_paned_get_position (GTK_PANED (impl->browse_widgets_hpaned)));
|
||||
g_settings_set_enum (settings, SETTINGS_KEY_DATE_FORMAT, impl->show_time ? DATE_FORMAT_WITH_TIME : DATE_FORMAT_REGULAR);
|
||||
g_settings_set_enum (settings, SETTINGS_KEY_TYPE_FORMAT, impl->type_format);
|
||||
g_settings_set_enum (settings, SETTINGS_KEY_VIEW_TYPE, impl->view_type);
|
||||
|
||||
/* Now apply the settings */
|
||||
g_settings_apply (settings);
|
||||
|
@ -55,6 +55,11 @@
|
||||
<value nick='category' value='2'/>
|
||||
</enum>
|
||||
|
||||
<enum id='org.gtk.gtk4.Settings.FileChooser.ViewType'>
|
||||
<value nick='list' value='0'/>
|
||||
<value nick='grid' value='1'/>
|
||||
</enum>
|
||||
|
||||
<schema id='org.gtk.gtk4.Settings.FileChooser' path='/org/gtk/gtk4/settings/file-chooser/'>
|
||||
<key name='location-mode' enum='org.gtk.gtk4.Settings.FileChooser.LocationMode'>
|
||||
<default>'path-bar'</default>
|
||||
@ -169,6 +174,13 @@
|
||||
'category' -> 'Video'
|
||||
</description>
|
||||
</key>
|
||||
<key name="view-type" enum="org.gtk.gtk4.Settings.FileChooser.ViewType">
|
||||
<default>'list'</default>
|
||||
<summary>View type</summary>
|
||||
<description>
|
||||
Whether the files are shown in a list or in a grid.
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
|
||||
</schemalist>
|
||||
|
Loading…
Reference in New Issue
Block a user