ocarina: Create a GtkBuilder tab for the recent playlist
I also remove the old code for showing the recent playlist. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
b138c24e6d
commit
3ed02e221e
|
@ -16,6 +16,7 @@ static GtkWidget *open_button;
|
|||
static GtkWidget *yes_image;
|
||||
static GtkWidget *no_image;
|
||||
static GtkTreeModel *library_filter;
|
||||
static GtkTreeModel *recent_filter;
|
||||
|
||||
static void find_exe_path(string &res)
|
||||
{
|
||||
|
@ -91,6 +92,8 @@ GObject *get_object(const string &name)
|
|||
return G_OBJECT(no_image);
|
||||
else if (name == "LibraryFilter")
|
||||
return G_OBJECT(library_filter);
|
||||
else if (name == "RecentFilter")
|
||||
return G_OBJECT(recent_filter);
|
||||
return gtk_builder_get_object(builder, name.c_str());
|
||||
}
|
||||
|
||||
|
@ -144,6 +147,9 @@ static void init_widgets()
|
|||
library_filter = gtk_tree_model_filter_new(
|
||||
GTK_TREE_MODEL(get_object("LibraryPlist")),
|
||||
NULL);
|
||||
recent_filter = gtk_tree_model_filter_new(
|
||||
GTK_TREE_MODEL(get_object("RecentPlist")),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void init(int argc, char **argv)
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include <cstdio>
|
||||
|
||||
static ocarina::Playlist recent_renderer(PL_STATIC);
|
||||
static ocarina::Playlist banned_renderer(PL_STATIC);
|
||||
|
||||
namespace ocarina
|
||||
|
@ -20,11 +19,6 @@ namespace ocarina
|
|||
new Playlist(plist);
|
||||
}
|
||||
|
||||
void playlist::switch_to_recent()
|
||||
{
|
||||
recent_renderer.switch_to();
|
||||
}
|
||||
|
||||
void playlist::switch_to_banned()
|
||||
{
|
||||
banned_renderer.switch_to();
|
||||
|
@ -45,7 +39,6 @@ namespace ocarina
|
|||
{
|
||||
libsaria::set_on_new_playlist(on_new_playlist);
|
||||
banned_renderer.set_playlist(libsaria::ban::get_banned_plist());
|
||||
recent_renderer.set_playlist(libsaria::deck::get_recent_plist());
|
||||
}
|
||||
|
||||
}; /* Namespace: ocarina */
|
||||
|
@ -91,6 +84,8 @@ static GtkListStore *find_list(libsaria::Playlist *plist)
|
|||
{
|
||||
if (plist == libsaria::library::get_playlist())
|
||||
return GTK_LIST_STORE(get_object("LibraryPlist"));
|
||||
else if (plist == libsaria::deck::get_recent_plist())
|
||||
return GTK_LIST_STORE(get_object("RecentPlist"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -98,6 +93,8 @@ static GtkWidget *find_label(libsaria::Playlist *plist)
|
|||
{
|
||||
if (plist == libsaria::library::get_playlist())
|
||||
return get_widget("LibrarySize");
|
||||
else if (plist == libsaria::deck::get_recent_plist())
|
||||
return get_widget("RecentSize");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -105,6 +102,8 @@ static GtkTreeModelFilter *find_filter(libsaria::Playlist *plist)
|
|||
{
|
||||
if (plist == libsaria::library::get_playlist())
|
||||
return GTK_TREE_MODEL_FILTER(get_object("LibraryFilter"));
|
||||
else if (plist == libsaria::deck::get_recent_plist())
|
||||
return GTK_TREE_MODEL_FILTER(get_object("RecentFilter"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -154,17 +153,23 @@ void update_playlist(notify_t event, libsaria::PlaylistNotification *data)
|
|||
playlist_refilter(data->plist);
|
||||
}
|
||||
|
||||
static void init_playlist_tab(libsaria::Playlist *playlist, const string &view_name,
|
||||
const string &entry_name)
|
||||
{
|
||||
GtkTreeModel *model = GTK_TREE_MODEL(find_filter(playlist));
|
||||
GtkWidget *treeview = get_widget(view_name);
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), model);
|
||||
gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(model),
|
||||
is_visible, playlist, NULL);
|
||||
|
||||
connect_signal(view_name, "row-activated", G_CALLBACK(track_selected), NULL);
|
||||
connect_signal(entry_name, "changed", G_CALLBACK(do_filter), playlist);
|
||||
}
|
||||
|
||||
void init_playlist()
|
||||
{
|
||||
GtkTreeModel *library_filter = GTK_TREE_MODEL(get_object("LibraryFilter"));
|
||||
libsaria::Playlist *library = libsaria::library::get_playlist();
|
||||
|
||||
init_playlist2();
|
||||
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(get_widget("LibraryPlistView")), library_filter);
|
||||
gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(library_filter),
|
||||
is_visible, library, NULL);
|
||||
|
||||
connect_signal("LibraryPlistView", "row-activated", G_CALLBACK(track_selected), NULL);
|
||||
connect_signal("LibraryEntry", "changed", G_CALLBACK(do_filter), library);
|
||||
init_playlist_tab(libsaria::library::get_playlist(), "LibraryPlistView", "LibraryEntry");
|
||||
init_playlist_tab(libsaria::deck::get_recent_plist(), "RecentView", "RecentEntry");
|
||||
}
|
||||
|
|
232
xml/ocarina.xml
232
xml/ocarina.xml
|
@ -393,6 +393,214 @@
|
|||
<property name="tab_fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox9">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="RecentEntry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<property name="invisible_char_set">True</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="secondary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">True</property>
|
||||
<property name="secondary_icon_sensitive">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">automatic</property>
|
||||
<property name="vscrollbar_policy">automatic</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="RecentView">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="model">RecentPlist</property>
|
||||
<property name="headers_clickable">False</property>
|
||||
<property name="rules_hint">True</property>
|
||||
<property name="search_column">1</property>
|
||||
<property name="tooltip_column">9</property>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn12">
|
||||
<property name="resizable">True</property>
|
||||
<property name="sizing">fixed</property>
|
||||
<property name="fixed_width">20</property>
|
||||
<property name="min_width">2</property>
|
||||
<property name="max_width">700</property>
|
||||
<property name="title" translatable="yes">#</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext11"/>
|
||||
<attributes>
|
||||
<attribute name="text">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn13">
|
||||
<property name="resizable">True</property>
|
||||
<property name="sizing">fixed</property>
|
||||
<property name="fixed_width">300</property>
|
||||
<property name="min_width">2</property>
|
||||
<property name="max_width">700</property>
|
||||
<property name="title" translatable="yes">Title</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext12"/>
|
||||
<attributes>
|
||||
<attribute name="text">2</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn14">
|
||||
<property name="resizable">True</property>
|
||||
<property name="min_width">2</property>
|
||||
<property name="max_width">700</property>
|
||||
<property name="title" translatable="yes">Length</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext13"/>
|
||||
<attributes>
|
||||
<attribute name="text">3</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">125</property>
|
||||
<property name="min_width">2</property>
|
||||
<property name="max_width">700</property>
|
||||
<property name="title" translatable="yes">Artist</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext14"/>
|
||||
<attributes>
|
||||
<attribute name="text">4</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">125</property>
|
||||
<property name="min_width">2</property>
|
||||
<property name="max_width">700</property>
|
||||
<property name="title" translatable="yes">Album</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext15"/>
|
||||
<attributes>
|
||||
<attribute name="text">5</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn17">
|
||||
<property name="resizable">True</property>
|
||||
<property name="min_width">2</property>
|
||||
<property name="max_width">700</property>
|
||||
<property name="title" translatable="yes">Year</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext16"/>
|
||||
<attributes>
|
||||
<attribute name="text">6</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn18">
|
||||
<property name="resizable">True</property>
|
||||
<property name="min_width">2</property>
|
||||
<property name="max_width">700</property>
|
||||
<property name="title" translatable="yes">Count</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext17"/>
|
||||
<attributes>
|
||||
<attribute name="text">7</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn19">
|
||||
<property name="resizable">True</property>
|
||||
<property name="min_width">2</property>
|
||||
<property name="max_width">700</property>
|
||||
<property name="title" translatable="yes">Played</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext18"/>
|
||||
<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="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child type="tab">
|
||||
<object class="GtkVBox" id="vbox8">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label6">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="yalign">0</property>
|
||||
<property name="label" translatable="yes">Recent</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="RecentSize">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="yalign">0</property>
|
||||
<property name="label" translatable="yes">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
<property name="tab_fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
|
@ -948,4 +1156,28 @@
|
|||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkListStore" id="RecentPlist">
|
||||
<columns>
|
||||
<!-- column-name Pointer -->
|
||||
<column type="gpointer"/>
|
||||
<!-- column-name # -->
|
||||
<column type="guint"/>
|
||||
<!-- column-name Title -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Length -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Artist -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Album -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Year -->
|
||||
<column type="guint"/>
|
||||
<!-- column-name Count -->
|
||||
<column type="guint"/>
|
||||
<!-- column-name Last -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Filepath -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
Loading…
Reference in New Issue