Exemple #1
0
void panel_menu_bar_change_background(PanelMenuBar* menubar)
{
#if GTK_CHECK_VERSION (3, 0, 0)
	panel_background_apply_css(&menubar->priv->panel->background, GTK_WIDGET(menubar));
#else
	panel_background_change_background_on_widget(&menubar->priv->panel->background, GTK_WIDGET(menubar));
#endif
}
Exemple #2
0
static gboolean
panel_background_prepare (PanelBackground *background)
{
	PanelBackgroundType  effective_type;
	GtkWidget           *widget = NULL;

	if (!background->transformed)
		return FALSE;

	effective_type = panel_background_effective_type (background);

	switch (effective_type) {
	case PANEL_BACK_NONE:
		if (background->default_pattern) {
			/* the theme background-image pattern must be scaled by
			* the width & height of the panel so that when the
			* backing region is cleared
			* (gdk_window_clear_backing_region), the correctly
			* scaled pattern is used */
			cairo_matrix_t m;
			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", "unsupported value of 'background-image' in GTK+ theme (such as '-gtk-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);
		break;

	case PANEL_BACK_COLOR:
		if (background->has_alpha &&
		    !gdk_window_check_composited_wm(background->window))
			set_pixbuf_background (background);
		else {
			gdk_window_set_background_rgba (background->window,
			                                &background->color);
		}
		break;

	case PANEL_BACK_IMAGE:
		set_pixbuf_background (background);
		break;

	default:
		g_assert_not_reached ();
		break;
	}

	/* Panel applets may use the panel's background pixmap to
	 * decide how to draw themselves.  Therefore, we need to
	 * make sure that all drawing has been completed before
	 * the applet looks at the pixmap. */
	gdk_display_sync (gdk_window_get_display (background->window));

	gdk_window_get_user_data (GDK_WINDOW (background->window),
				  (gpointer) &widget);

	if (GTK_IS_WIDGET (widget)) {
		panel_background_apply_css (background, gtk_widget_get_toplevel(widget));
		gtk_widget_set_app_paintable(widget,TRUE);
		gtk_widget_queue_draw (widget);
	}

	background->notify_changed (background, background->user_data);

	return TRUE;
}