-
Notifications
You must be signed in to change notification settings - Fork 164
[GTK] Use gtk_widget_set_visible instead of gtk_widget_hide/show #2125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[GTK] Use gtk_widget_set_visible instead of gtk_widget_hide/show #2125
Conversation
I was wondering if this is a valid approach, @akurtakov ? Also, I don't know why but the contribution headers were automatically removed, either when I saved some changes or when I ran the Maven target to build the SWT native binaries. Does this happen to you too? |
This complicates things IMO. As https://docs.gtk.org/gtk3/method.Widget.set_visible.html is available since Gtk 2.18 it should be valid to replace the calls to gtk_widget_show/hide with gtk_widget_set_visible and have things even clearer. |
You can see how straightforward the c code is at https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gtk/gtkwidget.c?ref_type=heads#L9091 so if you want to reduce deprecated usages please start replacing gtk_widget_hide/show with gtk_widget_set_visible. |
I know that the change is trivial: just renaming and adding 1 boolean parameter i.e. in GTK4:
My point was that it would be better to preserve the existing methods If this approach (centralizing the
I reduced the usage of deprecated methods from 80+ to 2 since |
BTW the next step in the migration (deprecating and removing the calls to GTK3) would be easier because one would only have to:
|
My suggestion if you want to continue that path is to put the method delegating to gtk3/4 methods in Widget.java for the sake of consistency - there are already a bunch of such "helper" methods there like gdk_event_free/gdk_event_get_surface_or_window/gdk_event_get_state/gtk_box_set_child_packing/gtk_box_pack_end/gtk_container_get_border_width_or_margin/etc. |
You can not call GTK4.gtk_widget_set_visible on GTK3 as it will be linked to gtk4.so file which will cause runtime crash. The method has to stay in GTK.java if it's to be used in both GTK3/4.
|
I know that, but I see that I was unclear so let me rephrase: when the time is proper and all code using GTK3 is to be removed from SWT (it might take years to reach that point) having all such Thank you for the hint about the helper methods on the |
I adapted the JNI generator tools when introducing a new JNI class to the Win32 implementation (#2054), as the auto-generated contributor information was basically wrong. Since this contributor information is rather unnecessary (we have the Git history for that) and cannot be properly maintained for JNI-generated classes (it will always just contain IBM) anyway, I chose to remove it. |
dd88f1f
to
d3a3696
Compare
7e46bcc
to
f8ae3d1
Compare
@akurtakov I moved the methods to |
f8ae3d1
to
bc01357
Compare
bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java
Outdated
Show resolved
Hide resolved
68351c6
to
dd02a6d
Compare
Hm, odd. There are issues with the native binaries in Linux: Error: Tests run: 140, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 5.237 s <<< FAILURE! -- in org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Combo
Error: org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Combo.test_copy -- Time elapsed: 0.645 s <<< ERROR!
java.lang.UnsatisfiedLinkError: 'void org.eclipse.swt.internal.gtk3.GTK3.gtk_editable_paste_clipboard(long)'
at org.eclipse.swt.internal.gtk3.GTK3.gtk_editable_paste_clipboard(Native Method)
at org.eclipse.swt.widgets.Combo.paste(Combo.java:1968)
at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Combo.test_copy(Test_org_eclipse_swt_widgets_Combo.java:238)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
Suppressed: java.lang.Throwable: Screenshot written to /tmp/org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Combo.test_copy.png
at org.eclipse.test.Screenshots$ScreenshotOnFailure.failed(Screenshots.java:41)
Error: org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Combo.test_paste -- Time elapsed: 0.565 s <<< ERROR!
java.lang.UnsatisfiedLinkError: 'void org.eclipse.swt.internal.gtk3.GTK3.gtk_editable_paste_clipboard(long)'
at org.eclipse.swt.internal.gtk3.GTK3.gtk_editable_paste_clipboard(Native Method)
at org.eclipse.swt.widgets.Combo.paste(Combo.java:1968)
at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Combo.test_paste(Test_org_eclipse_swt_widgets_Combo.java:503)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
Suppressed: java.lang.Throwable: Screenshot written to /tmp/org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Combo.test_paste.png
at org.eclipse.test.Screenshots$ScreenshotOnFailure.failed(Screenshots.java:41) @akurtakov Do you know what could be the issue here? |
It's because of the gtk4 label. The GH builder tries to run the tests with gtk4 in this case but this port still crashes. I'll remove the label and restart it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few cleanups more and it should be ready to go.
bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
Outdated
Show resolved
Hide resolved
As it's restart of failed builds it still does run tests on gtk4. Maybe when you fix the review issues it will start on gtk3? |
@akurtakov actually I would just keep the gtk4 label, as Jenkins run the test as well, we can at least see that GTK4 still crash (but maybe not crash that often). In any case if you add/remove the label after PR creation, one need to push new changes to the branch to take it into effect. If it makes too much trouble we can also think about changing the label to trigger this e.g. to |
@laeubi It would be best to have the gtk3 build always and the gtk4 being an extra one not showing failure (if possible) for now or with a label (ignored/for devel purposes only). |
…ipse-platform#228 Add helper methods that redirect to GTK/GTK3 in Widget for convenience. Contributes to eclipse-platform#228
dd02a6d
to
6bd572e
Compare
gtk3 +4 are always build the only difference is if tests are executed using gtk3 or gtk4. Making the gtk4 an extra one would require more work and possible duplication, and you can't easily compare it against master build.
Another approach of course would be to have that test not working on GTK4 have an |
Use the old native method as a wrapper that redirects to GTK3/4