changeset 2965:f84d09bada0f trunk

correct _move_relative() and _resize_relative()
author Tomasz Mon <desowin@gmail.com>
date Mon, 02 Jul 2007 11:18:25 +0200
parents 7926d46872c8
children dd4a213bab66
files src/audacious/ui_playlist.c src/audacious/ui_skinned_button.c src/audacious/ui_skinned_textbox.c
diffstat 3 files changed, 71 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/ui_playlist.c	Mon Jul 02 10:28:05 2007 +0200
+++ b/src/audacious/ui_playlist.c	Mon Jul 02 11:18:25 2007 +0200
@@ -687,7 +687,12 @@
     playlistwin_set_mask();
 
     widget_list_lock(playlistwin_wlist);
-
+    GList *iter;
+    for (iter = GTK_FIXED (SKINNED_WINDOW(playlistwin)->fixed)->children; iter; iter = g_list_next (iter)) {
+         GtkFixedChild *child_data = (GtkFixedChild *) iter->data;
+         GtkWidget *child = child_data->widget;
+         g_signal_emit_by_name(child, "redraw");
+    }
     widget_list_change_pixmap(playlistwin_wlist, playlistwin_bg);
     playlistwin_draw_frame();
     widget_list_draw(playlistwin_wlist, &redraw, TRUE);
--- a/src/audacious/ui_skinned_button.c	Mon Jul 02 10:28:05 2007 +0200
+++ b/src/audacious/ui_skinned_button.c	Mon Jul 02 11:18:25 2007 +0200
@@ -27,6 +27,8 @@
 #define UI_SKINNED_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UI_TYPE_SKINNED_BUTTON, UiSkinnedButtonPrivate))
 typedef struct _UiSkinnedButtonPrivate UiSkinnedButtonPrivate;
 
+static GMutex *mutex = NULL;
+
 enum {
 	PRESSED,
 	RELEASED,
@@ -47,6 +49,7 @@
         SkinPixmapId     skin_index2;
         GtkWidget        *fixed;
         gboolean         double_size;
+        gint             move_x, move_y;
 };
 
 
@@ -173,10 +176,13 @@
 
 static void ui_skinned_button_init (UiSkinnedButton *button) {
         UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
+        mutex = g_mutex_new();
         priv->image = gtk_image_new();
         button->redraw = TRUE;
         button->inside = FALSE;
         button->type = TYPE_NOT_SET;
+        priv->move_x = 0;
+        priv->move_y = 0;
 
         g_object_set (priv->image, "visible", TRUE, NULL);
         gtk_container_add(GTK_CONTAINER(GTK_WIDGET(button)), priv->image);
@@ -327,6 +333,7 @@
 }
 
 static void ui_skinned_button_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
+        g_mutex_lock(mutex);
         UiSkinnedButton *button = UI_SKINNED_BUTTON (widget);
         UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
         GtkAllocation child_alloc;
@@ -347,6 +354,10 @@
 
         button->x = widget->allocation.x/(priv->double_size ? 2 : 1);
         button->y = widget->allocation.y/(priv->double_size ? 2 : 1);
+        priv->move_x = 0;
+        priv->move_y = 0;
+
+        g_mutex_unlock(mutex);
 }
 
 static void button_pressed(UiSkinnedButton *button) {
@@ -505,8 +516,13 @@
 }
 
 static void ui_skinned_button_redraw(UiSkinnedButton *button) {
+        g_mutex_lock(mutex);
+        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);
 }
 
 
@@ -534,7 +550,9 @@
 }
 
 void ui_skinned_button_move_relative(GtkWidget *button, gint x, gint y) {
-        UiSkinnedButton *b = UI_SKINNED_BUTTON(button);
-        UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
-        gtk_fixed_move(GTK_FIXED(priv->fixed), button, b->x+x, b->y+y);
+    g_mutex_lock(mutex);
+    UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
+    priv->move_x += x;
+    priv->move_y += y;
+    g_mutex_unlock(mutex);
 }
--- a/src/audacious/ui_skinned_textbox.c	Mon Jul 02 10:28:05 2007 +0200
+++ b/src/audacious/ui_skinned_textbox.c	Mon Jul 02 11:18:25 2007 +0200
@@ -36,6 +36,8 @@
 #define UI_SKINNED_TEXTBOX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UI_TYPE_SKINNED_TEXTBOX, UiSkinnedTextboxPrivate))
 typedef struct _UiSkinnedTextboxPrivate UiSkinnedTextboxPrivate;
 
+static GMutex *mutex = NULL;
+
 enum {
     CLICKED,
     DOUBLE_CLICKED,
@@ -65,6 +67,8 @@
     GdkPixmap        *pixmap;
     gboolean         scroll_allowed, scroll_enabled;
     gint             scroll_dummy;
+    gint             resize_width, resize_height;
+    gint             move_x, move_y;
 };
 
 
@@ -180,7 +184,12 @@
 
 static void ui_skinned_textbox_init (UiSkinnedTextbox *textbox) {
     UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE (textbox);
+    mutex = g_mutex_new();
     priv->image = gtk_image_new();
+    priv->resize_width = 0;
+    priv->resize_height = 0;
+    priv->move_x = 0;
+    priv->move_y = 0;
     textbox->redraw = TRUE;
 
     g_object_set (priv->image, "visible", TRUE, NULL);
@@ -289,6 +298,7 @@
 }
 
 static void ui_skinned_textbox_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
+    g_mutex_lock(mutex);
     UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget);
     UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE (textbox);
     GtkAllocation child_alloc;
@@ -309,14 +319,20 @@
 
     textbox->x = widget->allocation.x/(priv->double_size ? 2 : 1);
     textbox->y = widget->allocation.y/(priv->double_size ? 2 : 1);
+    priv->move_x = 0;
+    priv->move_y = 0;
 
-    if (textbox->width !=  widget->allocation.width) {
+    if (textbox->width != widget->allocation.width) {
         textbox->width = widget->allocation.width;
+        priv->resize_width = 0;
+        priv->resize_height = 0;
         if (priv->pixmap_text) g_free(priv->pixmap_text);
         priv->pixmap_text = NULL;
         priv->offset = 0;
-        ui_skinned_textbox_redraw(textbox);
+        textbox->redraw = TRUE;
+        gtk_widget_queue_draw(GTK_WIDGET(textbox));
     }
+    g_mutex_unlock(mutex);
 }
 
 static gboolean ui_skinned_textbox_textbox_press(GtkWidget *widget, GdkEventButton *event) {
@@ -374,7 +390,8 @@
             while (priv->offset > (priv->pixmap_width - textbox->width))
                 priv->offset = (priv->pixmap_width - textbox->width);
 
-            ui_skinned_textbox_redraw(textbox);
+            textbox->redraw = TRUE;
+            gtk_widget_queue_draw(widget);
         }
     }
 
@@ -442,8 +459,18 @@
 }
 
 static void ui_skinned_textbox_redraw(UiSkinnedTextbox *textbox) {
+    g_mutex_lock(mutex);
+    UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE (textbox);
+    if (priv->resize_width || priv->resize_height)
+        gtk_widget_set_size_request(GTK_WIDGET(textbox),
+                                   (textbox->width+priv->resize_width)*(1+priv->double_size),
+                                   (textbox->height+priv->resize_height)*(1+priv->double_size));
+    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);
+
     textbox->redraw = TRUE;
     gtk_widget_queue_draw(GTK_WIDGET(textbox));
+    g_mutex_unlock(mutex);
 }
 
 static gboolean ui_skinned_textbox_should_scroll(UiSkinnedTextbox *textbox) {
@@ -601,7 +628,8 @@
                 priv->scroll_back = FALSE;
                 priv->scroll_dummy = 0;
             }
-            ui_skinned_textbox_redraw(textbox);
+            textbox->redraw = TRUE;
+            gtk_widget_queue_draw(GTK_WIDGET(textbox));
         }
     }
     return TRUE;
@@ -731,7 +759,8 @@
         }
 
         priv->offset = 0;
-        ui_skinned_textbox_redraw(textbox);
+        textbox->redraw = TRUE;
+        gtk_widget_queue_draw(GTK_WIDGET(textbox));
     }
 }
 
@@ -847,12 +876,17 @@
 }
 
 void ui_skinned_textbox_move_relative(GtkWidget *widget, gint x, gint y) {
-        UiSkinnedTextbox *t = UI_SKINNED_TEXTBOX(widget);
-        UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE (widget);
-        gtk_fixed_move(GTK_FIXED(priv->fixed), widget, t->x+x, t->y+y);
+    g_mutex_lock(mutex);
+    UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE (widget);
+    priv->move_x += x;
+    priv->move_y += y;
+    g_mutex_unlock(mutex);
 }
 
 void ui_skinned_textbox_resize_relative(GtkWidget *widget, gint w, gint h) {
-        UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX(widget);
-        gtk_widget_set_size_request(widget, textbox->width+w, textbox->height+h);
+    g_mutex_lock(mutex);
+    UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE (widget);
+    priv->resize_width += w;
+    priv->resize_height += h;
+    g_mutex_unlock(mutex);
 }