/*
* This file is part of DisOrder
- * Copyright (C) 2008 Richard Kettlewell
+ * Copyright (C) 2008, 2009 Richard Kettlewell
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/** @brief Count of playlists */
int nplaylists;
+/* Maintianng the list of playlists ----------------------------------------- */
+
/** @brief Schedule an update to the list of playlists */
static void playlists_update(const char attribute((unused)) *event,
void attribute((unused)) *eventdata,
event_raise("playlists-updated", 0);
}
-/** @brief Called to activate a playlist */
+/* Playlists menu ----------------------------------------------------------- */
+
+/** @brief Play received playlist contents
+ *
+ * Passed as a completion callback by menu_activate_playlist().
+ */
+static void playlist_play_content(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], NULL, NULL);
+}
+
+/** @brief Called to activate a playlist
+ *
+ * Called when the menu item for a playlist is clicked.
+ */
static void menu_activate_playlist(GtkMenuItem *menuitem,
gpointer attribute((unused)) user_data) {
GtkLabel *label = GTK_LABEL(GTK_BIN(menuitem)->child);
const char *playlist = gtk_label_get_text(label);
- fprintf(stderr, "activate playlist %s\n", playlist); /* TODO */
+ disorder_eclient_playlist_get(client, playlist_play_content, playlist, NULL);
}
/** @brief Called when the playlists change */
return; /* OMG too soon */
GtkMenuShell *menu = GTK_MENU_SHELL(playlists_menu);
/* TODO: we could be more sophisticated and only insert/remove widgets as
- * needed. For now that's too much effort. */
+ * needed. The current logic trashes the selection which is not acceptable
+ * and interacts badly with one playlist being currently locked and
+ * edited. */
while(menu->children)
gtk_container_remove(GTK_CONTAINER(menu), GTK_WIDGET(menu->children->data));
/* NB nplaylists can be -1 as well as 0 */
nplaylists >= 0);
}
+/* Playlists window (list of playlists) ------------------------------------- */
+
/** @brief (Re-)populate the playlist tree model */
static void playlists_fill(void) {
GtkTreeIter iter[1];
/* Unselect whatever is selected */
gtk_tree_selection_unselect_all(playlists_selection);
fprintf(stderr, "playlists_add\n");/* TODO */
+ /* We need to pop up a window asking for:
+ * - the name for the playlist
+ * - whether it is to be a public, private or shared playlist
+ * Moreover we should keep track of the known playlists and grey out OK
+ * if the name is a clash (as well as if it's actually invalid).
+ */
}
/** @brief Called when the 'Delete' button is pressed */
static void playlists_delete(GtkButton attribute((unused)) *button,
- gpointer attribute((unused)) userdata) {
+ gpointer attribute((unused)) userdata) {
GtkWidget *yesno;
int res;
GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
- "Do you really want to delete user %s?"
+ "Do you really want to delete playlist %s?"
" This action cannot be undone.",
playlists_selected);
res = gtk_dialog_run(GTK_DIALOG(yesno));
}
}
+/* Playlists window --------------------------------------------------------- */
+
+/** @brief Pop up the playlists window
+ *
+ * Called when the playlists menu item is selected
+ */
void edit_playlists(gpointer attribute((unused)) callback_data,
guint attribute((unused)) callback_action,
GtkWidget attribute((unused)) *menu_item) {