void queue_properties(struct queuelike *ql);
/* Pop up properties of selected items in some queue */
-void playing_update(void);
-/* Called whenever we think the currently playing track might have changed */
-
int queued(const char *track);
/* Return nonzero iff TRACK is queued or playing */
/** @brief Update everything */
void all_update(void) {
- playing_update();
queue_update();
recent_update();
volume_update();
/** @brief Called when the current track finishes playing */
static void log_completed(void attribute((unused)) *v,
const char attribute((unused)) *track) {
- playing = 0;
- playing_update();
}
/** @brief Called when the current track fails */
static void log_failed(void attribute((unused)) *v,
const char attribute((unused)) *track,
const char attribute((unused)) *status) {
- playing = 0;
- playing_update();
}
/** @brief Called when some track is moved within the queue */
static void log_playing(void attribute((unused)) *v,
const char attribute((unused)) *track,
const char attribute((unused)) *user) {
- playing = 1;
- playing_update();
- /* we get a log_removed() anyway so we don't need to update_queue() from
- * here */
}
/** @brief Called when a track is added to the queue */
static void log_scratched(void attribute((unused)) *v,
const char attribute((unused)) *track,
const char attribute((unused)) *user) {
- playing = 0;
- playing_update();
}
/** @brief Called when a state change occurs */
if(changes & m->mask)
m->callback(m->u);
}
- /* If the track is paused or resume then the currently playing track is
- * refetched so that we can continue to correctly calculate the played so-far
- * field */
- playing_update();
}
/** @brief Called when volume changes */
}
}
-/** @brief Add a monitor to the list */
+/** @brief Add a monitor to the list
+ * @param callback Function to call
+ * @param u User data to pass to @p callback
+ * @param mask Mask of flags that @p callback cares about
+ *
+ * Pass @p mask as -1UL to match all flags.
+ */
void register_monitor(monitor_callback *callback,
void *u,
unsigned long mask) {
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
+/** @file disobedience/queue.c
+ * @brief Queue widgets
+ *
+ * This file provides both the queue widget and the recently-played widget.
+ */
#include "disobedience.h"
{ 0, 0, 0, 0, 0 }
};
+/** @brief Called whenever @ref DISORDER_PLAYING or @ref DISORDER_TRACK_PAUSED changes
+ *
+ * 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"));
+ gtk_label_set_text(GTK_LABEL(report_label), "updating playing track");
+ disorder_eclient_playing(client, playing_completed, 0);
+}
+
+/** @brief Create the queue widget */
GtkWidget *queue_widget(void) {
D(("queue_widget"));
/* 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);
/* 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,
disorder_eclient_queue(client, queuelike_completed, cbd);
}
-void playing_update(void) {
- D(("playing_update"));
- gtk_label_set_text(GTK_LABEL(report_label), "updating playing track");
- disorder_eclient_playing(client, playing_completed, 0);
-}
-
/* Recently played tracks -------------------------------------------------- */
static struct queue_entry *fixup_recent(struct queue_entry *q) {