From 7d98669e567f164efbfefc63ac2a94a78ac5798d Mon Sep 17 00:00:00 2001 From: lukefromdc Date: Thu, 27 Jul 2017 01:24:30 -0400 Subject: fish: fix applet opening as thin line when built in-process Based on part of https://github.com/GNOME/gnome-panel/commit/f0f91805a1e39543487cfe67dfc47129e45e76f3 There was an issue where Wanda appeared as a thin line. The reason is that calling gtk_widget_set_size_request() in a size_allocate() handler doesn't work. So use an idle function for this. Also, only call gtk_widget_set_size_request() if really needed. --- applets/fish/fish.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'applets/fish') 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) -- cgit v1.2.1