gui/playlist: Add support for deleting playlists
System playlists cannot be deleted, but library playlists can. Deleting a library playlist removes the library and associated tracks from the database. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
382ee79c2e
commit
62e1b27b6c
|
@ -112,6 +112,35 @@ gboolean __playlist_on_select(GtkTreeSelection *selection, GtkTreeModel *model,
|
||||||
return queue != NULL;
|
return queue != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool __playlist_keypress(GtkTreeView *treeview, GdkEventKey *event,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
|
||||||
|
GtkTreeModel *model = GTK_TREE_MODEL(p_store);
|
||||||
|
gchar *name = NULL;
|
||||||
|
GtkTreePath *path;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GList *rows;
|
||||||
|
|
||||||
|
if (event->keyval != GDK_KEY_Delete)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
rows = gtk_tree_selection_get_selected_rows(selection, &model);
|
||||||
|
path = rows->data;
|
||||||
|
|
||||||
|
if (gtk_tree_model_get_iter(model, &iter, path))
|
||||||
|
name = __playlist_name(&iter);
|
||||||
|
if (!name)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (playlist_delete(__playlist_type(&iter), name))
|
||||||
|
gtk_tree_store_remove(GTK_TREE_STORE(model), &iter);
|
||||||
|
g_free(name);
|
||||||
|
out:
|
||||||
|
g_list_free_full(rows, (GDestroyNotify)gtk_tree_path_free);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool __playlist_queue_set_size(struct queue *queue, GtkTreeIter *iter)
|
static bool __playlist_queue_set_size(struct queue *queue, GtkTreeIter *iter)
|
||||||
{
|
{
|
||||||
struct gui_queue *gq = gui_queue(queue);
|
struct gui_queue *gq = gui_queue(queue);
|
||||||
|
|
|
@ -31,6 +31,7 @@ void __collection_toggled() {}
|
||||||
#endif /* TEST_NEED_COLLECTION */
|
#endif /* TEST_NEED_COLLECTION */
|
||||||
|
|
||||||
#ifdef TEST_NEED_PLAYLIST
|
#ifdef TEST_NEED_PLAYLIST
|
||||||
|
void __playlist_keypress() {}
|
||||||
void __playlist_selection_changed() {}
|
void __playlist_selection_changed() {}
|
||||||
#endif /* TEST_NEED_PLAYLIST */
|
#endif /* TEST_NEED_PLAYLIST */
|
||||||
|
|
||||||
|
|
|
@ -954,6 +954,7 @@
|
||||||
<property name="headers_visible">False</property>
|
<property name="headers_visible">False</property>
|
||||||
<property name="search_column">1</property>
|
<property name="search_column">1</property>
|
||||||
<property name="enable_tree_lines">True</property>
|
<property name="enable_tree_lines">True</property>
|
||||||
|
<signal name="key-press-event" handler="__playlist_keypress" swapped="no"/>
|
||||||
<child internal-child="selection">
|
<child internal-child="selection">
|
||||||
<object class="GtkTreeSelection" id="treeview-selection3">
|
<object class="GtkTreeSelection" id="treeview-selection3">
|
||||||
<signal name="changed" handler="__playlist_selection_changed" swapped="no"/>
|
<signal name="changed" handler="__playlist_selection_changed" swapped="no"/>
|
||||||
|
|
Loading…
Reference in New Issue