| Summary: | [GTK] Calling setBackground(Image) on a ToolBar will not work unless the Shell has SWT.INHERIT_DEFAULT | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Remy Suen <remy.suen> |
| Component: | SWT | Assignee: | Bogdan Gheorghe <gheorghe> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | ericwill, Kevin_McGuire, Silenio_Quarti, snorthov |
| Version: | 3.5 | Keywords: | triaged |
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux-GTK | ||
| Whiteboard: | stalebug | ||
|
Description
Remy Suen
I am having difficulties reproducing this problem in a trimmed down setting. Pure SWT code is no good. In fact, it's _worse_, setting the background image does _nothing_ to the ToolBar. I tried applying the demo's css to the pure SWT code but that didn't work either (yeah, I don't get it at all...). The root problem is probably an SWT problem (well, the fact that you can't set a background image is a problem in and of itself). I'll try cutting code from the demo until I can extract a pure SWT or pure SWT/CSS test case. Build id: I20090528-2000
The magic is in setting Shell's background mode to SWT.INHERIT_DEFAULT. When we apply the styles, we explicitly force the background image to be recalculated and set. This, however, is insufficient for whatever reasons. I guess the shell's background is not compensated for the change until it has to be (presumably when the shell's size has changed?).
Moving the bug to SWT. Please reproduce the problem with the snippet below. Unlike other bugs I have been pinging on recently, my gtk+ theme does not seem to affect this. Commenting out my theme specification in my .gtkrc-2.0 file does not make any difference.
final Display display = new Display();
Shell shell = new Shell( display );
//shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
shell.setLayout(new FillLayout());
final ToolBar toolBar = new ToolBar(shell, SWT.FLAT);
GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
toolBar.setLayoutData(data);
toolBar.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event event) {
Image originalImage = toolBar.getBackgroundImage();
Point p = toolBar.getSize();
Image bg = new Image(display, p.x, p.y);
GC gc = new GC(bg);
gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
gc.fillRectangle(0, 0, p.x, p.y);
gc.dispose();
toolBar.setBackgroundImage(bg);
if (originalImage != null) {
originalImage.dispose();
}
}
});
shell.setSize( 400, 300 );
shell.open();
while( !shell.isDisposed() ) {
if( !display.readAndDispatch() )
display.sleep();
}
display.dispose();
Not for 3.5 Eric, would you please verify this bug is fixed in Neon? Using ControlExample, it seems that a background image won't work at all, regardless of the SWT.INHERIT_* style of the parent Shell. This is true both for GTK3 and GTK2. Reproducible with master as of today, GTK3.24, and Fedora 29. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |