summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libmate-panel-applet/mate-panel-applet.c16
-rw-r--r--mate-panel/panel-background.c40
2 files changed, 45 insertions, 11 deletions
diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c
index 5efde6b3..f036b6ec 100644
--- a/libmate-panel-applet/mate-panel-applet.c
+++ b/libmate-panel-applet/mate-panel-applet.c
@@ -1776,18 +1776,30 @@ static void _mate_panel_applet_prepare_css (GtkStyleContext *context)
GtkCssProvider *provider;
provider = gtk_css_provider_new ();
+#if GTK_CHECK_VERSION (3, 18, 0)
gtk_css_provider_load_from_data (provider,
- ".mate-custom-panel-background{\n"
+ "#PanelPlug {\n"
+ " background-repeat: no-repeat;\n" /*disable in gtk theme features */
+ " background-size: cover; " /*that don't work on panel-toplevel */
+ " }\n"
+ ".mate-custom-panel-background{\n" /*prepare CSS for user set theme */
+ " background-color: rgba (0, 0, 0, 0);\n"
+ " background-image: none;\n"
+ "}",
+ -1, NULL);
+#else
+gtk_css_provider_load_from_data (provider,
+ ".mate-custom-panel-background{\n" /*prepare CSS for user set theme */
" background-color: rgba (0, 0, 0, 0);\n"
" background-image: none;\n"
"}",
-1, NULL);
+#endif
gtk_style_context_add_provider (context,
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
}
-
static void
mate_panel_applet_init (MatePanelApplet *applet)
{
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);