X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/86214c4a61b9ab346d7c4b6a12c9825a13caf921..1f2a5e52d2a40d7a80a18afc93f9da173e7a2196:/disobedience/choose-menu.c diff --git a/disobedience/choose-menu.c b/disobedience/choose-menu.c index f1aa3b0..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; @@ -121,7 +130,7 @@ static void choose_properties_activate(GtkMenuItem attribute((unused)) *item, gtk_tree_selection_selected_foreach(choose_selection, choose_gather_selected_files_callback, v); - properties(v->nvec, (const char **)v->vec); + properties(v->nvec, (const char **)v->vec, toplevel); } /** @brief Set sensitivity for select children @@ -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,