feat(gtk): port the backend to gtk4#369
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
9066f6c to
05dd179
Compare
|
CI should be in better shape now. Three things were failing: the test jobs pin a 1.73 toolchain that can't parse a v4 lockfile (MSRV is 1.92 with this port, so the pin moves with it), the runners were missing libgtk-4-dev, and the clippy gate caught one lint plus examples still calling the gtk API with gtk3-era tao types; those calls are commented until a tao release on gtk4 exists. Everything green locally on the exact CI commands for Linux and macOS. The audit failure is pre-existing rather than from this PR: quick-xml < 0.41 arrives through winit -> wayland-scanner in the dev-dependencies, the advisory is dated June 29, and dev's lockfile carries the same version, so a fresh audit fails identically on dev. Nothing here can reach the patched version until wayland-scanner bumps. |
|
can you target my |
|
Done. The PR now targets feat/gtk4, with the delta in three commits on top of your branch: the port (rmakestrash-jpg's continuation adapted to current dev), the icon rendering fix, and CI. One note on the diff: dev's shared modules moved to the KeyAccelerator API after the branch split, so part of the delta is re-syncing those files with current dev. |
Builds on the feat/gtk4 backend: brings in the extension work from rmakestrash's fork and adapts everything to dev's current API, so the public surface stays what dev ships today and call sites compile unchanged. - gtk4 0.11 and png 0.18, MSRV 1.92 to match gtk4's floor - the gtk dependency is optional behind a `gtk` feature (part of default) with dev's BSD-wide target cfg; `libxdo` stays as a no-op feature name for compatibility - shared modules follow dev's current API (the KeyAccelerator line); the only changes there are the feature and target cfg gates - backend methods keep their gtk3 names and shapes; only widget types move with the toolkit (Menu to PopoverMenu, MenuBar to PopoverMenuBar, Container bounds to Widget) - predefined item accelerators are wired on gtk, matching macOS - KeyAccelerator::to_gtk covers the Key-based accelerator path Co-authored-by: amrbashir <github@amrbashir.me> Co-authored-by: rmakestrash-jpg <rmakestrash-jpg@users.noreply.github.com>
GTK4's PopoverMenu does not render icons set on a gio::MenuItem, which is why menu icons were blank on the gtk4 backend. Mark icon items with a `custom` attribute and bind an icon+label widget (a flat button carrying the item's action) via PopoverMenu/PopoverMenuBar add_child; the binding reaches nested submenu slots too. Context menus rebuild on show so label, icon, and checked-state changes are reflected instead of showing a stale first build. Verified headless (xvfb) with a menu whose icon and label are mutated live: the icon renders and updates, addressing the icon issue tracked in tauri-apps#270.
The runners need libgtk-4-dev next to the existing gtk3 packages, which stay for the tao and wry dev-dependencies. The test job's pinned toolchain moves to 1.92 to match the crate's MSRV, set via the action's toolchain input because dtolnay/rust-toolchain has no 1.92 tag.
Toward #270: the gtk4 port, targeting feat/gtk4 (#272) so the diff is what sits on top of that branch, in three commits: the port (@rmakestrash-jpg's continuation from #341 adapted to current dev), the icon rendering fix, and CI. Part of the delta is re-syncing shared modules with dev's current API (the KeyAccelerator line), which moved after the branch split.
The API: GTK4 deleted
gtk::Menu,gtk::MenuBar, andgtk::Container, so those types can't survive. Every method keeps its name and shape.gtk_context_menu()returnsgtk::PopoverMenu,gtk_menubar_for_gtk_windowreturnsOption<gtk::PopoverMenuBar>,Containerbounds widen toWidget. gtk3 call sites compile unchanged -- checked against tauri and tauri-apps/tao#1258 -- and no gtk3 process can link a gtk4 muda anyway.Icons:
PopoverMenuignores icons set on model items, so icon items get acustomslot with a real icon+label widget bound viaadd_child. Here it is in a running Tauri app on the full gtk4 stack (tao#1258 + wry gtk4 + this); label, icon, and checked changes show up live:Also fixes the macOS break from #341 (
KeyAcceleratorthroughout) and drops the ksni and sync-workflow changes per the feedback there. check, clippy, and tests green on Linux (GTK 4.18) and macOS. MSRV 1.92; CI needslibgtk-4-dev. The two changed return types are the main review question.