Per directory settings
So here is the latest version of my attempt to add support for per-directory viewing settings to Thunar, as requested in issue #8. Thanks to everyone who has given feedback and suggestions on previous versions!
This MR implements per-directory saving of view type, sort column, and sort order. I do intend to implement per-directory support for the other features requested (zoom level, column width, hidden files), but I think that view type, sort column, and sort order are the most important ones for now.
A quick summary of the new features
- view type, sort column, and sort order can be set individually for each directory
- the use of per-directory settings is enabled/disabled by a new checkbox in the preferences dialog (Display tab)
- when per-directory settings are disabled (the default option), everything should work as it does before these changes
- per-directory settings are only saved/changed in response to an explicit action from the user, not simply by opening a folder
- any saved settings for the current directory can be deleted via an option in the view menu
It is possible that you may see errors like
Gtk-CRITICAL ... gtk_tree_selection_path_is_selected: assertion 'GTK_IS_TREE_SELECTION (selection)' failed
Gtk-CRITICAL ... gtk_tree_selection_get_select_function: assertion 'GTK_IS_TREE_SELECTION (selection)' failed
These are caused by (what I think is) a bug in exo which can be easily fixed. However, I have not seen them while testing this version of the code, so they might have been solved (?).
I have set these new features to be off by default, as this causes the least change from the user's point of view, but it would be very easy to have them on by default.
A technical point. @alexxcons suggested in response to a previous version that the metadata attributes should not be prefixed with
metadata::thunar::view-type), as then other file browsers can use these settings. I have not implemented this suggestion in this MR, since two of the three metadata values saved (
sort-column) take Thunar-specific values (eg
THUNAR_COLUMN_DATE_MODIFIED) which (I think?) would not be useful to other file browsers.
sort-order does take a generic value provided by GTK, but it seems bad having different prefixing schemes for different attributes. Maybe there is some standard for exchanging this kind of information (?). I am very open to changing this design, however!
Also, I have implemented the function thunar_gvfs_metadata_is_supported (in thunar-gio-extensions) to test whether gvfs metadata is available by querying DBus. I based this function on a few code scraps I found, some experiments, and the comprehensive (but not always easy) GIO documentation. The function detects the presence of gvfs metadata support correctly in tests on my system, but I do not know how well it will function on other systems. Any advice or comments from people who know about GIO or DBus would be very welcome!
As always, comments, criticisms, and suggestions are very welcome!