plist: Move more playlist functions into lib/
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
97a8646977
commit
160d2ac3be
|
@ -12,7 +12,6 @@ Gtk::Window *ocarina_init(int *argc, char ***argv)
|
|||
lib :: init(argc, argv, "ocarina6.glade");
|
||||
|
||||
Gtk::Window *window = setup_gui();
|
||||
playlist :: select("Favorites");
|
||||
post_init_tabs();
|
||||
return window;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <gui/tabs.h>
|
||||
|
||||
|
||||
static Glib::ustring current_playlist();
|
||||
static bool find_cur_path(Gtk::TreePath &path);
|
||||
|
||||
/**
|
||||
* Playlist tab stuff
|
||||
|
@ -37,14 +37,16 @@ PlaylistTab :: ~PlaylistTab()
|
|||
|
||||
bool PlaylistTab :: on_key_press_event(const std::string &key)
|
||||
{
|
||||
Gtk::TreePath path;
|
||||
std::vector<unsigned int> ids;
|
||||
|
||||
if (key != "Delete")
|
||||
return Tab :: on_key_press_event(key);
|
||||
|
||||
tab_selected_ids(ids);
|
||||
for (unsigned int i = 0; i < ids.size(); i++)
|
||||
playlist :: del(tagdb :: lookup(ids[i]), current_playlist());
|
||||
if (find_cur_path(path)) {
|
||||
tab_selected_ids(ids);
|
||||
plist :: del_path_ids(path, ids);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -63,18 +65,11 @@ static bool find_cur_path(Gtk::TreePath &path)
|
|||
return !path.empty();
|
||||
}
|
||||
|
||||
static Glib::ustring current_playlist()
|
||||
static void on_playlist_cursor_changed()
|
||||
{
|
||||
Gtk::TreePath path;
|
||||
if (find_cur_path(path))
|
||||
return plist :: get_path(path);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
static void on_playlist_cursor_changed()
|
||||
{
|
||||
playlist::select(current_playlist());
|
||||
plist :: select_path(path);
|
||||
}
|
||||
|
||||
static bool on_playlist_clicked(GdkEventButton *button)
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace plist
|
|||
void init();
|
||||
|
||||
Glib::ustring get_path(const Gtk::TreePath &);
|
||||
void select_path(const Gtk::TreePath &);
|
||||
void del_path_ids(const Gtk::TreePath &, std::vector<unsigned int> &);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/playlist.h>
|
||||
#include <lib/lib.h>
|
||||
#include <lib/plist.h>
|
||||
|
||||
|
@ -30,3 +31,17 @@ Glib::ustring plist :: get_path(const Gtk::TreePath &path)
|
|||
Gtk::TreeModel::Row row = *(p_list->get_iter(path));
|
||||
return row[p_cols.p_name];
|
||||
}
|
||||
|
||||
void plist :: select_path(const Gtk::TreePath &path)
|
||||
{
|
||||
playlist :: select(get_path(path));
|
||||
}
|
||||
|
||||
void plist :: del_path_ids(const Gtk::TreePath &path,
|
||||
std::vector<unsigned int> &ids)
|
||||
{
|
||||
std::string name = plist :: get_path(path);
|
||||
|
||||
for (unsigned int i = 0; i < ids.size(); i++)
|
||||
playlist :: del(tagdb :: lookup(ids[i]), name);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue