- /* TODO can we de-dupe with choose_next_clicked? Probably yes. */
- if(!choose_n_search_results)
- return;
- /* Find the first visible row */
- GtkTreePath *startpath;
- gboolean startvalid = choose_get_visible_range(GTK_TREE_VIEW(choose_view),
- &startpath,
- NULL);
- if(!startvalid)
- return;
- /* Find a the last search result earlier than it. They're sorted so we could
- * actually do much better than this if necessary. */
- for(int n = choose_n_search_references - 1; n >= 0; --n) {
- GtkTreePath *path
- = gtk_tree_row_reference_get_path(choose_search_references[n]);
- if(!path)
- continue;
- if(gtk_tree_path_compare(startpath, path) > 0) {
- choose_make_path_visible(path, 0.5);
- gtk_tree_path_free(path);
- return;
- }
- gtk_tree_path_free(path);
- }
- /* We didn't find one. Loop down to the last. */
- for(int n = choose_n_search_references - 1; n >= 0; --n) {
- GtkTreePath *path
- = gtk_tree_row_reference_get_path(choose_search_references[n]);
- if(!path)
- continue;
- choose_make_path_visible(path, 0.5);
- gtk_tree_path_free(path);
- return;
- }