static bool_t search_cb (GtkTreeModel * model, int column, const char * key, GtkTreeIter * iter, void * user) { GtkTreePath * path = gtk_tree_model_get_path (model, iter); g_return_val_if_fail (path, TRUE); int row = gtk_tree_path_get_indices (path)[0]; gtk_tree_path_free (path); char * title = aud_playlist_get_title (row); g_return_val_if_fail (title, TRUE); Index * keys = str_list_to_index (key, " "); int count = index_count (keys); bool_t match = FALSE; for (int i = 0; i < count; i ++) { if (strstr_nocase_utf8 (title, index_get (keys, i))) match = TRUE; else { match = FALSE; break; } } index_free_full (keys, (IndexFreeFunc) str_unref); str_unref (title); return ! match; /* TRUE == not matched, FALSE == matched */ }
void pw_col_init (void) { pw_num_cols = 0; char * columns = aud_get_str ("gtkui", "playlist_columns"); Index * index = str_list_to_index (columns, " "); int count = index_count (index); if (count > PW_COLS) count = PW_COLS; for (int c = 0; c < count; c ++) { char * column = index_get (index, c); int i = 0; while (i < PW_COLS && strcmp (column, pw_col_keys[i])) i ++; if (i == PW_COLS) break; pw_cols[pw_num_cols ++] = i; } index_free_full (index, (IndexFreeFunc) str_unref); str_unref (columns); }
static void set_search_phrase (const char * phrase) { char * folded = str_tolower_utf8 (phrase); index_free_full (search_terms, (IndexFreeFunc) str_unref); search_terms = str_list_to_index (folded, " "); str_unref (folded); }
static bool_t search_cb (GtkTreeModel * model, int column, const char * search, GtkTreeIter * iter, void * user) { GtkTreePath * path = gtk_tree_model_get_path (model, iter); g_return_val_if_fail (path, TRUE); int row = gtk_tree_path_get_indices (path)[0]; g_return_val_if_fail (row >= 0, TRUE); gtk_tree_path_free (path); Index * keys = str_list_to_index (search, " "); int n_keys = index_count (keys); bool_t matched = FALSE; if (n_keys) { char * s[3] = {NULL, NULL, NULL}; aud_playlist_entry_describe (((PlaylistWidgetData *) user)->list, row, & s[0], & s[1], & s[2], FALSE); for (int i = 0; i < ARRAY_LEN (s); i ++) { if (! s[i]) continue; for (int j = 0; j < n_keys;) { if (strstr_nocase_utf8 (s[i], index_get (keys, j))) { index_delete_full (keys, j, 1, (IndexFreeFunc) str_unref); n_keys --; } else j ++; } str_unref (s[i]); } matched = ! n_keys; } index_free_full (keys, (IndexFreeFunc) str_unref); return ! matched; }