gui/queue: Remember search text when switching queues
I wasn't doing this, but I also wasn't refiltering queues when they were changed. This resulted in showing a filtered queue, but without a way to clear it. Remembering the text lets me simply set the text, instead of refiltering queues whenever they are changed. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
44a6ad0d78
commit
f7e9e8b321
|
@ -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
|
||||
|
|
11
gui/queue.c
11
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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue