gui: Remove some reimplemented code
This helps to clean out tab.cpp so I can keep track of what still needs to be done. I also adjusted some of the spacing and section divisions. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
5acf8239c8
commit
83a2908eb6
146
gui/tabs.cpp
146
gui/tabs.cpp
|
@ -14,7 +14,9 @@ static std::map<Playqueue *, Tab *> queue_mapping;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* Tab class basics
|
* Tab class basics
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Tab :: Tab(Playqueue *pq)
|
Tab :: Tab(Playqueue *pq)
|
||||||
|
@ -46,7 +48,9 @@ void Tab :: tab_finish_init()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* Tab internal helper functions
|
* Tab internal helper functions
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Tab :: tab_init_random()
|
void Tab :: tab_init_random()
|
||||||
|
@ -117,7 +121,9 @@ bool Tab :: tab_queue_selected(bool random)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* Tab callback functions
|
* Tab callback functions
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Tab :: on_post_init() {}
|
void Tab :: on_post_init() {}
|
||||||
|
@ -154,7 +160,9 @@ bool Tab :: on_key_press_event(const std::string &key)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* GTK-MM callback functions
|
* GTK-MM callback functions
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Tab :: on_random_toggled()
|
void Tab :: on_random_toggled()
|
||||||
|
@ -186,7 +194,9 @@ bool Tab :: on_key_pressed(GdkEventKey *event)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* Tab filtering functions
|
* Tab filtering functions
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool Tab :: on_filter_visible(const Gtk::TreeIter &iter)
|
bool Tab :: on_filter_visible(const Gtk::TreeIter &iter)
|
||||||
|
@ -217,10 +227,12 @@ void Tab :: on_entry_changed()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* Global functions
|
* Global functions
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static Tab *find_tab(Playqueue *pq)
|
Tab *find_tab(Playqueue *pq)
|
||||||
{
|
{
|
||||||
std::map<Playqueue *, Tab *>::iterator it;
|
std::map<Playqueue *, Tab *>::iterator it;
|
||||||
it = queue_mapping.find(pq);
|
it = queue_mapping.find(pq);
|
||||||
|
@ -428,65 +440,6 @@ static void prepare_rc_menu()
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* Tab class definition
|
|
||||||
*/
|
|
||||||
/*class OcarinaTab : public Gtk::HBox {
|
|
||||||
public:
|
|
||||||
OcarinaTab();
|
|
||||||
~OcarinaTab();
|
|
||||||
virtual void set_size(unsigned int) = 0;
|
|
||||||
virtual void set_number(unsigned int) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
OcarinaTab::OcarinaTab() {}
|
|
||||||
OcarinaTab::~OcarinaTab() {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PQTab : public OcarinaTab {
|
|
||||||
public:
|
|
||||||
Gtk::Label number_label;
|
|
||||||
Gtk::Label size_label;
|
|
||||||
Gtk::Image close_icon;
|
|
||||||
Gtk::Button close_button;
|
|
||||||
PQTab();
|
|
||||||
~PQTab();
|
|
||||||
void set_size(unsigned int);
|
|
||||||
void set_number(unsigned int);
|
|
||||||
};
|
|
||||||
|
|
||||||
PQTab::PQTab() : number_label("0", 0, 0.5), size_label("0", 0.5, 0.5)
|
|
||||||
{
|
|
||||||
close_icon.set_from_icon_name("window-close", Gtk::ICON_SIZE_MENU);
|
|
||||||
close_button.set_image(close_icon);
|
|
||||||
close_button.set_relief(Gtk::RELIEF_NONE);
|
|
||||||
number_label.set_justify(Gtk::JUSTIFY_CENTER);
|
|
||||||
|
|
||||||
pack_start(number_label, false, false);
|
|
||||||
pack_start(size_label, true, true);
|
|
||||||
pack_start(close_button, false, false);
|
|
||||||
show_all();
|
|
||||||
}
|
|
||||||
|
|
||||||
PQTab::~PQTab() {}
|
|
||||||
|
|
||||||
void PQTab::set_size(unsigned int size)
|
|
||||||
{
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << "<span size='x-large'>" << size << "</span>";
|
|
||||||
size_label.set_markup(ss.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void PQTab::set_number(unsigned int num)
|
|
||||||
{
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << "<span size='x-large'>" << num << ". </span>";
|
|
||||||
number_label.set_markup(ss.str());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ocarina class definition
|
* Ocarina class definition
|
||||||
*/
|
*/
|
||||||
|
@ -545,25 +498,6 @@ public:
|
||||||
void on_focus_search();
|
void on_focus_search();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
OcarinaPage::OcarinaPage(Playqueue *pq, unsigned int flags, unsigned int pg)
|
|
||||||
: init_flags(flags)
|
|
||||||
{
|
|
||||||
PQTab *pqt = new PQTab();
|
|
||||||
tab = pqt;
|
|
||||||
|
|
||||||
pqt->close_button.signal_clicked().connect(sigc::mem_fun(*this,
|
|
||||||
&OcarinaPage::on_close_clicked));
|
|
||||||
setup_common(pq, pg);
|
|
||||||
notebook->set_tab_reorderable(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
OcarinaPage::~OcarinaPage()
|
|
||||||
{
|
|
||||||
notebook->remove_page(*this);
|
|
||||||
tab_map.erase(model->queue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OcarinaPage::setup_common(Playqueue *pq, unsigned int pg)
|
void OcarinaPage::setup_common(Playqueue *pq, unsigned int pg)
|
||||||
{
|
{
|
||||||
get_builder()->get_widget("o_notebook", notebook);
|
get_builder()->get_widget("o_notebook", notebook);
|
||||||
|
@ -674,11 +608,6 @@ void OcarinaPage::check_pq_flags()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OcarinaPage::on_close_clicked()
|
|
||||||
{
|
|
||||||
deck :: remove(notebook->page_num(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
void OcarinaPage::on_repeat_toggled()
|
void OcarinaPage::on_repeat_toggled()
|
||||||
{
|
{
|
||||||
if (page_repeat.get_active())
|
if (page_repeat.get_active())
|
||||||
|
@ -702,11 +631,6 @@ void OcarinaPage::on_column_clicked(unsigned int col_index)
|
||||||
sigc::ptr_fun(dec_sort_timeout), 2);
|
sigc::ptr_fun(dec_sort_timeout), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OcarinaPage::on_page_renumbered()
|
|
||||||
{
|
|
||||||
tab->set_number(notebook->page_num(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OcarinaPage::on_add_to_pq(unsigned int n)
|
bool OcarinaPage::on_add_to_pq(unsigned int n)
|
||||||
{
|
{
|
||||||
if (n >= deck :: size())
|
if (n >= deck :: size())
|
||||||
|
@ -797,50 +721,6 @@ bool OcarinaPage::on_view_button_pressed(GdkEventButton *button)
|
||||||
* Do stuff with tabs
|
* Do stuff with tabs
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
static void renumber_pqs()
|
|
||||||
{
|
|
||||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
|
||||||
for (it = tab_map.begin(); it != tab_map.end(); it++)
|
|
||||||
it->second->on_page_renumbered();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void on_page_reordered(Gtk::Widget *page, int num)
|
|
||||||
{
|
|
||||||
Gtk::Notebook *notebook;
|
|
||||||
OcarinaPage *tab = (OcarinaPage *)page;
|
|
||||||
|
|
||||||
get_builder()->get_widget("o_notebook", notebook);
|
|
||||||
|
|
||||||
if ((unsigned int)num >= deck :: size())
|
|
||||||
notebook->reorder_child(*page, deck::size() - 1);
|
|
||||||
else {
|
|
||||||
deck :: move(tab->model->queue, num);
|
|
||||||
renumber_pqs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void on_pq_created(Playqueue *pq, unsigned int num)
|
|
||||||
{
|
|
||||||
OcarinaPage *page = new OcarinaPage(pq, PQ_RANDOM | PQ_REPEAT, num);
|
|
||||||
page->check_pq_flags();
|
|
||||||
renumber_pqs();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void on_pq_removed(Playqueue *pq)
|
|
||||||
{
|
|
||||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
|
||||||
it = tab_map.find(pq);
|
|
||||||
if (it != tab_map.end())
|
|
||||||
delete it->second;
|
|
||||||
renumber_pqs();
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
/*static void on_new_queue()
|
|
||||||
{
|
|
||||||
queue_selected(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void on_add_to_queue(unsigned int num)
|
static void on_add_to_queue(unsigned int num)
|
||||||
{
|
{
|
||||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
||||||
|
|
Loading…
Reference in New Issue