* - a close button
*/
#include "disobedience.h"
+#include "queue-generic.h"
+#include "popup.h"
#if PLAYLISTS
/** @brief Count of playlists */
int nplaylists;
+/** @brief Columns for the playlist editor */
+static const struct queue_column playlist_columns[] = {
+ { "Artist", column_namepart, "artist", COL_EXPAND|COL_ELLIPSIZE },
+ { "Album", column_namepart, "album", COL_EXPAND|COL_ELLIPSIZE },
+ { "Title", column_namepart, "title", COL_EXPAND|COL_ELLIPSIZE },
+ { "Length", column_length, 0, COL_RIGHT }
+};
+
+/** @brief Pop-up menu for playlist editor */
+// TODO some of these may not be generic enough yet - check!
+static struct menuitem playlist_menuitems[] = {
+ { "Track properties", ql_properties_activate, ql_properties_sensitive, 0, 0 },
+ { "Play track", ql_play_activate, ql_play_sensitive, 0, 0 },
+ //{ "Play playlist", ql_playall_activate, ql_playall_sensitive, 0, 0 },
+ { "Remove track from queue", ql_remove_activate, ql_remove_sensitive, 0, 0 },
+ { "Select all tracks", ql_selectall_activate, ql_selectall_sensitive, 0, 0 },
+ { "Deselect all tracks", ql_selectnone_activate, ql_selectnone_sensitive, 0, 0 },
+};
+
+/** @brief Queuelike for editing a playlist */
+static struct queuelike ql_playlist = {
+ .name = "playlist",
+ .columns = playlist_columns,
+ .ncolumns = sizeof playlist_columns / sizeof *playlist_columns,
+ .menuitems = playlist_menuitems,
+ .nmenuitems = sizeof playlist_menuitems / sizeof *playlist_menuitems,
+ //.drop = playlist_drop //TODO
+};
+
/* Maintaining the list of playlists ---------------------------------------- */
/** @brief Schedule an update to the list of playlists */
/* Playlists window (edit current playlist) --------------------------------- */
static GtkWidget *playlists_window_edit(void) {
- return NULL;
+ assert(ql_playlist.view == NULL); /* better not be set up already */
+ GtkWidget *w = init_queuelike(&ql_playlist);
+ return w;
}
/* Playlists window --------------------------------------------------------- */
}
}
-/** @brief Pop up the playlists window
+/** @brief Called when the playlist window is destroyed */
+static void playlists_window_destroyed(GtkWidget attribute((unused)) *widget,
+ GtkWidget **widget_pointer) {
+ fprintf(stderr, "playlists_window_destroy\n");
+ destroy_queuelike(&ql_playlist);
+ *widget_pointer = NULL;
+}
+
+/** @BRIEF Pop up the playlists window
*
* Called when the playlists menu item is selected
*/
playlists_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_style(playlists_window, tool_style);
g_signal_connect(playlists_window, "destroy",
- G_CALLBACK(gtk_widget_destroyed), &playlists_window);
+ G_CALLBACK(playlists_window_destroyed), &playlists_window);
gtk_window_set_title(GTK_WINDOW(playlists_window), "Playlists Management");
/* TODO loads of this is very similar to (copied from!) users.c - can we
* de-dupe? */
/* The selection should support multiple things being selected */
ql->selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ql->view));
+ g_object_ref(ql->selection);
gtk_tree_selection_set_mode(ql->selection, GTK_SELECTION_MULTIPLE);
/* Catch button presses */
/* TODO style? */
- ql->init(ql);
+ if(ql->init)
+ ql->init(ql);
/* Update display text when lookups complete */
event_register("lookups-completed", queue_lookups_completed, ql);
return scrolled;
}
+/** @brief Destroy a queuelike
+ * @param ql Queuelike to destroy
+ *
+ * Returns @p ql to its initial state.
+ */
+void destroy_queuelike(struct queuelike *ql) {
+ if(ql->store) {
+ g_object_unref(ql->store);
+ ql->store = NULL;
+ }
+ if(ql->view) {
+ gtk_object_destroy(GTK_OBJECT(ql->view));
+ ql->view = NULL;
+ }
+ if(ql->menu) {
+ gtk_object_destroy(GTK_OBJECT(ql->menu));
+ ql->menu = NULL;
+ }
+ if(ql->selection) {
+ g_object_unref(ql->selection);
+ ql->selection = NULL;
+ }
+ ql->q = NULL;
+}
+
/*
Local Variables:
c-basic-offset:2
/*
* This file is part of DisOrder
- * Copyright (C) 2006-2008 Richard Kettlewell
+ * Copyright (C) 2006-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
void (*drop)(struct queuelike *ql, int ntracks, char **tracks, char **ids,
struct queue_entry *after_me);
- /** @brief Stashed drag target row */
- GtkTreePath *drag_target;
};
enum {
GdkEventButton *event,
gpointer user_data);
GtkWidget *init_queuelike(struct queuelike *ql);
+void destroy_queuelike(struct queuelike *ql);
void ql_update_list_store(struct queuelike *ql) ;
void ql_update_row(struct queue_entry *q,
GtkTreeIter *iter);