Skip to content

[GTK4] Mirror columns, menus and expand items for right to left - #3755

Merged
akurtakov merged 1 commit into
eclipse-platform:masterfrom
akurtakov:gtk4-rtl
Oct 21, 2026
Merged

akurtakov merged 1 commit into
eclipse-platform:masterfrom
akurtakov:gtk4-rtl

Conversation

@akurtakov

Copy link
Copy Markdown
Member

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)

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)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 1 026 files  ± 0   1 026 suites  ±0   1h 20m 34s ⏱️ - 6m 14s
 5 066 tests + 4   5 038 ✅ + 4     28 💤 ±0  0 ❌ ±0 
29 755 runs  +24  27 219 ✅ +24  2 536 💤 ±0  0 ❌ ±0 

Results for commit fefe242. ± Comparison against base commit ddeb80e.

@akurtakov
akurtakov merged commit 824198d into eclipse-platform:master Oct 21, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants