ocarina/gui/buttons/volume.cpp

41 lines
1019 B
C++

#include <libsaria/libsaria.h>
#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)
{
libsaria_get()->set_volume(value);
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;
}