Fix #314: Remote commands for thumbnail maintenance
[geeqie.git] / src / view_dir_tree.c
index 7a5feea..a90a9db 100644 (file)
@@ -1,13 +1,22 @@
 /*
- * Geeqie
- * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
  * Author: John Ellis
  *
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include "main.h"
@@ -431,6 +440,7 @@ gboolean vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gboolean f
        time_t current_time;
        GtkTreeIter child;
        NodeData *nd;
+       gboolean add_hidden = FALSE;
 
        store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));
        gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1);
@@ -455,13 +465,8 @@ gboolean vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gboolean f
                        return TRUE;
                        }
                file_data_check_changed_files(nd->fd); /* make sure we have recent info */
-               if (nd->fd->version == nd->version) return TRUE;
                }
 
-       vdtree_busy_push(vd);
-
-       filelist_read(nd->fd, NULL, &list);
-
        /* when hidden files are not enabled, and the user enters a hidden path,
         * allow the tree to display that path by specifically inserting the hidden entries
         */
@@ -473,21 +478,32 @@ gboolean vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gboolean f
 
                n = strlen(nd->fd->path);
                if (target_fd->path[n] == G_DIR_SEPARATOR && target_fd->path[n+1] == '.')
-                       {
-                       gchar *name8;
+                       add_hidden = TRUE;
+               }
+
+       if (nd->expanded && (!force && !add_hidden) && nd->fd->version == nd->version)
+               return TRUE;
 
-                       n++;
+       vdtree_busy_push(vd);
 
-                       while (target_fd->path[n] != '\0' && target_fd->path[n] != G_DIR_SEPARATOR) n++;
-                       name8 = g_strndup(target_fd->path, n);
+       filelist_read(nd->fd, NULL, &list);
 
-                       if (isdir(name8))
-                               {
-                               list = g_list_prepend(list, file_data_new_dir(name8));
-                               }
+       if (add_hidden)
+               {
+               gint n;
+               gchar *name8;
+
+               n = strlen(nd->fd->path) + 1;
+
+               while (target_fd->path[n] != '\0' && target_fd->path[n] != G_DIR_SEPARATOR) n++;
+               name8 = g_strndup(target_fd->path, n);
 
-                       g_free(name8);
+               if (isdir(name8))
+                       {
+                       list = g_list_prepend(list, file_data_new_dir(name8));
                        }
+
+               g_free(name8);
                }
 
        old = NULL;