ocarina: Add back Title / Artist / Album labels

Using GtkBuilder now...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-07-29 16:03:42 -04:00
parent 037577850f
commit ff0f4a2c66
4 changed files with 135 additions and 1 deletions

View File

@ -13,6 +13,9 @@ string lib_file(const string &);
/* window.cpp */
void init_window();
/* status.cpp */
void update_status();
namespace ocarina
{

View File

@ -77,6 +77,7 @@ string lib_file(const string &path)
static gboolean timeout_poll(gpointer data)
{
idle_add();
update_status();
/* ocarina::body::set_now_playing();
ocarina::body::update_controls();*/
return TRUE;

33
ocarina/status.cpp Normal file
View File

@ -0,0 +1,33 @@
// Copyright (c) 2012 Bryan Schumaker
#include <ocarina/ocarina.h>
#include <libsaria/track.h>
static libsaria::Track *current = NULL;
static void set_label(const string &name, const string &text, const string &size)
{
GtkWidget *label = get_widget(name);
if (label) {
char *escaped = g_markup_escape_text(text.c_str(), -1);
string markup = "<span size='" + size + "'>" + escaped + "</span>";
gtk_label_set_markup(GTK_LABEL(label), markup.c_str());
g_free(escaped);
}
}
static void refresh_widgets()
{
set_label("TitleLabel", current->get_title(), "xx-large");
set_label("ArtistLabel", current->get_artist(), "x-large");
set_label("AlbumLabel", current->get_album(), "x-large");
}
void update_status()
{
libsaria::Track *cur = libsaria::current_track();
if (cur == current)
return;
current = cur;
refresh_widgets();
}

View File

@ -1,13 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkWindow" id="MainWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="default_width">800</property>
<property name="default_height">600</property>
<child>
<placeholder/>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<object class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="TitleLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;span size='xx-large'&gt; &lt;/span&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="ArtistLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="label" translatable="yes">&lt;span size='x-large'&gt; &lt;/span&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="AlbumLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="label" translatable="yes">&lt;span size='x-large'&gt; &lt;/span&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</interface>