diff --git a/gui/queue.c b/gui/queue.c
index ad07af8d..ed1a271b 100644
--- a/gui/queue.c
+++ b/gui/queue.c
@@ -10,6 +10,15 @@
static struct gui_queue *gq_queue = NULL;
+enum gq_filter_how {
+ GQ_FILTER_DEFAULT,
+ GQ_FILTER_ALBUM,
+ GQ_FILTER_ARTIST,
+ GQ_FILTER_GENRE,
+ GQ_FILTER_TITLE,
+};
+
+
static void __queue_set_runtime(struct gui_queue *queue)
{
gchar *len;
@@ -72,6 +81,7 @@ static gboolean __queue_visible_func(GtkTreeModel *model, GtkTreeIter *iter,
struct track *track;
unsigned int i;
gchar *token;
+ bool match;
if (!gq_queue || !gq_queue->gq_search)
return TRUE;
@@ -81,11 +91,28 @@ static gboolean __queue_visible_func(GtkTreeModel *model, GtkTreeIter *iter,
for (i = 0; gq_queue->gq_search[i]; i++) {
token = gq_queue->gq_search[i];
- if (!track_match_token(track, token) &&
- !artist_match_token(track->tr_artist, token) &&
- !album_match_token(track->tr_album, token) &&
- !genre_match_token(track->tr_genre, token))
- return FALSE;
+ switch (gq_queue->gq_active) {
+ case GQ_FILTER_ALBUM:
+ match = album_match_token(track->tr_album, token);
+ break;
+ case GQ_FILTER_ARTIST:
+ match = artist_match_token(track->tr_artist, token);
+ break;
+ case GQ_FILTER_GENRE:
+ match = genre_match_token(track->tr_genre, token);
+ break;
+ case GQ_FILTER_TITLE:
+ match = track_match_token(track, token);
+ break;
+ default: /* GQ_FILTER_DEFAULT */
+ match = track_match_token(track, token) ||
+ album_match_token(track->tr_album, token) ||
+ artist_match_token(track->tr_artist, token) ||
+ genre_match_token(track->tr_genre, token);
+ }
+
+ if (!match)
+ return false;
}
return TRUE;
@@ -93,7 +120,8 @@ static gboolean __queue_visible_func(GtkTreeModel *model, GtkTreeIter *iter,
void __queue_filter(GtkSearchEntry *entry, gpointer data)
{
- const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
+ const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
+ GtkComboBox *combo = GTK_COMBO_BOX(gui_builder_widget("filter_how"));
if (!gq_queue)
return;
@@ -101,13 +129,20 @@ void __queue_filter(GtkSearchEntry *entry, gpointer data)
g_strfreev(gq_queue->gq_search);
gq_queue->gq_search = NULL;
}
- if (strlen(text) > 0)
+ if (strlen(text) > 0) {
gq_queue->gq_search = g_str_tokenize_and_fold(text, NULL, NULL);
+ gq_queue->gq_active = gtk_combo_box_get_active(combo);
+ }
gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(gq_queue->gq_filter));
gui_view_scroll();
}
+void __queue_filter_how_changed(int n)
+{
+ __queue_filter(GTK_SEARCH_ENTRY(gui_builder_widget("o_search")), NULL);
+}
+
struct gui_queue *gui_queue_alloc(struct playlist *playlist, struct queue *queue,
const gchar *text, unsigned int flags)
{
diff --git a/include/gui/queue.h b/include/gui/queue.h
index 02fd9eed..a7c3ee76 100644
--- a/include/gui/queue.h
+++ b/include/gui/queue.h
@@ -15,6 +15,7 @@ enum gui_queue_flags {
struct gui_queue {
unsigned int gq_flags;
+ unsigned int gq_active;
gchar *gq_text;
gchar **gq_search;
diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade
index 2bc4e8a1..30a1d348 100644
--- a/share/ocarina/ocarina6.glade
+++ b/share/ocarina/ocarina6.glade
@@ -996,6 +996,28 @@
True
False
5
+
+
+
+ False
+ True
+ 0
+
+
@@ -1026,7 +1048,7 @@
False
True
- 1
+ 2
@@ -1295,8 +1317,10 @@