gui: Rip out some code from tabs.cpp
Most of this was related to the playlist tab. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
1d4ba1474d
commit
1ac05c6b52
170
gui/tabs.cpp
170
gui/tabs.cpp
|
@ -20,13 +20,6 @@ static std::map<Playqueue *, OcarinaPage *> tab_map;
|
|||
static std::list<TabFuncs *> tab_types;
|
||||
static unsigned int sort_timeout_count = 0;
|
||||
|
||||
static class SidebarColumns : public Gtk::TreeModelColumnRecord {
|
||||
public:
|
||||
SidebarColumns()
|
||||
{ add(sb_col_name); }
|
||||
|
||||
Gtk::TreeModelColumn<std::string> sb_col_name;
|
||||
} sb_cols;
|
||||
|
||||
static class QueueColumns : public Gtk::TreeModelColumnRecord {
|
||||
public:
|
||||
|
@ -152,51 +145,6 @@ OcarinaTab::~OcarinaTab() {}
|
|||
|
||||
|
||||
|
||||
class PresetTab : public OcarinaTab {
|
||||
public:
|
||||
Gtk::Label name_label;
|
||||
Gtk::Label size_label;
|
||||
Gtk::Image tab_icon;
|
||||
Gtk::VBox box;
|
||||
|
||||
PresetTab(const std::string &, const std::string &);
|
||||
~PresetTab();
|
||||
void set_size(unsigned int);
|
||||
void set_number(unsigned int);
|
||||
};
|
||||
|
||||
PresetTab::PresetTab(const std::string &name, const std::string &icon)
|
||||
: name_label("<big>" + name + "</big>", 0.5, 0.5),
|
||||
size_label("0", 0.5, 0.5)
|
||||
{
|
||||
tab_icon.set_from_icon_name(icon, Gtk::ICON_SIZE_MENU);
|
||||
tab_icon.set_alignment(0, 0.5);
|
||||
name_label.set_use_markup();
|
||||
name_label.set_margin_right(1);
|
||||
name_label.set_justify(Gtk::JUSTIFY_CENTER);
|
||||
size_label.set_justify(Gtk::JUSTIFY_CENTER);
|
||||
set_spacing(5);
|
||||
|
||||
box.pack_start(name_label);
|
||||
box.pack_start(size_label);
|
||||
|
||||
pack_start(tab_icon);
|
||||
pack_start(box);
|
||||
show_all();
|
||||
}
|
||||
|
||||
PresetTab::~PresetTab() {}
|
||||
void PresetTab::set_number(unsigned int num) {}
|
||||
|
||||
void PresetTab::set_size(unsigned int size)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << size;
|
||||
size_label.set_text(ss.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
class PQTab : public OcarinaTab {
|
||||
public:
|
||||
Gtk::Label number_label;
|
||||
|
@ -240,37 +188,6 @@ void PQTab::set_number(unsigned int num)
|
|||
|
||||
|
||||
|
||||
class ManagerTab : public OcarinaTab {
|
||||
public:
|
||||
Gtk::Label name_label;
|
||||
Gtk::Image tab_icon;
|
||||
|
||||
ManagerTab(const std::string &, const std::string &);
|
||||
~ManagerTab();
|
||||
void set_size(unsigned int);
|
||||
void set_number(unsigned int);
|
||||
};
|
||||
|
||||
ManagerTab::ManagerTab(const std::string &name, const std::string &icon)
|
||||
: name_label(name, 0.5, 0.5)
|
||||
{
|
||||
name_label.set_justify(Gtk::JUSTIFY_CENTER);
|
||||
tab_icon.set_from_icon_name(icon, Gtk::ICON_SIZE_MENU);
|
||||
tab_icon.set_alignment(0, 0.5);
|
||||
|
||||
set_spacing(5);
|
||||
pack_start(tab_icon);
|
||||
pack_start(name_label);
|
||||
show_all();
|
||||
}
|
||||
|
||||
ManagerTab::~ManagerTab() {}
|
||||
void ManagerTab::set_size(unsigned int) {}
|
||||
void ManagerTab::set_number(unsigned int) {}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Ocarina class definition
|
||||
*/
|
||||
|
@ -291,14 +208,8 @@ private:
|
|||
Gtk::HBox page_viewbox;
|
||||
Gtk::TreeView page_view;
|
||||
|
||||
/* Sidebar widgets */
|
||||
Glib::RefPtr<Gtk::ListStore> sb_store;
|
||||
Gtk::TreeView sb_view;
|
||||
Gtk::ScrolledWindow sb_scroll;
|
||||
|
||||
void setup_common(Playqueue *, unsigned int, bool);
|
||||
void setup_common(Playqueue *, unsigned int);
|
||||
void setup_toolbar();
|
||||
void setup_sidebar();
|
||||
void setup_treeview();
|
||||
void setup_columns();
|
||||
void set_tab_size();
|
||||
|
@ -308,10 +219,7 @@ public:
|
|||
Glib::RefPtr<PlayqueueModel> model;
|
||||
Glib::RefPtr<Gtk::TreeModelFilter> filter;
|
||||
|
||||
OcarinaPage(const std::string &, const std::string &,
|
||||
Playqueue *, unsigned int);
|
||||
OcarinaPage(Playqueue *, unsigned int, unsigned int);
|
||||
OcarinaPage(const std::string &, const std::string &, Playqueue *);
|
||||
~OcarinaPage();
|
||||
bool is_current_tab();
|
||||
void check_pq_flags();
|
||||
|
@ -334,21 +242,11 @@ public:
|
|||
bool on_delete_selected();
|
||||
bool on_favorite_selected();
|
||||
bool on_view_key_pressed(GdkEventKey *);
|
||||
void on_sidebar_cursor_changed();
|
||||
bool on_sidebar_clicked(GdkEventButton *);
|
||||
bool on_view_button_pressed(GdkEventButton *);
|
||||
void on_focus_search();
|
||||
};
|
||||
|
||||
|
||||
OcarinaPage::OcarinaPage(const std::string &name, const std::string &icon,
|
||||
Playqueue *pq, unsigned int flags)
|
||||
: init_flags(flags)
|
||||
{
|
||||
tab = new PresetTab(name, icon);
|
||||
setup_common(pq, 0, false);
|
||||
}
|
||||
|
||||
OcarinaPage::OcarinaPage(Playqueue *pq, unsigned int flags, unsigned int pg)
|
||||
: init_flags(flags)
|
||||
{
|
||||
|
@ -357,27 +255,17 @@ OcarinaPage::OcarinaPage(Playqueue *pq, unsigned int flags, unsigned int pg)
|
|||
|
||||
pqt->close_button.signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&OcarinaPage::on_close_clicked));
|
||||
setup_common(pq, pg, false);
|
||||
setup_common(pq, pg);
|
||||
notebook->set_tab_reorderable(*this);
|
||||
}
|
||||
|
||||
OcarinaPage::OcarinaPage(const std::string &name, const std::string &icon,
|
||||
Playqueue *pq)
|
||||
: init_flags(0)
|
||||
{
|
||||
ManagerTab *man_tab = new ManagerTab(name, icon);
|
||||
tab = man_tab;
|
||||
|
||||
setup_common(pq, 0, true);
|
||||
}
|
||||
|
||||
OcarinaPage::~OcarinaPage()
|
||||
{
|
||||
notebook->remove_page(*this);
|
||||
tab_map.erase(model->queue);
|
||||
}
|
||||
|
||||
void OcarinaPage::setup_common(Playqueue *pq, unsigned int pg, bool sidebar)
|
||||
void OcarinaPage::setup_common(Playqueue *pq, unsigned int pg)
|
||||
{
|
||||
get_builder()->get_widget("o_notebook", notebook);
|
||||
model = Glib::RefPtr<PlayqueueModel>(new PlayqueueModel(pq));
|
||||
|
@ -389,9 +277,6 @@ void OcarinaPage::setup_common(Playqueue *pq, unsigned int pg, bool sidebar)
|
|||
set_margin_right(1);
|
||||
set_spacing(1);
|
||||
|
||||
setup_toolbar();
|
||||
if (sidebar == true)
|
||||
setup_sidebar();
|
||||
setup_treeview();
|
||||
pack_start(page_viewbox);
|
||||
show_all();
|
||||
|
@ -430,34 +315,6 @@ void OcarinaPage::setup_toolbar()
|
|||
pack_start(page_toolbar, false, false);
|
||||
}
|
||||
|
||||
void OcarinaPage::setup_sidebar()
|
||||
{
|
||||
Gtk::TreeModel::Row row;
|
||||
|
||||
sb_store = Gtk::ListStore::create(sb_cols);
|
||||
sb_view.append_column("Playlists", sb_cols.sb_col_name);
|
||||
sb_view.set_model(sb_store);
|
||||
sb_view.get_selection()->set_mode(Gtk::SELECTION_BROWSE);
|
||||
sb_view.signal_cursor_changed().connect(sigc::mem_fun(*this,
|
||||
&OcarinaPage::on_sidebar_cursor_changed));
|
||||
sb_view.signal_button_press_event().connect(sigc::mem_fun(*this,
|
||||
&OcarinaPage::on_sidebar_clicked), false);
|
||||
|
||||
row = *(sb_store->append());
|
||||
row[sb_cols.sb_col_name] = "Favorites";
|
||||
|
||||
row = *(sb_store->append());
|
||||
row[sb_cols.sb_col_name] = "Banned";
|
||||
|
||||
sb_view.set_cursor(Gtk::TreePath("0"));
|
||||
sb_scroll.set_shadow_type(Gtk::SHADOW_IN);
|
||||
sb_scroll.set_margin_left(5);
|
||||
sb_scroll.set_margin_bottom(5);
|
||||
sb_scroll.add(sb_view);
|
||||
|
||||
page_viewbox.pack_start(sb_scroll, false, false);
|
||||
}
|
||||
|
||||
void OcarinaPage::setup_treeview()
|
||||
{
|
||||
/* Make page content */
|
||||
|
@ -724,23 +581,6 @@ bool OcarinaPage::on_view_key_pressed(GdkEventKey *event)
|
|||
return false;
|
||||
}
|
||||
|
||||
void OcarinaPage::on_sidebar_cursor_changed()
|
||||
{
|
||||
Gtk::TreePath path;
|
||||
Gtk::TreeViewColumn *col;
|
||||
|
||||
sb_view.get_cursor(path, col);
|
||||
Gtk::TreeModel::Row row = *(sb_store->get_iter(path));
|
||||
playlist :: select(row[sb_cols.sb_col_name]);
|
||||
}
|
||||
|
||||
bool OcarinaPage::on_sidebar_clicked(GdkEventButton *button)
|
||||
{
|
||||
if (button->button != 3)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OcarinaPage::on_view_button_pressed(GdkEventButton *button)
|
||||
{
|
||||
Gtk::Menu *menu;
|
||||
|
@ -918,10 +758,6 @@ void init_tabs()
|
|||
Gtk::Notebook *notebook;
|
||||
get_builder()->get_widget("o_notebook", notebook);
|
||||
|
||||
new OcarinaPage("Playlist\nManager", "emblem-documents", playlist::get_pq());
|
||||
new OcarinaPage("History", "document-open-recent", audio::get_recent_pq(), 0);
|
||||
new OcarinaPage("Collection", "media-optical", deck::get_library_pq(), PQ_RANDOM);
|
||||
|
||||
get_callbacks()->on_pq_created = on_pq_created;
|
||||
get_callbacks()->on_pq_removed = on_pq_removed;
|
||||
get_callbacks()->on_queue_track_add = on_track_added;
|
||||
|
|
Loading…
Reference in New Issue