gui: Merge lib/plist.cpp back into gui/plist.cpp
The lib/ experiment made the gui code a little more complicated than I was expecting, so I'm going to begin merging everything back into gui/ Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
b4db3ba98f
commit
4bfdb2d0d4
|
@ -3,11 +3,23 @@
|
|||
*/
|
||||
#include <core/audio.h>
|
||||
#include <core/playlist.h>
|
||||
#include <lib/plist.h>
|
||||
#include <gui/tabs.h>
|
||||
|
||||
|
||||
static Glib::ustring get_path(const Gtk::TreePath &);
|
||||
static bool find_cur_path(Gtk::TreePath &);
|
||||
static void del_path_ids(const Gtk::TreePath &, std::vector<unsigned int> &);
|
||||
|
||||
|
||||
static class PlaylistColumns : public Gtk::TreeModelColumnRecord {
|
||||
public:
|
||||
Gtk::TreeModelColumn<Glib::ustring> p_name;
|
||||
|
||||
PlaylistColumns()
|
||||
{
|
||||
add(p_name);
|
||||
}
|
||||
} p_cols;
|
||||
|
||||
|
||||
class PlaylistTab : public Tab {
|
||||
|
@ -34,7 +46,7 @@ public:
|
|||
return Tab :: on_key_press_event(key);
|
||||
if (find_cur_path(path)) {
|
||||
tab_selected_ids(ids);
|
||||
plist :: del_path_ids(path, ids);
|
||||
del_path_ids(path, ids);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -45,11 +57,18 @@ static Gtk::ToggleButton *o_fav;
|
|||
|
||||
static PlaylistTab *p_tab;
|
||||
static Gtk::TreeView *p_treeview;
|
||||
static Glib::RefPtr<Gtk::ListStore> p_list;
|
||||
|
||||
|
||||
/*
|
||||
* Sidebar code
|
||||
*/
|
||||
static Glib::ustring get_path(const Gtk::TreePath &path)
|
||||
{
|
||||
Gtk::TreeModel::Row row = *(p_list->get_iter(path));
|
||||
return row[p_cols.p_name];
|
||||
}
|
||||
|
||||
static bool find_cur_path(Gtk::TreePath &path)
|
||||
{
|
||||
Gtk::TreeViewColumn *col;
|
||||
|
@ -57,11 +76,20 @@ static bool find_cur_path(Gtk::TreePath &path)
|
|||
return !path.empty();
|
||||
}
|
||||
|
||||
static void del_path_ids(const Gtk::TreePath &path,
|
||||
std::vector<unsigned int> &ids)
|
||||
{
|
||||
std::string name = get_path(path);
|
||||
|
||||
for (unsigned int i = 0; i < ids.size(); i++)
|
||||
playlist :: del(tags :: get_track(ids[i]), name);
|
||||
}
|
||||
|
||||
static void on_playlist_cursor_changed()
|
||||
{
|
||||
Gtk::TreePath path;
|
||||
if (find_cur_path(path))
|
||||
plist :: select_path(path);
|
||||
playlist :: select(get_path(path));
|
||||
}
|
||||
|
||||
static bool on_playlist_clicked(GdkEventButton *button)
|
||||
|
@ -102,8 +130,8 @@ void on_track_loaded(Track *track)
|
|||
|
||||
void init_playlist_tab()
|
||||
{
|
||||
plist :: init();
|
||||
p_tab = new PlaylistTab;
|
||||
p_list = lib :: get_object<Gtk::ListStore>("plist_list");
|
||||
p_treeview = lib :: get_widget<Gtk::TreeView>("plist_treeview");
|
||||
|
||||
p_treeview->signal_cursor_changed().connect(sigc::ptr_fun(on_playlist_cursor_changed));
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef OCARINA_LIB_PLIST_H
|
||||
#define OCARINA_LIB_PLIST_H
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <string>
|
||||
|
||||
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> &);
|
||||
|
||||
}
|
||||
|
||||
#endif /* OCARINA_LIB_PLIST_H */
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/playlist.h>
|
||||
#include <lib/lib.h>
|
||||
#include <lib/plist.h>
|
||||
|
||||
|
||||
class PlaylistColumns : public Gtk::TreeModelColumnRecord {
|
||||
public:
|
||||
Gtk::TreeModelColumn<Glib::ustring> p_name;
|
||||
|
||||
PlaylistColumns()
|
||||
{
|
||||
add(p_name);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static PlaylistColumns p_cols;
|
||||
static Glib::RefPtr<Gtk::ListStore> p_list;
|
||||
|
||||
|
||||
void plist :: init()
|
||||
{
|
||||
p_list = lib :: get_object<Gtk::ListStore>("plist_list");
|
||||
}
|
||||
|
||||
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(tags :: get_track(ids[i]), name);
|
||||
}
|
Loading…
Reference in New Issue