Created a "delete playlist" button
On the libsaria side, I created a function for finding and deleting a playlist pointer. On the ocarina side, I added a button to each playlist tab to remove the tab. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
d03e38ffbb
commit
2dd1e362d1
|
@ -26,6 +26,8 @@ namespace libsaria
|
|||
void init();
|
||||
|
||||
void new_playlist(list<Track *> &, PlaylistType, bool);
|
||||
void delete_playlist(Playlist *);
|
||||
|
||||
Playlist *get_playlist(unsigned int);
|
||||
Playlist *get_recent_plist();
|
||||
|
||||
|
|
|
@ -132,6 +132,18 @@ namespace libsaria
|
|||
plist->add_tracks(tracks);
|
||||
}
|
||||
|
||||
void deck::delete_playlist(Playlist *plist)
|
||||
{
|
||||
list<libsaria::Playlist *>::iterator it;
|
||||
for (it = playlist_deck.begin(); (*it) != plist; it++);
|
||||
|
||||
plist->prepare_for_removal();
|
||||
delete plist;
|
||||
|
||||
playlist_deck.erase(it);
|
||||
garbage_collect();
|
||||
}
|
||||
|
||||
void deck::init()
|
||||
{
|
||||
app::mkdir("playlist");
|
||||
|
|
|
@ -1,13 +1,21 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <ocarina/playlist.h>
|
||||
#include <ocarina/button.h>
|
||||
#include <ocarina/body.h>
|
||||
|
||||
#include <libsaria/format.h>
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/deck.h>
|
||||
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
static void delete_playlist(GtkWidget *button, gpointer d)
|
||||
{
|
||||
libsaria::Playlist *plist = (libsaria::Playlist *)d;
|
||||
libsaria::deck::delete_playlist(plist);
|
||||
}
|
||||
|
||||
static void selected_foreach_list(GtkTreeModel *model, GtkTreePath *path,
|
||||
GtkTreeIter *iter, gpointer data)
|
||||
{
|
||||
|
@ -142,6 +150,7 @@ namespace ocarina
|
|||
void Playlist::set_playlist(libsaria::Playlist *p)
|
||||
{
|
||||
GtkWidget *label_box = gtk_hbox_new(FALSE, 0);
|
||||
GtkWidget *close_button;
|
||||
|
||||
libsaria::PlaylistRenderer::set_playlist(p);
|
||||
|
||||
|
@ -154,14 +163,18 @@ namespace ocarina
|
|||
|
||||
entry = gtk_entry_new();
|
||||
g_signal_connect(entry, "changed", G_CALLBACK(do_filter), this);
|
||||
//g_signal_connect(entry, "key-press-event", G_CALLBACK(entry_keypress), this);
|
||||
gtk_box_pack_start(GTK_BOX(box), entry, FALSE, FALSE, 0);
|
||||
setup_treeview();
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(label_box), number, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(label_box), name, TRUE, TRUE, 0);
|
||||
gtk_widget_show_all(label_box);
|
||||
|
||||
if (!p->is_static()) {
|
||||
close_button = make_button_data(GTK_STOCK_CLOSE, delete_playlist, p, true);
|
||||
gtk_box_pack_start(GTK_BOX(label_box), close_button, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
gtk_widget_show_all(label_box);
|
||||
gtk_widget_show_all(box);
|
||||
|
||||
set_label_text();
|
||||
|
|
Loading…
Reference in New Issue