Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 404163 - [GTK3] setBackgroundImage not working on Fedora 18
Summary: [GTK3] setBackgroundImage not working on Fedora 18
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.3   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 4.3 M7   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 340067
  Show dependency tree
 
Reported: 2013-03-22 11:59 EDT by Silenio Quarti CLA
Modified: 2013-05-24 09:25 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Silenio Quarti CLA 2013-03-22 11:59:27 EDT
This snippet fails on GTK3 when running on Fedora 18.

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.*;


public class Test {
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);

	shell.setBackgroundImage(display.getSystemImage(SWT.ICON_ERROR));
	
	Composite composite = new Composite(shell, SWT.BORDER);
	composite.setBounds(30, 20, 200, 200);
	composite.setBackgroundImage(display.getSystemImage(SWT.ICON_WARNING));
	

	shell.setSize(300, 300);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
}
Comment 1 Silenio Quarti CLA 2013-04-03 10:45:33 EDT
This also fails on Ubuntu 12.10.

I have investigated whether we could have our own implementation of GtkStyleProvider and use it instead of the gtk_widget_override_XXX in order to set color/background-color/font and background-image. There is no API to override the background-image in the GtkModifierStyle and using the GtkCssProvider is problematic because we would have to serialize fonts in CSS strings and in-memory images would have to be saved to disk to let the theming engine load it.

It turns out that implementing our own GtkStyleProvider (so that you could override background-image as well) is impossible using only public API.  In order to proper implement a GtkStyleProvider, we would need to add the GtkStyleProviderPrivate interface which is not available.

This patch fixes the problem by drawing the background image ourselves. Note that it also draws the background color of canvas when it is transparent.  This is done to solve the fact that the preferences window is white instead of grey.

Fixed

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=fb6bc4c89147f7b506bef4e864f80773bf8c749f