Part fix #711: Deleting image should not scroll file list unnecessarily
[geeqie.git] / src / view_file / view_file_icon.c
index 177e272..64c9baa 100644 (file)
@@ -1135,7 +1135,7 @@ static void vficon_set_focus(ViewFile *vf, FileData *fd)
                        /* ensure focus row col are correct */
                        vficon_find_position(vf, VFICON(vf)->focus_fd, &VFICON(vf)->focus_row, &VFICON(vf)->focus_column);
 #if GTK_CHECK_VERSION(3,0,0)
-/* FIXME: Refer to issue #467 on Github. The thumbnail position is not
+/** @FIXME Refer to issue #467 on Github. The thumbnail position is not
  * preserved when the icon view is refreshed. Caused by an unknown call from
  * the idle loop. This patch hides the problem.
  */
@@ -1799,7 +1799,7 @@ FileData *vficon_thumb_next_fd(ViewFile *vf)
                        GList *list;
                        gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1);
 
-                       // TODO(xsdg): for loop here.
+                       /** @todo (xsdg): for loop here. */
                        for (; list; list = list->next)
                                {
                                FileData *fd = list->data;
@@ -1944,9 +1944,13 @@ static gboolean vficon_refresh_real(ViewFile *vf, gboolean keep_position)
        GList *new_filelist = NULL;
        GList *new_fd_list = NULL;
        GList *old_selected = NULL;
+       GtkTreePath *end_path = NULL;
+       GtkTreePath *start_path = NULL;
 
        focus_fd = VFICON(vf)->focus_fd;
 
+       gtk_tree_view_get_visible_range(GTK_TREE_VIEW(vf->listview), &start_path, &end_path);
+
        if (vf->dir_fd)
                {
                ret = filelist_read(vf->dir_fd, &new_filelist, NULL);
@@ -2080,12 +2084,14 @@ static gboolean vficon_refresh_real(ViewFile *vf, gboolean keep_position)
                }
        file_data_unref(first_selected);
 
-       /* attempt to keep focus on same icon when refreshing */
-       if (focus_fd && g_list_find(vf->list, focus_fd))
+       if (start_path)
                {
-               vficon_set_focus(vf, focus_fd);
+               gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vf->listview), start_path, NULL, FALSE, 0.0, 0.0);
                }
 
+       gtk_tree_path_free(start_path);
+       gtk_tree_path_free(end_path);
+
        return ret;
 }