diff --git a/.gitignore b/.gitignore index 68dabb44..927fc2b9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.sw* *.out *.glade~ +*.ui~ share/ocarina/#* bin/ .sconsign.dblite diff --git a/gui/queue.cpp b/gui/queue.cpp index 901ea9f7..54504906 100644 --- a/gui/queue.cpp +++ b/gui/queue.cpp @@ -4,10 +4,10 @@ #include #include #include +#include static void renumber_queues(); -static unsigned int q_col_width[] = { 20, 300, 60, 100, 100, 45, 100, 60, 1 }; static class QueueColumns : public Gtk::TreeModelColumnRecord { public: @@ -33,6 +33,8 @@ public: class QueueTab : public Tab { private: + Glib::RefPtr builder; + /** * Queue tab widgets */ @@ -58,7 +60,7 @@ private: /* Treeview widgets */ Gtk::ScrolledWindow q_window; - Gtk::TreeView q_treeview; + QueueView *q_treeview; public: @@ -92,6 +94,9 @@ static std::map queue_mapping; QueueTab :: QueueTab(Queue *pq, unsigned int num) : Tab(pq) { + builder = Gtk::Builder::create(); + builder->add_from_file(gui :: share_file("QueueView.ui")); + /* * Create our tab widget */ @@ -131,12 +136,12 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num) /* * And the treeview with scrolled window */ + builder->get_widget_derived("QueueView", q_treeview); q_window.set_shadow_type(Gtk::SHADOW_IN); q_window.set_margin_left(5); q_window.set_margin_right(5); q_window.set_margin_bottom(5); - q_window.add(q_treeview); - setup_treeview(); + q_window.add(*q_treeview); /* @@ -158,7 +163,7 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num) tab_repeat = &q_repeat; tab_search = &q_search; tab_size = &q_tab_size; - tab_treeview = &q_treeview; + tab_treeview = q_treeview; tab_widget = &q_vbox; tab_finish_init(); @@ -192,33 +197,6 @@ void QueueTab :: on_track_removed(unsigned int row) * */ -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_enable_search(false); - q_treeview.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); - q_treeview.set_rubber_banding(); - - std::vector 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() { tab_init_random(); @@ -284,7 +262,7 @@ void QueueTab :: queue_set_sensitive(bool sensitive) { q_tab_number.set_sensitive(sensitive); q_tab_size.set_sensitive(sensitive); - q_treeview.set_sensitive(sensitive); + q_treeview->set_sensitive(sensitive); } diff --git a/gui/queue/view.cpp b/gui/queue/view.cpp new file mode 100644 index 00000000..cc9d37ef --- /dev/null +++ b/gui/queue/view.cpp @@ -0,0 +1,14 @@ +/* + * Copyright 2015 (c) Anna Schumaker. + */ +#include + +QueueView :: QueueView(BaseObjectType *cobject, + const Glib::RefPtr builder) + : Gtk::TreeView(cobject), _builder(builder) +{ +} + +QueueView :: ~QueueView() +{ +} diff --git a/include/gui/queue/view.h b/include/gui/queue/view.h new file mode 100644 index 00000000..435994d0 --- /dev/null +++ b/include/gui/queue/view.h @@ -0,0 +1,18 @@ +/* + * Copyright 2015 (c) Anna Schumaker. + */ +#ifndef OCARINA_GUI_QUEUE_VIEW_H +#define OCARINA_GUI_QUEUE_VIEW_H + +#include + +class QueueView : public Gtk::TreeView { +private: + Glib::RefPtr _builder; + +public: + QueueView(BaseObjectType *, const Glib::RefPtr); + ~QueueView(); +}; + +#endif /* OCARINA_GUI_QUEUE_VIEW_H */ diff --git a/share/ocarina/QueueView.ui b/share/ocarina/QueueView.ui new file mode 100644 index 00000000..db6c75b7 --- /dev/null +++ b/share/ocarina/QueueView.ui @@ -0,0 +1,152 @@ + + + + + + True + True + False + True + 9 + + + multiple + + + + + True + fixed + 20 + # + True + + + + 0 + + + + + + + True + fixed + 300 + Title + True + + + + 1 + + + + + + + True + fixed + 60 + Length + True + + + + 2 + + + + + + + True + fixed + 100 + Artist + True + + + + 3 + + + + + + + True + fixed + 100 + Album + True + + + + 4 + + + + + + + True + fixed + 45 + Year + True + + + + 5 + + + + + + + True + fixed + 100 + Genre + True + + + + 6 + + + + + + + True + fixed + 60 + Count + True + + + + 7 + + + + + + + True + fixed + 1 + Played + True + + + + 8 + + + + + +