From a49ece1c2659e81118e2f2f77e6ae480d39327f1 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Fri, 27 Nov 2009 19:54:51 +0000 Subject: [PATCH] Add new 'play children' option to track chooser. This will play all the files in a directory. It also opens the directory, giving the user feedback. (But it does not select the children.) Organization: Straylight/Edgeware From: Richard Kettlewell --- disobedience/choose-menu.c | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/disobedience/choose-menu.c b/disobedience/choose-menu.c index 44ad04f..61943d2 100644 --- a/disobedience/choose-menu.c +++ b/disobedience/choose-menu.c @@ -22,6 +22,15 @@ #include "popup.h" #include "choose.h" +static void choose_playchildren_callback(GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data); +static void choose_playchildren_received(void *v, + const char *err, + int nvec, char **vec); +static void choose_playchildren_played(void *v, const char *err); + /** @brief Popup menu */ static GtkWidget *choose_menu; @@ -210,6 +219,48 @@ static void choose_selectchildren_activate 0); } +/** @brief Play all children */ +static void choose_playchildren_activate + (GtkMenuItem attribute((unused)) *item, + gpointer attribute((unused)) userdata) { + /* Only one thing is selected */ + gtk_tree_selection_selected_foreach(choose_selection, + choose_playchildren_callback, + 0); +} + +static void choose_playchildren_callback(GtkTreeModel attribute((unused)) *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer attribute((unused)) data) { + /* Find the children and play them */ + disorder_eclient_files(client, choose_playchildren_received, + choose_get_track(iter), + NULL/*re*/, + NULL); + /* Expand the node */ + gtk_tree_view_expand_row(GTK_TREE_VIEW(choose_view), path, FALSE); +} + +static void choose_playchildren_received(void attribute((unused)) *v, + const char *err, + int nvec, char **vec) { + if(err) { + popup_protocol_error(0, err); + return; + } + for(int n = 0; n < nvec; ++n) + disorder_eclient_play(client, vec[n], choose_playchildren_played, NULL); +} + +static void choose_playchildren_played(void attribute((unused)) *v, + const char *err) { + if(err) { + popup_protocol_error(0, err); + return; + } +} + /** @brief Pop-up menu for choose */ static struct menuitem choose_menuitems[] = { { @@ -233,6 +284,13 @@ static struct menuitem choose_menuitems[] = { 0, 0 }, + { + "Play children", + choose_playchildren_activate, + choose_selectchildren_sensitive, /* re-use */ + 0, + 0 + }, { "Deselect all tracks", choose_selectnone_activate, -- [mdw]