Skip to content

Fix GTK4 MenuItem: only create custom widgets for POP_UP menus#79

Closed
Copilot wants to merge 5 commits intomasterfrom
copilot/implement-menuitem-icon-gtk4
Closed

Fix GTK4 MenuItem: only create custom widgets for POP_UP menus#79
Copilot wants to merge 5 commits intomasterfrom
copilot/implement-menuitem-icon-gtk4

Conversation

Copy link

Copilot AI commented Feb 8, 2026

GTK4 MenuItem implementation attempted to register custom widgets with all menu types, causing assertion failures:

gtk_popover_menu_add_child: assertion 'GTK_IS_POPOVER_MENU (popover)' failed

Root Cause

GTK4 menu handles vary by style:

  • SWT.POP_UPGtkPopoverMenu (widget)
  • SWT.BARGtkPopoverMenuBar (different widget type)
  • SWT.DROP_DOWNGMenuModel (not a widget)

Only GtkPopoverMenu accepts gtk_popover_menu_add_child().

Changes

MenuItem.java line ~315: Gate custom widget creation on parent menu style:

// Before: created for all non-separator items
if ((style & SWT.SEPARATOR) == 0) {
    // Create custom widgets...
    GTK4.gtk_popover_menu_add_child(parent.handle, buttonHandle, idBytes);  // Crashes for BAR/DROP_DOWN
}

// After: only for POP_UP menus
if ((style & SWT.SEPARATOR) == 0 && (parent.style & SWT.POP_UP) != 0) {
    // Create custom widgets...
    GTK4.gtk_popover_menu_add_child(parent.handle, buttonHandle, idBytes);  // parent.handle guaranteed to be PopoverMenu
}

Scope

Icon support now works for popup/context menus without errors. Menu bar and submenu icons remain unsupported (GTK4 architectural constraint - no widget handle access).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repo.eclipse.org
    • Triggering command: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/21.0.10-7/x64/bin/java /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/21.0.10-7/x64/bin/java --enable-native-access=ALL-UNNAMED -classpath /opt/hostedtoolcache/maven/3.9.12/x64/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/opt/hostedtoolcache/maven/3.9.12/x64/bin/m2.conf -Dmaven.home=/opt/hostedtoolcache/maven/3.9.12/x64 -Dlibrary.jansi.path=/opt/hostedtoolcache/maven/3.9.12/x64/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/eclipse.platform.swt/eclipse.platform.swt org.codehaus.plexus.classworlds.launcher.Launcher clean compile -DskipTests -pl bundles/org.eclipse.swt (dns block)
    • Triggering command: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/21.0.10-7/x64/bin/java /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/21.0.10-7/x64/bin/java --enable-native-access=ALL-UNNAMED -classpath /opt/hostedtoolcache/maven/3.9.12/x64/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/opt/hostedtoolcache/maven/3.9.12/x64/bin/m2.conf -Dmaven.home=/opt/hostedtoolcache/maven/3.9.12/x64 -Dlibrary.jansi.path=/opt/hostedtoolcache/maven/3.9.12/x64/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/eclipse.platform.swt/eclipse.platform.swt org.codehaus.plexus.classworlds.launcher.Launcher clean install -DskipTests -pl bundles/org.eclipse.swt,binaries/org.eclipse.swt.gtk.linux.x86_64 -am (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 8, 2026 16:55
Co-authored-by: akurtakov <574788+akurtakov@users.noreply.github.com>
Co-authored-by: akurtakov <574788+akurtakov@users.noreply.github.com>
Copilot AI changed the title [WIP] Add implementation of SWT MenuItem with icon on GTK 4 Implement MenuItem icon support for GTK4 using custom widgets Feb 8, 2026
Copilot AI requested a review from akurtakov February 8, 2026 17:02
Co-authored-by: akurtakov <574788+akurtakov@users.noreply.github.com>
Copilot AI changed the title Implement MenuItem icon support for GTK4 using custom widgets Fix GTK4 MenuItem: only create custom widgets for POP_UP menus Feb 9, 2026
@akurtakov akurtakov closed this Feb 9, 2026
@akurtakov akurtakov deleted the copilot/implement-menuitem-icon-gtk4 branch February 9, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants