X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Flibrary.c;h=614fca434766d3131bd160aa989bd38fcf145116;hb=9357149b3f7d105e03c93439cced8dcd12aa9dba;hp=9a05e12a0b1c85cd606caf2ee507fd80ad9cb517;hpb=be35f211e1af32ce8940db1f10e2fb283bf1fe0a;p=melted_gui diff --git a/src/library.c b/src/library.c index 9a05e12..614fca4 100644 --- a/src/library.c +++ b/src/library.c @@ -21,12 +21,17 @@ # include #endif +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + #include #include #include #include #include #include +#include #include "omnplay.h" #include "ui.h" @@ -386,4 +391,41 @@ playlist_item_t* omnplay_library_get_selected(omnplay_instance_t* app, int *coun void omnplay_library_search(omnplay_instance_t* app, int next) { + int idx = 0, i; + int* idxs; + const char *search; + GtkTreePath* path; + + pthread_mutex_lock(&app->library.lock); + + idxs = get_selected_idx_library(app); + if(idxs) idx = idxs[1]; + free(idxs); + + if(!next) idx = 0; + else idx++; + + search = gtk_entry_get_text(GTK_ENTRY(app->library.search)); + + if(search[0]) + { + for(i = idx; i < app->library.count; i++) + if( strcasestr(app->library.item[i].id, search) || + strcasestr(app->library.item[i].title, search)) + break; + + if(i < app->library.count) + { + fprintf(stderr, "found at pos=%d\n", i); + + /* select */ + path = gtk_tree_path_new_from_indices(i, -1); + gtk_tree_selection_select_path(gtk_tree_view_get_selection( + GTK_TREE_VIEW(app->library_grid)), path); + gtk_tree_view_set_cursor(GTK_TREE_VIEW(app->library_grid), path, NULL, FALSE); + gtk_tree_path_free(path); + }; + }; + + pthread_mutex_unlock(&app->library.lock); };