ocarina: Watch for insert() operations in the Playlist
And update the GtkListStore when we see these calls. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
6bb3cd38a4
commit
9464e0d33d
|
@ -23,6 +23,11 @@ namespace ocarina
|
|||
~Playlist();
|
||||
|
||||
void set_playlist(libsaria::Playlist *);
|
||||
|
||||
void insert_prepare();
|
||||
void insert(libsaria::Track *, unsigned int);
|
||||
void insert_done();
|
||||
|
||||
};
|
||||
|
||||
namespace playlist
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <ocarina/playlist.h>
|
||||
#include <libsaria/track.h>
|
||||
|
||||
static string formatted(string str)
|
||||
{
|
||||
char *escaped = g_markup_escape_text(str.c_str(), -1);
|
||||
string ret = escaped;
|
||||
g_free(escaped);
|
||||
return ret;
|
||||
}
|
||||
|
||||
namespace ocarina
|
||||
{
|
||||
|
||||
void Playlist::insert_prepare()
|
||||
{
|
||||
gtk_widget_freeze_child_notify(treeview);
|
||||
}
|
||||
|
||||
void Playlist::insert(libsaria::Track *track, unsigned int index)
|
||||
{
|
||||
gtk_list_store_insert_with_values(liststore, NULL, index,
|
||||
0, track,
|
||||
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(),
|
||||
7, formatted(track->get_filepath()).c_str(),
|
||||
-1);
|
||||
}
|
||||
|
||||
void Playlist::insert_done()
|
||||
{
|
||||
gtk_widget_thaw_child_notify(treeview);
|
||||
set_label_text();
|
||||
}
|
||||
|
||||
};
|
|
@ -58,7 +58,6 @@ static GtkListStore *setup_liststore(GtkWidget *treeview)
|
|||
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), col);
|
||||
};
|
||||
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(liststore));
|
||||
return liststore;
|
||||
}
|
||||
|
||||
|
@ -72,6 +71,10 @@ namespace ocarina
|
|||
treeview = gtk_tree_view_new();
|
||||
liststore = setup_liststore(treeview);
|
||||
|
||||
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(liststore));
|
||||
gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(treeview), 7);
|
||||
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker
|
||||
#include <ocarina/songlist.h>
|
||||
|
||||
/*
|
||||
string formatted(string str)
|
||||
{
|
||||
char *escaped = g_markup_escape_text(str.c_str(), -1);
|
||||
|
@ -8,7 +9,7 @@ string formatted(string str)
|
|||
g_free(escaped);
|
||||
return ret;
|
||||
}
|
||||
|
||||
*/
|
||||
void SongList::freeze()
|
||||
{
|
||||
gtk_widget_freeze_child_notify(treeview);
|
||||
|
|
Loading…
Reference in New Issue