/** @brief Main tab group */
GtkWidget *tabs;
+/** @brief Mini-mode widget for playing track */
+GtkWidget *playing_mini;
+
/** @brief Main client */
disorder_eclient *client;
static GtkWidget *notebook_box;
-static int main_current_fullmode = 1;
-
static void check_rtp_address(const char *event,
void *eventdata,
void *callbackdata);
static void main_minimode(const char attribute((unused)) *event,
void attribute((unused)) *evendata,
void attribute((unused)) *callbackdata) {
- if(full_mode == main_current_fullmode)
- return;
if(full_mode) {
- /* Remove queue from display */
- g_object_ref(queue);
- gtk_container_remove(GTK_CONTAINER(notebook_box), queue);
- /* Add queue to notebook */
- gtk_notebook_prepend_page(GTK_NOTEBOOK(tabs), queue,
- gtk_label_new("Queue"));
- g_object_unref(queue);
- /* Add notebook to display */
- gtk_container_add(GTK_CONTAINER(notebook_box), tabs);
- g_object_unref(tabs);
+ gtk_widget_show(tabs);
+ gtk_widget_hide(playing_mini);
/* Show the queue (bit confusing otherwise!) */
gtk_notebook_set_current_page(GTK_NOTEBOOK(tabs), 0);
} else {
- /* Remove notebook from display */
- g_object_ref(tabs);
- gtk_container_remove(GTK_CONTAINER(notebook_box), tabs);
- /* Remove queue from notebook */
- g_object_ref(queue);
- gtk_container_remove(GTK_CONTAINER(tabs), queue);
- /* Add queue to display */
- gtk_container_add(GTK_CONTAINER(notebook_box), queue);
- g_object_unref(queue);
+ gtk_widget_hide(tabs);
+ gtk_widget_show(playing_mini);
}
- main_current_fullmode = full_mode;
}
/** @brief Create and populate the main window */
FALSE, /* expand */
FALSE, /* fill */
0);
+ playing_mini = playing_widget();
+ gtk_box_pack_start(GTK_BOX(vbox),
+ playing_mini,
+ FALSE,
+ FALSE,
+ 0);
notebook_box = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(notebook_box), notebook());
gtk_container_add(GTK_CONTAINER(vbox), notebook_box);
/* reset styles now everything has its name */
gtk_rc_reset_styles(gtk_settings_get_for_screen(gdk_screen_get_default()));
gtk_widget_show_all(toplevel);
+ gtk_widget_hide(playing_mini);
/* issue a NOP every so often */
g_timeout_add_full(G_PRIORITY_LOW,
2000/*interval, ms*/,
break;
if(q) {
disorder_eclient_playing(client, playing_completed, 0);
- if(full_mode)
- disorder_eclient_queue(client, queue_completed, 0);
+ disorder_eclient_queue(client, queue_completed, 0);
return;
}
}
ql_new_queue(&ql_queue, q);
/* Tell anyone who cares */
event_raise("queue-list-changed", q);
- event_raise("playing-track-changed", q);
+ event_raise("playing-track-changed", playing_track);
}
/** @brief Update the queue itself */
popup_protocol_error(0, err);
return;
}
- if(full_mode)
- actual_queue = q;
- else
- actual_queue = NULL;
+ actual_queue = q;
queue_playing_changed();
}
void attribute((unused)) *eventdata,
void attribute((unused)) *callbackdata) {
D(("queue_changed"));
- if(!full_mode)
- return;
gtk_label_set_text(GTK_LABEL(report_label), "updating queue");
disorder_eclient_queue(client, queue_completed, 0);
}
static void queue_init(struct queuelike attribute((unused)) *ql) {
/* Arrange a callback whenever the playing state changes */
event_register("playing-changed", playing_changed, 0);
+ event_register("playing-started", playing_changed, 0);
/* We reget both playing track and queue at pause/resume so that start times
* can be computed correctly */
event_register("pause-changed", playing_changed, 0);
return FALSE; /* Propagate */
}
-static void queue_minimode(const char attribute((unused)) *event,
- void attribute((unused)) *evendata,
- void attribute((unused)) *callbackdata) {
- if(full_mode) {
- /* We will need to refetch the queue */
- disorder_eclient_queue(client, queue_completed, 0);
- } else {
- /* We will need to hide the queue */
- if(actual_queue)
- queue_completed(NULL, NULL, NULL);
- }
-}
-
GtkWidget *queue_widget(void) {
GtkWidget *const w = init_queuelike(&ql_queue);
/* Catch keypresses */
g_signal_connect(ql_queue.view, "key-press-event",
G_CALLBACK(queue_key_press), &ql_queue);
-
- event_register("mini-mode-changed", queue_minimode, 0);
return w;
}
return 0;
}
+/* Playing widget for mini-mode */
+
+static void queue_set_playing_widget(const char attribute((unused)) *event,
+ void attribute((unused)) *eventdata,
+ void *callbackdata) {
+ GtkLabel *w = callbackdata;
+
+ if(playing_track) {
+ const char *artist = namepart(playing_track->track, "display", "artist");
+ const char *album = namepart(playing_track->track, "display", "album");
+ const char *title = namepart(playing_track->track, "display", "title");
+ const char *ldata = column_length(playing_track, NULL);
+ if(!ldata)
+ ldata = "";
+ char *text;
+ byte_xasprintf(&text, "%s/%s/%s %s", artist, album, title, ldata);
+ gtk_label_set_text(w, text);
+ } else
+ gtk_label_set_text(w, "");
+}
+
+GtkWidget *playing_widget(void) {
+ GtkWidget *w = gtk_label_new("");
+ gtk_misc_set_alignment(GTK_MISC(w), 1.0, 0);
+ /* Spot changes to the playing track */
+ event_register("playing-track-changed",
+ queue_set_playing_widget,
+ w);
+ /* Use the best-known name for it */
+ event_register("lookups-complete",
+ queue_set_playing_widget,
+ w);
+ /* Keep the amount played so far up to date */
+ event_register("periodic-fast",
+ queue_set_playing_widget,
+ w);
+ return frame_widget(w, NULL);
+}
+
/*
Local Variables:
c-basic-offset:2