changeset 2833:1e97a0a228b7 trunk

[svn] - reduce number of redraws
author desowin
date Wed, 13 Jun 2007 09:16:36 -0700
parents a6f541819bbc
children 0598469fe2a9
files ChangeLog src/audacious/build_stamp.c src/audacious/widgets/audacious_pbutton.c src/audacious/widgets/audacious_pbutton.h
diffstat 4 files changed, 40 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jun 11 23:32:00 2007 -0700
+++ b/ChangeLog	Wed Jun 13 09:16:36 2007 -0700
@@ -1,3 +1,10 @@
+2007-06-12 06:32:00 +0000  Ben Tucker <bnt@interchange.ubc.ca>
+  revision [4690]
+  fixed bug #972
+  trunk/src/audacious/main.c |   42 ++++++++++++++++++++++--------------------
+  1 file changed, 22 insertions(+), 20 deletions(-)
+
+
 2007-06-11 19:53:55 +0000  Tomasz Mon <desowin@atheme.org>
   revision [4688]
   - free images
--- a/src/audacious/build_stamp.c	Mon Jun 11 23:32:00 2007 -0700
+++ b/src/audacious/build_stamp.c	Wed Jun 13 09:16:36 2007 -0700
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070611-4688";
+const gchar *svn_stamp = "20070612-4690";
--- a/src/audacious/widgets/audacious_pbutton.c	Mon Jun 11 23:32:00 2007 -0700
+++ b/src/audacious/widgets/audacious_pbutton.c	Wed Jun 13 09:16:36 2007 -0700
@@ -66,6 +66,7 @@
 static gint audacious_pbutton_enter_notify(GtkWidget *widget, GdkEventCrossing *event);
 static gint audacious_pbutton_leave_notify(GtkWidget *widget, GdkEventCrossing *event);
 static void audacious_pbutton_paint(AudaciousPButton *button);
+static void audacious_pbutton_redraw(AudaciousPButton *button);
 
 GType audacious_pbutton_get_type (void) {
         static GType button_type = 0;
@@ -120,7 +121,7 @@
         klass->released = button_released;
         klass->clicked = NULL;
         klass->doubled = audacious_pbutton_toggle_doublesize;
-        klass->redraw = audacious_pbutton_paint;
+        klass->redraw = audacious_pbutton_redraw;
 
         button_signals[PRESSED] = 
                     g_signal_new ("pressed", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST,
@@ -153,6 +154,8 @@
 static void audacious_pbutton_init (AudaciousPButton *button) {
         AudaciousPButtonPrivate *priv = AUDACIOUS_PBUTTON_GET_PRIVATE (button);
         priv->image = gtk_image_new();
+        button->redraw = TRUE;
+
         g_object_set (priv->image, "visible", TRUE, NULL);
         gtk_container_add(GTK_CONTAINER(GTK_WIDGET(button)), priv->image);
 
@@ -291,6 +294,7 @@
 void _audacious_pbutton_set_pressed (AudaciousPButton *button, gboolean pressed) {
         if (pressed != button->pressed) {
                 button->pressed = pressed;
+                button->redraw = TRUE;
                 audacious_pbutton_paint(button);
         }
 }
@@ -312,6 +316,7 @@
         AudaciousPButton *button;
         if (event->button == 1) {
                 button = AUDACIOUS_PBUTTON(widget);
+                button->redraw = TRUE;
                 audacious_pbutton_released(button);
         }
 
@@ -365,6 +370,7 @@
         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;
         audacious_pbutton_paint(button);
 }
 
@@ -372,21 +378,29 @@
         GtkWidget *widget = GTK_WIDGET (button);
         AudaciousPButtonPrivate *priv = AUDACIOUS_PBUTTON_GET_PRIVATE (button);
 
-        GdkPixmap *obj;
-        obj = gdk_pixmap_new(NULL, priv->w, priv->h, gdk_rgb_get_visual()->depth);
-        skin_draw_pixmap(bmp_active_skin, obj, priv->gc, priv->skin_index2,
-                        button->pressed ? button->px : button->nx,
-                        button->pressed ? button->py : button->ny,
-                        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);
-             gtk_image_set(GTK_IMAGE(priv->image), img2x, NULL);
-             g_object_unref(img2x);
-             g_object_unref(img);
-        } else
-             gtk_image_set_from_pixmap(GTK_IMAGE(priv->image), obj, NULL);
+        if (button->redraw == TRUE) {
+            button->redraw = FALSE;
+            GdkPixmap *obj;
+            obj = gdk_pixmap_new(NULL, priv->w, priv->h, gdk_rgb_get_visual()->depth);
+            skin_draw_pixmap(bmp_active_skin, obj, priv->gc, priv->skin_index2,
+                             button->pressed ? button->px : button->nx,
+                             button->pressed ? button->py : button->ny,
+                             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);
+                 gtk_image_set(GTK_IMAGE(priv->image), img2x, NULL);
+                 g_object_unref(img2x);
+                 g_object_unref(img);
+            } else
+                 gtk_image_set_from_pixmap(GTK_IMAGE(priv->image), obj, NULL);
         g_object_unref(obj);
         gtk_widget_queue_resize(widget);
+        }
 }
+
+static void audacious_pbutton_redraw(AudaciousPButton *button) {
+        button->redraw = TRUE;
+        audacious_pbutton_paint(button);
+}
--- a/src/audacious/widgets/audacious_pbutton.h	Mon Jun 11 23:32:00 2007 -0700
+++ b/src/audacious/widgets/audacious_pbutton.h	Wed Jun 13 09:16:36 2007 -0700
@@ -59,6 +59,8 @@
 	gboolean hover : 1;
 	//Skinned part, used in ui_playlist.c
 	gint x, y, nx, ny, px, py;
+
+	gboolean redraw;
 };
 
 struct _AudaciousPButtonClass {