Add a new option in Preferences > Filtering to allow the
authorLaurent Monin <geeqie@norz.org>
Tue, 15 Apr 2008 20:36:11 +0000 (20:36 +0000)
committerLaurent Monin <geeqie@norz.org>
Tue, 15 Apr 2008 20:36:11 +0000 (20:36 +0000)
user to choose to display '.' directory in folder lists or not.
This option is saved to rc file as file_filter.show_dot_directory.
A minor fix was made to disable display of .. in folder selection
dialogs when current path is /.

src/globals.c
src/preferences.c
src/rcfile.c
src/typedefs.h
src/ui_pathsel.c
src/view_dir_list.c

index e0aa112..a08a79c 100644 (file)
@@ -67,7 +67,9 @@ ConfOptions *init_options(ConfOptions *options)
        options->thumbnails.fast = TRUE;
        options->thumbnails.spec_standard = TRUE;
        options->enable_metadata_dirs = FALSE;
+
        options->file_filter.show_hidden_files = FALSE;
+       options->file_filter.show_dot_directory = FALSE;
        options->file_filter.disable = FALSE;
        
        
index c90a01c..c9a6d89 100644 (file)
@@ -179,6 +179,7 @@ static void config_window_apply(void)
        if (buf && strlen(buf) > 0) options->file_ops.safe_delete_path = remove_trailing_slash(buf);
 
        if (options->file_filter.show_hidden_files != c_options->file_filter.show_hidden_files) 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;
 
@@ -209,6 +210,8 @@ static void config_window_apply(void)
        options->thumbnails.spec_standard = c_options->thumbnails.spec_standard;
        options->enable_metadata_dirs = c_options->enable_metadata_dirs;
        options->file_filter.show_hidden_files = c_options->file_filter.show_hidden_files;
+       options->file_filter.show_dot_directory = c_options->file_filter.show_dot_directory;
+
        options->file_sort.case_sensitive = c_options->file_sort.case_sensitive;
        options->file_filter.disable = c_options->file_filter.disable;
 
@@ -1031,6 +1034,8 @@ static void config_tab_filtering(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 dot directory"),
+                             options->file_filter.show_dot_directory, &c_options->file_filter.show_dot_directory);
        pref_checkbox_new_int(group, _("Case sensitive sort"),
                              options->file_sort.case_sensitive, &c_options->file_sort.case_sensitive);
 
index ad7c723..8519c3d 100644 (file)
@@ -433,6 +433,7 @@ void save_options(void)
        WRITE_SUBTITLE("Filtering Options");
 
        WRITE_BOOL(file_filter.show_hidden_files);
+       WRITE_BOOL(file_filter.show_dot_directory);
        WRITE_BOOL(file_filter.disable);
        WRITE_SEPARATOR();
 
@@ -706,6 +707,7 @@ void load_options(void)
                /* filtering options */
 
                READ_BOOL(file_filter.show_hidden_files);
+               READ_BOOL(file_filter.show_dot_directory);
                READ_BOOL(file_filter.disable);
 
                if (strcasecmp(option, "file_filter.ext") == 0)
index 8ab0180..c442e26 100644 (file)
@@ -802,6 +802,7 @@ struct _ConfOptions
        /* file filtering */
        struct {
                gint show_hidden_files;
+               gint show_dot_directory;
                gint disable;
        } file_filter;
 
index 22c9027..808a677 100644 (file)
@@ -178,6 +178,12 @@ static void dest_populate(Dest_Data *dd, const gchar *path)
                }
        while ((dir = readdir(dp)) != NULL)
                {
+               if (!options->file_filter.show_dot_directory
+                   && dir->d_name[0] == '.' && dir->d_name[1] == '\0')
+                       continue;
+               if (dir->d_name[0] == '.' && dir->d_name[1] == '.' && dir->d_name[2] == '\0'
+                   && pathl[0] == '/' && pathl[1] == '\0')
+                       continue; /* no .. for root directory */
                if (dd->show_hidden || !is_hidden(dir->d_name))
                        {
                        gchar *name = dir->d_name;
index d5a9426..e4d5619 100644 (file)
@@ -861,10 +861,14 @@ gint vdlist_set_path(ViewDirList *vdl, const gchar *path)
                vdl->list = g_list_prepend(vdl->list, fd);
                g_free(filepath);
                }
-       filepath = g_strconcat(vdl->path, "/", ".", NULL); 
-       fd = file_data_new_simple(filepath);
-       vdl->list = g_list_prepend(vdl->list, fd);
-       g_free(filepath);
+       
+       if (options->file_filter.show_dot_directory)
+               {
+               filepath = g_strconcat(vdl->path, "/", ".", NULL); 
+               fd = file_data_new_simple(filepath);
+               vdl->list = g_list_prepend(vdl->list, fd);
+               g_free(filepath);
+       }
 
        vdlist_populate(vdl);