summaryrefslogtreecommitdiff
path: root/callbacks.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2009-08-11 21:15:29 +0200
committerGravatar waker <wakeroid@gmail.com>2009-08-11 21:15:29 +0200
commitcde6b46df8e0e8d462e1f361a1b929ebe295a1f7 (patch)
treecc37417edede97bd808f985aaf8ca0fbbbb3a047 /callbacks.c
parenteab6142e7233f7c79287fe62de41d3f91cc57b9f (diff)
new volumebar widget
Diffstat (limited to 'callbacks.c')
-rw-r--r--callbacks.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/callbacks.c b/callbacks.c
index f96aaff0..4299bdcc 100644
--- a/callbacks.c
+++ b/callbacks.c
@@ -933,3 +933,99 @@ on_seekbar_button_release_event (GtkWidget *widget,
}
+
+
+gboolean
+on_volumebar_configure_event (GtkWidget *widget,
+ GdkEventConfigure *event,
+ gpointer user_data)
+{
+
+ return FALSE;
+}
+
+
+void
+volumebar_draw (GtkWidget *widget) {
+ if (!widget) {
+ return;
+ }
+ cairo_t *cr;
+ cr = gdk_cairo_create (widget->window);
+ if (!cr) {
+ return;
+ }
+
+ int n = widget->allocation.width / 4;
+ int vol = p_get_volume () * n;
+ int h = 16;
+ for (int i = 0; i < n; i++) {
+ if (i <= vol) {
+ cairo_set_source_rgb (cr, 0xf4/255.f, 0x7e/255.f, 0x46/255.f);
+ }
+ else {
+ cairo_set_source_rgb (cr, 0x21/255.f, 0x23/255.f, 0x1f/255.f);
+ }
+ cairo_rectangle (cr, i * 4, (widget->allocation.height/2-h/2) + h - 1 - (h* i / n), 3, h * i / n);
+ cairo_fill (cr);
+ }
+
+ cairo_destroy (cr);
+}
+
+gboolean
+on_volumebar_expose_event (GtkWidget *widget,
+ GdkEventExpose *event,
+ gpointer user_data)
+{
+ volumebar_draw (widget);
+ return FALSE;
+}
+
+
+gboolean
+on_volumebar_motion_notify_event (GtkWidget *widget,
+ GdkEventMotion *event,
+ gpointer user_data)
+{
+ if (event->state & GDK_BUTTON1_MASK) {
+ float volume = event->x / widget->allocation.width;
+ if (volume < 0) {
+ volume = 0;
+ }
+ if (volume > 1) {
+ volume = 1;
+ }
+ p_set_volume (volume);
+ volumebar_draw (widget);
+ }
+ return FALSE;
+}
+
+gboolean
+on_volumebar_button_press_event (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ float volume = event->x / widget->allocation.width;
+ if (volume < 0) {
+ volume = 0;
+ }
+ if (volume > 1) {
+ volume = 1;
+ }
+ p_set_volume (volume);
+ volumebar_draw (widget);
+ return FALSE;
+}
+
+
+gboolean
+on_volumebar_button_release_event (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+
+ return FALSE;
+}
+