gui: Create a treeview and add columns
I haven't created the model for the treeview yet, but it's coming! Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
a0067c4542
commit
6c58f9bc2f
73
gui/tabs.cpp
73
gui/tabs.cpp
|
@ -13,6 +13,26 @@
|
|||
class OcarinaTab;
|
||||
static std::map<Playqueue *, OcarinaTab *> tab_map;
|
||||
|
||||
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); }
|
||||
|
||||
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;
|
||||
} queue_cols;
|
||||
static unsigned int q_col_width[] = { 20, 300, 1, 125, 125, 1, 125, 1, 1 };
|
||||
|
||||
|
||||
/*
|
||||
* Tab class definition
|
||||
*/
|
||||
|
@ -25,7 +45,16 @@ private:
|
|||
Gtk::Label tab_name;
|
||||
Gtk::Label tab_size;
|
||||
|
||||
Gtk::VBox tab_page;
|
||||
/* Page widgets */
|
||||
Gtk::VBox page_box;
|
||||
Gtk::HBox page_toolbar;
|
||||
Gtk::SearchEntry page_entry;
|
||||
Gtk::ToggleButton page_random;
|
||||
//Gtk::ToggleButton page_repeat;
|
||||
Gtk::ScrolledWindow page_scroll;
|
||||
Gtk::TreeView page_view;
|
||||
|
||||
void setup_columns();
|
||||
|
||||
public:
|
||||
OcarinaTab(const std::string &, Playqueue *);
|
||||
|
@ -42,6 +71,7 @@ OcarinaTab::OcarinaTab(const std::string &text, Playqueue *pq)
|
|||
Gtk::Notebook *notebook;
|
||||
get_builder()->get_widget("o_notebook", notebook);
|
||||
|
||||
|
||||
/* Make tab label */
|
||||
tab_name.set_use_markup();
|
||||
tab_box.pack_start(tab_name);
|
||||
|
@ -50,15 +80,43 @@ OcarinaTab::OcarinaTab(const std::string &text, Playqueue *pq)
|
|||
set_tab_size();
|
||||
|
||||
|
||||
/* Make page content */
|
||||
page_random.set_image_from_icon_name("media-playlist-shuffle");
|
||||
page_random.set_active(pq->get_flags() & PQ_RANDOM);
|
||||
//page_repeat.set_image_from_icon_name("media-playlist-repeat");
|
||||
page_toolbar.set_spacing(5);
|
||||
|
||||
tab_page.set_visible();
|
||||
notebook->prepend_page(tab_page, tab_box);
|
||||
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_scroll.add(page_view);
|
||||
setup_columns();
|
||||
|
||||
page_toolbar.pack_start(page_entry);
|
||||
page_toolbar.pack_start(page_random, false, false);
|
||||
//page_toolbar.pack_start(page_repeat, false, false);
|
||||
page_box.pack_start(page_toolbar, false, false);
|
||||
page_box.pack_start(page_scroll);
|
||||
page_box.show_all();
|
||||
|
||||
|
||||
/* Add to notebook */
|
||||
notebook->prepend_page(page_box, tab_box);
|
||||
tab_map[pq] = this;
|
||||
};
|
||||
|
||||
OcarinaTab::~OcarinaTab()
|
||||
{
|
||||
Gtk::Notebook *notebook;
|
||||
get_builder()->get_widget("o_notebook", notebook);
|
||||
notebook->remove_page(page_box);
|
||||
|
||||
tab_map.erase(queue);
|
||||
}
|
||||
|
||||
|
@ -69,6 +127,15 @@ void OcarinaTab::set_tab_size()
|
|||
tab_size.set_text(ss.str());
|
||||
}
|
||||
|
||||
void OcarinaTab::setup_columns()
|
||||
{
|
||||
std::vector<Gtk::TreeViewColumn *> columns = page_view.get_columns();
|
||||
for (unsigned int i = 0; i < columns.size(); i++) {
|
||||
columns[i]->set_resizable();
|
||||
columns[i]->set_fixed_width(q_col_width[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -18,7 +18,7 @@ void get_object(const std::string &, Glib::RefPtr<T> &);
|
|||
/*
|
||||
* Collection manager functions
|
||||
*/
|
||||
class CollectionColumns : public Gtk::TreeModelColumnRecord {
|
||||
static class CollectionColumns : public Gtk::TreeModelColumnRecord {
|
||||
public:
|
||||
CollectionColumns()
|
||||
{ add(c_col_id); add(c_col_enabled); add(c_col_size); add(c_col_path); }
|
||||
|
@ -27,8 +27,7 @@ public:
|
|||
Gtk::TreeModelColumn<bool> c_col_enabled;
|
||||
Gtk::TreeModelColumn<unsigned int> c_col_size;
|
||||
Gtk::TreeModelColumn<Glib::ustring> c_col_path;
|
||||
};
|
||||
static CollectionColumns collection_cols;
|
||||
} collection_cols;
|
||||
|
||||
static void on_collection_ok()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue