Skip to content

feat: Native GTK4 modal dialog windows for PushModalAsync#9

Merged
Redth merged 1 commit intomainfrom
feature/native-modal-dialogs
Mar 1, 2026
Merged

feat: Native GTK4 modal dialog windows for PushModalAsync#9
Redth merged 1 commit intomainfrom
feature/native-modal-dialogs

Conversation

@Redth
Copy link
Copy Markdown
Owner

@Redth Redth commented Mar 1, 2026

Summary

PushModalAsync now presents pages as native GTK4 modal windows (Gtk.Window with SetModal/SetTransientFor) by default, replacing the previous inline widget-swapping behavior.

New API: GtkPage attached properties

Aligned with the macOS MacOSPage API:

Property Type Default Effect
ModalPresentationStyle GtkModalPresentationStyle Dialog Dialog (native window) vs Inline (legacy)
ModalSizesToContent bool false Measures MAUI content and fits dialog to it
ModalWidth / ModalHeight double -1 Explicit size (-1 = match parent window)
ModalMinWidth / ModalMinHeight double -1 Minimum size constraints

Usage

// Default — full-size native GTK4 dialog:
await Navigation.PushModalAsync(new MyPage());

// Custom size:
GtkPage.SetModalWidth(page, 400);
GtkPage.SetModalHeight(page, 300);
await Navigation.PushModalAsync(page);

// Sizes to content:
GtkPage.SetModalSizesToContent(page, true);
GtkPage.SetModalMinWidth(page, 250);
await Navigation.PushModalAsync(page);

// Inline (legacy behavior):
GtkPage.SetModalPresentationStyle(page, GtkModalPresentationStyle.Inline);
await Navigation.PushModalAsync(page);

Changes

  • GtkPage.cs — New attached property class with enum + sizing properties
  • WindowHandler.csOnModalPushed/OnModalPopped create native dialog windows; ComputeDialogSize handles sizing logic
  • ModalDemoPage.cs — Sample page demonstrating all modal options
  • README.md / Checklist — Updated docs

Demo

The sample app includes a "🪟 Modal Pages" entry in the sidebar with buttons for each presentation style.

PushModalAsync now presents pages as native GTK4 modal windows
(Gtk.Window with SetModal/SetTransientFor) by default, instead of
inline widget swapping within the main window.

New GtkPage attached properties (aligned with macOS MacOSPage API):
- ModalPresentationStyle: Dialog (default) or Inline (legacy)
- ModalSizesToContent: measure MAUI content and fit dialog to it
- ModalWidth/ModalHeight: explicit dialog dimensions (-1 = parent size)
- ModalMinWidth/ModalMinHeight: minimum size constraints

Includes ModalDemoPage in the sample app demonstrating all options.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Redth Redth merged commit 2ee1de8 into main Mar 1, 2026
2 checks passed
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.

1 participant