const struct queue_entry *q,
const char *data);
static int draggable_row(const struct queue_entry *q);
+static void recent_changed(const char *event,
+ void *eventdata,
+ void *callbackdata);
+static void added_changed(const char *event,
+ void *eventdata,
+ void *callbackdata);
+static void queue_changed(const char *event,
+ void *eventdata,
+ void *callbackdata);
static const struct tabtype tabtype_queue; /* forward */
* We monitor pause/resume as well as whether the track is playing in order to
* keep the time played so far up to date correctly. See playing_completed().
*/
-static void playing_update(void attribute((unused)) *v) {
- D(("playing_update"));
+static void playing_changed(const char attribute((unused)) *event,
+ void attribute((unused)) *evendata,
+ void attribute((unused)) *callbackdata) {
+ D(("playing_changed"));
gtk_label_set_text(GTK_LABEL(report_label), "updating playing track");
disorder_eclient_playing(client, playing_completed, 0);
}
/* Arrange periodic update of the so-far played field */
g_timeout_add(1000/*ms*/, adjust_sofar, 0);
/* Arrange a callback whenever the playing state changes */
- register_monitor(playing_update, 0, DISORDER_PLAYING|DISORDER_TRACK_PAUSED);
- register_reset(queue_update);
+ event_register("playing-changed", playing_changed, 0);
+ event_register("pause-changed", playing_changed, 0);
+ event_register("queue-changed", queue_changed, 0);
/* We pass choose_update() as our notify function since the choose screen
* marks tracks that are playing/in the queue. */
return queuelike(&ql_queue, fixup_queue, choose_update, queue_menu,
* Called when a track is added to the queue, removed from the queue (by user
* cmmand or because it is to be played) or moved within the queue
*/
-void queue_update(void) {
- D(("queue_update"));
+void queue_changed(const char attribute((unused)) *event,
+ void attribute((unused)) *eventdata,
+ void attribute((unused)) *callbackdata) {
+ D(("queue_changed"));
gtk_label_set_text(GTK_LABEL(report_label), "updating queue");
disorder_eclient_queue(client, queuelike_completed, &ql_queue);
}
/** @brief Create the recently-played list */
GtkWidget *recent_widget(void) {
D(("recent_widget"));
- register_reset(recent_update);
+ event_register("recent-changed",
+ recent_changed,
+ 0);
return queuelike(&ql_recent, fixup_recent, 0, recent_menu,
maincolumns, NMAINCOLUMNS);
}
*
* Called whenever a track is added to it or removed from it.
*/
-void recent_update(void) {
- D(("recent_update"));
+static void recent_changed(const char attribute((unused)) *event,
+ void attribute((unused)) *eventdata,
+ void attribute((unused)) *callbackdata) {
+ D(("recent_changed"));
gtk_label_set_text(GTK_LABEL(report_label), "updating recently played list");
disorder_eclient_recent(client, queuelike_completed, &ql_recent);
}
/** @brief Create the newly-added list */
GtkWidget *added_widget(void) {
D(("added_widget"));
- register_reset(added_update);
+ event_register("added-changed", added_changed, 0);
return queuelike(&ql_added, 0/*fixup*/, 0/*notify*/, added_menu,
addedcolumns, NADDEDCOLUMNS);
}
* disobedience/queue.c requires @ref queue_entry structures with a valid and
* unique @c id field. This function fakes it.
*/
-static void new_completed(void attribute((unused)) *v, int nvec, char **vec) {
- struct queue_entry *q, *qh, *qlast = 0, **qq = &qh;
- int n;
-
- for(n = 0; n < nvec; ++n) {
- q = xmalloc(sizeof *q);
- q->prev = qlast;
- q->track = vec[n];
- q->id = vec[n];
- *qq = q;
- qq = &q->next;
- qlast = q;
+static void new_completed(void *v,
+ const char *error,
+ int nvec, char **vec) {
+ if(error)
+ popup_protocol_error(0, error);
+ else {
+ struct queuelist *ql = v;
+ /* Convert the vector result to a queue linked list */
+ struct queue_entry *q, *qh, *qlast = 0, **qq = &qh;
+ int n;
+
+ for(n = 0; n < nvec; ++n) {
+ q = xmalloc(sizeof *q);
+ q->prev = qlast;
+ q->track = vec[n];
+ q->id = vec[n];
+ *qq = q;
+ qq = &q->next;
+ qlast = q;
+ }
+ *qq = 0;
+ queuelike_completed(ql, 0, qh);
}
- *qq = 0;
- queuelike_completed(&ql_added, 0, qh);
}
/** @brief Update the newly-added list */
-void added_update(void) {
- struct callbackdata *cbd;
- D(("added_update"));
+static void added_changed(const char attribute((unused)) *event,
+ void attribute((unused)) *eventdata,
+ void attribute((unused)) *callbackdata) {
+ D(("added_changed"));
- cbd = xmalloc(sizeof *cbd);
- cbd->onerror = 0;
- cbd->u.ql = &ql_added;
gtk_label_set_text(GTK_LABEL(report_label),
"updating newly added track list");
- disorder_eclient_new_tracks(client, new_completed, 0/*all*/, cbd);
+ disorder_eclient_new_tracks(client, new_completed, 0/*all*/, &ql_added);
}
/* Main menu plumbing ------------------------------------------------------ */