Allow to choose to show parent folder
authorKlaus Ethgen <Klaus@Ethgen.de>
Tue, 16 Feb 2016 14:42:38 +0000 (15:42 +0100)
committerKlaus Ethgen <Klaus@Ethgen.de>
Tue, 16 Feb 2016 14:42:38 +0000 (15:42 +0100)
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.

src/options.c
src/options.h
src/preferences.c
src/rcfile.c
src/view_dir_list.c

index 15c0351..1c02f94 100644 (file)
@@ -42,6 +42,7 @@ ConfOptions *init_options(ConfOptions *options)
        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;
index f888e7e..c32b164 100644 (file)
@@ -89,6 +89,7 @@ struct _ConfOptions
        /* file filtering */
        struct {
                gboolean show_hidden_files;
+               gboolean show_parent_directory;
                gboolean show_dot_directory;
                gboolean disable;
        } file_filter;
index d91b8ed..c647d0f 100644 (file)
@@ -197,6 +197,7 @@ static void config_window_apply(void)
        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 @@ static void config_window_apply(void)
        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 @@ static void config_tab_files(GtkWidget *notebook)
 
        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);
 
index ad17096..a7ce0b6 100644 (file)
@@ -364,6 +364,7 @@ static void write_global_attributes(GString *outstr, gint indent)
 
        /* 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 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar **
 
                /* 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;
index 959eb31..6a678e6 100644 (file)
@@ -146,7 +146,15 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
        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)
                {