changeset 3889:8f8d7ac51b08

fix skins with not-standard sized numbers pixmap
author Tomasz Mon <desowin@gmail.com>
date Fri, 02 Nov 2007 11:59:42 +0100
parents edd7da52849f
children 0c0306a20e60
files src/audacious/skin.c src/audacious/ui_skinned_number.c src/audacious/ui_skinned_number.h
diffstat 3 files changed, 32 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/skin.c	Thu Nov 01 19:50:20 2007 -0500
+++ b/src/audacious/skin.c	Fri Nov 02 11:59:42 2007 +0100
@@ -48,6 +48,7 @@
 #include "vfs.h"
 
 #include "ui_skinned_window.h"
+#include "ui_skinned_number.h"
 
 #define EXTENSION_TARGETS 7
 
@@ -1581,6 +1582,14 @@
     g_free(command);
 }
 
+static SkinPixmap *
+skin_get_pixmap(Skin * skin, SkinPixmapId map_id)
+{
+    g_return_val_if_fail(skin != NULL, NULL);
+    g_return_val_if_fail(map_id < SKIN_PIXMAP_COUNT, NULL);
+
+    return &skin->pixmaps[map_id];
+}
 
 gboolean
 skin_load(Skin * skin, const gchar * path)
@@ -1595,7 +1604,15 @@
     skin_lock(skin);
     error = skin_load_nolock(skin, path, FALSE);
     skin_unlock(skin);
-    
+
+    SkinPixmap *pixmap = skin_get_pixmap(skin, SKIN_NUMBERS);
+    if (pixmap) {
+        ui_skinned_number_set_size(mainwin_minus_num, 9, pixmap->height);
+        ui_skinned_number_set_size(mainwin_10min_num, 9, pixmap->height);
+        ui_skinned_number_set_size(mainwin_min_num, 9, pixmap->height);
+        ui_skinned_number_set_size(mainwin_10sec_num, 9, pixmap->height);
+        ui_skinned_number_set_size(mainwin_sec_num, 9, pixmap->height);
+    }
     return error;
 }
 
@@ -1618,16 +1635,6 @@
     skin_load_nolock(skin, skin->path, TRUE);
 }
 
-
-static SkinPixmap *
-skin_get_pixmap(Skin * skin, SkinPixmapId map_id)
-{
-    g_return_val_if_fail(skin != NULL, NULL);
-    g_return_val_if_fail(map_id < SKIN_PIXMAP_COUNT, NULL);
-
-    return &skin->pixmaps[map_id];
-}
-
 GdkBitmap *
 skin_get_mask(Skin * skin, SkinMaskId mi)
 {
@@ -1703,9 +1710,9 @@
     g_return_if_fail(pixmap->pixmap != NULL);
 
     if (xsrc+width > pixmap->width || ysrc+height > pixmap->height) {
-        if (pixmap_id == SKIN_NUMBERS)
+        if (pixmap_id == SKIN_NUMBERS) {
             xsrc = 90;
-        else if (pixmap_id == SKIN_VOLUME) {
+        } else if (pixmap_id == SKIN_VOLUME) {
             /* some winamp skins have too strait SKIN_VOLUME, so let's copy what's remain from SKIN_MAIN */
             gdk_draw_drawable(drawable, gc, skin_get_pixmap(bmp_active_skin, SKIN_MAIN)->pixmap,
                               skin->properties.mainwin_volume_x, skin->properties.mainwin_volume_y,
--- a/src/audacious/ui_skinned_number.c	Thu Nov 01 19:50:20 2007 -0500
+++ b/src/audacious/ui_skinned_number.c	Fri Nov 02 11:59:42 2007 +0100
@@ -227,6 +227,7 @@
 }
 
 void ui_skinned_number_set_number(GtkWidget *widget, gint num) {
+    g_return_if_fail(UI_SKINNED_IS_NUMBER(widget));
     UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
 
     if (number->num == num)
@@ -235,3 +236,13 @@
     number->num = num;
     gtk_widget_queue_draw(GTK_WIDGET(number));
 }
+
+void ui_skinned_number_set_size(GtkWidget *widget, gint width, gint height) {
+    g_return_if_fail(UI_SKINNED_IS_NUMBER(widget));
+    UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
+
+    number->width = width;
+    number->height = height;
+
+    gtk_widget_set_size_request(widget, width*(1+number->double_size), height*(1+number->double_size));
+}
--- a/src/audacious/ui_skinned_number.h	Thu Nov 01 19:50:20 2007 -0500
+++ b/src/audacious/ui_skinned_number.h	Fri Nov 02 11:59:42 2007 +0100
@@ -53,6 +53,7 @@
 GtkWidget* ui_skinned_number_new (GtkWidget *fixed, gint x, gint y, SkinPixmapId si);
 GtkType ui_skinned_number_get_type(void);
 void ui_skinned_number_set_number(GtkWidget *widget, gint num);
+void ui_skinned_number_set_size(GtkWidget *widget, gint width, gint height);
 
 #ifdef __cplusplus
 }