changeset 3040:067e0186623a

import UiSkinnedHorizontalSlider
author Tomasz Mon <desowin@gmail.com>
date Thu, 12 Jul 2007 12:26:18 +0200
parents ff886a3a2098
children 910bc20f6816
files src/audacious/Makefile src/audacious/playback.c src/audacious/ui_main.c src/audacious/ui_main.h src/audacious/ui_skinned_horizontal_slider.c src/audacious/ui_skinned_horizontal_slider.h
diffstat 6 files changed, 492 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/Makefile	Wed Jul 11 22:33:43 2007 +0200
+++ b/src/audacious/Makefile	Thu Jul 12 12:26:18 2007 +0200
@@ -111,6 +111,7 @@
 	ui_skinned_button.c \
 	ui_skinned_textbox.c \
 	ui_skinned_number.c \
+	ui_skinned_horizontal_slider.c \
 	ui_vis.c \
 	ui_skinselector.c \
 	ui_urlopener.c \
--- a/src/audacious/playback.c	Wed Jul 11 22:33:43 2007 +0200
+++ b/src/audacious/playback.c	Thu Jul 12 12:26:18 2007 +0200
@@ -116,6 +116,7 @@
         gtk_widget_show(mainwin_min_num);
         gtk_widget_show(mainwin_10sec_num);
         gtk_widget_show(mainwin_sec_num);
+        gtk_widget_show(mainwin_position);
     }
 
     hook_call("playback begin", entry);
--- a/src/audacious/ui_main.c	Wed Jul 11 22:33:43 2007 +0200
+++ b/src/audacious/ui_main.c	Thu Jul 12 12:26:18 2007 +0200
@@ -84,6 +84,7 @@
 #include "ui_skinned_button.h"
 #include "ui_skinned_textbox.h"
 #include "ui_skinned_number.h"
+#include "ui_skinned_horizontal_slider.h"
 #include "ui_jumptotrack.h"
 
 static GTimeVal cb_time; /* click delay for tristate is defined by TRISTATE_THRESHOLD */
@@ -152,7 +153,9 @@
 HSlider *mainwin_sposition = NULL;
 
 static MenuRow *mainwin_menurow;
-static HSlider *mainwin_volume, *mainwin_balance, *mainwin_position;
+static HSlider *mainwin_volume, *mainwin_balance;
+GtkWidget *mainwin_position;
+
 static MonoStereo *mainwin_monostereo;
 static GtkWidget *mainwin_srew, *mainwin_splay, *mainwin_spause;
 static GtkWidget *mainwin_sstop, *mainwin_sfwd, *mainwin_seject, *mainwin_about;
@@ -178,8 +181,8 @@
 static void change_timer_mode(void);
 static void mainwin_refresh_hints(void);
 
-void mainwin_position_motion_cb(gint pos);
-void mainwin_position_release_cb(gint pos);
+void mainwin_position_motion_cb(GtkWidget *widget, gint pos);
+void mainwin_position_release_cb(GtkWidget *widget, gint pos);
 
 void set_doublesize(gboolean doublesize);
 void mainwin_eq_pushed(gboolean toggled);
@@ -762,7 +765,7 @@
         bmp_active_skin->properties.mainwin_balance_y);
 
     if (bmp_active_skin->properties.mainwin_position_x && bmp_active_skin->properties.mainwin_position_y)
-    widget_move(WIDGET(mainwin_position), bmp_active_skin->properties.mainwin_position_x,
+    gtk_fixed_move(GTK_FIXED(SKINNED_WINDOW(mainwin)->fixed), GTK_WIDGET(mainwin_position), bmp_active_skin->properties.mainwin_position_x,
         bmp_active_skin->properties.mainwin_position_y);
 
     if (bmp_active_skin->properties.mainwin_previous_x && bmp_active_skin->properties.mainwin_previous_y)
@@ -897,10 +900,8 @@
     if (playlist_get_current_length(playlist) != -1) {
         if (cfg.player_shaded)
             widget_show(WIDGET(mainwin_sposition));
-        widget_show(WIDGET(mainwin_position));
     }
     else {
-        widget_hide(WIDGET(mainwin_position));
         widget_hide(WIDGET(mainwin_sposition));
         mainwin_force_redraw = TRUE;
     }
@@ -948,7 +949,7 @@
     /* clear sampling parameters */
     playback_set_sample_params(0, 0, 0);
 
-    mainwin_position->hs_pressed = FALSE;
+    UI_SKINNED_HORIZONTAL_SLIDER(mainwin_position)->pressed = FALSE;
     mainwin_sposition->hs_pressed = FALSE;
 
     /* clear sampling parameter displays */
@@ -969,7 +970,7 @@
     gtk_widget_hide(mainwin_stime_min);
     gtk_widget_hide(mainwin_stime_sec);
 
-    widget_hide(WIDGET(mainwin_position));
+    gtk_widget_hide(mainwin_position);
     widget_hide(WIDGET(mainwin_sposition));
 
     gtk_widget_hide(mainwin_othertext);
@@ -985,13 +986,14 @@
     if (!mainwin)
         return;
 
+    gtk_widget_hide(mainwin_position);
+
     /*
      * We dont call draw_main_window() here so this will not
      * remove them visually.  It will only prevent us from sending
      * any seek calls to the input plugin before the input plugin
      * calls ->set_info().
      */
-    widget_hide(WIDGET(mainwin_position));
     widget_hide(WIDGET(mainwin_sposition));
 }
 
@@ -1562,7 +1564,7 @@
 {
     g_get_current_time(&cb_time);
 
-    seek_initial_pos = hslider_get_position(mainwin_position);
+    seek_initial_pos = ui_skinned_horizontal_slider_get_position(mainwin_position);
     seek_state = MAINWIN_SEEK_REV;
 }
 
@@ -1588,7 +1590,7 @@
     else
     {
         /* interpret as 'seek' */
-        mainwin_position_release_cb( hslider_get_position(mainwin_position) );
+        mainwin_position_release_cb( mainwin_position, ui_skinned_horizontal_slider_get_position(mainwin_position) );
     }
 
     seek_state = MAINWIN_SEEK_NIL;
@@ -1598,7 +1600,7 @@
 mainwin_fwd_pushed(void)
 {
     g_get_current_time(&cb_time);
-    seek_initial_pos = hslider_get_position(mainwin_position);
+    seek_initial_pos = ui_skinned_horizontal_slider_get_position(mainwin_position);
     seek_state = MAINWIN_SEEK_FWD;
 }
 
@@ -1624,7 +1626,7 @@
     else
     {
         /* interpret as 'seek' */
-        mainwin_position_release_cb( hslider_get_position(mainwin_position) );
+        mainwin_position_release_cb( mainwin_position, ui_skinned_horizontal_slider_get_position(mainwin_position) );
     }
 
     seek_state = MAINWIN_SEEK_NIL;
@@ -1751,7 +1753,7 @@
 }
 
 void
-mainwin_position_motion_cb(gint pos)
+mainwin_position_motion_cb(GtkWidget *widget, gint pos)
 {
     gint length, time;
     gchar *seek_msg;
@@ -1767,7 +1769,7 @@
 }
 
 void
-mainwin_position_release_cb(gint pos)
+mainwin_position_release_cb(GtkWidget *widget, gint pos)
 {
     gint length, time;
 
@@ -2864,12 +2866,10 @@
     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_position =
-        create_hslider(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 16, 72, 248,
-                       10, 248, 0, 278, 0, 29, 10, 10, 0, 0, 219, NULL,
-                       mainwin_position_motion_cb,
-                       mainwin_position_release_cb, SKIN_POSBAR);
-    widget_hide(WIDGET(mainwin_position));
+    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, NULL, SKIN_POSBAR);
+    g_signal_connect(mainwin_position, "motion", G_CALLBACK(mainwin_position_motion_cb), NULL);
+    g_signal_connect(mainwin_position, "release", G_CALLBACK(mainwin_position_release_cb), NULL);
 
     mainwin_sposition =
         create_hslider(&mainwin_wlist, mainwin_bg, SKINNED_WINDOW(mainwin)->gc, 226, 4, 17,
@@ -2905,7 +2905,6 @@
 
     ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_svis));
 
-    ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_position));
     ui_skinned_window_widgetlist_associate(mainwin, WIDGET(mainwin_sposition));
 }
 
@@ -2994,6 +2993,8 @@
     gtk_widget_hide(mainwin_sec_num);
     gtk_widget_hide(mainwin_othertext);
 
+    gtk_widget_hide(mainwin_position);
+
     if (bmp_active_skin->properties.mainwin_vis_visible)
         gtk_widget_show(mainwin_vis);
     else
@@ -3067,18 +3068,18 @@
     length /= 1000;
     if (length > 0) {
         if (time > length) {
-            hslider_set_position(mainwin_position, 219);
+            ui_skinned_horizontal_slider_set_position(mainwin_position, 219);
             hslider_set_position(mainwin_sposition, 13);
         }
         /* update the slider position ONLY if there is not a seek in progress */
         else if (seek_state == MAINWIN_SEEK_NIL)  {
-            hslider_set_position(mainwin_position, (time * 219) / length);
+            ui_skinned_horizontal_slider_set_position(mainwin_position, (time * 219) / length);
             hslider_set_position(mainwin_sposition,
                                  ((time * 12) / length) + 1);
         }
     }
     else {
-        hslider_set_position(mainwin_position, 0);
+        ui_skinned_horizontal_slider_set_position(mainwin_position, 0);
         hslider_set_position(mainwin_sposition, 1);
     }
 
@@ -3168,8 +3169,8 @@
         else if ( np > 219 )
           np = 219;
 
-        hslider_set_position( mainwin_position , np );
-        mainwin_position_motion_cb( np );
+        ui_skinned_horizontal_slider_set_position( mainwin_position , np );
+        mainwin_position_motion_cb( mainwin_position, np );
       }
     }
 
--- a/src/audacious/ui_main.h	Wed Jul 11 22:33:43 2007 +0200
+++ b/src/audacious/ui_main.h	Thu Jul 12 12:26:18 2007 +0200
@@ -114,6 +114,7 @@
 extern GtkWidget *mainwin_10sec_num, *mainwin_sec_num;
 
 extern HSlider *mainwin_sposition;
+extern GtkWidget *mainwin_position;
 
 void mainwin_create(void);
 void read_volume(gint when);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/ui_skinned_horizontal_slider.c	Thu Jul 12 12:26:18 2007 +0200
@@ -0,0 +1,394 @@
+/*
+ * 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_skinned_horizontal_slider.h"
+#include "main.h"
+#include <gtk/gtkmain.h>
+#include <gtk/gtkmarshal.h>
+#include <gtk/gtkimage.h>
+
+#define UI_TYPE_SKINNED_HORIZONTAL_SLIDER           (ui_skinned_horizontal_slider_get_type())
+#define UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UI_TYPE_SKINNED_HORIZONTAL_SLIDER, UiSkinnedHorizontalSliderPrivate))
+typedef struct _UiSkinnedHorizontalSliderPrivate UiSkinnedHorizontalSliderPrivate;
+
+enum {
+    MOTION,
+    RELEASE,
+    DOUBLED,
+    LAST_SIGNAL
+};
+
+struct _UiSkinnedHorizontalSliderPrivate {
+    GtkWidget        *fixed;
+    SkinPixmapId     skin_index;
+    gboolean         double_size;
+    gint             frame, frame_offset, frame_height, min, max;
+    gint             knob_nx, knob_ny, knob_px, knob_py;
+    gint             knob_width, knob_height;
+    gint             position;
+    gint             width, height;
+    gint             (*frame_cb) (gint);
+};
+
+static void ui_skinned_horizontal_slider_class_init         (UiSkinnedHorizontalSliderClass *klass);
+static void ui_skinned_horizontal_slider_init               (UiSkinnedHorizontalSlider *horizontal_slider);
+static void ui_skinned_horizontal_slider_destroy            (GtkObject *object);
+static void ui_skinned_horizontal_slider_realize            (GtkWidget *widget);
+static void ui_skinned_horizontal_slider_size_request       (GtkWidget *widget, GtkRequisition *requisition);
+static void ui_skinned_horizontal_slider_size_allocate      (GtkWidget *widget, GtkAllocation *allocation);
+static gboolean ui_skinned_horizontal_slider_expose         (GtkWidget *widget, GdkEventExpose *event);
+static gboolean ui_skinned_horizontal_slider_button_press   (GtkWidget *widget, GdkEventButton *event);
+static gboolean ui_skinned_horizontal_slider_button_release (GtkWidget *widget, GdkEventButton *event);
+static gboolean ui_skinned_horizontal_slider_motion_notify  (GtkWidget *widget, GdkEventMotion *event);
+static void ui_skinned_horizontal_slider_toggle_doublesize  (UiSkinnedHorizontalSlider *horizontal_slider);
+
+static GtkWidgetClass *parent_class = NULL;
+static guint horizontal_slider_signals[LAST_SIGNAL] = { 0 };
+
+GType ui_skinned_horizontal_slider_get_type() {
+    static GType horizontal_slider_type = 0;
+    if (!horizontal_slider_type) {
+        static const GTypeInfo horizontal_slider_info = {
+            sizeof (UiSkinnedHorizontalSliderClass),
+            NULL,
+            NULL,
+            (GClassInitFunc) ui_skinned_horizontal_slider_class_init,
+            NULL,
+            NULL,
+            sizeof (UiSkinnedHorizontalSlider),
+            0,
+            (GInstanceInitFunc) ui_skinned_horizontal_slider_init,
+        };
+        horizontal_slider_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedHorizontalSlider", &horizontal_slider_info, 0);
+    }
+
+    return horizontal_slider_type;
+}
+
+static void ui_skinned_horizontal_slider_class_init(UiSkinnedHorizontalSliderClass *klass) {
+    GObjectClass *gobject_class;
+    GtkObjectClass *object_class;
+    GtkWidgetClass *widget_class;
+
+    gobject_class = G_OBJECT_CLASS(klass);
+    object_class = (GtkObjectClass*) klass;
+    widget_class = (GtkWidgetClass*) klass;
+    parent_class = gtk_type_class (gtk_widget_get_type ());
+
+    object_class->destroy = ui_skinned_horizontal_slider_destroy;
+
+    widget_class->realize = ui_skinned_horizontal_slider_realize;
+    widget_class->expose_event = ui_skinned_horizontal_slider_expose;
+    widget_class->size_request = ui_skinned_horizontal_slider_size_request;
+    widget_class->size_allocate = ui_skinned_horizontal_slider_size_allocate;
+    widget_class->button_press_event = ui_skinned_horizontal_slider_button_press;
+    widget_class->button_release_event = ui_skinned_horizontal_slider_button_release;
+    widget_class->motion_notify_event = ui_skinned_horizontal_slider_motion_notify;
+
+    klass->motion = NULL;
+    klass->release = NULL;
+    klass->doubled = ui_skinned_horizontal_slider_toggle_doublesize;
+
+    horizontal_slider_signals[MOTION] = 
+        g_signal_new ("motion", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+                      G_STRUCT_OFFSET (UiSkinnedHorizontalSliderClass, motion), NULL, NULL,
+                      gtk_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+
+    horizontal_slider_signals[RELEASE] = 
+        g_signal_new ("release", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+                      G_STRUCT_OFFSET (UiSkinnedHorizontalSliderClass, release), NULL, NULL,
+                      gtk_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+
+    horizontal_slider_signals[DOUBLED] = 
+        g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+                      G_STRUCT_OFFSET (UiSkinnedHorizontalSliderClass, doubled), NULL, NULL,
+                      gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+    g_type_class_add_private (gobject_class, sizeof (UiSkinnedHorizontalSliderPrivate));
+}
+
+static void ui_skinned_horizontal_slider_init(UiSkinnedHorizontalSlider *horizontal_slider) {
+    horizontal_slider->pressed = FALSE;
+}
+
+GtkWidget* ui_skinned_horizontal_slider_new(GtkWidget *fixed, gint x, gint y, gint w, gint h, gint knx, gint kny,
+                                            gint kpx, gint kpy, gint kw, gint kh, gint fh,
+                                            gint fo, gint min, gint max, gint(*fcb) (gint), SkinPixmapId si) {
+
+    UiSkinnedHorizontalSlider *hs = g_object_new (ui_skinned_horizontal_slider_get_type (), NULL);
+    UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs);
+
+    hs->x = x;
+    hs->y = y;
+    priv->width = w;
+    priv->height = h;
+    priv->fixed = fixed;
+    priv->knob_nx = knx;
+    priv->knob_ny = kny;
+    priv->knob_px = kpx;
+    priv->knob_py = kpy;
+    priv->knob_width = kw;
+    priv->knob_height = kh;
+    priv->frame_height = fh;
+    priv->frame_offset = fo;
+    priv->min = min;
+    priv->position = min;
+    priv->max = max;
+    priv->frame_cb = fcb;
+    if (priv->frame_cb)
+        priv->frame = priv->frame_cb(0);
+    priv->skin_index = si;
+
+    gtk_fixed_put(GTK_FIXED(priv->fixed), GTK_WIDGET(hs), hs->x, hs->y);
+
+    return GTK_WIDGET(hs);
+}
+
+static void ui_skinned_horizontal_slider_destroy(GtkObject *object) {
+    UiSkinnedHorizontalSlider *horizontal_slider;
+
+    g_return_if_fail (object != NULL);
+    g_return_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (object));
+
+    horizontal_slider = UI_SKINNED_HORIZONTAL_SLIDER (object);
+
+    if (GTK_OBJECT_CLASS (parent_class)->destroy)
+        (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+static void ui_skinned_horizontal_slider_realize(GtkWidget *widget) {
+    UiSkinnedHorizontalSlider *horizontal_slider;
+    GdkWindowAttr attributes;
+    gint attributes_mask;
+
+    g_return_if_fail (widget != NULL);
+    g_return_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER(widget));
+
+    GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
+    horizontal_slider = UI_SKINNED_HORIZONTAL_SLIDER(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);
+    attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | 
+                             GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK |
+                             GDK_POINTER_MOTION_HINT_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);
+
+    gdk_window_set_user_data(widget->window, widget);
+}
+
+static void ui_skinned_horizontal_slider_size_request(GtkWidget *widget, GtkRequisition *requisition) {
+    UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
+
+    requisition->width = priv->width*(1+priv->double_size);
+    requisition->height = priv->height*(1+priv->double_size);
+}
+
+static void ui_skinned_horizontal_slider_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
+    UiSkinnedHorizontalSlider *horizontal_slider = UI_SKINNED_HORIZONTAL_SLIDER (widget);
+    UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(horizontal_slider);
+
+    widget->allocation = *allocation;
+    widget->allocation.x *= (1+priv->double_size);
+    widget->allocation.y *= (1+priv->double_size);
+    if (GTK_WIDGET_REALIZED (widget))
+        gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
+
+    horizontal_slider->x = widget->allocation.x/(priv->double_size ? 2 : 1);
+    horizontal_slider->y = widget->allocation.y/(priv->double_size ? 2 : 1);
+}
+
+static gboolean ui_skinned_horizontal_slider_expose(GtkWidget *widget, GdkEventExpose *event) {
+    g_return_val_if_fail (widget != NULL, FALSE);
+    g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), FALSE);
+    g_return_val_if_fail (event != NULL, FALSE);
+
+    UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER (widget);
+    UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs);
+
+    GdkPixmap *obj = NULL;
+    GdkGC *gc;
+
+    obj = gdk_pixmap_new(NULL, priv->width, priv->height, gdk_rgb_get_visual()->depth);
+    gc = gdk_gc_new(obj);
+
+    skin_draw_pixmap(bmp_active_skin, obj, gc,
+                     priv->skin_index, priv->frame_offset,
+                     priv->frame * priv->frame_height,
+                     0, 0, priv->width, priv->height);
+    if (hs->pressed)
+        skin_draw_pixmap(bmp_active_skin, obj, gc,
+                         priv->skin_index, priv->knob_px,
+                         priv->knob_py, priv->position,
+                         ((priv->height - priv->knob_height) / 2),
+                         priv->knob_width, priv->knob_height);
+    else
+        skin_draw_pixmap(bmp_active_skin, obj, gc,
+                         priv->skin_index, priv->knob_nx,
+                         priv->knob_ny, priv->position,
+                         ((priv->height - priv->knob_height) / 2),
+                         priv->knob_width, priv->knob_height);
+
+    GdkPixmap *image;
+    image = gdk_pixmap_new(NULL, priv->width*(1+priv->double_size),
+                                 priv->height*(1+priv->double_size),
+                                 gdk_rgb_get_visual()->depth);
+
+    if (priv->double_size) {
+        GdkPixbuf *img, *img2x;
+        GdkColormap *colormap = gdk_colormap_get_system();
+        img = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, priv->width, priv->height);
+        gdk_pixbuf_get_from_drawable(img, obj, colormap, 0, 0, 0, 0, priv->width, priv->height);
+        img2x = gdk_pixbuf_scale_simple(img, priv->width*2, priv->height*2, GDK_INTERP_NEAREST);
+        gdk_draw_pixbuf (image, gc, img2x, 0, 0, 0, 0, priv->width*2, priv->height*2, GDK_RGB_DITHER_NONE, 0, 0);
+        g_object_unref(img);
+        g_object_unref(img2x);
+        g_object_unref(colormap);
+    } else
+        gdk_draw_drawable (image, gc, obj, 0, 0, 0, 0, priv->width, priv->height);
+
+
+    g_object_unref(obj);
+
+    gdk_draw_drawable (widget->window, gc, image, 0, 0, 0, 0,
+                       priv->width*(1+priv->double_size), priv->height*(1+priv->double_size));
+    g_object_unref(gc);
+    g_object_unref(image);
+
+    return FALSE;
+}
+
+static gboolean ui_skinned_horizontal_slider_button_press(GtkWidget *widget, GdkEventButton *event) {
+    g_return_val_if_fail (widget != NULL, FALSE);
+    g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), FALSE);
+    g_return_val_if_fail (event != NULL, FALSE);
+
+    UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER (widget);
+    UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs);
+
+    if (event->type == GDK_BUTTON_PRESS) {
+        if (event->button == 1) {
+        gint x;
+
+        x = event->x - priv->knob_width / 2;
+        hs->pressed = TRUE;
+
+        priv->position = x;
+        if (priv->position < priv->min)
+                    priv->position = priv->min;
+                if (priv->position > priv->max)
+                    priv->position = priv->max;
+                if (priv->frame_cb)
+                    priv->frame = priv->frame_cb(priv->position);
+
+        g_signal_emit_by_name(widget, "motion", priv->position);
+        gtk_widget_queue_draw(widget);
+        }
+    }
+    return TRUE;
+}
+
+static gboolean ui_skinned_horizontal_slider_button_release(GtkWidget *widget, GdkEventButton *event) {
+    UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER(widget);
+    UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
+
+    if (event->button == 1) {
+        hs->pressed = FALSE;
+        g_signal_emit_by_name(widget, "release", priv->position);
+        gtk_widget_queue_draw(widget);
+    }
+    return TRUE;
+}
+
+static gboolean ui_skinned_horizontal_slider_motion_notify(GtkWidget *widget, GdkEventMotion *event) {
+    g_return_val_if_fail (widget != NULL, FALSE);
+    g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), FALSE);
+    g_return_val_if_fail (event != NULL, FALSE);
+    UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER(widget);
+    UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
+
+    if (hs->pressed) {
+        gint x;
+
+        x = event->x - hs->x;
+        priv->position = x;
+
+        if (priv->position < priv->min)
+            priv->position = priv->min;
+
+        if (priv->position > priv->max)
+            priv->position = priv->max;
+
+        if (priv->frame_cb)
+            priv->frame = priv->frame_cb(priv->position);
+
+        g_signal_emit_by_name(widget, "motion", priv->position);
+        gtk_widget_queue_draw(widget);
+    }
+
+    return TRUE;
+}
+
+static void ui_skinned_horizontal_slider_toggle_doublesize(UiSkinnedHorizontalSlider *horizontal_slider) {
+    GtkWidget *widget = GTK_WIDGET (horizontal_slider);
+    UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(horizontal_slider);
+
+    priv->double_size = !priv->double_size;
+
+    gtk_widget_set_size_request(widget, priv->width*(1+priv->double_size), priv->height*(1+priv->double_size));
+
+    gtk_widget_queue_draw(GTK_WIDGET(horizontal_slider));
+}
+
+void ui_skinned_horizontal_slider_set_position(GtkWidget *widget, gint pos) {
+    g_return_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget));
+    UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER(widget);
+    UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
+
+    if (pos == priv->position || hs->pressed)
+        return;
+
+    priv->position = pos;
+
+    if (priv->frame_cb)
+        priv->frame = priv->frame_cb(priv->position);
+
+    gtk_widget_queue_draw(widget);
+}
+
+gint ui_skinned_horizontal_slider_get_position(GtkWidget *widget) {
+    g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), -1);
+    UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
+    return priv->position;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/ui_skinned_horizontal_slider.h	Thu Jul 12 12:26:18 2007 +0200
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+#ifndef UISKINNEDHORIZONTAL_SLIDER_H
+#define UISKINNEDHORIZONTAL_SLIDER_H
+
+#include <gdk/gdk.h>
+#include <gtk/gtkadjustment.h>
+#include <gtk/gtkwidget.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define UI_SKINNED_HORIZONTAL_SLIDER(obj)          GTK_CHECK_CAST (obj, ui_skinned_horizontal_slider_get_type (), UiSkinnedHorizontalSlider)
+#define UI_SKINNED_HORIZONTAL_SLIDER_CLASS(klass)  GTK_CHECK_CLASS_CAST (klass, ui_skinned_horizontal_slider_get_type (), UiSkinnedHorizontalSliderClass)
+#define UI_SKINNED_IS_HORIZONTAL_SLIDER(obj)       GTK_CHECK_TYPE (obj, ui_skinned_horizontal_slider_get_type ())
+
+typedef struct _UiSkinnedHorizontalSlider        UiSkinnedHorizontalSlider;
+typedef struct _UiSkinnedHorizontalSliderClass   UiSkinnedHorizontalSliderClass;
+
+struct _UiSkinnedHorizontalSlider {
+    GtkWidget   widget;
+    gboolean    pressed;
+    gint        x, y;
+};
+
+struct _UiSkinnedHorizontalSliderClass {
+    GtkWidgetClass    parent_class;
+    void (* motion)   (UiSkinnedHorizontalSlider *horizontal_slider);
+    void (* release)  (UiSkinnedHorizontalSlider *horizontal_slider);
+    void (* doubled)  (UiSkinnedHorizontalSlider *horizontal_slider);
+    void (* redraw)   (UiSkinnedHorizontalSlider *horizontal_slider);
+};
+GtkWidget* ui_skinned_horizontal_slider_new(GtkWidget *fixed, gint x, gint y, gint w, gint h, gint knx, gint kny,
+                                            gint kpx, gint kpy, gint kw, gint kh, gint fh,
+                                            gint fo, gint min, gint max, gint(*fcb) (gint), SkinPixmapId si);
+GtkType ui_skinned_horizontal_slider_get_type(void);
+void ui_skinned_horizontal_slider_set_position(GtkWidget *widget, gint pos);
+gint ui_skinned_horizontal_slider_get_position(GtkWidget *widget);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif