summaryrefslogtreecommitdiff
path: root/applets/fish
diff options
context:
space:
mode:
authorlukefromdc <[email protected]>2017-07-27 01:24:30 -0400
committerlukefromdc <[email protected]>2017-08-02 16:00:53 -0400
commit7d98669e567f164efbfefc63ac2a94a78ac5798d (patch)
tree796aa67bd9900ed39b9347b1e7175441c24728eb /applets/fish
parentbdee659c5338a846c941dc716f2df34c01d3c60d (diff)
downloadmate-panel-7d98669e567f164efbfefc63ac2a94a78ac5798d.tar.bz2
mate-panel-7d98669e567f164efbfefc63ac2a94a78ac5798d.tar.xz
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.
Diffstat (limited to 'applets/fish')
-rw-r--r--applets/fish/fish.c32
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)