Skip to content

Feat/gtk4#341

Open
rmakestrash-jpg wants to merge 10 commits into
tauri-apps:feat/gtk4from
rmakestrash-jpg:feat/gtk4
Open

Feat/gtk4#341
rmakestrash-jpg wants to merge 10 commits into
tauri-apps:feat/gtk4from
rmakestrash-jpg:feat/gtk4

Conversation

@rmakestrash-jpg

Copy link
Copy Markdown

Gtk4

rmakestrash-jpg and others added 10 commits December 15, 2025 13:16
- implement PredefinedMenuItem handlers with GTK4 GActions
- add parent_menu tracking to GtkMenuChild for remove/update ops
- implement Menu::remove() and Submenu::remove() with position tracking
- implement set_text() and set_icon() with remove+reinsert pattern
- implement remove_for_gtk_window() cleanup
- fix typo: applicaiton -> application
- fix new_native_icon type (Submenu -> Icon)
- add duplicate action guards for Fullscreen/About

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add icon() getter method to MenuChild
- Populate icon bytes in IconMenuItem constructors for compat layer
- Extract PNG bytes before Icon is moved to MenuChild
- Add set_icon/set_native_icon methods to Submenu
- Store raw PNG bytes in PlatformIcon for Send+Sync safety

Part of GTK4 migration for Tauri Linux support.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add explicit lifetime annotations to Ref/RefMut returns
- Use #[cfg_attr(not(feature = "linux-ksni"), allow(dead_code))] for
  icon() and png_data() methods used only by linux-ksni feature
- Use #[cfg_attr(target_os = "linux", allow(dead_code))] for
  accelerator() which is only used on Windows/macOS
- Mark from_gtk_mnemonic() as #[cfg(test)] since it's only used in tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… support

Rename GTK's `new_menu_item()` back to `new()` to match Windows/macOS backends.
The feat/gtk4 branch had an API mismatch where normal.rs called `new_menu_item()`
but only GTK defined it - Windows/macOS still used `new()`.

This fixes Windows build error E0599: "no function or associated item named
`new_menu_item` found for struct `MenuChild`"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Match native GNOME/WebKitGTK behavior by setting has_arrow=false
on PopoverMenu widgets used for context menus.

Reference: https://bugs.webkit.org/show_bug.cgi?id=211241

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedarc-swap@​1.7.110010093100100

View full report

@amrbashir

Copy link
Copy Markdown
Member

can you cleanup the PR so it only has changes related to gtk4 migration? mainly the sync workflow file, and compatibility files/structs.

@C0D3-M4513R

C0D3-M4513R commented May 21, 2026

Copy link
Copy Markdown

Mac compilation seems to fail when using this version:

error[E0308]: mismatched types
   --> /Users/runner/.cargo/git/checkouts/muda-1cd08768e64a4ee2/350b9bd/src/items/predefined.rs:343:17
    |
342 |             PredefinedMenuItemKind::Redo => Some(Accelerator::new(
    |                                                  ---------------- arguments to this function are incorrect
343 |                 Some(CMD_OR_CTRL | Modifiers::SHIFT),
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Modifiers`, found `Option<Modifiers>`
    |
    = note: expected struct `Modifiers`
                 found enum `Option<Modifiers>`
note: associated function defined here
   --> /Users/runner/.cargo/git/checkouts/muda-1cd08768e64a4ee2/350b9bd/src/accelerator.rs:62:12
    |
 62 |     pub fn new(mut mods: Modifiers, key: Code) -> Self {
    |            ^^^ -------------------

error[E0308]: mismatched types
   --> /Users/runner/.cargo/git/checkouts/muda-1cd08768e64a4ee2/350b9bd/src/items/predefined.rs:352:17
    |
351 |             PredefinedMenuItemKind::Fullscreen => Some(Accelerator::new(
    |                                                        ---------------- arguments to this function are incorrect
352 |                 Some(Modifiers::META | Modifiers::CONTROL),
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Modifiers`, found `Option<Modifiers>`
    |
    = note: expected struct `Modifiers`
                 found enum `Option<Modifiers>`
note: associated function defined here
   --> /Users/runner/.cargo/git/checkouts/muda-1cd08768e64a4ee2/350b9bd/src/accelerator.rs:62:12
    |
 62 |     pub fn new(mut mods: Modifiers, key: Code) -> Self {
    |            ^^^ -------------------

For more information about this error, try `rustc --explain E0308`.

from: https://github.com/C0D3-M4513R/DexProtectOscRS/actions/runs/26201385288/job/77091930610
at: rmakestrash-jpg@350b9bd

johncarmack1984 added a commit to johncarmack1984/muda that referenced this pull request Jul 3, 2026
Builds on the feat/gtk4 line (tauri-apps#272 by @amrbashir, continued
in tauri-apps#341 by @rmakestrash-jpg), merged onto current dev and adapted to the
current shared API: KeyAccelerator (with a Key-based to_gtk conversion),
PredefinedMenuItemType, and predefined-item accelerators wired like the
macOS backend.

The public gtk API keeps every method name and signature shape. Only the
gtk types follow the toolkit: gtk::Menu -> gtk::PopoverMenu, gtk::MenuBar
-> gtk::PopoverMenuBar, and IsA<gtk::Container> bounds widen to
IsA<gtk::Widget>. ContextMenu::gtk_context_menu is retained, built on
demand from the default gio::Application. A consumer that compiled against
the gtk3 API compiles against this one unchanged at every call site; a
gtk3 consumer process cannot link a gtk4 muda anyway, so no working
program is broken by the type moves.

The ksni tray integration and the fork-sync workflow from tauri-apps#341 are not
included, per review feedback there. gtk4 is exposed under the existing
`gtk` feature and dependency alias, so shared code and consumers see the
same names. MSRV rises to 1.92 (gtk4-rs 0.11).
johncarmack1984 added a commit to johncarmack1984/muda that referenced this pull request Jul 3, 2026
Builds on the feat/gtk4 line (tauri-apps#272 by @amrbashir, continued
in tauri-apps#341 by @rmakestrash-jpg), merged onto current dev and adapted to the
current shared API: KeyAccelerator (with a Key-based to_gtk conversion),
PredefinedMenuItemType, and predefined-item accelerators wired like the
macOS backend.

The public gtk API keeps every method name and signature shape. Only the
gtk types follow the toolkit: gtk::Menu -> gtk::PopoverMenu, gtk::MenuBar
-> gtk::PopoverMenuBar, and IsA<gtk::Container> bounds widen to
IsA<gtk::Widget>. ContextMenu::gtk_context_menu is retained, built on
demand from the default gio::Application. A consumer that compiled against
the gtk3 API compiles against this one unchanged at every call site; a
gtk3 consumer process cannot link a gtk4 muda anyway, so no working
program is broken by the type moves.

The ksni tray integration and the fork-sync workflow from tauri-apps#341 are not
included, per review feedback there. gtk4 is exposed under the existing
`gtk` feature and dependency alias, so shared code and consumers see the
same names. MSRV rises to 1.92 (gtk4-rs 0.11).
johncarmack1984 added a commit to johncarmack1984/muda that referenced this pull request Jul 3, 2026
Builds on the feat/gtk4 line (tauri-apps#272, continued in tauri-apps#341), merged onto
current dev and adapted to the current shared API: KeyAccelerator with a
Key-based to_gtk conversion, PredefinedMenuItemType, and predefined-item
accelerators wired like the macOS backend.

The public gtk API keeps every method name and signature shape; only the
widget types follow the toolkit (PopoverMenu, PopoverMenuBar, Widget
bounds). ContextMenu::gtk_context_menu is retained, built on demand from
the default gio::Application.

Icon menu items render: gtk4's PopoverMenu ignores icons on model items,
so icon items are marked with a custom attribute and a real icon+label
widget is bound via add_child, reaching nested submenu slots. Context
menus rebuild on show so label, icon, and checked-state changes are
reflected.

gtk4 is exposed under the existing gtk feature and dependency alias.
MSRV rises to 1.92 (gtk4-rs 0.11).

Co-authored-by: amrbashir <github@amrbashir.me>
Co-authored-by: rmakestrash-jpg <rmakestrash-jpg@users.noreply.github.com>
johncarmack1984 added a commit to johncarmack1984/muda that referenced this pull request Jul 3, 2026
The gtk4 backend as inherited from the feat/gtk4 line (tauri-apps#272, continued
in tauri-apps#341): PopoverMenuBar and gio::Menu based, with accelerators, checks,
icons, context menus, and the about dialog.

Co-authored-by: amrbashir <github@amrbashir.me>
Co-authored-by: rmakestrash-jpg <rmakestrash-jpg@users.noreply.github.com>
johncarmack1984 added a commit to johncarmack1984/muda that referenced this pull request Jul 3, 2026
Builds on the feat/gtk4 line (tauri-apps#272 by @amrbashir, continued
in tauri-apps#341 by @rmakestrash-jpg), merged onto current dev and adapted to the
current shared API: KeyAccelerator (with a Key-based to_gtk conversion),
PredefinedMenuItemType, and predefined-item accelerators wired like the
macOS backend.

The public gtk API keeps every method name and signature shape. Only the
gtk types follow the toolkit: gtk::Menu -> gtk::PopoverMenu, gtk::MenuBar
-> gtk::PopoverMenuBar, and IsA<gtk::Container> bounds widen to
IsA<gtk::Widget>. ContextMenu::gtk_context_menu is retained, built on
demand from the default gio::Application. A consumer that compiled against
the gtk3 API compiles against this one unchanged at every call site; a
gtk3 consumer process cannot link a gtk4 muda anyway, so no working
program is broken by the type moves.

The ksni tray integration and the fork-sync workflow from tauri-apps#341 are not
included, per review feedback there. gtk4 is exposed under the existing
`gtk` feature and dependency alias, so shared code and consumers see the
same names. MSRV rises to 1.92 (gtk4-rs 0.11).
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.

3 participants