From c6e9c176d8a4833150e69356cda80b9343507769 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Mon, 1 Aug 2016 10:24:52 -0400 Subject: [PATCH] gui/playlist: Select playlists by double clicking I make the current playlist bold so the user has an easier time finding it. Signed-off-by: Anna Schumaker --- gui/playlist.c | 39 +++++++++++++++++++++++++++++++----- share/ocarina/ocarina6.glade | 1 + 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/gui/playlist.c b/gui/playlist.c index b978768c..7f93a88a 100644 --- a/gui/playlist.c +++ b/gui/playlist.c @@ -2,6 +2,7 @@ * Copyright 2016 (c) Anna Schumaker. */ #include +#include #include #include #include @@ -17,6 +18,7 @@ static GtkTreeStore *p_store; static gchar *p_name = NULL; static bool p_init_done = false; +static void __playlist_update_sizes(struct queue *); static inline enum playlist_type_t __playlist_type(GtkTreeIter *iter) { @@ -37,12 +39,14 @@ static void __playlist_set(GtkTreeIter *iter, const gchar *name, static void __playlist_set_size(GtkTreeIter *iter, const gchar *name) { GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(p_store), iter); - unsigned int size = playlist_size(__playlist_type(iter), name); + enum playlist_type_t type = __playlist_type(iter); + unsigned int size = playlist_size(type, name); const gchar *fmt = "%s\n%d track%s"; gchar *text; - if (gtk_tree_path_get_depth(path) == 1) - fmt = "%s\n%d track%s"; + if (settings_get("core.playlist.cur.type") == type && + settings_get("core.playlist.cur.id") == playlist_get_id(type, name)) + fmt = "%s\n%d track%s"; text = g_markup_printf_escaped(fmt, name, size, (size == 1) ? "" : "s"); gtk_tree_store_set(p_store, iter, P_SB_NAME, text, -1); @@ -139,6 +143,31 @@ out: return true; } +void __playlist_row_activated(GtkTreeView *treeview, GtkTreePath *path, + GtkTreeViewColumn *col, gpointer data) +{ + enum playlist_type_t type; + struct queue *queue; + GtkTreeIter iter; + unsigned int id; + gchar *name; + + type = settings_get("core.playlist.cur.type"); + id = settings_get("core.playlist.cur.id"); + + gtk_tree_model_get_iter(GTK_TREE_MODEL(p_store), &iter, path); + + name = __playlist_name(&iter); + playlist_select(__playlist_type(&iter), name); + __playlist_set_size(&iter, name); + g_free(name); + + name = playlist_get_name(type, id); + queue = playlist_get_queue(type, name); + __playlist_update_sizes(queue); + g_free(name); +} + static bool __playlist_queue_set_size(struct queue *queue, GtkTreeIter *iter) { struct gui_queue *gq = gui_queue(queue); @@ -179,10 +208,10 @@ static void *__playlist_init(struct queue *queue, void *data) struct playlist *playlist = (struct playlist *)data; unsigned int flags = 0; - if (string_match(playlist->pl_name, "Collection")) + if (!string_match(playlist->pl_name, "History")) flags = GQ_CAN_RANDOM; if (string_match(playlist->pl_name, "Queued Tracks")) - flags = GQ_CAN_RANDOM | GQ_CAN_REPEAT; + flags = GQ_CAN_REPEAT; if (p_init_done && playlist->pl_type == PL_ARTIST) gui_playlist_add_artist(artist_find(playlist->pl_name)); return gui_queue_alloc(playlist, queue, playlist->pl_name, flags); diff --git a/share/ocarina/ocarina6.glade b/share/ocarina/ocarina6.glade index 71b97edc..021e0eb5 100644 --- a/share/ocarina/ocarina6.glade +++ b/share/ocarina/ocarina6.glade @@ -722,6 +722,7 @@ 1 True +