ocarina: Added a "now playing" panel
This is just an initial implementation, so it's not very good right now. It does give all the information, though. That's a plus. I also set the artist / album / playlist whenever a SONG_LOADED callback is given.
This commit is contained in:
parent
9d22d6b278
commit
fc4f311971
|
@ -1,10 +1,12 @@
|
|||
|
||||
#include <libsaria/libsaria.h>
|
||||
#include <libsaria/callback.h>
|
||||
#include <libsaria/print.h>
|
||||
#include <ocarina/ocarina.h>
|
||||
#include <ocarina/button.h>
|
||||
#include <ocarina/library.h>
|
||||
#include <ocarina/settings.h>
|
||||
#include <ocarina/footer.h>
|
||||
|
||||
void cb_play()
|
||||
{
|
||||
|
@ -33,6 +35,12 @@ void cb_library_refresh()
|
|||
library_settings_refresh();
|
||||
}
|
||||
|
||||
void cb_track_loaded()
|
||||
{
|
||||
println("Ocarina TRACK_LOADED callback!");
|
||||
libsaria::current_track(set_footer_track);
|
||||
}
|
||||
|
||||
void setup_callbacks()
|
||||
{
|
||||
println("Ocarina setting up callbacks");
|
||||
|
@ -40,4 +48,5 @@ void setup_callbacks()
|
|||
register_callback(PAUSE, cb_pause);
|
||||
register_callback(IDLE_TASK_QUEUED, cb_idle_task_queued);
|
||||
register_callback(LIBRARY_REFRESH, cb_library_refresh);
|
||||
register_callback(TRACK_LOADED, cb_track_loaded);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
#include <ocarina/footer.h>
|
||||
#include <libsaria/track.h>
|
||||
#include "footer.h"
|
||||
|
||||
static GtkWidget *footer = NULL;
|
||||
|
@ -17,8 +16,9 @@ static void make_footer()
|
|||
* this point, and then add the controls
|
||||
*/
|
||||
gtk_widget_show_all(footer);
|
||||
box_pack_start(footer, sep, FALSE, FALSE, 0);
|
||||
box_pack_start(footer, get_controls(), FALSE, FALSE, 0);
|
||||
box_pack_start(footer, sep, FALSE, FALSE, 0);
|
||||
box_pack_start(footer, get_controls(), FALSE, FALSE, 0);
|
||||
box_pack_start(footer, get_nowplaying(), FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
GtkWidget *get_footer()
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
#define OCARINA_FOOTER_PRIVATE_H
|
||||
|
||||
GtkWidget *get_controls();
|
||||
GtkWidget *get_nowplaying();
|
||||
|
||||
#endif /* OCARINA_FOOTER_PRIVATE_H */
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
#include <libsaria/track.h>
|
||||
#include <ocarina/gtk.h>
|
||||
#include "footer.h"
|
||||
|
||||
static GtkWidget *now_playing = NULL;
|
||||
static GtkWidget *title = NULL;
|
||||
static GtkWidget *artist = NULL;
|
||||
static GtkWidget *album = NULL;
|
||||
|
||||
static void make_nowplaying()
|
||||
{
|
||||
GtkWidget *tag_box = gtk_vbox_new(FALSE, 0);
|
||||
now_playing = gtk_hbox_new(FALSE, 0);
|
||||
|
||||
title = gtk_label_new("");
|
||||
artist = gtk_label_new("");
|
||||
album = gtk_label_new("");
|
||||
|
||||
box_pack_start(tag_box, title, FALSE, FALSE, 0);
|
||||
box_pack_start(tag_box, artist, FALSE, FALSE, 0);
|
||||
box_pack_start(tag_box, album, FALSE, FALSE, 0);
|
||||
|
||||
box_pack_start(now_playing, tag_box, FALSE, FALSE, 0);
|
||||
gtk_widget_show_all(now_playing);
|
||||
}
|
||||
|
||||
GtkWidget *get_nowplaying()
|
||||
{
|
||||
if (now_playing == NULL)
|
||||
make_nowplaying();
|
||||
return now_playing;
|
||||
}
|
||||
|
||||
static void change_label(GtkWidget *label, string prefix, string text)
|
||||
{
|
||||
if (text != "")
|
||||
gtk_label_set_text(GTK_LABEL(label), (prefix + text).c_str());
|
||||
else
|
||||
gtk_label_set_text(GTK_LABEL(label), "");
|
||||
}
|
||||
|
||||
void set_footer_track(Track &track)
|
||||
{
|
||||
change_label(title , "", track.get_title());
|
||||
change_label(artist, "by ", track.get_artist());
|
||||
change_label(album, "from ", track.get_album());
|
||||
}
|
Loading…
Reference in New Issue