changeset 2265:15d51cf8ff3d

Allow to choose to show parent folder With e9fc136 we learned buttons for parent folder in directory list. This disabled the ".." handle in the view itself. This was found to be not optimal as the users are used to it. With this patch, that entry is now configurable in preferences. It is enabled by default but could be disabled if the user don't like it.
author Klaus Ethgen <Klaus@Ethgen.de>
date Tue, 16 Feb 2016 15:42:38 +0100
parents d30109a4e36d
children 451165c18b34
files src/options.c src/options.h src/preferences.c src/rcfile.c src/view_dir_list.c
diffstat 5 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/options.c	Mon Feb 15 22:09:52 2016 +0100
+++ b/src/options.c	Tue Feb 16 15:42:38 2016 +0100
@@ -42,6 +42,7 @@
 	options->file_filter.disable = FALSE;
 	options->file_filter.show_dot_directory = FALSE;
 	options->file_filter.show_hidden_files = FALSE;
+	options->file_filter.show_parent_directory = TRUE;
 
 	options->save_window_positions = TRUE;
 	options->tools_restore_state = TRUE;
--- a/src/options.h	Mon Feb 15 22:09:52 2016 +0100
+++ b/src/options.h	Tue Feb 16 15:42:38 2016 +0100
@@ -89,6 +89,7 @@
 	/* file filtering */
 	struct {
 		gboolean show_hidden_files;
+		gboolean show_parent_directory;
 		gboolean show_dot_directory;
 		gboolean disable;
 	} file_filter;
--- a/src/preferences.c	Mon Feb 15 22:09:52 2016 +0100
+++ b/src/preferences.c	Tue Feb 16 15:42:38 2016 +0100
@@ -197,6 +197,7 @@
 	config_entry_to_option(safe_delete_path_entry, &options->file_ops.safe_delete_path, remove_trailing_slash);
 
 	if (options->file_filter.show_hidden_files != c_options->file_filter.show_hidden_files) refresh = TRUE;
+	if (options->file_filter.show_parent_directory != c_options->file_filter.show_parent_directory) refresh = TRUE;
 	if (options->file_filter.show_dot_directory != c_options->file_filter.show_dot_directory) refresh = TRUE;
 	if (options->file_sort.case_sensitive != c_options->file_sort.case_sensitive) refresh = TRUE;
 	if (options->file_filter.disable != c_options->file_filter.disable) refresh = TRUE;
@@ -234,6 +235,7 @@
 	options->thumbnails.spec_standard = c_options->thumbnails.spec_standard;
 	options->metadata.enable_metadata_dirs = c_options->metadata.enable_metadata_dirs;
 	options->file_filter.show_hidden_files = c_options->file_filter.show_hidden_files;
+	options->file_filter.show_parent_directory = c_options->file_filter.show_parent_directory;
 	options->file_filter.show_dot_directory = c_options->file_filter.show_dot_directory;
 
 	options->file_sort.case_sensitive = c_options->file_sort.case_sensitive;
@@ -1502,6 +1504,8 @@
 
 	pref_checkbox_new_int(group, _("Show hidden files or folders"),
 			      options->file_filter.show_hidden_files, &c_options->file_filter.show_hidden_files);
+	pref_checkbox_new_int(group, _("Show parent folder (..)"),
+			      options->file_filter.show_parent_directory, &c_options->file_filter.show_parent_directory);
 	pref_checkbox_new_int(group, _("Case sensitive sort"),
 			      options->file_sort.case_sensitive, &c_options->file_sort.case_sensitive);
 
--- a/src/rcfile.c	Mon Feb 15 22:09:52 2016 +0100
+++ b/src/rcfile.c	Tue Feb 16 15:42:38 2016 +0100
@@ -364,6 +364,7 @@
 
 	/* Filtering Options */
 	WRITE_NL(); WRITE_BOOL(*options, file_filter.show_hidden_files);
+	WRITE_NL(); WRITE_BOOL(*options, file_filter.show_parent_directory);
 	WRITE_NL(); WRITE_BOOL(*options, file_filter.show_dot_directory);
 	WRITE_NL(); WRITE_BOOL(*options, file_filter.disable);
 	WRITE_SEPARATOR();
@@ -622,6 +623,7 @@
 
 		/* Filtering options */
 		if (READ_BOOL(*options, file_filter.show_hidden_files)) continue;
+		if (READ_BOOL(*options, file_filter.show_parent_directory)) continue;
 		if (READ_BOOL(*options, file_filter.show_dot_directory)) continue;
 		if (READ_BOOL(*options, file_filter.disable)) continue;
 		if (READ_CHAR(*options, sidecar.ext)) continue;
--- a/src/view_dir_list.c	Mon Feb 15 22:09:52 2016 +0100
+++ b/src/view_dir_list.c	Tue Feb 16 15:42:38 2016 +0100
@@ -146,7 +146,15 @@
 	ret = filelist_read(vd->dir_fd, NULL, &VDLIST(vd)->list);
 	VDLIST(vd)->list = filelist_sort(VDLIST(vd)->list, sort_type, sort_ascend);
 
-	/* add . */
+	/* add . and .. */
+
+	if (options->file_filter.show_parent_directory && strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0)
+		{
+		filepath = g_build_filename(vd->dir_fd->path, "..", NULL);
+		fd = file_data_new_dir(filepath);
+		VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
+		g_free(filepath);
+		}
 
 	if (options->file_filter.show_dot_directory)
 		{