gui: Begin the redesigned history tab
This code will be in its own self-contained file: history.cpp Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
97511f82a9
commit
4104a4cede
83
gui/history.cpp
Normal file
83
gui/history.cpp
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
|
*/
|
||||||
|
#include <audio.h>
|
||||||
|
#include <ocarina.h>
|
||||||
|
|
||||||
|
static Glib::RefPtr<PlayqueueModel> model;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Basic helper functions
|
||||||
|
*/
|
||||||
|
static inline Playqueue *history_pq()
|
||||||
|
{
|
||||||
|
return audio::get_recent_pq();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_queue_size()
|
||||||
|
{
|
||||||
|
Gtk::Label *label = get_widget<Gtk::Label>("o_history_size");
|
||||||
|
label->set_text(itoa(history_pq()->size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gtk signal functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Functions exposed through a TabFuncs structure
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void history_init_late()
|
||||||
|
{
|
||||||
|
set_queue_size();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void history_cleanup() {}
|
||||||
|
|
||||||
|
static bool history_has_queue(Playqueue *pq)
|
||||||
|
{
|
||||||
|
return pq == history_pq();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void history_track_added(Playqueue *pq, unsigned int row)
|
||||||
|
{
|
||||||
|
model->on_row_inserted(row);
|
||||||
|
set_queue_size();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void history_track_deleted(Playqueue *pq, unsigned int row)
|
||||||
|
{
|
||||||
|
model->on_row_deleted(row);
|
||||||
|
set_queue_size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static struct TabFuncs history_funcs = {
|
||||||
|
.init_late = history_init_late,
|
||||||
|
.cleanup = history_cleanup,
|
||||||
|
|
||||||
|
.has_queue = history_has_queue,
|
||||||
|
.track_added = history_track_added,
|
||||||
|
.track_deleted = history_track_deleted,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Basic tab setup
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct TabFuncs *init_history_tab()
|
||||||
|
{
|
||||||
|
model = Glib::RefPtr<PlayqueueModel>(new PlayqueueModel(history_pq()));
|
||||||
|
get_widget<Gtk::TreeView>("o_history_treeview")->set_model(model);
|
||||||
|
|
||||||
|
return &history_funcs;
|
||||||
|
}
|
|
@ -453,15 +453,191 @@
|
||||||
<object class="GtkBox" id="box16">
|
<object class="GtkBox" id="box16">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="margin_left">1</property>
|
||||||
|
<property name="margin_right">1</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<object class="GtkSearchEntry" id="searchentry2">
|
||||||
|
<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>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<object class="GtkScrolledWindow" id="scrolledwindow3">
|
||||||
|
<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_history_treeview">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="rules_hint">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-selection4">
|
||||||
|
<property name="mode">multiple</property>
|
||||||
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<object class="GtkTreeViewColumn" id="treeviewcolumn13">
|
||||||
|
<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="cellrenderertext12"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">0</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="treeviewcolumn14">
|
||||||
|
<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="cellrenderertext13"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">1</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="treeviewcolumn15">
|
||||||
|
<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="cellrenderertext14"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">2</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="treeviewcolumn16">
|
||||||
|
<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="cellrenderertext15"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">3</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="treeviewcolumn17">
|
||||||
|
<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="cellrenderertext16"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">4</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="treeviewcolumn18">
|
||||||
|
<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="cellrenderertext17"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">5</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="treeviewcolumn19">
|
||||||
|
<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="cellrenderertext18"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">6</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="treeviewcolumn20">
|
||||||
|
<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="cellrenderertext19"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">7</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="treeviewcolumn21">
|
||||||
|
<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="cellrenderertext20"/>
|
||||||
|
<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>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
|
@ -508,7 +684,7 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="label10">
|
<object class="GtkLabel" id="o_history_size">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="label" translatable="yes">0</property>
|
<property name="label" translatable="yes">0</property>
|
||||||
|
|
|
@ -944,6 +944,7 @@ void init_tabs()
|
||||||
init_menu_item("o_pq_9", 9);*/
|
init_menu_item("o_pq_9", 9);*/
|
||||||
|
|
||||||
tab_types.push_back(init_collection_tab());
|
tab_types.push_back(init_collection_tab());
|
||||||
|
tab_types.push_back(init_history_tab());
|
||||||
|
|
||||||
notebook->signal_switch_page().connect(sigc::ptr_fun(on_switch_page));
|
notebook->signal_switch_page().connect(sigc::ptr_fun(on_switch_page));
|
||||||
notebook->signal_page_reordered().connect(sigc::ptr_fun(on_page_reordered));
|
notebook->signal_page_reordered().connect(sigc::ptr_fun(on_page_reordered));
|
||||||
|
|
|
@ -8,13 +8,19 @@
|
||||||
#include <tabs.h>
|
#include <tabs.h>
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
|
|
||||||
/* collection.cpp */
|
/* collection.cpp */
|
||||||
struct TabFuncs *init_collection_tab();
|
struct TabFuncs *init_collection_tab();
|
||||||
|
|
||||||
|
|
||||||
/* collection_mgr.cpp */
|
/* collection_mgr.cpp */
|
||||||
void collection_mgr_init();
|
void collection_mgr_init();
|
||||||
|
|
||||||
|
|
||||||
|
/* history.cpp */
|
||||||
|
struct TabFuncs *init_history_tab();
|
||||||
|
|
||||||
|
|
||||||
/* main.cpp */
|
/* main.cpp */
|
||||||
Gtk::Window *ocarina_init(int *, char ***);
|
Gtk::Window *ocarina_init(int *, char ***);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user