summaryrefslogtreecommitdiff
path: root/mate-panel
diff options
context:
space:
mode:
authorlukefromdc <[email protected]>2017-06-28 01:14:26 -0400
committerlukefromdc <[email protected]>2017-07-02 13:35:19 -0400
commita1445bc208e22260c27ce67ad4ebce6040ff5a3c (patch)
tree06a244b6f33eb854b6a010362c89379b92abef2e /mate-panel
parent03bf5cecd39646e0e7c19af097d5fc64b05c40d5 (diff)
downloadmate-panel-a1445bc208e22260c27ce67ad4ebce6040ff5a3c.tar.bz2
mate-panel-a1445bc208e22260c27ce67ad4ebce6040ff5a3c.tar.xz
Make panel image background in GTK theme work again
*Support both url(image file) and gradient image panel backgrounds in the GTK theme. *Scaling by 1.0/panel dimensions should never have worked, doesn't now. Get the actual image dimensions instead *Background: disable in PanelPlug features that don't work on panel toplevel *panel-background: catch error on unsupported image such as -gtk-gradient An image bg set in the GTK theme needs to be a file or a css gradient as the older -gtk-gradient does not return a valid cairo_pattern_t when read directly *GTK 3.14,3.16: fix theme bg image render in plugs PanelPlug rendering is handled differently with GTK 3.14 and 3.16 than later versions. Handle this so all supported image backgrounds in GTK themes render properly in all supported GTK versions
Diffstat (limited to 'mate-panel')
-rw-r--r--mate-panel/panel-background.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/mate-panel/panel-background.c b/mate-panel/panel-background.c
index 11812faa..1b388f92 100644
--- a/mate-panel/panel-background.c
+++ b/mate-panel/panel-background.c
@@ -109,15 +109,37 @@ panel_background_prepare (PanelBackground *background)
* (gdk_window_clear_backing_region), the correctly
* scaled pattern is used */
cairo_matrix_t m;
-
- cairo_matrix_init_translate (&m, 0, 0);
- cairo_matrix_scale (&m,
- 1.0 / background->region.width,
- 1.0 / background->region.height);
- cairo_pattern_set_matrix (background->default_pattern, &m);
-
- gdk_window_set_background_pattern (background->window,
- background->default_pattern);
+ cairo_surface_t *surface;
+ double width, height;
+
+ surface = NULL;
+ width = 1.0;
+ height = 1.0;
+ cairo_pattern_get_surface(background->default_pattern, &surface);
+ /* catch invalid images (e.g. -gtk-gradient) before scaling and rendering */
+ if (surface != NULL ){
+ cairo_surface_reference(surface);
+ width = cairo_image_surface_get_width (surface);
+ height = cairo_image_surface_get_height (surface);
+ cairo_matrix_init_translate (&m, 0, 0);
+ cairo_matrix_scale (&m,
+ width / background->region.width,
+ height / background->region.height);
+ cairo_pattern_set_matrix (background->default_pattern, &m);
+
+ gdk_window_set_background_pattern (background->window,
+ background->default_pattern);
+ }
+ else {
+ g_warning ("%s\n",
+ ("unsupported panel image background such as -gtk-gradient"));
+ g_warning ("%s\n",
+ ("use an image file or a standard css gradient"));
+ /* use any background color that has been set if image is invalid */
+ gdk_window_set_background_rgba (
+ background->window, &background->default_color);
+ }
+ cairo_surface_destroy(surface);
} else
gdk_window_set_background_rgba (
background->window, &background->default_color);