diff --git a/CHANGELOG b/CHANGELOG index 06b12f8f..71c5e2ba 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ 6.4.17: - Fix memory leak in __playlist_name() +- Remember search text when changing displayed playlist 6.4.17-rc: - Filter can use GHashTables directly diff --git a/gui/queue.c b/gui/queue.c index f53f79c5..2da8ba4a 100644 --- a/gui/queue.c +++ b/gui/queue.c @@ -81,8 +81,12 @@ void __queue_filter(GtkSearchEntry *entry, gpointer data) if (!gq_queue) return; - if (strlen(text) > 0) + if (gq_queue->gq_search) + g_free(gq_queue->gq_search); + if (strlen(text) > 0) { gq_queue->gq_visible = filter_search(text); + gq_queue->gq_search = g_strdup(text); + } gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(gq_queue->gq_filter)); gui_view_scroll(); @@ -98,6 +102,7 @@ struct gui_queue *gui_queue_alloc(struct queue *queue, const gchar *text, gq->gq_flags = flags; gq->gq_text = g_strdup(text); + gq->gq_search = NULL; gq->gq_model = gui_queue_model_new(queue); gq->gq_filter = gtk_tree_model_filter_new( GTK_TREE_MODEL(gq->gq_model), NULL); @@ -120,6 +125,8 @@ void gui_queue_free(struct queue *queue) if (gq_queue == gq) gui_view_set_model(NULL); + if (gq->gq_search) + g_free(gq->gq_search); g_object_unref(gq->gq_model); g_free(gq->gq_text); g_free(gq); @@ -163,7 +170,7 @@ void gui_queue_show(struct gui_queue *queue) gtk_widget_set_sensitive(GTK_WIDGET(view), is_enabled); gtk_widget_set_sensitive(GTK_WIDGET(search), queue != NULL); - gtk_entry_set_text(search, ""); + gtk_entry_set_text(search, (queue && queue->gq_search) ? queue->gq_search : ""); } void gui_queue_added(struct queue *queue, unsigned int row) diff --git a/include/gui/queue.h b/include/gui/queue.h index 7f315ee9..e57110e0 100644 --- a/include/gui/queue.h +++ b/include/gui/queue.h @@ -16,6 +16,7 @@ enum gui_queue_flags { struct gui_queue { unsigned int gq_flags; gchar *gq_text; + gchar *gq_search; GuiQueueModel *gq_model; GtkTreeModel *gq_filter;