Show the play count in the playlist renderer
I created a new renderer function for updating tracks when they change. Using this, I can show the new playcount of tracks as it is incremented. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
61769f74fd
commit
ca9f3e6cf9
|
@ -93,6 +93,7 @@ namespace libsaria
|
|||
void add_tracks(list<Track *> &);
|
||||
void remove_indices(list<unsigned int> &);
|
||||
void remove_tracks(list<Track *> &);
|
||||
void track_updated(Track *);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace libsaria
|
|||
Playlist *get_playlist();
|
||||
virtual void renumbered(int);
|
||||
virtual void refilter();
|
||||
virtual void track_updated(Track *);
|
||||
|
||||
bool is_static();
|
||||
virtual void prepare_for_removal();
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace libsaria
|
|||
unsigned int &get_track();
|
||||
unsigned int &get_libid();
|
||||
unsigned int &get_id();
|
||||
unsigned int &get_count();
|
||||
bool &get_banned();
|
||||
|
||||
void set_banned(bool);
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace ocarina
|
|||
void set_playlist(libsaria::Playlist *);
|
||||
void renumbered(int);
|
||||
void refilter();
|
||||
void track_updated(libsaria::Track *);
|
||||
void prepare_for_removal();
|
||||
void on_disable(bool);
|
||||
|
||||
|
|
|
@ -42,6 +42,11 @@ namespace libsaria
|
|||
RENDER( on_disable(is_disabled()) );
|
||||
}
|
||||
|
||||
void Playlist::track_updated(Track *track)
|
||||
{
|
||||
RENDER( track_updated(track) );
|
||||
}
|
||||
|
||||
void Playlist::prepare_for_removal()
|
||||
{
|
||||
/*
|
||||
|
|
|
@ -33,6 +33,10 @@ namespace libsaria
|
|||
{
|
||||
}
|
||||
|
||||
void PlaylistRenderer::track_updated(Track *track)
|
||||
{
|
||||
}
|
||||
|
||||
bool PlaylistRenderer::is_static()
|
||||
{
|
||||
return (flags & PL_STATIC) == PL_STATIC;
|
||||
|
|
|
@ -54,6 +54,11 @@ namespace libsaria
|
|||
return path->id;
|
||||
}
|
||||
|
||||
unsigned int &Track::get_count()
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
bool &Track::get_banned()
|
||||
{
|
||||
return banned;
|
||||
|
|
|
@ -152,6 +152,7 @@ namespace libsaria
|
|||
{
|
||||
time_t now = time(0);
|
||||
tm *ltm = localtime(&now);
|
||||
list<Playlist *>::iterator it;
|
||||
|
||||
if (path && audio::played()) {
|
||||
count++;
|
||||
|
@ -160,7 +161,10 @@ namespace libsaria
|
|||
last_year = 1900 + ltm->tm_year;
|
||||
|
||||
path->data_state = DIRTY;
|
||||
libsaria::library::save_path(path);
|
||||
library::save_path(path);
|
||||
|
||||
for (it = playlists.begin(); it != playlists.end(); it++)
|
||||
(*it)->track_updated(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@ namespace ocarina
|
|||
4, track->get_artist().c_str(),
|
||||
5, track->get_album().c_str(),
|
||||
6, track->get_year(),
|
||||
7, formatted(track->get_filepath()).c_str(),
|
||||
7, track->get_count(),
|
||||
8, formatted(track->get_filepath()).c_str(),
|
||||
-1);
|
||||
}
|
||||
|
||||
|
@ -52,4 +53,29 @@ namespace ocarina
|
|||
set_label_text();
|
||||
}
|
||||
|
||||
void Playlist::track_updated(libsaria::Track *track)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
libsaria::Track *t;
|
||||
|
||||
gtk_tree_model_get_iter_first(GTK_TREE_MODEL(liststore), &iter);
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(liststore), &iter, 0, &t, -1);
|
||||
|
||||
while (t != track) {
|
||||
gtk_tree_model_iter_next(GTK_TREE_MODEL(liststore), &iter);
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(liststore), &iter, 0, &t, -1);
|
||||
}
|
||||
|
||||
gtk_list_store_set(liststore, &iter,
|
||||
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, track->get_count(),
|
||||
8, formatted(track->get_filepath()).c_str(),
|
||||
-1);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -27,9 +27,11 @@ static struct column_info columns[] = {
|
|||
column_info( "Artist", G_TYPE_STRING, 125, true),
|
||||
column_info( "Album", G_TYPE_STRING, 125, true),
|
||||
column_info( "Year", G_TYPE_INT, 50, true),
|
||||
column_info( "Count", G_TYPE_INT, 50, true),
|
||||
column_info("Filepath", G_TYPE_STRING, 2, false),
|
||||
};
|
||||
|
||||
#define TOOLTIP 8
|
||||
#define NUM_COLUMNS (sizeof(columns) / sizeof(column_info))
|
||||
|
||||
static void track_selected(GtkWidget *treeview, GtkTreePath *path,
|
||||
|
@ -124,7 +126,7 @@ namespace ocarina
|
|||
|
||||
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), filter);
|
||||
gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(treeview), 7);
|
||||
gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(treeview), TOOLTIP);
|
||||
gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), -1);
|
||||
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win),
|
||||
|
|
Loading…
Reference in New Issue