changeset 2998:c200d6764e91 trunk

fix expose events, thanks to giacomo
author Tomasz Mon <desowin@gmail.com>
date Sat, 07 Jul 2007 17:50:31 +0200
parents 0adc8c00fc57
children e6340ab753a1
files src/audacious/ui_skinned_button.c src/audacious/ui_skinned_button.h src/audacious/ui_skinned_textbox.c
diffstat 3 files changed, 92 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/ui_skinned_button.c	Sat Jul 07 12:17:13 2007 +0200
+++ b/src/audacious/ui_skinned_button.c	Sat Jul 07 17:50:31 2007 +0200
@@ -164,7 +164,6 @@
 static void ui_skinned_button_init (UiSkinnedButton *button) {
     UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
     mutex = g_mutex_new();
-    button->redraw = TRUE;
     button->inside = FALSE;
     button->type = TYPE_NOT_SET;
     priv->move_x = 0;
@@ -253,57 +252,51 @@
     if (button->type == TYPE_SMALL || button->type == TYPE_NOT_SET)
         return FALSE;
 
-    if (button->redraw == TRUE) {
-        button->redraw = FALSE;
-
-        GdkPixmap *obj;
-        obj = gdk_pixmap_new(NULL, priv->w, priv->h, gdk_rgb_get_visual()->depth);
-        switch (button->type) {
-            case TYPE_PUSH:
+    GdkPixmap *obj;
+    obj = gdk_pixmap_new(NULL, priv->w, priv->h, gdk_rgb_get_visual()->depth);
+    switch (button->type) {
+        case TYPE_PUSH:
+            skin_draw_pixmap(bmp_active_skin, obj, priv->gc,
+                             button->pressed ? priv->skin_index2 : priv->skin_index1,
+                             button->pressed ? button->px : button->nx,
+                             button->pressed ? button->py : button->ny,
+                             0, 0, priv->w, priv->h);
+            break;
+        case TYPE_TOGGLE:
+            if (button->inside)
+                skin_draw_pixmap(bmp_active_skin, obj, priv->gc,
+                                 button->pressed ? priv->skin_index2 : priv->skin_index1,
+                                 button->pressed ? button->ppx : button->pnx,
+                                 button->pressed ? button->ppy : button->pny,
+                                 0, 0, priv->w, priv->h);
+            else
                 skin_draw_pixmap(bmp_active_skin, obj, priv->gc,
                                  button->pressed ? priv->skin_index2 : priv->skin_index1,
                                  button->pressed ? button->px : button->nx,
                                  button->pressed ? button->py : button->ny,
                                  0, 0, priv->w, priv->h);
-                break;
-            case TYPE_TOGGLE:
-                if (button->inside)
-                    skin_draw_pixmap(bmp_active_skin, obj, priv->gc,
-                                     button->pressed ? priv->skin_index2 : priv->skin_index1,
-                                     button->pressed ? button->ppx : button->pnx,
-                                     button->pressed ? button->ppy : button->pny,
-                                     0, 0, priv->w, priv->h);
-                else
-                    skin_draw_pixmap(bmp_active_skin, obj, priv->gc,
-                                     button->pressed ? priv->skin_index2 : priv->skin_index1,
-                                     button->pressed ? button->px : button->nx,
-                                     button->pressed ? button->py : button->ny,
-                                     0, 0, priv->w, priv->h);
-                break;
-            default:
-                break;
-        }
+            break;
+        default:
+            break;
+    }
+
+    if (priv->img)
+        g_object_unref(priv->img);
+    priv->img = gdk_pixmap_new(NULL, priv->w*(1+priv->double_size),
+                               priv->h*(1+priv->double_size),
+                               gdk_rgb_get_visual()->depth);
 
-        if (priv->img)
-                g_object_unref(priv->img);
-        priv->img = gdk_pixmap_new(NULL, priv->w*(1+priv->double_size),
-                                         priv->h*(1+priv->double_size),
-                                         gdk_rgb_get_visual()->depth);
+    if (priv->double_size) {
+        GdkImage *img, *img2x;
+        img = gdk_drawable_get_image(obj, 0, 0, priv->w, priv->h);
+        img2x = create_dblsize_image(img);
+        gdk_draw_image (priv->img, priv->gc, img2x, 0, 0, 0, 0, priv->w*2, priv->h*2);
+        g_object_unref(img2x);
+        g_object_unref(img);
+    } else
+        gdk_draw_drawable (priv->img, priv->gc, obj, 0, 0, 0, 0, priv->w, priv->h);
 
-        if (priv->double_size) {
-            GdkImage *img, *img2x;
-            img = gdk_drawable_get_image(obj, 0, 0, priv->w, priv->h);
-            img2x = create_dblsize_image(img);
-            gdk_draw_image (priv->img, priv->gc, img2x, 0, 0, 0, 0, priv->w*2, priv->h*2);
-            g_object_unref(img2x);
-            g_object_unref(img);
-        } else
-            gdk_draw_drawable (priv->img, priv->gc, obj, 0, 0, 0, 0, priv->w, priv->h);
-
-        g_object_unref(obj);
-        gtk_widget_queue_resize(widget);
-
-    }
+    g_object_unref(obj);
 
     gdk_draw_drawable (widget->window, priv->gc, priv->img, 0, 0, 0, 0,
                        priv->w*(1+priv->double_size), priv->h*(1+priv->double_size));
@@ -398,7 +391,6 @@
 static void ui_skinned_button_set_pressed (UiSkinnedButton *button, gboolean pressed) {
     if (pressed != button->pressed) {
         button->pressed = pressed;
-        button->redraw = TRUE;
         gtk_widget_queue_draw(GTK_WIDGET(button));
     }
 }
@@ -420,7 +412,6 @@
     UiSkinnedButton *button;
     if (event->button == 1) {
             button = UI_SKINNED_BUTTON(widget);
-            button->redraw = TRUE;
             ui_skinned_button_released(button);
     } else if (event->button == 3) {
             g_signal_emit(widget, button_signals[RIGHT_CLICKED], 0);
@@ -473,7 +464,6 @@
     gtk_widget_set_size_request(widget, priv->w*(1+priv->double_size), priv->h*(1+priv->double_size));
     gtk_widget_set_uposition(widget, button->x*(1+priv->double_size), button->y*(1+priv->double_size));
 
-    button->redraw = TRUE;
     gtk_widget_queue_draw(widget);
 }
 
@@ -482,7 +472,7 @@
     UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
     if (priv->move_x || priv->move_y)
         gtk_fixed_move(GTK_FIXED(priv->fixed), GTK_WIDGET(button), button->x+priv->move_x, button->y+priv->move_y);
-    button->redraw = TRUE;
+
     gtk_widget_queue_draw(GTK_WIDGET(button));
     g_mutex_unlock(mutex);
 }
--- a/src/audacious/ui_skinned_button.h	Sat Jul 07 12:17:13 2007 +0200
+++ b/src/audacious/ui_skinned_button.h	Sat Jul 07 17:50:31 2007 +0200
@@ -56,8 +56,6 @@
 
 	//Toogle button needs also those
 	gint pnx, pny, ppx, ppy;
-
-	gboolean redraw;
 };
 
 struct _UiSkinnedButtonClass {
--- a/src/audacious/ui_skinned_textbox.c	Sat Jul 07 12:17:13 2007 +0200
+++ b/src/audacious/ui_skinned_textbox.c	Sat Jul 07 17:50:31 2007 +0200
@@ -52,7 +52,6 @@
 };
 
 struct _UiSkinnedTextboxPrivate {
-    gboolean         redraw;
     GdkPixmap        *img;
     GdkGC            *gc;
     SkinPixmapId     skin_index;
@@ -293,74 +292,70 @@
     UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget);
     UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
 
-    if(priv->redraw) {
-        priv->redraw = FALSE;
-        GdkPixmap *obj = NULL;
-        gint cw;
+    GdkPixmap *obj = NULL;
+    gint cw;
 
-        if (textbox->text && (!priv->pixmap_text || strcmp(textbox->text, priv->pixmap_text)))
+    if (textbox->text && (!priv->pixmap_text || strcmp(textbox->text, priv->pixmap_text)))
+        textbox_generate_pixmap(textbox);
+
+    if (priv->pixmap) {
+        if (skin_get_id() != priv->skin_id) {
+            priv->skin_id = skin_get_id();
             textbox_generate_pixmap(textbox);
-
-        if (priv->pixmap) {
-            if (skin_get_id() != priv->skin_id) {
-                priv->skin_id = skin_get_id();
-                textbox_generate_pixmap(textbox);
-            }
-            obj = gdk_pixmap_new(NULL, textbox->width, textbox->height, gdk_rgb_get_visual()->depth);
+        }
+        obj = gdk_pixmap_new(NULL, textbox->width, textbox->height, gdk_rgb_get_visual()->depth);
 
-            if(cfg.twoway_scroll) { // twoway scroll
-                cw = priv->pixmap_width - priv->offset;
-                if (cw > textbox->width)
-                    cw = textbox->width;
-                gdk_draw_drawable(obj, priv->gc, priv->pixmap, priv->offset, 0, 0, 0, cw, textbox->height);
-                if (cw < textbox->width)
-                    gdk_draw_drawable(obj, priv->gc, priv->pixmap, 0, 0,
-                                      textbox->x + cw, textbox->y,
-                                      textbox->width - cw, textbox->height);
-            }
-            else { // oneway scroll
-                int cw1, cw2;
+        if (cfg.twoway_scroll) { // twoway scroll
+            cw = priv->pixmap_width - priv->offset;
+            if (cw > textbox->width)
+                cw = textbox->width;
+            gdk_draw_drawable(obj, priv->gc, priv->pixmap, priv->offset, 0, 0, 0, cw, textbox->height);
+            if (cw < textbox->width)
+                gdk_draw_drawable(obj, priv->gc, priv->pixmap, 0, 0,
+                                  textbox->x + cw, textbox->y,
+                                  textbox->width - cw, textbox->height);
+        } else { // oneway scroll
+            int cw1, cw2;
 
-                if(priv->offset >= priv->pixmap_width)
-                    priv->offset = 0;
+            if (priv->offset >= priv->pixmap_width)
+                priv->offset = 0;
 
-                if(priv->pixmap_width - priv->offset > textbox->width){ // case1
-                    cw1 = textbox->width;
-                    gdk_draw_drawable(obj, priv->gc, priv->pixmap, priv->offset, 0,
-                                      0, 0, cw1, textbox->height);
-                }
-                else { // case 2
-                    cw1 = priv->pixmap_width - priv->offset;
-                    gdk_draw_drawable(obj, priv->gc, priv->pixmap, priv->offset, 0,
-                                      0, 0, cw1, textbox->height);
-                    cw2 = textbox->width - cw1;
-                    gdk_draw_drawable(obj, priv->gc, priv->pixmap, 0, 0, cw1, 0, cw2, textbox->height);
-                }
-
+            if (priv->pixmap_width - priv->offset > textbox->width) { // case1
+                cw1 = textbox->width;
+                gdk_draw_drawable(obj, priv->gc, priv->pixmap, priv->offset, 0,
+                                  0, 0, cw1, textbox->height);
+            } else { // case 2
+                cw1 = priv->pixmap_width - priv->offset;
+                gdk_draw_drawable(obj, priv->gc, priv->pixmap, priv->offset, 0,
+                                  0, 0, cw1, textbox->height);
+                cw2 = textbox->width - cw1;
+                gdk_draw_drawable(obj, priv->gc, priv->pixmap, 0, 0, cw1, 0, cw2, textbox->height);
             }
-        if (priv->img)
-                g_object_unref(priv->img);
-        priv->img = gdk_pixmap_new(NULL, textbox->width*(1+priv->double_size),
-                                            textbox->height*(1+priv->double_size),
-                                            gdk_rgb_get_visual()->depth);
+
+        }
+    if (priv->img)
+        g_object_unref(priv->img);
+    priv->img = gdk_pixmap_new(NULL, textbox->width*(1+priv->double_size),
+                               textbox->height*(1+priv->double_size),
+                               gdk_rgb_get_visual()->depth);
 
-        if (priv->double_size) {
-            GdkImage *img, *img2x;
-            img = gdk_drawable_get_image(obj, 0, 0, textbox->width, textbox->height);
-            img2x = create_dblsize_image(img);
-            gdk_draw_image (priv->img, priv->gc, img2x, 0, 0, 0, 0, textbox->width*2, textbox->height*2);
-            g_object_unref(img2x);
-            g_object_unref(img);
-        } else
-            gdk_draw_drawable (priv->img, priv->gc, obj, 0, 0, 0, 0, textbox->width, textbox->height);
-            g_object_unref(obj);
-            gtk_widget_queue_resize(widget);
-        }
+    if (priv->double_size) {
+        GdkImage *img, *img2x;
+        img = gdk_drawable_get_image(obj, 0, 0, textbox->width, textbox->height);
+        img2x = create_dblsize_image(img);
+        gdk_draw_image (priv->img, priv->gc, img2x, 0, 0, 0, 0, textbox->width*2, textbox->height*2);
+        g_object_unref(img2x);
+        g_object_unref(img);
+    } else
+        gdk_draw_drawable (priv->img, priv->gc, obj, 0, 0, 0, 0, textbox->width, textbox->height);
+
+
+        g_object_unref(obj);
     }
 
     gdk_draw_drawable (widget->window, priv->gc, priv->img, 0, 0, 0, 0,
                        textbox->width*(1+priv->double_size), textbox->height*(1+priv->double_size));
-  return FALSE;
+    return FALSE;
 }
 
 static gboolean ui_skinned_textbox_button_press(GtkWidget *widget, GdkEventButton *event) {
@@ -423,7 +418,6 @@
             while (priv->offset > (priv->pixmap_width - textbox->width))
                 priv->offset = (priv->pixmap_width - textbox->width);
 
-            priv->redraw = TRUE;
             gtk_widget_queue_draw(widget);
         }
     }
@@ -440,7 +434,6 @@
     gtk_widget_set_size_request(widget, textbox->width*(1+priv->double_size), textbox->height*(1+priv->double_size));
     gtk_widget_set_uposition(widget, textbox->x*(1+priv->double_size), textbox->y*(1+priv->double_size));
 
-    priv->redraw = TRUE;
     gtk_widget_queue_draw(GTK_WIDGET(textbox));
 }
 
@@ -455,7 +448,6 @@
     if (priv->move_x || priv->move_y)
         gtk_fixed_move(GTK_FIXED(priv->fixed), GTK_WIDGET(textbox), textbox->x+priv->move_x, textbox->y+priv->move_y);
 
-    priv->redraw = TRUE;
     gtk_widget_queue_draw(GTK_WIDGET(textbox));
     g_mutex_unlock(mutex);
 }
@@ -537,7 +529,6 @@
     if (textbox->text)
         g_free(textbox->text);
 
-    priv->redraw = TRUE;
     textbox->text = str_to_utf8(text);
     priv->scroll_back = FALSE;
     gtk_widget_queue_draw(GTK_WIDGET(textbox));
@@ -627,7 +618,6 @@
                 priv->scroll_back = FALSE;
                 priv->offset += 1;
             }
-            priv->redraw=TRUE;
             gtk_widget_queue_draw(GTK_WIDGET(textbox));
         }
     }