*
* TODO:
* - cleverer focus to implement typeahead find
- * - don't steal ^A
*/
#include "disobedience.h"
#include "choose.h"
+int choose_auto_expanding;
+
static GtkWidget *choose_search_entry;
static GtkWidget *choose_next;
static GtkWidget *choose_prev;
}
if(is_prefix(dir, track)) {
/* We found a prefix of the target track. */
- //fprintf(stderr, " is a prefix\n");
+ //fprintf(stderr, " %s is a prefix\n", dir);
const gboolean expanded
= gtk_tree_view_row_expanded(GTK_TREE_VIEW(choose_view), path);
if(expanded) {
} else {
//fprintf(stderr, " requesting expansion of %s\n", dir);
/* Track is below a non-expanded directory. So let's expand it.
- * choose_make_visible() will arrange a revisit in due course. */
+ * choose_make_visible() will arrange a revisit in due course.
+ *
+ * We mark the row as auto-expanded.
+ */
+ ++choose_auto_expanding;
gtk_tree_view_expand_row(GTK_TREE_VIEW(choose_view),
path,
FALSE/*open_all*/);
gtk_tree_path_free(path);
- /* TODO: the old version would remember which rows had been expanded
- * just to show search results and collapse them again. We should
- * probably do that. */
+ --choose_auto_expanding;
return 0;
}
} else
*
* If @p row_align is negative no row alignemt is performed. Otherwise
* it must be between 0 (the top) and 1 (the bottom).
+ *
+ * TODO: if the row is already visible do nothing.
*/
static int choose_make_path_visible(GtkTreePath *path,
gfloat row_align) {
/* If there's work left to be done make sure we get a callback when
* something changes */
if(!choose_inserted_handle)
- choose_inserted_handle = event_register("choose-inserted-tracks",
+ choose_inserted_handle = event_register("choose-more-tracks",
choose_make_visible, 0);
} else {
/* Suppress callbacks if there's nothing more to do */
return;
}
//fprintf(stderr, "*** %d search results\n", nvec);
+ /* We're actually going to use these search results. Autocollapse anything
+ * left over from the old search. */
+ choose_auto_collapse();
choose_search_hash = hash_new(1);
if(nvec) {
for(int n = 0; n < nvec; ++n)