summaryrefslogtreecommitdiff
path: root/src/gtkvumeter.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtkvumeter.c')
-rw-r--r--src/gtkvumeter.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/gtkvumeter.c b/src/gtkvumeter.c
index d57cc62..34a2038 100644
--- a/src/gtkvumeter.c
+++ b/src/gtkvumeter.c
@@ -1,3 +1,11 @@
+/*
+ Adapted From GtkVuMeter by Todd Goyen
+ Copyright 2003 Todd Goyen
+ wettoad@knighthoodofbuh.or
+
+ Improved rendering performance (no individual drawline calls)
+
+*/
#include <string.h>
#include "gtkvumeter.h"
@@ -18,10 +26,12 @@ static void free_drawbuf(guchar *pixels, gpointer data);
static void gtk_vu_meter_size_request (GtkWidget *widget, GtkRequisition *requisition);
static void gtk_vu_meter_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
static gint gtk_vu_meter_sound_level_to_draw_level (GtkVuMeter *vumeter);
+static void gtk_vu_meter_realize (GtkWidget *widget);
static void gtk_vu_meter_class_init (GtkVuMeterClass *class) {
GtkWidgetClass *widget_class;
widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->realize = gtk_vu_meter_realize;
widget_class->expose_event = gtk_vu_meter_expose;
widget_class->size_request = gtk_vu_meter_size_request;
widget_class->size_allocate = gtk_vu_meter_size_allocate;
@@ -33,6 +43,38 @@ static void gtk_vu_meter_init (GtkVuMeter *vumeter) {
gtk_vu_meter_setup_colors(vumeter);
}
+static void gtk_vu_meter_realize (GtkWidget *widget)
+{
+ GtkVuMeter *vumeter;
+ GdkWindowAttr attributes;
+ gint attributes_mask;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (GTK_IS_VU_METER (widget));
+
+ GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+ vumeter = GTK_VU_METER (widget);
+
+ attributes.x = widget->allocation.x;
+ attributes.y = widget->allocation.y;
+ attributes.width = widget->allocation.width;
+ attributes.height = widget->allocation.height;
+ attributes.wclass = GDK_INPUT_OUTPUT;
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
+ attributes.visual = gtk_widget_get_visual (widget);
+ attributes.colormap = gtk_widget_get_colormap (widget);
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+ widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask);
+
+ widget->style = gtk_style_attach (widget->style, widget->window);
+
+ gdk_window_set_user_data (widget->window, widget);
+ gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+
+ gtk_vu_meter_setup_colors (vumeter);
+}
+
void gtk_vu_meter_set_gradient (GtkVuMeter *vumeter, gint f_gradient_key_count, GdkColor *f_gradient_keys, gint b_gradient_key_count, GdkColor *b_gradient_keys) {
//XXX : memdup is a bad idea ?
GdkColor *fgk = g_memdup(f_gradient_keys, f_gradient_key_count*sizeof(GdkColor));