gui: Add columns to a queue treeview
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
2a1f695ea8
commit
196088dcfa
|
@ -7,6 +7,31 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
|
static unsigned int q_col_width[] = { 20, 300, 60, 100, 100, 45, 100, 60, 1 };
|
||||||
|
|
||||||
|
static class QueueColumns : public Gtk::TreeModelColumnRecord {
|
||||||
|
public:
|
||||||
|
QueueColumns()
|
||||||
|
{ add(q_col_track); add(q_col_title); add(q_col_length);
|
||||||
|
add(q_col_artist); add(q_col_album); add(q_col_year);
|
||||||
|
add(q_col_genre); add(q_col_count); add(q_col_played);
|
||||||
|
add(q_col_path); }
|
||||||
|
|
||||||
|
Gtk::TreeModelColumn<unsigned int> q_col_track;
|
||||||
|
Gtk::TreeModelColumn<std::string> q_col_title;
|
||||||
|
Gtk::TreeModelColumn<std::string> q_col_length;
|
||||||
|
Gtk::TreeModelColumn<std::string> q_col_artist;
|
||||||
|
Gtk::TreeModelColumn<std::string> q_col_album;
|
||||||
|
Gtk::TreeModelColumn<unsigned int> q_col_year;
|
||||||
|
Gtk::TreeModelColumn<std::string> q_col_genre;
|
||||||
|
Gtk::TreeModelColumn<unsigned int> q_col_count;
|
||||||
|
Gtk::TreeModelColumn<std::string> q_col_played;
|
||||||
|
Gtk::TreeModelColumn<std::string> q_col_path;
|
||||||
|
} queue_cols;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class QueueTab : public Tab {
|
class QueueTab : public Tab {
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +48,9 @@ private:
|
||||||
*/
|
*/
|
||||||
Gtk::VBox q_vbox;
|
Gtk::VBox q_vbox;
|
||||||
|
|
||||||
/* Toolbar widgets */
|
/**
|
||||||
|
* Toolbar widgets
|
||||||
|
*/
|
||||||
Gtk::HBox q_toolbar_box;
|
Gtk::HBox q_toolbar_box;
|
||||||
Gtk::SearchEntry q_search;
|
Gtk::SearchEntry q_search;
|
||||||
Gtk::ToggleButton q_random;
|
Gtk::ToggleButton q_random;
|
||||||
|
@ -33,6 +60,7 @@ private:
|
||||||
Gtk::ScrolledWindow q_window;
|
Gtk::ScrolledWindow q_window;
|
||||||
Gtk::TreeView q_treeview;
|
Gtk::TreeView q_treeview;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QueueTab(Playqueue *, unsigned int num);
|
QueueTab(Playqueue *, unsigned int num);
|
||||||
~QueueTab();
|
~QueueTab();
|
||||||
|
@ -40,6 +68,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Helper functions
|
* Helper functions
|
||||||
*/
|
*/
|
||||||
|
void setup_treeview();
|
||||||
void on_post_init();
|
void on_post_init();
|
||||||
void tab_set_size();
|
void tab_set_size();
|
||||||
void queue_set_number(unsigned int);
|
void queue_set_number(unsigned int);
|
||||||
|
@ -103,6 +132,7 @@ QueueTab :: QueueTab(Playqueue *pq, unsigned int num)
|
||||||
q_window.set_margin_right(5);
|
q_window.set_margin_right(5);
|
||||||
q_window.set_margin_bottom(5);
|
q_window.set_margin_bottom(5);
|
||||||
q_window.add(q_treeview);
|
q_window.add(q_treeview);
|
||||||
|
setup_treeview();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -150,6 +180,34 @@ QueueTab :: ~QueueTab()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void QueueTab :: setup_treeview()
|
||||||
|
{
|
||||||
|
q_treeview.append_column("#", queue_cols.q_col_track);
|
||||||
|
q_treeview.append_column("Title", queue_cols.q_col_title);
|
||||||
|
q_treeview.append_column("Length", queue_cols.q_col_length);
|
||||||
|
q_treeview.append_column("Artist", queue_cols.q_col_artist);
|
||||||
|
q_treeview.append_column("Album", queue_cols.q_col_album);
|
||||||
|
q_treeview.append_column("Year", queue_cols.q_col_year);
|
||||||
|
q_treeview.append_column("Genre", queue_cols.q_col_genre);
|
||||||
|
q_treeview.append_column("Count", queue_cols.q_col_count);
|
||||||
|
q_treeview.append_column("Played", queue_cols.q_col_played);
|
||||||
|
|
||||||
|
q_treeview.set_tooltip_column(9);
|
||||||
|
q_treeview.set_rules_hint();
|
||||||
|
q_treeview.set_enable_search(false);
|
||||||
|
q_treeview.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
|
||||||
|
q_treeview.set_rubber_banding();
|
||||||
|
|
||||||
|
std::vector<Gtk::TreeViewColumn *> columns = q_treeview.get_columns();
|
||||||
|
for (unsigned int i = 0; i < columns.size(); i++) {
|
||||||
|
columns[i]->set_resizable();
|
||||||
|
columns[i]->set_fixed_width(q_col_width[i]);
|
||||||
|
columns[i]->set_sizing(Gtk::TREE_VIEW_COLUMN_FIXED);
|
||||||
|
columns[i]->set_clickable();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void QueueTab :: on_post_init()
|
void QueueTab :: on_post_init()
|
||||||
{
|
{
|
||||||
tab_init_random();
|
tab_init_random();
|
||||||
|
|
61
gui/tabs.cpp
61
gui/tabs.cpp
|
@ -349,26 +349,6 @@ static std::list<TabType *> tab_types;
|
||||||
static unsigned int sort_timeout_count = 0;
|
static unsigned int sort_timeout_count = 0;
|
||||||
|
|
||||||
|
|
||||||
static class QueueColumns : public Gtk::TreeModelColumnRecord {
|
|
||||||
public:
|
|
||||||
QueueColumns()
|
|
||||||
{ add(q_col_track); add(q_col_title); add(q_col_length);
|
|
||||||
add(q_col_artist); add(q_col_album); add(q_col_year);
|
|
||||||
add(q_col_genre); add(q_col_count); add(q_col_played);
|
|
||||||
add(q_col_path); }
|
|
||||||
|
|
||||||
Gtk::TreeModelColumn<unsigned int> q_col_track;
|
|
||||||
Gtk::TreeModelColumn<std::string> q_col_title;
|
|
||||||
Gtk::TreeModelColumn<std::string> q_col_length;
|
|
||||||
Gtk::TreeModelColumn<std::string> q_col_artist;
|
|
||||||
Gtk::TreeModelColumn<std::string> q_col_album;
|
|
||||||
Gtk::TreeModelColumn<unsigned int> q_col_year;
|
|
||||||
Gtk::TreeModelColumn<std::string> q_col_genre;
|
|
||||||
Gtk::TreeModelColumn<unsigned int> q_col_count;
|
|
||||||
Gtk::TreeModelColumn<std::string> q_col_played;
|
|
||||||
Gtk::TreeModelColumn<std::string> q_col_path;
|
|
||||||
} queue_cols;
|
|
||||||
static unsigned int q_col_width[] = { 20, 300, 60, 100, 100, 45, 100, 60, 1 };
|
|
||||||
static sort_t q_col_sorts[] = {
|
static sort_t q_col_sorts[] = {
|
||||||
SORT_TRACK, SORT_TITLE, SORT_LENGTH,
|
SORT_TRACK, SORT_TITLE, SORT_LENGTH,
|
||||||
SORT_ARTIST, SORT_ALBUM, SORT_YEAR,
|
SORT_ARTIST, SORT_ALBUM, SORT_YEAR,
|
||||||
|
@ -515,51 +495,10 @@ public:
|
||||||
void on_focus_search();
|
void on_focus_search();
|
||||||
};
|
};
|
||||||
|
|
||||||
void OcarinaPage::setup_treeview()
|
|
||||||
{*/
|
|
||||||
/* Make page content */
|
|
||||||
/*page_view.append_column("#", queue_cols.q_col_track);
|
|
||||||
page_view.append_column("Title", queue_cols.q_col_title);
|
|
||||||
page_view.append_column("Length", queue_cols.q_col_length);
|
|
||||||
page_view.append_column("Artist", queue_cols.q_col_artist);
|
|
||||||
page_view.append_column("Album", queue_cols.q_col_album);
|
|
||||||
page_view.append_column("Year", queue_cols.q_col_year);
|
|
||||||
page_view.append_column("Genre", queue_cols.q_col_genre);
|
|
||||||
page_view.append_column("Count", queue_cols.q_col_count);
|
|
||||||
page_view.append_column("Played", queue_cols.q_col_played);
|
|
||||||
page_view.set_tooltip_column(9);
|
|
||||||
|
|
||||||
page_view.signal_row_activated().connect(sigc::mem_fun(*this,
|
|
||||||
&OcarinaPage::on_row_activated));
|
|
||||||
page_view.signal_key_press_event().connect(sigc::mem_fun(*this,
|
|
||||||
&OcarinaPage::on_view_key_pressed));
|
|
||||||
page_view.signal_button_press_event().connect(sigc::mem_fun(*this,
|
|
||||||
&OcarinaPage::on_view_button_pressed), false);
|
|
||||||
|
|
||||||
page_view.set_model(filter);
|
|
||||||
page_view.set_rules_hint();
|
|
||||||
page_view.set_enable_search(false);
|
|
||||||
page_view.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
|
|
||||||
page_view.set_rubber_banding();
|
|
||||||
|
|
||||||
page_scroll.set_shadow_type(Gtk::SHADOW_IN);
|
|
||||||
page_scroll.set_margin_left(5);
|
|
||||||
page_scroll.set_margin_right(5);
|
|
||||||
page_scroll.set_margin_bottom(5);
|
|
||||||
page_scroll.add(page_view);
|
|
||||||
|
|
||||||
setup_columns();
|
|
||||||
page_viewbox.pack_start(page_scroll, true, true);
|
|
||||||
};
|
|
||||||
|
|
||||||
void OcarinaPage::setup_columns()
|
void OcarinaPage::setup_columns()
|
||||||
{
|
{
|
||||||
std::vector<Gtk::TreeViewColumn *> columns = page_view.get_columns();
|
std::vector<Gtk::TreeViewColumn *> columns = page_view.get_columns();
|
||||||
for (unsigned int i = 0; i < columns.size(); i++) {
|
for (unsigned int i = 0; i < columns.size(); i++) {
|
||||||
columns[i]->set_resizable();
|
|
||||||
columns[i]->set_fixed_width(q_col_width[i]);
|
|
||||||
columns[i]->set_sizing(Gtk::TREE_VIEW_COLUMN_FIXED);
|
|
||||||
columns[i]->set_clickable();
|
|
||||||
columns[i]->signal_clicked().connect(sigc::bind<unsigned int> (
|
columns[i]->signal_clicked().connect(sigc::bind<unsigned int> (
|
||||||
sigc::mem_fun(*this, &OcarinaPage::on_column_clicked),
|
sigc::mem_fun(*this, &OcarinaPage::on_column_clicked),
|
||||||
i));
|
i));
|
||||||
|
|
Loading…
Reference in New Issue