changeset 3054:34f37c59e87b

replace svis with UiSVis
author Tomasz Mon <desowin@gmail.com>
date Fri, 13 Jul 2007 11:40:00 +0200
parents 712b3d476e06
children 3a754f73c8f9
files src/audacious/Makefile src/audacious/playback.c src/audacious/ui_main.c src/audacious/ui_main.h src/audacious/ui_svis.c src/audacious/ui_svis.h src/audacious/visualization.c src/audacious/widgets/Makefile src/audacious/widgets/widgetcore.h
diffstat 9 files changed, 650 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/Makefile	Fri Jul 13 09:47:21 2007 +0200
+++ b/src/audacious/Makefile	Fri Jul 13 11:40:00 2007 +0200
@@ -113,6 +113,7 @@
 	ui_skinned_number.c \
 	ui_skinned_horizontal_slider.c \
 	ui_vis.c \
+	ui_svis.c \
 	ui_skinselector.c \
 	ui_urlopener.c \
 	util.c \
--- a/src/audacious/playback.c	Fri Jul 13 09:47:21 2007 +0200
+++ b/src/audacious/playback.c	Fri Jul 13 11:40:00 2007 +0200
@@ -84,7 +84,7 @@
         playback_stop();
 
     ui_vis_clear_data(mainwin_vis);
-    svis_clear_data(mainwin_svis);
+    ui_svis_clear_data(mainwin_svis);
     mainwin_disable_seekbar();
 
     entry = playlist_get_entry_to_play(playlist);
--- a/src/audacious/ui_main.c	Fri Jul 13 09:47:21 2007 +0200
+++ b/src/audacious/ui_main.c	Fri Jul 13 11:40:00 2007 +0200
@@ -148,7 +148,7 @@
 static gboolean setting_volume = FALSE;
 
 GtkWidget *mainwin_vis;
-SVis *mainwin_svis;
+GtkWidget *mainwin_svis;
 
 GtkWidget *mainwin_sposition = NULL;
 
@@ -269,8 +269,12 @@
         dock_shade(dock_window_list, GTK_WINDOW(mainwin),
                    MAINWIN_SHADED_HEIGHT * (cfg.doublesize + 1));
 
-        widget_show(WIDGET(mainwin_svis));
-        ui_vis_clear_data(mainwin_vis);
+        gtk_widget_show(mainwin_svis);
+        ui_svis_clear_data(mainwin_svis);
+        if (cfg.vis_type != VIS_OFF)
+            ui_svis_set_visible(mainwin_svis, TRUE);
+        else
+            ui_svis_set_visible(mainwin_svis, FALSE);
 
         gtk_widget_show(mainwin_srew);
         gtk_widget_show(mainwin_splay);
@@ -300,8 +304,14 @@
 
         dock_shade(dock_window_list, GTK_WINDOW(mainwin), height * (cfg.doublesize + 1));
 
-        widget_hide(WIDGET(mainwin_svis));
-        svis_clear_data(mainwin_svis);
+        gtk_widget_hide(mainwin_svis);
+        ui_svis_clear_data(mainwin_svis);
+
+        gtk_widget_show(mainwin_vis);
+        if (cfg.vis_type != VIS_OFF)
+            ui_vis_set_visible(mainwin_vis, TRUE);
+        else
+            ui_vis_set_visible(mainwin_vis, FALSE);
 
         gtk_widget_hide(mainwin_srew);
         gtk_widget_hide(mainwin_splay);
@@ -395,16 +405,26 @@
     cfg.vis_type = mode;
 
     if (mode == VIS_OFF) {
-        if (cfg.player_shaded && cfg.player_visible)
-            svis_clear(mainwin_svis);
-        else {
+        if (cfg.player_shaded) {
+            ui_svis_set_visible(mainwin_svis, FALSE);
+            ui_vis_set_visible(mainwin_vis, TRUE);
+        } else {
+            ui_svis_set_visible(mainwin_svis, TRUE);
             ui_vis_set_visible(mainwin_vis, FALSE);
         }
     }
     if (mode == VIS_ANALYZER || mode == VIS_SCOPE || mode == VIS_VOICEPRINT) {
-        ui_vis_clear_data(mainwin_vis);
-        ui_vis_set_visible(mainwin_vis, TRUE);
-        svis_clear_data(mainwin_svis);
+        if (cfg.player_shaded) {
+            ui_svis_clear_data(mainwin_svis);
+            ui_svis_set_visible(mainwin_svis, TRUE);
+            ui_vis_clear_data(mainwin_vis);
+            ui_vis_set_visible(mainwin_vis, FALSE);
+        } else {
+            ui_svis_clear_data(mainwin_svis);
+            ui_svis_set_visible(mainwin_svis, FALSE);
+            ui_vis_clear_data(mainwin_vis);
+            ui_vis_set_visible(mainwin_vis, TRUE);
+        }
     }
 }
 
@@ -969,6 +989,7 @@
 
     playlistwin_hide_timer();
     ui_vis_clear_data(mainwin_vis);
+    ui_svis_clear_data(mainwin_svis);
     draw_main_window(TRUE);
 }
 
@@ -1114,18 +1135,8 @@
         draw_main_window(FALSE);
     }
 
-    if ((event->button == 1) && event->type != GDK_2BUTTON_PRESS &&
-         widget_contains(WIDGET(mainwin_svis), event->x, event->y) ) {
-         /* it'll get sorted out when svis will become UiSvis */
-    }
-
     if (event->button == 3) {
-            if (widget_contains(WIDGET(mainwin_svis), event->x, event->y)) {
-            ui_manager_popup_menu_show(GTK_MENU(mainwin_visualization_menu), event->x_root,
-                                    event->y_root, 3, event->time);
-            grab = FALSE;
-        }
-        else if ( (event->y > 70) && (event->x < 128) )
+        if ( (event->y > 70) && (event->x < 128) )
         {
 
             ui_manager_popup_menu_show(GTK_MENU(mainwin_playback_menu),
@@ -1964,7 +1975,7 @@
     check_set( toggleaction_group_others , "show player", FALSE);
 
     if (cfg.player_shaded)
-        svis_clear_data(mainwin_svis);
+        ui_svis_clear_data(mainwin_svis);
 
     if (!cfg.show_wm_decorations) {
         nullmask = gdk_pixmap_new(mainwin->window, 20, 20, 1);
@@ -2850,7 +2861,8 @@
 
     mainwin_vis = ui_vis_new(SKINNED_WINDOW(mainwin)->fixed, 24, 43, 76);
     g_signal_connect(mainwin_vis, "button-press-event", G_CALLBACK(mainwin_vis_cb), NULL);
-    mainwin_svis = create_svis(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 79, 5);
+    mainwin_svis = ui_svis_new(SKINNED_WINDOW(mainwin)->fixed, 79, 5);
+    g_signal_connect(mainwin_svis, "button-press-event", G_CALLBACK(mainwin_vis_cb), NULL);
 
     mainwin_position = ui_skinned_horizontal_slider_new(SKINNED_WINDOW(mainwin)->fixed, 16, 72, 248,
                                                         10, 248, 0, 278, 0, 29, 10, 10, 0, 0, 219,
@@ -2885,8 +2897,6 @@
 
     ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_monostereo));
     ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_playstatus));
-
-    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_svis));
 }
 
 static void
@@ -2965,6 +2975,7 @@
         gtk_widget_hide(mainwin_seject);
         gtk_widget_hide(mainwin_stime_min);
         gtk_widget_hide(mainwin_stime_sec);
+        gtk_widget_hide(mainwin_svis);
     }
 
     gtk_widget_hide(mainwin_minus_num);
--- a/src/audacious/ui_main.h	Fri Jul 13 09:47:21 2007 +0200
+++ b/src/audacious/ui_main.h	Fri Jul 13 11:40:00 2007 +0200
@@ -25,6 +25,7 @@
 
 #include "widgets/widgetcore.h"
 #include "ui_vis.h"
+#include "ui_svis.h"
 
 /* yes, main window size is fixed */
 #define MAINWIN_WIDTH            (gint)275
@@ -106,7 +107,7 @@
 extern GtkWidget *mainwin_stime_min, *mainwin_stime_sec;
 
 extern GtkWidget *mainwin_vis;
-extern SVis *mainwin_svis;
+extern GtkWidget *mainwin_svis;
 
 extern PlayStatus *mainwin_playstatus;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/ui_svis.c	Fri Jul 13 11:40:00 2007 +0200
@@ -0,0 +1,543 @@
+/*
+ * Audacious - a cross-platform multimedia player
+ * Copyright (c) 2007  Audacious development team.
+ *
+ * Based on:
+ * BMP - Cross-platform multimedia player
+ * Copyright (C) 2003-2004  BMP development team.
+ * XMMS:
+ * Copyright (C) 1998-2003  XMMS development team.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; under version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "widgets/widgetcore.h"
+#include "ui_svis.h"
+#include "ui_vis.h"
+#include "main.h"
+#include "util.h"
+#include "strings.h"
+#include "playback.h"
+#include <string.h>
+#include <ctype.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkmarshal.h>
+#include <gtk/gtkimage.h>
+
+#define UI_TYPE_SVIS           (ui_svis_get_type())
+
+static gint svis_redraw_delays[] = { 1, 2, 4, 8 };
+
+/* FIXME: Are the svis_scope_colors correct? */
+static guint8 svis_scope_colors[] = { 20, 19, 18, 19, 20 };
+static guint8 svis_vu_normal_colors[] = { 17, 17, 17, 12, 12, 12, 2, 2 };
+
+#define DRAW_DS_PIXEL(ptr,value) \
+	*(ptr) = (value); \
+	*((ptr) + 1) = (value); \
+	*((ptr) + 76) = (value); \
+	*((ptr) + 77) = (value);
+
+#define SVIS_HEIGHT 5
+#define SVIS_WIDTH 38
+
+enum {
+    DOUBLED,
+    LAST_SIGNAL
+};
+
+static void ui_svis_class_init         (UiSVisClass *klass);
+static void ui_svis_init               (UiSVis *svis);
+static void ui_svis_destroy            (GtkObject *object);
+static void ui_svis_realize            (GtkWidget *widget);
+static void ui_svis_unrealize          (GtkWidget *widget);
+static void ui_svis_map                (GtkWidget *widget);
+static void ui_svis_unmap              (GtkWidget *widget);
+static void ui_svis_size_request       (GtkWidget *widget, GtkRequisition *requisition);
+static void ui_svis_size_allocate      (GtkWidget *widget, GtkAllocation *allocation);
+static gboolean ui_svis_expose         (GtkWidget *widget, GdkEventExpose *event);
+static void ui_svis_toggle_doublesize  (UiSVis *svis);
+
+static GtkWidgetClass *parent_class = NULL;
+static guint vis_signals[LAST_SIGNAL] = { 0 };
+
+GType ui_svis_get_type() {
+    static GType vis_type = 0;
+    if (!vis_type) {
+        static const GTypeInfo vis_info = {
+            sizeof (UiSVisClass),
+            NULL,
+            NULL,
+            (GClassInitFunc) ui_svis_class_init,
+            NULL,
+            NULL,
+            sizeof (UiSVis),
+            0,
+            (GInstanceInitFunc) ui_svis_init,
+        };
+        vis_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSVis", &vis_info, 0);
+    }
+
+    return vis_type;
+}
+
+static void ui_svis_class_init(UiSVisClass *klass) {
+    GtkObjectClass *object_class;
+    GtkWidgetClass *widget_class;
+
+    object_class = (GtkObjectClass*) klass;
+    widget_class = (GtkWidgetClass*) klass;
+    parent_class = gtk_type_class (gtk_widget_get_type ());
+
+    object_class->destroy = ui_svis_destroy;
+
+    widget_class->realize = ui_svis_realize;
+    widget_class->unrealize = ui_svis_unrealize;
+    widget_class->map = ui_svis_map;
+    widget_class->unmap = ui_svis_unmap;
+    widget_class->expose_event = ui_svis_expose;
+    widget_class->size_request = ui_svis_size_request;
+    widget_class->size_allocate = ui_svis_size_allocate;
+
+    klass->doubled = ui_svis_toggle_doublesize;
+
+    vis_signals[DOUBLED] = 
+        g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+                      G_STRUCT_OFFSET (UiSVisClass, doubled), NULL, NULL,
+                      gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
+}
+
+static void ui_svis_init(UiSVis *svis) {
+
+}
+
+GtkWidget* ui_svis_new(GtkWidget *fixed, gint x, gint y) {
+    UiSVis *svis = g_object_new (ui_svis_get_type (), NULL);
+
+    svis->x = x;
+    svis->y = y;
+
+    svis->width = SVIS_WIDTH;
+    svis->height = SVIS_HEIGHT;
+
+    svis->fixed = fixed;
+    svis->double_size = FALSE;
+
+    svis->visible_window = TRUE;
+    svis->event_window = NULL;
+
+    gtk_fixed_put(GTK_FIXED(svis->fixed), GTK_WIDGET(svis), svis->x, svis->y);
+
+    return GTK_WIDGET(svis);
+}
+
+static void ui_svis_destroy(GtkObject *object) {
+    UiSVis *svis;
+
+    g_return_if_fail (object != NULL);
+    g_return_if_fail (UI_IS_SVIS (object));
+
+    svis = UI_SVIS (object);
+
+    if (GTK_OBJECT_CLASS (parent_class)->destroy)
+        (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+static void ui_svis_realize(GtkWidget *widget) {
+    UiSVis *svis;
+    GdkWindowAttr attributes;
+    gint attributes_mask;
+
+    g_return_if_fail (widget != NULL);
+    g_return_if_fail (UI_IS_SVIS(widget));
+
+    GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
+    svis = UI_SVIS(widget);
+
+    attributes.x = widget->allocation.x;
+    attributes.y = widget->allocation.y;
+    attributes.width = widget->allocation.width;
+    attributes.height = widget->allocation.height;
+    attributes.window_type = GDK_WINDOW_CHILD;
+    attributes.event_mask = gtk_widget_get_events(widget);
+    attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK;
+
+    if (svis->visible_window)
+    {
+      attributes.visual = gtk_widget_get_visual(widget);
+      attributes.colormap = gtk_widget_get_colormap(widget);
+      attributes.wclass = GDK_INPUT_OUTPUT;
+      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);
+      GTK_WIDGET_UNSET_FLAGS(widget, GTK_NO_WINDOW);
+      gdk_window_set_user_data(widget->window, widget);
+    }
+    else
+    {
+      widget->window = gtk_widget_get_parent_window (widget);
+      g_object_ref (widget->window);
+
+      attributes.wclass = GDK_INPUT_ONLY;
+      attributes_mask = GDK_WA_X | GDK_WA_Y;
+      svis->event_window = gdk_window_new (widget->window, &attributes, attributes_mask);
+      GTK_WIDGET_SET_FLAGS (widget, GTK_NO_WINDOW);
+      gdk_window_set_user_data(svis->event_window, widget);
+    }
+
+    widget->style = gtk_style_attach(widget->style, widget->window);
+}
+
+static void ui_svis_unrealize(GtkWidget *widget) {
+    UiSVis *svis;
+    svis = UI_SVIS(widget);
+
+    if ( svis->event_window != NULL )
+    {
+      gdk_window_set_user_data( svis->event_window , NULL );
+      gdk_window_destroy( svis->event_window );
+      svis->event_window = NULL;
+    }
+
+    if (GTK_WIDGET_CLASS (parent_class)->unrealize)
+        (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
+}
+
+static void ui_svis_map(GtkWidget *widget)
+{
+    UiSVis *svis;
+    svis = UI_SVIS(widget);
+
+    if (svis->event_window != NULL)
+      gdk_window_show (svis->event_window);
+
+    if (GTK_WIDGET_CLASS (parent_class)->map)
+      (* GTK_WIDGET_CLASS (parent_class)->map) (widget);
+}
+
+static void ui_svis_unmap (GtkWidget *widget)
+{
+    UiSVis *svis;
+    svis = UI_SVIS(widget);
+
+    if (svis->event_window != NULL)
+      gdk_window_hide (svis->event_window);
+
+    if (GTK_WIDGET_CLASS (parent_class)->unmap)
+      (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
+}
+
+static void ui_svis_size_request(GtkWidget *widget, GtkRequisition *requisition) {
+    UiSVis *svis = UI_SVIS(widget);
+
+    requisition->width = svis->width*(1+svis->double_size);
+    requisition->height = svis->height*(1+svis->double_size);
+}
+
+static void ui_svis_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
+    UiSVis *svis = UI_SVIS (widget);
+
+    widget->allocation = *allocation;
+    widget->allocation.x *= (1+svis->double_size);
+    widget->allocation.y *= (1+svis->double_size);
+    if (GTK_WIDGET_REALIZED (widget))
+    {
+        if (svis->event_window != NULL)
+            gdk_window_move_resize(svis->event_window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
+        else
+            gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
+    }
+
+    svis->x = widget->allocation.x/(svis->double_size ? 2 : 1);
+    svis->y = widget->allocation.y/(svis->double_size ? 2 : 1);
+}
+
+static gboolean ui_svis_expose(GtkWidget *widget, GdkEventExpose *event) {
+    g_return_val_if_fail (widget != NULL, FALSE);
+    g_return_val_if_fail (UI_IS_SVIS (widget), FALSE);
+    g_return_val_if_fail (event != NULL, FALSE);
+
+    UiSVis *svis = UI_SVIS (widget);
+
+    gint x, y, h;
+    guchar svis_color[24][3];
+    guchar rgb_data[SVIS_WIDTH * 2 * SVIS_HEIGHT * 2], *ptr, c;
+    guint32 colors[24];
+    GdkRgbCmap *cmap;
+
+    if (!GTK_WIDGET_VISIBLE(widget))
+        return FALSE;
+
+    if (!svis->visible_window)
+        return FALSE;
+
+    skin_get_viscolor(bmp_active_skin, svis_color);
+    for (y = 0; y < 24; y++) {
+        colors[y] =
+            svis_color[y][0] << 16 | svis_color[y][1] << 8 | svis_color[y][2];
+    }
+    cmap = gdk_rgb_cmap_new(colors, 24);
+
+    if (!cfg.doublesize) {
+      memset(rgb_data, 0, SVIS_WIDTH * SVIS_HEIGHT);
+      if (cfg.vis_type == VIS_ANALYZER  && !playback_get_paused() && playback_get_playing()){
+	for(y=0; y < SVIS_HEIGHT; y++){
+	  if (cfg.analyzer_type == ANALYZER_BARS){
+	    for(x=0;x< SVIS_WIDTH; x++){
+	      if(svis->data[x] > y << 1)
+		{
+		  rgb_data[x*3+ (SVIS_HEIGHT - y) * SVIS_WIDTH] = 23;
+		  rgb_data[x*3+1 + (SVIS_HEIGHT - y) * SVIS_WIDTH] = 23;
+		  
+		}
+	    }
+	  }
+	  else{
+	    for(x=0;x< SVIS_WIDTH; x++){
+	      if(svis->data[x] > y << 1)
+		{
+		  rgb_data[x + (SVIS_HEIGHT - y) * SVIS_WIDTH] = 23;
+		}
+	    }
+	  }
+	}
+      }
+	else if (cfg.vis_type == VIS_VOICEPRINT){
+	  switch (cfg.vu_mode) {
+	  case VU_NORMAL:
+	    for (y = 0; y < 2; y++) {
+	      ptr = rgb_data + ((y * 3) * 38);
+	      h = (svis->data[y] * 7) / 37;
+	      for (x = 0; x < h; x++, ptr += 5) {
+		c = svis_vu_normal_colors[x];
+		*(ptr) = c;
+		*(ptr + 1) = c;
+		*(ptr + 2) = c;
+		*(ptr + 38) = c;
+		*(ptr + 39) = c;
+		*(ptr + 40) = c;
+	      }
+	    }
+	    break;
+	  case VU_SMOOTH:
+	    for (y = 0; y < 2; y++) {
+	      ptr = rgb_data + ((y * 3) * SVIS_WIDTH);
+	      for (x = 0; x < svis->data[y]; x++, ptr++) {
+		c = 17 - ((x * 15) / 37);
+		*(ptr) = c;
+		*(ptr + 38) = c;
+	      }
+	    }
+	    break;
+	  }	  
+	}
+        else if (cfg.vis_type == VIS_SCOPE) {
+            for (x = 0; x < 38; x++) {
+                h = svis->data[x << 1] / 3;
+                ptr = rgb_data + ((4 - h) * 38) + x;
+                *ptr = svis_scope_colors[h];
+            }
+        }
+
+    }
+    else {                      /* doublesize */
+
+        memset(rgb_data, 0, SVIS_WIDTH * 2 * SVIS_HEIGHT * 2);
+        if (cfg.vis_type == VIS_ANALYZER && !playback_get_paused() && playback_get_playing()){
+	  for(y=0; y < SVIS_HEIGHT; y++){
+            if (cfg.analyzer_type == ANALYZER_BARS){
+              for(x=0;x< SVIS_WIDTH; x++){
+                if(svis->data[x] > y << 1)
+                {
+                  ptr = rgb_data + x * 6 + (SVIS_HEIGHT * 2 - y * 2) * SVIS_WIDTH * 2;
+                  DRAW_DS_PIXEL(ptr, 23);
+                  DRAW_DS_PIXEL(ptr + 2, 23);
+                }
+              }
+            }
+            else{
+              for(x=0;x< SVIS_WIDTH; x++){
+                if(svis->data[x] > y << 1)
+                {
+                  ptr = rgb_data + x * 2 + (SVIS_HEIGHT * 2 - y * 2) * SVIS_WIDTH * 2;
+                  DRAW_DS_PIXEL(ptr, 23);
+                }
+              }
+            }
+	  }
+        }
+	else if (cfg.vis_type == VIS_VOICEPRINT){
+	  switch (cfg.vu_mode) {
+	  case VU_NORMAL:
+	    for (y = 0; y < 2; y++) {
+	      ptr = rgb_data + ((y * 3) * 152);
+	      h = (svis->data[y] * 8) / 37;
+	      for (x = 0; x < h; x++, ptr += 10) {
+		c = svis_vu_normal_colors[x];
+		DRAW_DS_PIXEL(ptr, c);
+		DRAW_DS_PIXEL(ptr + 2, c);
+		DRAW_DS_PIXEL(ptr + 4, c);
+		DRAW_DS_PIXEL(ptr + 152, c);
+		DRAW_DS_PIXEL(ptr + 154, c);
+		DRAW_DS_PIXEL(ptr + 156, c);
+	      }
+	    }
+	    break;
+	  case VU_SMOOTH:
+	    for (y = 0; y < 2; y++) {
+	      ptr = rgb_data + ((y * 3) * 152);
+	      for (x = 0; x < svis->data[y]; x++, ptr += 2) {
+		c = 17 - ((x * 15) / 37);
+		DRAW_DS_PIXEL(ptr, c);
+		DRAW_DS_PIXEL(ptr + 152, c);
+	      }
+	    }
+	    break;
+	  }  
+	}
+        else if (cfg.vis_type == VIS_SCOPE) {
+            for (x = 0; x < 38; x++) {
+                h = svis->data[x << 1] / 3;
+                ptr = rgb_data + ((4 - h) * 152) + (x << 1);
+                *ptr = svis_scope_colors[h];
+                *(ptr + 1) = svis_scope_colors[h];
+                *(ptr + 76) = svis_scope_colors[h];
+                *(ptr + 77) = svis_scope_colors[h];
+            }
+        }
+
+
+    }
+
+    GdkPixmap *obj = NULL;
+    GdkGC *gc;
+    obj = gdk_pixmap_new(NULL, svis->width*(1+svis->double_size), svis->height*(1+svis->double_size), gdk_rgb_get_visual()->depth);
+    gc = gdk_gc_new(obj);
+
+    if (!svis->double_size) {
+        gdk_draw_indexed_image(obj, gc, 0, 0, svis->width, svis->height,
+                               GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data,
+                               38, cmap);
+    } else {
+        gdk_draw_indexed_image(obj, gc,
+                               0 << 1, 0 << 1,
+                               svis->width << 1, svis->height << 1,
+                               GDK_RGB_DITHER_NONE, (guchar *) rgb_data,
+                               76, cmap);
+    }
+
+    gdk_rgb_cmap_free(cmap);
+    gdk_draw_drawable (widget->window, gc, obj, 0, 0, 0, 0,
+                       svis->width*(1+svis->double_size), svis->height*(1+svis->double_size));
+    g_object_unref(obj);
+    g_object_unref(gc);
+
+    return FALSE;
+}
+
+static void ui_svis_toggle_doublesize(UiSVis *svis) {
+    GtkWidget *widget = GTK_WIDGET (svis);
+    svis->double_size = !svis->double_size;
+
+    gtk_widget_set_size_request(widget, svis->width*(1+svis->double_size), svis->height*(1+svis->double_size));
+
+    gtk_widget_queue_draw(widget);
+}
+
+void ui_svis_set_visible(GtkWidget *widget, gboolean window_is_visible)
+{
+    UiSVis *svis;
+    gboolean widget_is_visible;
+
+    g_return_if_fail(UI_IS_SVIS(widget));
+
+    svis = UI_SVIS (widget);
+    widget_is_visible = GTK_WIDGET_VISIBLE(widget);
+
+    svis->visible_window = window_is_visible;
+
+    if (GTK_WIDGET_REALIZED (widget))
+    {
+        if ( widget_is_visible )
+            gtk_widget_hide(widget);
+
+        gtk_widget_unrealize(widget);
+        gtk_widget_realize(widget);
+
+        if ( widget_is_visible )
+            gtk_widget_show(widget);
+    }
+
+    if (widget_is_visible)
+        gtk_widget_queue_resize(widget);
+}
+
+void ui_svis_clear_data(GtkWidget *widget) {
+    gint i;
+
+    UiSVis *svis = UI_SVIS (widget);
+
+    for (i = 0; i < 75; i++) {
+        svis->data[i] = (cfg.vis_type == VIS_SCOPE) ? 6 : 0;
+    }
+}
+
+void ui_svis_timeout_func(GtkWidget *widget, guchar * data) {
+    UiSVis *svis = UI_SVIS (widget);
+    static GTimer *timer = NULL;
+    gulong micros = 9999999;
+    gboolean falloff = FALSE;
+    gint i;
+
+    if (!timer) {
+        timer = g_timer_new();
+        g_timer_start(timer);
+    }
+    else {
+        g_timer_elapsed(timer, &micros);
+        if (micros > 14000)
+            g_timer_reset(timer);
+
+    }
+
+    if (cfg.vis_type == VIS_VOICEPRINT) {
+        if (micros > 14000)
+            falloff = TRUE;
+
+        for (i = 0; i < 2; i++) {
+            if (falloff || data) {
+                if (data && data[i] > svis->data[i])
+                    svis->data[i] = data[i];
+                else if (falloff) {
+                    if (svis->data[i] >= 2)
+                        svis->data[i] -= 2;
+                    else
+                        svis->data[i] = 0;
+                }
+            }
+
+        }
+    }
+    else if (data) {
+        for (i = 0; i < 75; i++)
+            svis->data[i] = data[i];
+    }
+
+    if (micros > 14000) {
+        if (!svis->refresh_delay) {
+            gtk_widget_queue_draw(widget);
+            svis->refresh_delay = svis_redraw_delays[cfg.vis_refresh];
+        }
+        svis->refresh_delay--;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/ui_svis.h	Fri Jul 13 11:40:00 2007 +0200
@@ -0,0 +1,64 @@
+/*
+ * Audacious - a cross-platform multimedia player
+ * Copyright (c) 2007  Audacious development team.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; under version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef UISVIS_H
+#define UISVIS_H
+
+#include <gdk/gdk.h>
+#include <gtk/gtkadjustment.h>
+#include <gtk/gtkwidget.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define UI_SVIS(obj)          GTK_CHECK_CAST (obj, ui_svis_get_type (), UiSVis)
+#define UI_SVIS_CLASS(klass)  GTK_CHECK_CLASS_CAST (klass, ui_svis_get_type (), UiSVisClass)
+#define UI_IS_SVIS(obj)       GTK_CHECK_TYPE (obj, ui_svis_get_type ())
+
+typedef struct _UiSVis        UiSVis;
+typedef struct _UiSVisClass   UiSVisClass;
+
+struct _UiSVis {
+    GtkWidget        widget;
+
+    gint             x, y, width, height;
+    gint             data[75];
+    gint             refresh_delay;
+    gboolean         double_size;
+    GtkWidget        *fixed;
+    gboolean         visible_window;
+    GdkWindow        *event_window;
+};
+
+struct _UiSVisClass {
+    GtkWidgetClass          parent_class;
+    void (* doubled)        (UiSVis *vis);
+};
+
+GtkWidget* ui_svis_new (GtkWidget *fixed, gint x, gint y);
+GtkType ui_svis_get_type(void);
+void ui_svis_clear_data(GtkWidget *widget);
+void ui_svis_timeout_func(GtkWidget *widget, guchar * data);
+void ui_svis_set_visible(GtkWidget *widget, gboolean window_is_visible);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- a/src/audacious/visualization.c	Fri Jul 13 09:47:21 2007 +0200
+++ b/src/audacious/visualization.c	Fri Jul 13 11:40:00 2007 +0200
@@ -284,7 +284,7 @@
     if (!pcm_data || nch < 1) {
         if (cfg.vis_type != VIS_OFF) {
             if (cfg.player_shaded && cfg.player_visible)
-                svis_timeout_func(mainwin_svis, NULL);
+                ui_svis_timeout_func(mainwin_svis, NULL);
             else
                 ui_vis_timeout_func(mainwin_vis, NULL);
         }
@@ -464,7 +464,7 @@
         }
     }
     if (cfg.player_shaded && cfg.player_visible)
-        svis_timeout_func(mainwin_svis, intern_vis_data);
+        ui_svis_timeout_func(mainwin_svis, intern_vis_data);
     else
         ui_vis_timeout_func(mainwin_vis, intern_vis_data);
 }
--- a/src/audacious/widgets/Makefile	Fri Jul 13 09:47:21 2007 +0200
+++ b/src/audacious/widgets/Makefile	Fri Jul 13 11:40:00 2007 +0200
@@ -22,7 +22,6 @@
 	widget.c \
 	menurow.c \
 	monostereo.c \
-	svis.c \
 	playstatus.c \
 	playlist_list.c \
 	playlist_slider.c \
--- a/src/audacious/widgets/widgetcore.h	Fri Jul 13 09:47:21 2007 +0200
+++ b/src/audacious/widgets/widgetcore.h	Fri Jul 13 11:40:00 2007 +0200
@@ -28,7 +28,6 @@
 #include "playlist_slider.h"
 #include "playstatus.h"
 #include "skin.h"
-#include "svis.h"
 #include "widget.h"
 
 #endif