ocarina: Look for double clicking treeview rows
I now have direct access to the track that was selected, so I created a dummy function to play it (to be filled in soon). Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
570b483b9b
commit
a0d509cdff
|
@ -45,6 +45,7 @@ namespace libsaria
|
|||
~Track();
|
||||
void save(OutFile &);
|
||||
void do_cleanup();*/
|
||||
void play_now();
|
||||
|
||||
string &get_filepath();
|
||||
string get_title();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker.
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/format.h>
|
||||
#include <libsaria/print.h>
|
||||
/*#include <libsaria/library.h>
|
||||
#include <libsaria/index.h>*/
|
||||
|
||||
|
@ -76,6 +77,11 @@ namespace libsaria
|
|||
{
|
||||
}
|
||||
|
||||
void Track::play_now()
|
||||
{
|
||||
println("Playing: " + title + " by " + artist);
|
||||
}
|
||||
|
||||
/* Track::Track()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker
|
||||
#include <ocarina/playlist.h>
|
||||
#include <libsaria/track.h>
|
||||
|
||||
struct column_info {
|
||||
const char *name;
|
||||
|
@ -29,6 +30,20 @@ static struct column_info columns[] = {
|
|||
|
||||
#define NUM_COLUMNS (sizeof(columns) / sizeof(column_info))
|
||||
|
||||
static void track_selected(GtkWidget *treeview, GtkTreePath *path,
|
||||
GtkTreeViewColumn *col, gpointer data)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
libsaria::Track *track;
|
||||
|
||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
|
||||
gtk_tree_model_get_iter(model, &iter, path);
|
||||
gtk_tree_model_get(model, &iter, 0, &track, -1);
|
||||
|
||||
track->play_now();
|
||||
}
|
||||
|
||||
static GtkListStore *setup_liststore(GtkWidget *treeview)
|
||||
{
|
||||
GtkListStore *liststore;
|
||||
|
@ -71,6 +86,8 @@ namespace ocarina
|
|||
treeview = gtk_tree_view_new();
|
||||
liststore = setup_liststore(treeview);
|
||||
|
||||
g_signal_connect(treeview, "row-activated", G_CALLBACK(track_selected), NULL);
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue