Community
Participate
Working Groups
The changes in: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=7c1b8eca79b80c0d72e829a1c54df2844c3fbc3c caused several problems: 1) NullPointerException when setting the color to null (should reset to default) - Run ControlExample - Check "Background Color" in the "Background Mode on Parent" group - Uncheck same box 2) Every time the code in Control.setBackgroundColor (int, GdkColor) runs a new provider is created and added to the GtkStyleContext. I suspect this is a leak and not optimal. 3) Controls are not inheriting the background image anymore since the code that was setting the alpha value was removed. - run ControlExample - Check "Background Image" in the "Background Mode on Parent" group - Select SWT.INHERIT_DEFAULT - The Button groups do not show the image background
Silenio, I start to feel lost here. So function to set color doesn't work, if I have to respect background I would have to fetch it from style and construct a css that sets it too but I'm pretty sure we would face a case where smth else settable via css (e.g. font ) is lost as we override it in general. Any ideas on how this can be resolved if the function call simply doesn't work for us?
Submited too fast. Maybe keeping a property of the full css per component which we modify and apply ?
(In reply to comment #2) > Submited too fast. > Maybe keeping a property of the full css per component which we modify and > apply ? I think that could work. We would have to stop using all gtk_widget_override_XXX in favor of our on style provider. I am not sure how we would set the font though. Serializing it in CSS seems wrong. I think we would have to write our own GtkStyleProvider instead of using GtkCssProvider. How can I reproduce the original problem you are trying to fix?
The following snippet: public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); Text text = new Text (shell, SWT.BORDER | SWT.V_SCROLL| SWT.SINGLE); text.setBackground(display.getSystemColor(SWT.COLOR_BLUE)); Rectangle clientArea = shell.getClientArea (); text.setBounds ( clientArea.x + 10, clientArea.y + 10, 200, 200); shell.open (); while (!shell.isDisposed()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); } Note on gtk 2.x the background is properly set to blue, while on gtk 3.x it's not.
Created attachment 229049 [details] work in progress The GtkEntry background-color property in CSS is used as the selection color. We can see this in the snippet by typing some test and selecting it. It seems that the only way to change the background of a GtkEntry is to change its background-image property. This patch changes the background-image with a linear gradient that is actualy a solid color. It works on Fedora 17 and 18. It has an issue on Ubuntu 12.04: the selection color also changes. The patch handles properly problems 1) and 2) of comment#0. 3) works for most widgets on Fedora 17, but fails for GtkEntry. On Fedora 18, 3) does not work at all (see bug#404163). The only pratical solution I see for bug#404163 is for us to implement our own GtkStyleProvider that has similar functionality as the gtk_widget_override_XXX functions, but also provides a way to override the background_image. If we implement our own provide, this patch will probably have to be modified. Note that the patch does not fix Spinner (need to run same code).
(In reply to comment #5) > It has an issue on Ubuntu 12.04: the selection color also changes. This is not an issue at all. I did not reliaze that I was changing the background to some color that was very close to the default selection color on Ubuntu (orange color).
See bug#404163 for more info on implementing our own GtkStyleProvider. I have cleaned up this patch and released it since it is an improvement. Fixed http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=d039075da3f3215b34e155a4c18404920facdf22