ocarina: Play a song when a row is double-clicked

This is a natural way for the user to play a specific song.
This commit is contained in:
Bryan Schumaker 2011-09-20 08:35:24 -04:00
parent 2017e8a2f1
commit 284176fb5c
1 changed files with 15 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#include <ocarina/gtk.h>
#include <libsaria/library.h>
#include <libsaria/print.h>
#include "songlist.h"
@ -15,6 +16,19 @@ SongList::~SongList()
string columns[7] = { "Id", "#", "Title", "Length", "Artist", "Album", "Year" };
int col_width[7] = { 2, 20, 300, 60, 125, 125, 50 };
static void songlist_row_activated(GtkTreeView *treeview, GtkTreePath *path,
GtkTreeViewColumn *column, gpointer data)
{
GtkTreeIter iter;
ino_t inode;
GtkTreeModel *model = gtk_tree_view_get_model(treeview);
gtk_tree_model_get_iter(model, &iter, path);
gtk_tree_model_get(model, &iter, 0, &inode, -1);
print("Double click! ");
println(inode);
libsaria_play_id(inode);
}
void SongList::add_column(unsigned int index)
{
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(
@ -43,6 +57,7 @@ void SongList::init(string text)
text_cell = gtk_cell_renderer_text_new();
gtk_cell_renderer_text_set_fixed_height_from_font(
GTK_CELL_RENDERER_TEXT(text_cell), 1);
GTK_CONNECT(treeview, "row-activated", songlist_row_activated, NULL);
liststore = gtk_list_store_new(7, G_TYPE_LONG, G_TYPE_INT, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,