Fix #314: Remote commands for thumbnail maintenance
[geeqie.git] / src / view_dir_list.c
index 244c81f..73f427c 100644 (file)
@@ -1,13 +1,22 @@
 /*
- * Geeqie
- * (C) 2004 John Ellis
- * Copyright (C) 2008 - 2010 The Geeqie Team
+ * Copyright (C) 2004 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"
@@ -96,11 +105,7 @@ static void vdlist_scroll_to_row(ViewDir *vd, FileData *fd, gfloat y_align)
 {
        GtkTreeIter iter;
 
-#if GTK_CHECK_VERSION(2,20,0)
        if (gtk_widget_get_realized(vd->view) && vd_find_row(vd, fd, &iter))
-#else
-       if (GTK_WIDGET_REALIZED(vd->view) && vd_find_row(vd, fd, &iter))
-#endif
                {
                GtkTreeModel *store;
                GtkTreePath *tpath;
@@ -111,11 +116,7 @@ static void vdlist_scroll_to_row(ViewDir *vd, FileData *fd, gfloat y_align)
                gtk_tree_view_set_cursor(GTK_TREE_VIEW(vd->view), tpath, NULL, FALSE);
                gtk_tree_path_free(tpath);
 
-#if GTK_CHECK_VERSION(2,20,0)
                if (!gtk_widget_has_focus(vd->view)) gtk_widget_grab_focus(vd->view);
-#else
-               if (!GTK_WIDGET_HAS_FOCUS(vd->view)) gtk_widget_grab_focus(vd->view);
-#endif
                }
 }
 
@@ -156,7 +157,7 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
 
        /* add . and .. */
 
-       if (strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0)
+       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);
@@ -184,7 +185,7 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
                GdkPixbuf *pixbuf;
                const gchar *date = "";
                gboolean done = FALSE;
-               
+
                fd = work->data;
 
                if (access_file(fd->path, R_OK | X_OK) && fd->name)
@@ -229,7 +230,7 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
 
                                        if (match == 0) g_warning("multiple fd for the same path");
                                        }
-                                       
+
                                }
                        else
                                {
@@ -285,7 +286,7 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
 
                valid = gtk_list_store_remove(store, &iter);
                }
-               
+
 
        vd->click_fd = NULL;
        vd->drop_fd = NULL;
@@ -297,7 +298,7 @@ static gboolean vdlist_populate(ViewDir *vd, gboolean clear)
 gboolean vdlist_set_fd(ViewDir *vd, FileData *dir_fd)
 {
        gboolean ret;
-       gchar *old_path = NULL;
+       gchar *old_path = NULL; /* Used to store directory for walking up */
 
        if (!dir_fd) return FALSE;
        if (vd->dir_fd == dir_fd) return TRUE;
@@ -309,7 +310,7 @@ gboolean vdlist_set_fd(ViewDir *vd, FileData *dir_fd)
                base = remove_level_from_path(vd->dir_fd->path);
                if (strcmp(base, dir_fd->path) == 0)
                        {
-                       old_path = g_strdup(vd->dir_fd->name);
+                       old_path = g_strdup(filename_from_path(vd->dir_fd->path));
                        }
                g_free(base);
                }
@@ -339,11 +340,7 @@ gboolean vdlist_set_fd(ViewDir *vd, FileData *dir_fd)
                return ret;
                }
 
-#if GTK_CHECK_VERSION(2,20,0)
        if (gtk_widget_get_realized(vd->view))
-#else
-       if (GTK_WIDGET_REALIZED(vd->view))
-#endif
                {
                gtk_tree_view_scroll_to_point(GTK_TREE_VIEW(vd->view), 0, 0);
                }
@@ -361,7 +358,7 @@ gboolean vdlist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer dat
        ViewDir *vd = data;
        GtkTreePath *tpath;
 
-       if (event->keyval != GDK_Menu) return FALSE;
+       if (event->keyval != GDK_KEY_Menu) return FALSE;
 
        gtk_tree_view_get_cursor(GTK_TREE_VIEW(vd->view), &tpath, NULL);
        if (tpath)
@@ -409,16 +406,19 @@ gboolean vdlist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer dat
                }
 
        vd->click_fd = fd;
-       vd_color_set(vd, vd->click_fd, TRUE);
+
+       if (options->view_dir_list_single_click_enter)
+               vd_color_set(vd, vd->click_fd, TRUE);
 
        if (bevent->button == MOUSE_BUTTON_RIGHT)
                {
                vd->popup = vd_pop_menu(vd, vd->click_fd);
                gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL,
                               bevent->button, bevent->time);
+               return TRUE;
                }
 
-       return TRUE;
+       return options->view_dir_list_single_click_enter;
 }
 
 void vdlist_destroy_cb(GtkWidget *widget, gpointer data)