gui: Convert the playlist tab to use the new template files

I also created a new PlaylistWindow class for displaying the names of
each playlist.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-04-14 08:45:32 -04:00
parent b2b23bec46
commit 8f570f1f24
6 changed files with 211 additions and 343 deletions

View File

@ -4,14 +4,14 @@
#include <core/audio.h>
#include <core/playlist.h>
#include <gui/tabs.h>
#include <gui/queue/label.h>
#include <gui/queue/toolbar.h>
#include <gui/queue/window.h>
static Gtk::ToggleButton *o_ban;
static Gtk::ToggleButton *o_fav;
static Gtk::TreeView *p_treeview;
static Glib::RefPtr<Gtk::ListStore> p_list;
static Glib::ustring current_playlist();
static class PlaylistColumns : public Gtk::TreeModelColumnRecord {
@ -22,14 +22,100 @@ public:
class PlaylistWindow : public Gtk::ScrolledWindow {
private:
Glib::RefPtr<Gtk::Builder> _builder;
public:
Gtk::TreeView *p_treeview;
Glib::RefPtr<Gtk::ListStore> p_list;
PlaylistWindow(BaseObjectType *cobject,
const Glib::RefPtr<Gtk::Builder> builder)
: Gtk::ScrolledWindow(cobject), _builder(builder)
{
_builder->get_widget("p_treeview", p_treeview);
p_list = Glib::RefPtr<Gtk::ListStore>::cast_static(_builder->get_object("p_list"));
p_treeview->signal_cursor_changed().connect(sigc::mem_fun(*this,
&PlaylistWindow::on_cursor_changed));
p_treeview->signal_button_press_event().connect(sigc::mem_fun(*this,
&PlaylistWindow::on_clicked));
}
~PlaylistWindow() {}
Glib::ustring current_playlist()
{
Gtk::TreePath path;
Gtk::TreeModel::Row row;
Gtk::TreeViewColumn *col;
p_treeview->get_cursor(path, col);
row = *(p_list->get_iter(path));
return row[p_cols.p_name];
}
void on_cursor_changed()
{
playlist :: select(current_playlist());
}
bool on_clicked(GdkEventButton *button)
{
return button->button == 3;
}
};
static class PlaylistTab : public Tab {
private:
Glib::RefPtr<Gtk::Builder> builder;
Gtk::VBox playlist_vbox;
Gtk::HBox playlist_hbox;
PlaylistLabel *playlist_label;
PlaylistWindow *playlist_window;
QueueToolbar *playlist_toolbar;
QueueWindow *playlist_tracks;
public:
PlaylistTab() : Tab(playlist :: get_queue())
{
tab_search = gui :: get_widget<Gtk::SearchEntry>("o_playlist_entry");
tab_treeview = gui :: get_widget<Gtk::TreeView>("o_playlist_pq_treeview");
tab_widget = gui :: get_widget<Gtk::Widget>("o_playlist_page");
builder = Gtk::Builder::create();
builder->add_from_file(gui :: share_file("QueueWindow.ui"));
builder->add_from_file(gui :: share_file("QueueToolbar.ui"));
builder->add_from_file(gui :: share_file("QueueLabel.ui"));
builder->add_from_file(gui :: share_file("PlaylistWindow.ui"));
builder->get_widget_derived("PlaylistLabel", playlist_label);
builder->get_widget_derived("PlaylistWindow", playlist_window);
builder->get_widget_derived("QueueToolbar", playlist_toolbar);
builder->get_widget_derived("QueueWindow", playlist_tracks);
playlist_toolbar->q_switch->hide();
playlist_toolbar->q_repeat->hide();
playlist_hbox.pack_start(*playlist_window, false, true);
playlist_hbox.pack_start(*playlist_tracks, true, true);
playlist_hbox.show();
playlist_vbox.set_margin_left(1);
playlist_vbox.set_margin_right(1);
playlist_vbox.set_homogeneous(false);
playlist_vbox.pack_start(*playlist_toolbar, false, true, 2);
playlist_vbox.pack_start(playlist_hbox, true, true);
playlist_vbox.show();
tab_random = playlist_toolbar->q_random;
tab_repeat = playlist_toolbar->q_repeat;
tab_search = playlist_toolbar->q_search;
tab_treeview = playlist_tracks->q_treeview;
tab_widget = &playlist_vbox;
tab_finish_init();
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(playlist_vbox, *playlist_label, 0);
}
~PlaylistTab()
@ -45,7 +131,7 @@ public:
if (key != "Delete")
return Tab :: on_key_press_event(key);
cur = current_playlist();
cur = playlist_window->current_playlist();
if (cur == "")
return true;
@ -58,27 +144,6 @@ public:
static Glib::ustring current_playlist()
{
Gtk::TreePath path;
Gtk::TreeModel::Row row;
Gtk::TreeViewColumn *col;
p_treeview->get_cursor(path, col);
row = *(p_list->get_iter(path));
return row[p_cols.p_name];
}
static void on_cursor_changed()
{
playlist :: select(current_playlist());
}
static bool on_clicked(GdkEventButton *button)
{
return button->button == 3;
}
static void on_ban()
{
Track *track = audio :: current_track();
@ -111,11 +176,6 @@ void plist :: track_loaded(Track *track)
void plist :: init()
{
p_tab = new PlaylistTab;
p_list = gui :: get_object<Gtk::ListStore>("plist_list");
p_treeview = gui :: get_widget<Gtk::TreeView>("plist_treeview");
p_treeview->signal_cursor_changed().connect(sigc::ptr_fun(on_cursor_changed));
p_treeview->signal_button_press_event().connect(sigc::ptr_fun(on_clicked));
o_ban = gui :: get_widget<Gtk::ToggleButton>("o_ban");
o_fav = gui :: get_widget<Gtk::ToggleButton>("o_favorite");

View File

@ -30,6 +30,18 @@ HistoryLabel :: ~HistoryLabel()
PlaylistLabel :: PlaylistLabel(BaseObjectType *cobject,
const Glib::RefPtr<Gtk::Builder> builder)
: Gtk::HBox(cobject), _builder(builder)
{
}
PlaylistLabel :: ~PlaylistLabel()
{
}
TempLabel :: TempLabel(BaseObjectType *cobject,
const Glib::RefPtr<Gtk::Builder> builder)
: Gtk::HBox(cobject), _builder(builder)

View File

@ -33,6 +33,17 @@ public:
class PlaylistLabel : public Gtk::HBox {
private:
Glib::RefPtr<Gtk::Builder> _builder;
public:
PlaylistLabel(BaseObjectType *, const Glib::RefPtr<Gtk::Builder>);
~PlaylistLabel();
};
class TempLabel : public Gtk::HBox {
private:
Glib::RefPtr<Gtk::Builder> _builder;

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkListStore" id="p_list">
<columns>
<!-- column-name Playlists -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Favorites</col>
</row>
<row>
<col id="0" translatable="yes">Banned</col>
</row>
<row>
<col id="0" translatable="yes">Most Played</col>
</row>
<row>
<col id="0" translatable="yes">Least Played</col>
</row>
<row>
<col id="0" translatable="yes">Unplayed</col>
</row>
</data>
</object>
<object class="GtkScrolledWindow" id="PlaylistWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_bottom">5</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="p_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">p_list</property>
<property name="enable_search">False</property>
<property name="search_column">0</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection5">
<property name="mode">browse</property>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title" translatable="yes">Playlists</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@ -7,7 +7,7 @@
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image2">
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">media-optical</property>
@ -63,7 +63,7 @@
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image3">
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">document-open-recent</property>
@ -115,6 +115,38 @@
</packing>
</child>
</object>
<object class="GtkBox" id="PlaylistLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">emblem-documents</property>
<property name="icon_size">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Playlist
Manager</property>
<property name="justify">center</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<object class="GtkBox" id="TempLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -159,7 +191,7 @@
<property name="receives_default">True</property>
<property name="relief">none</property>
<child>
<object class="GtkImage" id="image1">
<object class="GtkImage" id="image4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">window-close</property>

View File

@ -195,29 +195,6 @@
<property name="step_increment">1000000000</property>
<property name="page_increment">10000000000</property>
</object>
<object class="GtkListStore" id="plist_list">
<columns>
<!-- column-name Playlists -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Favorites</col>
</row>
<row>
<col id="0" translatable="yes">Banned</col>
</row>
<row>
<col id="0" translatable="yes">Most Played</col>
</row>
<row>
<col id="0" translatable="yes">Least Played</col>
</row>
<row>
<col id="0" translatable="yes">Unplayed</col>
</row>
</data>
</object>
<object class="GtkWindow" id="o_window">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -237,286 +214,6 @@
<property name="tab_pos">left</property>
<property name="scrollable">True</property>
<property name="enable_popup">True</property>
<child>
<object class="GtkBox" id="o_playlist_page">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">1</property>
<property name="margin_right">1</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchEntry" id="o_playlist_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box25">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow6">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_left">5</property>
<property name="margin_bottom">5</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="plist_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">plist_list</property>
<property name="enable_search">False</property>
<property name="search_column">0</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection">
<property name="mode">browse</property>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title" translatable="yes">Playlists</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext30"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow5">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_bottom">5</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="o_playlist_pq_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="enable_search">False</property>
<property name="rubber_banding">True</property>
<property name="tooltip_column">9</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection7">
<property name="mode">multiple</property>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn22">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">20</property>
<property name="title" translatable="yes">#</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext21"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn23">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">300</property>
<property name="title" translatable="yes">Title</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext22"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn24">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">60</property>
<property name="title" translatable="yes">Length</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext23"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn25">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">100</property>
<property name="title" translatable="yes">Artist</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext24"/>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn26">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">100</property>
<property name="title" translatable="yes">Album</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext25"/>
<attributes>
<attribute name="text">4</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn27">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">45</property>
<property name="title" translatable="yes">Year</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext26"/>
<attributes>
<attribute name="text">5</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn28">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">100</property>
<property name="title" translatable="yes">Genre</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext27"/>
<attributes>
<attribute name="text">6</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn29">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">60</property>
<property name="title" translatable="yes">Count</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext28"/>
<attributes>
<attribute name="text">7</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn30">
<property name="resizable">True</property>
<property name="sizing">fixed</property>
<property name="fixed_width">1</property>
<property name="title" translatable="yes">Played</property>
<property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext29"/>
<attributes>
<attribute name="text">8</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="tab">
<object class="GtkBox" id="box22">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image16">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">emblem-documents</property>
<property name="icon_size">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">1</property>
<property name="label" translatable="yes">Playlist
Manager</property>
<property name="justify">center</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box8">
<property name="visible">True</property>
@ -721,9 +418,6 @@ Manager</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child type="tab">
<object class="GtkBox" id="box1">
@ -760,7 +454,6 @@ Manager</property>
</child>
</object>
<packing>
<property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>