ocarina: Added volume button

This button will eventually be used to control the libsaria volume.  It
doesn't do anything useful yet.
This commit is contained in:
Bryan Schumaker 2011-09-02 08:26:44 -04:00
parent f49b5e1d6d
commit 6137ec8a83
3 changed files with 51 additions and 9 deletions

38
gui/buttons/volume.cpp Normal file
View File

@ -0,0 +1,38 @@
#include <libsaria/print.h>
#include <ocarina/button.h>
static void resize(GtkWidget *volume)
{
const gchar *icon = NULL;
GList *list = gtk_container_get_children(GTK_CONTAINER(volume));
gpointer ptr = g_list_nth_data(list, 0);
GtkWidget *image = (GtkWidget *)ptr;
gtk_image_get_icon_name(GTK_IMAGE(image), &icon, NULL);
gtk_image_set_from_icon_name(GTK_IMAGE(image),
icon,
GTK_ICON_SIZE_MENU);
}
static void set_increment(GtkWidget *volume, double incr)
{
GtkAdjustment *adj = gtk_scale_button_get_adjustment(
GTK_SCALE_BUTTON(volume));
gtk_adjustment_set_page_increment(adj, incr);
}
static void changed(GtkWidget *button, gdouble value, gpointer data)
{
resize(button);
}
GtkWidget *make_volume_button()
{
GtkWidget *volume = gtk_volume_button_new();
gtk_widget_show(volume);
set_increment(volume, 0.05);
resize(volume);
GTK_CONNECT(volume, "value-changed", changed, NULL);
return volume;
}

View File

@ -12,22 +12,25 @@ void ocarina_init(int argc, char **argv)
GtkWidget *play;
GtkWidget *pause;
GtkWidget *stop;
GtkWidget *volume;
GtkWidget *hbox;
window_init();
window_title("Ocarina " + vers_str());
window_icon("images/ocarina.png");
hbox = gtk_hbox_new(FALSE, 0);
open = make_open_button(GTK_ICON_SIZE_MENU);
play = make_play_button(GTK_ICON_SIZE_MENU);
pause = make_pause_button(GTK_ICON_SIZE_MENU);
stop = make_stop_button(GTK_ICON_SIZE_MENU);
hbox = gtk_hbox_new(FALSE, 0);
open = make_open_button(GTK_ICON_SIZE_MENU);
play = make_play_button(GTK_ICON_SIZE_MENU);
pause = make_pause_button(GTK_ICON_SIZE_MENU);
stop = make_stop_button(GTK_ICON_SIZE_MENU);
volume = make_volume_button();
box_pack_start(hbox, open, FALSE, FALSE, 0);
box_pack_start(hbox, play, FALSE, FALSE, 0);
box_pack_start(hbox, pause, FALSE, FALSE, 0);
box_pack_start(hbox, stop, FALSE, FALSE, 0);
box_pack_start(hbox, open, FALSE, FALSE, 0);
box_pack_start(hbox, play, FALSE, FALSE, 0);
box_pack_start(hbox, pause , FALSE, FALSE, 0);
box_pack_start(hbox, stop, FALSE, FALSE, 0);
box_pack_start(hbox, volume, FALSE, FALSE, 0);
gtk_widget_show(hbox);
window_add(hbox);
}

View File

@ -15,6 +15,7 @@ GtkWidget *make_play_button(GtkIconSize);
GtkWidget *make_pause_button(GtkIconSize);
GtkWidget *make_stop_button(GtkIconSize);
GtkWidget *make_open_button(GtkIconSize);
GtkWidget *make_volume_button();
enum button_list_t {
PLAY_BUTTON_LIST,