X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/d64e1d92acaf5a00908f630848f1f308574847ea..3fe2333a1fa62389ad049a1c1ca43fee77a3fef0:/disobedience/choose-menu.c diff --git a/disobedience/choose-menu.c b/disobedience/choose-menu.c index 44ad04f..b4aa0ce 100644 --- a/disobedience/choose-menu.c +++ b/disobedience/choose-menu.c @@ -22,6 +22,17 @@ #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, + const char *id); + /** @brief Popup menu */ static GtkWidget *choose_menu; @@ -107,7 +118,7 @@ static void choose_play_activate(GtkMenuItem attribute((unused)) *item, choose_gather_selected_files_callback, v); for(int n = 0; n < v->nvec; ++n) - disorder_eclient_play(client, v->vec[n], choose_play_completed, 0); + disorder_eclient_play(client, choose_play_completed, v->vec[n], 0); } static int choose_properties_sensitive(void *extra) { @@ -210,10 +221,54 @@ 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, choose_playchildren_played, vec[n], NULL); +} + +static void choose_playchildren_played(void attribute((unused)) *v, + const char *err, + const char attribute((unused)) *id) { + if(err) { + popup_protocol_error(0, err); + return; + } +} + /** @brief Pop-up menu for choose */ static struct menuitem choose_menuitems[] = { { "Play track", + GTK_STOCK_MEDIA_PLAY, choose_play_activate, choose_play_sensitive, 0, @@ -221,6 +276,7 @@ static struct menuitem choose_menuitems[] = { }, { "Track properties", + GTK_STOCK_PROPERTIES, choose_properties_activate, choose_properties_sensitive, 0, @@ -228,13 +284,23 @@ static struct menuitem choose_menuitems[] = { }, { "Select children", + NULL, choose_selectchildren_activate, choose_selectchildren_sensitive, 0, 0 }, { + "Play children", + NULL, + choose_playchildren_activate, + choose_selectchildren_sensitive, /* re-use */ + 0, + 0 + }, + { "Deselect all tracks", + NULL, choose_selectnone_activate, choose_selectnone_sensitive, 0,