Community
Participate
Working Groups
Steps to reproduce: 1. Open Eclipse with GTK+3 2. Create Sample project with sample class 3. Run it Look into Console window - Terminate button is not faded even when the execution is over.
Snippet that shows the issue: (Run with both SWT_GTK3 = TRUE and SWT_GTK3 = FALSE and you will see the difference how disabled buttons are represented) public class Snippet47 { public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); Image image = new Image (display, 20, 20); Color color = display.getSystemColor (SWT.COLOR_BLUE); GC gc = new GC (image); gc.setBackground (color); gc.fillRectangle (image.getBounds ()); gc.dispose (); Image disabledImage = new Image (display, 20, 20); color = display.getSystemColor (SWT.COLOR_GREEN); gc = new GC (disabledImage); gc.setBackground (color); gc.fillRectangle (disabledImage.getBounds ()); gc.dispose (); Image hotImage = new Image (display, 20, 20); color = display.getSystemColor (SWT.COLOR_RED); gc = new GC (hotImage); gc.setBackground (color); gc.fillRectangle (hotImage.getBounds ()); gc.dispose (); ToolBar bar = new ToolBar (shell, SWT.BORDER | SWT.FLAT); Rectangle clientArea = shell.getClientArea (); bar.setBounds (clientArea.x, clientArea.y, 200, 32); for (int i=0; i<12; i++) { ToolItem item = new ToolItem (bar, 0); item.setImage (image); item.setDisabledImage (disabledImage); item.setHotImage (hotImage); if (i % 3 == 0) item.setEnabled (false); } shell.open (); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } image.dispose (); disabledImage.dispose (); hotImage.dispose (); display.dispose (); } }
Created attachment 231109 [details] Proposed fix It looks like this problem is caused by a GTK+ bug. I have created the above patch based on the workaround described in this forum post - http://www.gtkforums.com/viewtopic.php?f=3&t=178411 I have done some testing and it is working well for me. I'll try to improve the patch with some documentation and I also need to add handling for setHotImage () and setDisabledImage (). Silenio, kindly let me know what you think of these changes. Thanks!
(In reply to comment #2) > I have done some testing and it is working well for me. I'll try to improve > the patch with some documentation and I also need to add handling for > setHotImage () and setDisabledImage (). The patch works, but I am afraid it is leaking all images set in tool items. We would need to find a way of removing the buildin icon when it is not necessary anymore. I quickly searched and I could not find any way.
After consulting with GTK developers we need to use the GIcon functions in order to enable shading. Patch pushed to master http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=c5d929b161f90dfb73413ce6147670bc8d05fb20
These changes cause compilation errors while building are libraries. GIcon is not available on RHEL 5 (GTK 2.10). I think we can just remove the cast since the native is dynamic. [sshexec] gcc -O -Wall -DSWT_VERSION=4402 -DLINUX -DGTK -I/bluebird/teamswt/swt-builddir/JDKs/x86/ibm-java2-i386-50/include -I/bluebird/teamswt/swt-builddir/JDKs/x86/ibm-java2-i386-50/include/linux -fPIC -m32 `pkg-config --cflags gtk+-2.0` -c os.c [sshexec] os.c: In function 'Java_org_eclipse_swt_internal_gtk_OS__1gtk_1image_1set_1from_1gicon': [sshexec] [sshexec] os.c:11335: error: expected declaration specifiers or '...' before 'GIcon' [sshexec] [sshexec] os.c:11335: error: 'GIcon' undeclared (first use in this function) [sshexec] [sshexec] os.c:11335: error: (Each undeclared identifier is reported only once [sshexec] [sshexec] os.c:11335: error: for each function it appears in.) [sshexec] [sshexec] os.c:11335: error: expected expression before ')' token [sshexec] [sshexec] make: *** [os.o] Error 1
Took a closer look at the patch. We are passing a GdkPixbuf to a function that takes a GIcon. How does that work? Does gtk_image_set_from_gicon() converts the parameter?
GIcon is an interface and GdkPixbuf implements it so we actually pass GIcon instance to the function. The cast to GIcon is dropped to fix compilation with GTK 2.10.
Marking as fixed.
(In reply to comment #7) > GIcon is an interface and GdkPixbuf implements it so we actually pass GIcon > instance to the function. The cast to GIcon is dropped to fix compilation > with GTK 2.10. Nice.
Silenio, Ok to backport this for 4.3.1 too?
Reopened to include in 4.3.1. We usually only back port critical bugs like crashes and serious bugs that affect the usability of Eclipse. I do not think this is the case for this bug, but it certainly improves the l&f of the GTK 3 port without affecting the GTK2 port. +1
Backported 9e1e131..af26fb4 R4_3_maintenance -> R4_3_maintenance