diff options
-rw-r--r-- | applets/fish/fish.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/applets/fish/fish.c b/applets/fish/fish.c index 37fbb13d..f434f8a5 100644 --- a/applets/fish/fish.c +++ b/applets/fish/fish.c @@ -1336,9 +1336,17 @@ static gboolean load_fish_image(FishApplet* fish) return TRUE; } +static gboolean +update_pixmap_in_idle (gpointer data) +{ + update_pixmap (FISH_APPLET (data)); + return FALSE; +} + static void update_pixmap(FishApplet* fish) { GtkWidget *widget = fish->drawing_area; + GtkRequisition prev_requisition; GtkAllocation allocation; int width = -1; int height = -1; @@ -1367,6 +1375,8 @@ static void update_pixmap(FishApplet* fish) pixbuf_width = gdk_pixbuf_get_width (fish->pixbuf); pixbuf_height = gdk_pixbuf_get_height (fish->pixbuf); + prev_requisition = fish->requisition; + if (fish->orientation == MATE_PANEL_APPLET_ORIENT_UP || fish->orientation == MATE_PANEL_APPLET_ORIENT_DOWN) { height = allocation.height; @@ -1377,7 +1387,7 @@ static void update_pixmap(FishApplet* fish) if (!rotate) { width = allocation.width * fish->n_frames; height = pixbuf_height * ((gdouble) width / pixbuf_width); - fish->requisition.width = width; + fish->requisition.width = allocation.width; fish->requisition.height = height; } else { width = allocation.width; @@ -1387,9 +1397,12 @@ static void update_pixmap(FishApplet* fish) } } - gtk_widget_set_size_request (fish->drawing_area, - fish->requisition.width, - fish->requisition.height); + if (prev_requisition.width != fish->requisition.width || + prev_requisition.height != fish->requisition.height) { + gtk_widget_set_size_request (widget, + fish->requisition.width, + fish->requisition.height); + } g_assert (width != -1 && height != -1); @@ -1487,15 +1500,12 @@ static gboolean fish_applet_draw(GtkWidget* widget, cairo_t *cr, FishApplet* fis static void fish_applet_size_allocate(GtkWidget* widget, GtkAllocation* allocation, FishApplet* fish) { - GtkAllocation widget_allocation; - - gtk_widget_get_allocation (widget, &widget_allocation); - - if (widget_allocation.width != fish->prev_allocation.width || - widget_allocation.height != fish->prev_allocation.height) - update_pixmap (fish); + if (allocation->width == fish->prev_allocation.width && + allocation->height == fish->prev_allocation.height) + return; fish->prev_allocation = *allocation; + g_idle_add (update_pixmap_in_idle, fish); } static void fish_applet_realize(GtkWidget* widget, FishApplet* fish) |