-/** @brief Get entered new-playlist details
- * @param namep Where to store entered name (or NULL)
- * @param fullnamep Where to store computed full name (or NULL)
- * @param sharep Where to store 'shared' flag (or NULL)
- * @param publicp Where to store 'public' flag (or NULL)
- * @param privatep Where to store 'private' flag (or NULL)
- */
-static void playlist_new_details(char **namep,
- char **fullnamep,
- gboolean *sharedp,
- gboolean *publicp,
- gboolean *privatep) {
- gboolean shared, public, private;
- g_object_get(playlist_new_shared, "active", &shared, (char *)NULL);
- g_object_get(playlist_new_public, "active", &public, (char *)NULL);
- g_object_get(playlist_new_private, "active", &private, (char *)NULL);
- char *gname = gtk_editable_get_chars(GTK_EDITABLE(playlist_new_entry),
- 0, -1); /* name owned by calle */
- char *name = xstrdup(gname);
- g_free(gname);
- if(sharedp) *sharedp = shared;
- if(publicp) *publicp = public;
- if(privatep) *privatep = private;
- if(namep) *namep = name;
- if(fullnamep) {
- if(*sharedp) *fullnamep = *namep;
- else byte_xasprintf(fullnamep, "%s.%s", config->username, name);
- }
-}
-
-/** @brief Called when the newly created playlist has unlocked */
-static void playlist_new_unlocked(void attribute((unused)) *v, const char *err) {
- if(err)
- popup_protocol_error(0, err);
- /* Pop down the creation window */
- gtk_widget_destroy(playlist_new_window);
-}
-
-/** @brief Called when the new playlist has been created */
-static void playlist_new_created(void attribute((unused)) *v, const char *err) {
- if(err) {
- popup_protocol_error(0, err);
- return;
- }
- disorder_eclient_playlist_unlock(client, playlist_new_unlocked, NULL);
- // TODO arrange for the new playlist to be selected
-}
-
-/** @brief Called when the proposed new playlist's contents have been retrieved
- *
- * ...or rather, normally, when it's been reported that it does not exist.
- */
-static void playlist_new_retrieved(void *v, const char *err,
- int nvec,
- char attribute((unused)) **vec) {
- char *fullname = v;
- if(!err && nvec != -1)
- /* A rare case but not in principle impossible */
- err = "A playlist with that name already exists.";
- if(err) {
- popup_protocol_error(0, err);
- disorder_eclient_playlist_unlock(client, playlist_new_unlocked, fullname);
- return;
- }
- gboolean shared, public, private;
- playlist_new_details(0, 0, &shared, &public, &private);
- disorder_eclient_playlist_set_share(client, playlist_new_created, fullname,
- public ? "public"
- : private ? "private"
- : "shared",
- fullname);
-}
-
-/** @brief Called when the proposed new playlist has been locked */
-static void playlist_new_locked(void *v, const char *err) {
- char *fullname = v;
- if(err) {
- popup_protocol_error(0, err);
- return;
- }
- disorder_eclient_playlist_get(client, playlist_new_retrieved,
- fullname, fullname);
-}
-
-/** @brief Called when 'ok' is clicked in new-playlist popup */
-static void playlist_new_ok(GtkButton attribute((unused)) *button,
- gpointer attribute((unused)) userdata) {
- gboolean shared, public, private;
- char *name, *fullname;
- playlist_new_details(&name, &fullname, &shared, &public, &private);
-
- /* We need to:
- * - lock the playlist
- * - check it doesn't exist
- * - set sharing (which will create it empty
- * - unlock it
- *
- * TODO we should freeze the window while this is going on to stop a second
- * click.
- */
- disorder_eclient_playlist_lock(client, playlist_new_locked, fullname,
- fullname);
-}
-
-/** @brief Called when 'cancel' is clicked in new-playlist popup */
-static void playlist_new_cancel(GtkButton attribute((unused)) *button,
- gpointer attribute((unused)) userdata) {
- gtk_widget_destroy(playlist_new_window);
-}
-