ocarina: Insert songs in the songlist

I created an insert() function that will fill in the list and display
all the songs.
This commit is contained in:
Bryan Schumaker 2011-09-19 19:48:37 -04:00
parent 0326b9c7e4
commit 309cda851f
3 changed files with 29 additions and 4 deletions

View File

@ -30,5 +30,6 @@ static void fill_library()
void ocarina_library_refresh()
{
library_list.clear();
fill_library();
}

View File

@ -1,7 +1,8 @@
#include <ocarina/gtk.h>
#include "songlist.h"
#include <libsaria/print.h>
#include "songlist.h"
SongList::SongList()
{
@ -43,12 +44,13 @@ void SongList::init(string text)
gtk_cell_renderer_text_set_fixed_height_from_font(
GTK_CELL_RENDERER_TEXT(text_cell), 1);
liststore = gtk_list_store_new(7, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING,
liststore = gtk_list_store_new(7, G_TYPE_LONG, G_TYPE_INT, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING);
for (unsigned int i = 1; i < 7; i++)
G_TYPE_INT);
for (unsigned int i = 0; i < 7; i++)
add_column(i);
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);
gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(liststore));
container_add(window, treeview);
gtk_widget_show_all(window);
@ -68,7 +70,28 @@ GtkWidget *SongList::get_label()
return label;
}
void SongList::clear()
{
gtk_list_store_clear(liststore);
}
void SongList::insert(list<Track> &track_list)
{
int ins_next = 0;
Track *track;
list<Track>::iterator it;
for (it = track_list.begin(); it != track_list.end(); it++) {
track = &(*it);
gtk_list_store_insert_with_values(liststore, NULL, ins_next,
0, track->get_inode(),
1, track->get_track(),
2, track->get_title().c_str(),
3, track->get_lenstr().c_str(),
4, track->get_artist().c_str(),
5, track->get_album().c_str(),
6, track->get_year(),
-1);
ins_next++;
}
}

View File

@ -29,6 +29,7 @@ class SongList
GtkWidget *get_label();
void insert(list<Track> &track_list);
void clear();
};
#endif /* OCARINA_SONGLIST_H */