From a3602333d0e12150d84396b1e5a1841ea3689e96 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Thu, 12 Jun 2008 13:49:06 +0100 Subject: [PATCH] Playing checkbox in Disobedience choose tab is now only visible for tracks, and can be used to add the track to the queue. Organization: Straylight/Edgeware From: Richard Kettlewell --- disobedience/choose-menu.c | 6 ------ disobedience/choose.c | 37 ++++++++++++++++++++++++++++++++++++- disobedience/choose.h | 3 +++ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/disobedience/choose-menu.c b/disobedience/choose-menu.c index 4063c27..a4e5430 100644 --- a/disobedience/choose-menu.c +++ b/disobedience/choose-menu.c @@ -151,12 +151,6 @@ static int choose_play_sensitive(void attribute((unused)) *extra) { count_choosedatas(choose_get_selected(NULL), counts); return !counts[CHOOSE_DIRECTORY] && counts[CHOOSE_FILE]; } - -static void choose_play_completed(void attribute((unused)) *v, - const char *error) { - if(error) - popup_protocol_error(0, error); -} static void choose_play_activate(GtkMenuItem attribute((unused)) *item, gpointer attribute((unused)) userdata) { diff --git a/disobedience/choose.c b/disobedience/choose.c index e59d5b7..d1d791a 100644 --- a/disobedience/choose.c +++ b/disobedience/choose.c @@ -215,6 +215,7 @@ static void choose_populate(GtkTreeRowReference *parent_ref, vec[n], "display"), CHOOSEDATA_COLUMN, cd, + ISFILE_COLUMN, type == CHOOSE_FILE, -1); /* Update length and state; we expect this to kick off length lookups * rather than necessarily get the right value the first time round. */ @@ -266,6 +267,36 @@ static void choose_files_completed(void *v, choose_populate(v, nvec, vec, CHOOSE_FILE); } +void choose_play_completed(void attribute((unused)) *v, + const char *error) { + if(error) + popup_protocol_error(0, error); +} + +static void choose_state_toggled + (GtkCellRendererToggle attribute((unused)) *cell_renderer, + gchar *path_str, + gpointer attribute((unused)) user_data) { + GtkTreeIter it[1]; + /* Identify the track */ + gboolean itv = + gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(choose_store), + it, + path_str); + if(!itv) + return; + struct choosedata *cd = choose_iter_to_data(it); + if(!cd) + return; + if(cd->type != CHOOSE_FILE) + return; + if(queued(cd->track)) + return; + disorder_eclient_play(client, xstrdup(cd->track), + choose_play_completed, 0); + +} + static void choose_row_expanded(GtkTreeView attribute((unused)) *treeview, GtkTreeIter *iter, GtkTreePath *path, @@ -296,6 +327,7 @@ GtkWidget *choose_widget(void) { G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_BOOLEAN, G_TYPE_POINTER); /* Create the view */ @@ -325,6 +357,7 @@ GtkWidget *choose_widget(void) { (char *)0); gtk_tree_view_column_set_resizable(c, TRUE); gtk_tree_view_column_set_reorderable(c, TRUE); + g_object_set(r, "xalign", (gfloat)1.0, (char *)0); gtk_tree_view_append_column(GTK_TREE_VIEW(choose_view), c); } { @@ -333,11 +366,13 @@ GtkWidget *choose_widget(void) { ("Queued", r, "active", STATE_COLUMN, + "visible", ISFILE_COLUMN, (char *)0); gtk_tree_view_column_set_resizable(c, TRUE); gtk_tree_view_column_set_reorderable(c, TRUE); gtk_tree_view_append_column(GTK_TREE_VIEW(choose_view), c); - /* TODO make checkbox clickable to queue the track */ + g_signal_connect(r, "toggled", + G_CALLBACK(choose_state_toggled), 0); } /* The selection should support multiple things being selected */ diff --git a/disobedience/choose.h b/disobedience/choose.h index 49c9b60..812d88a 100644 --- a/disobedience/choose.h +++ b/disobedience/choose.h @@ -37,6 +37,7 @@ enum { STATE_COLUMN, NAME_COLUMN, LENGTH_COLUMN, + ISFILE_COLUMN, CHOOSEDATA_COLUMN }; @@ -56,6 +57,8 @@ struct choosedata *choose_path_to_data(GtkTreePath *path); gboolean choose_button_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data); +void choose_play_completed(void attribute((unused)) *v, + const char *error); #endif /* CHOOSE_H */ -- [mdw]