Part fix #711: Deleting image should not scroll file list unnecessarily
authorColin Clark <[email protected]>
Mon, 27 Sep 2021 13:41:52 +0000 (14:41 +0100)
committerColin Clark <[email protected]>
Mon, 27 Sep 2021 13:41:52 +0000 (14:41 +0100)
https://github.com/BestImageViewer/geeqie/issues/711

This fix still has the following problems:
1. The refresh scrolls the list so that the first thumbnail is
completely aligned in the view
2. Sometimes the first alignment is followed by a second
3. If a selection list is deleted, the thumb with focus is not brought
into the view area
4. If an image in the last row is deleted, sometimes the remaining last
row is not brought completely into the view

src/view_file/view_file_icon.c

index 779c0e0aa10f98360349da5daaf80cbbc3109040..64c9baa2ec084de66540d65e0ca154b4be895269 100644 (file)
@@ -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;
 }