Repository navigation
[GTK4] Mirror columns, menus and expand items for right to left - #3755
Merged
Merged
Conversation
Setting the orientation of a Table, Tree, Menu or ExpandBar with items, or creating an item in a right to left one, called gtk_container_forall, which does not exist in GTK4, and threw UnsatisfiedLinkError. A GTK widget does not take the direction of its parent, so the direction has to be set on each child. Add Widget.setOrientation(long, int), which sets the direction of a widget and its descendants, walking them with gtk_container_forall on GTK3 and with the child list on GTK4. On GTK4 a menu item and a DROP_DOWN menu are not widgets, so set the direction of the custom row and of the popover instead. GTK4 also builds menu rows and popovers after the orientation is set, so give them the direction of their menu when they are built. On GTK4 also clear the cascade of a replaced submenu, as GTK3 does, so it no longer refers to the item. Part of eclipse-platform#3743. Assisted-by: Anthropic Claude Code (claude-opus-5-5)
There was a problem hiding this comment.
🔵 Needs a closer look
Dynamic GTK4 menu creation and mixed-direction submenu handling need native UI validation beyond the added regression tests.
No open issues 🎉
What changed in this PR
Fixes GTK4 right-to-left orientation handling in SWT columns, menus, and expand items, addressing part of #3743.
Changes:
- Replaces GTK3-only traversal with a platform-aware direction helper.
- Applies menu direction to dynamically created GTK4 rows and popovers, and clears replaced submenu links.
- Adds orientation regression tests for four widget types.
| File | Description |
|---|---|
| tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java | Tests orientation with tree columns. |
| tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Table.java | Tests orientation with table columns. |
| tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Menu.java | Tests orientation with menu items. |
| tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_ExpandBar.java | Tests orientation with expand items. |
| bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java | Adds platform-aware recursive direction handling. |
| bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java | Uses the shared direction helper. |
| bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java | Uses the shared direction helper. |
| bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java | Orients custom rows and clears replaced submenu links. |
| bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java | Applies direction to GTK4 menu widgets as they are built. |
| bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java | Uses the shared direction helper. |
Review effort: Balanced
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Setting the orientation of a Table, Tree, Menu or ExpandBar with items, or creating an item in a right to left one, called gtk_container_forall, which does not exist in GTK4, and threw UnsatisfiedLinkError. A GTK widget does not take the direction of its parent, so the direction has to be set on each child.
Add Widget.setOrientation(long, int), which sets the direction of a widget and its descendants, walking them with gtk_container_forall on GTK3 and with the child list on GTK4. On GTK4 a menu item and a DROP_DOWN menu are not widgets, so set the direction of the custom row and of the popover instead. GTK4 also builds menu rows and popovers after the orientation is set, so give them the direction of their menu when they are built. On GTK4 also clear the cascade of a replaced submenu, as GTK3 does, so it no longer refers to the item.
Part of #3743.
Assisted-by: Anthropic Claude Code (claude-opus-5-5)