Community
Participate
Working Groups
The macro used upto now is deprecated and removed in GTK 3. Commit/patch: http://fedorapeople.org/gitweb?p=akurtakov/public_git/eclipse.platform.swt.git;a=commit;h=dedb20194a68795bd0f8c3b0e415ba018125408d
if (OS.VERSION(2, 20, 0) >= OS.GTK_VERSION) { hasDefault = OS.gtk_widget_has_default(handle); It looks to me like the version check needs to be reversed here. Also, the check can be modified to invoke gtk_widget_has_default() from GTK version 2.18 and above instead of version 2.20 as this function to replace the macro is available from GTK version 2.18 itself. Thanks!
(In reply to comment #1) > if (OS.VERSION(2, 20, 0) >= OS.GTK_VERSION) { > hasDefault = OS.gtk_widget_has_default(handle); > > It looks to me like the version check needs to be reversed here. > > Also, the check can be modified to invoke gtk_widget_has_default() from GTK > version 2.18 and above instead of version 2.20 as this function to replace the > macro is available from GTK version 2.18 itself. > > Thanks! Why should it be reversed ? I used the deprecation version of GTK_WIDGET_HAS_DEFAULT as the check version but I can change it to 2.18 if you prefer. But please explain the reversed I don't understand it.
(In reply to comment #2) > > Why should it be reversed ? The current if condition implies that gtk_widget_has_default() will be invoked when OS.GTK_VERSION <= OS.VERSION(2, 20, 0) and GTK_WIDGET_HAS_DEFAULT() macro will be invoked otherwise. Isn't that the exact opposite of what we intend to do here? Also, I do prefer changing the version to 2.18.
(In reply to comment #3) > (In reply to comment #2) > > > > Why should it be reversed ? > > The current if condition implies that gtk_widget_has_default() will be invoked > when OS.GTK_VERSION <= OS.VERSION(2, 20, 0) and GTK_WIDGET_HAS_DEFAULT() macro > will be invoked otherwise. Isn't that the exact opposite of what we intend to > do here? > > Also, I do prefer changing the version to 2.18. Well, the current code implies that gtk_widget_has_default will be called when GTK is newer than version 2.20 and this is exactly what it's intended to be.
(In reply to comment #4) > Well, the current code implies that gtk_widget_has_default will be called when > GTK is newer than version 2.20 and this is exactly what it's intended to be. I just took a look at the patch again and I still think the if check is wrong. If I assume my GTK version lets say is 2.24, the condition if (OS.VERSION(2, 20, 0) >= OS.GTK_VERSION) will fail because it effectively means 2.20 >= 2.24, implying that the else case of GTK_WIDGET_HAS_DEFAULT() macro gets invoked then. Am I making sense?
Ah sorry, I'm stupid today :). Will redo it on monday.
Ok, modified patch. http://fedorapeople.org/gitweb?p=akurtakov/public_git/eclipse.platform.swt.git;a=commit;h=c8a188e89cb18f89d56079c805fd32a9da717664
(In reply to comment #7) > Ok, modified patch. > > http://fedorapeople.org/gitweb?p=akurtakov/public_git/eclipse.platform.swt.git;a=commit;h=c8a188e89cb18f89d56079c805fd32a9da717664 Looks good to me, thanks for the modified patch! Silenio will probably push the changes soon.
The native GTK_WIDGET_HAS_DEFAULT cannot be dynamic for the same reason of https://bugs.eclipse.org/bugs/show_bug.cgi?id=374994#c1.
(In reply to comment #9) > The native GTK_WIDGET_HAS_DEFAULT cannot be dynamic for the same reason of > https://bugs.eclipse.org/bugs/show_bug.cgi?id=374994#c1. But GTK_WIDGET_HAS_DEFAULT is provided by libgtk so it's not exactly the same case. I have explicitly tested it and the dynamic case works for me too, when in the case you refer to I was getting crashes. The macro in question comes from gtkwidget.h so even if we can not make it dynamic we can not use the same approach as in the other bug. cat /usr/include/gtk-2.0/gtk/gtkwidget.h|grep GTK_WIDGET_HAS_DEFAULT * GTK_WIDGET_HAS_DEFAULT: #define GTK_WIDGET_HAS_DEFAULT(wid) ((GTK_WIDGET_FLAGS (wid) & GTK_HAS_DEFAULT) != 0)
GTK_WIDGET_HAS_DEFAULT is a macro, it cannot be look up dynamically. The function pointer is never found and the native always return false silently. Would putting something like this in os_custom.h work when compiling against GTK 3? #ifndef GTK_WIDGET_HAS_DEFAULT #define GTK_WIDGET_HAS_DEFAULT(arg0) 0 #endif
*** Bug 384749 has been marked as a duplicate of this bug. ***
My patch has #define GTK_WIDGET_HAS_DEFAULT as pointed by Silenio, feel free to use it, if you like: http://fedorapeople.org/gitweb?p=aspektor/public_git/eclipse.platform.swt.git;a=commit;h=ce3fc00e298b9fc1bb0b1a142f5a8d8f283e2572
Pushed to eclipse.org http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=2054549f26c019ff25e04cae93704a55f48e14ee Note that I fixed the formatting (missing a few spaces) to match the surronding code. http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=b53743a0bde0bb268ed9de951eee883e9f924c4c
Thank you for fixing formatting Silenio, I will pay more attention to spaces and tabs in my future patches. Regards, Anatoly