-static void choose_next_clicked(GtkButton attribute((unused)) *button,
- gpointer attribute((unused)) userdata) {
- /* Find the last visible row */
- GtkTreePath *endpath;
- gboolean endvalid = choose_get_visible_range(GTK_TREE_VIEW(choose_view),
- NULL,
- &endpath);
- if(!endvalid)
+/** @brief Move to the next/prev match
+ * @param direction -1 for prev, +1 for next
+ */
+static void choose_move(int direction) {
+ /* Refocus the main view so typahead find continues to work */
+ gtk_widget_grab_focus(choose_view);
+ /* If there's no results we have nothing to do */
+ if(!choose_n_search_results)
+ return;
+ /* Compute bounds for searching over the array in the right direction */
+ const int first = direction > 0 ? 0 : choose_n_search_references - 1;
+ const int limit = direction > 0 ? choose_n_search_references : -1;
+ /* Find the first/last currently visible row */
+ GtkTreePath *limitpath;
+ if(!choose_get_visible_range(GTK_TREE_VIEW(choose_view),
+ direction < 0 ? &limitpath : 0,
+ direction > 0 ? &limitpath : 0))