diff --git a/Sources/Adwaita/View/Dialogs/Dialog.swift b/Sources/Adwaita/View/Dialogs/Dialog.swift new file mode 100644 index 0000000..9ac2616 --- /dev/null +++ b/Sources/Adwaita/View/Dialogs/Dialog.swift @@ -0,0 +1,97 @@ +// +// Dialog.swift +// Adwaita +// +// Created by david-swift on 20.03.24. +// + +import CAdw + +/// The dialog widget. +struct Dialog: Widget { + + /// Whether the dialog is visible. + @Binding var visible: Bool + /// The dialog's title. + var title: String? + /// The wrapped view. + var child: View + /// The content of the dialog. + var content: Body + + /// The ID for the dialog's storage. + let dialogID = "dialog" + /// The ID for the content's storage. + let contentID = "content" + + /// Get the container of the child. + /// - Parameter modifiers: Modify views before being updated. + /// - Returns: The view storage. + func container(modifiers: [(View) -> View]) -> ViewStorage { + let storage = child.storage(modifiers: modifiers) + update(storage, modifiers: modifiers, updateProperties: true) + return storage + } + + /// Update the view storage of the child, dialog, and dialog content. + /// - Parameters: + /// - storage: The view storage. + /// - modifiers: Modify views before being updated. + /// - updateProperties: Whether to update properties. + func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { + child.widget(modifiers: modifiers).update(storage, modifiers: modifiers, updateProperties: updateProperties) + if let storage = storage.content[contentID]?.first as? ViewStorage { + content + .widget(modifiers: modifiers) + .update(storage, modifiers: modifiers, updateProperties: updateProperties) + } + guard updateProperties else { + return + } + if visible { + if storage.content[dialogID]?.first == nil { + createDialog(storage: storage, modifiers: modifiers) + adw_dialog_present(storage.content[dialogID]?.first?.pointer?.cast(), storage.pointer?.cast()) + } + adw_dialog_set_title(storage.content[dialogID]?.first?.pointer?.cast(), title ?? "") + } else { + if storage.content[dialogID]?.first != nil { + adw_dialog_close(storage.content[dialogID]?.first?.pointer?.cast()) + } + } + } + + /// Create a new instance of the dialog. + /// - Parameters: + /// - storage: The wrapped view's storage. + /// - modifiers: The view modifiers. + func createDialog(storage: ViewStorage, modifiers: [(View) -> View]) { + let pointer = adw_dialog_new() + let dialog = ViewStorage(pointer?.opaque()) + storage.content[dialogID] = [dialog] + let contentStorage = content.widget(modifiers: modifiers).storage(modifiers: modifiers) + adw_dialog_set_child(pointer, contentStorage.pointer?.cast()) + storage.content[contentID] = [contentStorage] + dialog.connectSignal(name: "closed") { + storage.content[dialogID] = [] + storage.content[contentID] = [] + if visible { + visible = false + } + } + } + +} + +extension View { + + /// Add a dialog to the parent window. + /// - Parameters: + /// - visible: Whether the dialog is presented. + /// - title: The dialog's title. + /// - content: The dialog's content. + public func dialog(visible: Binding, title: String? = nil, @ViewBuilder content: () -> Body) -> View { + Dialog(visible: visible, title: title, child: self, content: content()) + } + +} diff --git a/Sources/Adwaita/View/Generated/ActionRow.swift b/Sources/Adwaita/View/Generated/ActionRow.swift index c30569b..ea0c1a0 100644 --- a/Sources/Adwaita/View/Generated/ActionRow.swift +++ b/Sources/Adwaita/View/Generated/ActionRow.swift @@ -2,7 +2,7 @@ // ActionRow.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/Avatar.swift b/Sources/Adwaita/View/Generated/Avatar.swift index 5ce8cd1..22e234c 100644 --- a/Sources/Adwaita/View/Generated/Avatar.swift +++ b/Sources/Adwaita/View/Generated/Avatar.swift @@ -2,7 +2,7 @@ // Avatar.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/Banner.swift b/Sources/Adwaita/View/Generated/Banner.swift index 5bf5aa7..dd05cd1 100644 --- a/Sources/Adwaita/View/Generated/Banner.swift +++ b/Sources/Adwaita/View/Generated/Banner.swift @@ -2,7 +2,7 @@ // Banner.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/Bin.swift b/Sources/Adwaita/View/Generated/Bin.swift index 6b9939d..c6743ad 100644 --- a/Sources/Adwaita/View/Generated/Bin.swift +++ b/Sources/Adwaita/View/Generated/Bin.swift @@ -2,7 +2,7 @@ // Bin.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/Box.swift b/Sources/Adwaita/View/Generated/Box.swift index 9f4b226..59e73c4 100644 --- a/Sources/Adwaita/View/Generated/Box.swift +++ b/Sources/Adwaita/View/Generated/Box.swift @@ -2,7 +2,7 @@ // Box.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/Button.swift b/Sources/Adwaita/View/Generated/Button.swift index 0105efa..16ad40d 100644 --- a/Sources/Adwaita/View/Generated/Button.swift +++ b/Sources/Adwaita/View/Generated/Button.swift @@ -2,7 +2,7 @@ // Button.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/ButtonContent.swift b/Sources/Adwaita/View/Generated/ButtonContent.swift index c9ad0b5..6c8c0fc 100644 --- a/Sources/Adwaita/View/Generated/ButtonContent.swift +++ b/Sources/Adwaita/View/Generated/ButtonContent.swift @@ -2,7 +2,7 @@ // ButtonContent.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw @@ -29,12 +29,13 @@ import LevenshteinTransformations /// /// ``` /// buttoncontent +/// ╰── box /// ├── image /// ╰── label /// ``` /// -/// `AdwButtonContent`'s CSS node is called `buttoncontent`. It contains the -/// subnodes `image` and `label`. +/// `AdwButtonContent`'s CSS node is called `buttoncontent`. It contains a `box` +/// subnode that serves as a container for the `image` and `label` nodes. /// /// When inside a `GtkButton` or `AdwSplitButton`, the button will receive the /// `.image-text-button` style class. When inside a `GtkMenuButton`, the diff --git a/Sources/Adwaita/View/Generated/Carousel.swift b/Sources/Adwaita/View/Generated/Carousel.swift index b0009bf..8c3dbed 100644 --- a/Sources/Adwaita/View/Generated/Carousel.swift +++ b/Sources/Adwaita/View/Generated/Carousel.swift @@ -2,7 +2,7 @@ // Carousel.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw @@ -56,8 +56,10 @@ public struct Carousel: Widget where Element: Identifiable { /// This signal is emitted after a page has been changed. /// /// It can be used to implement "infinite scrolling" by amending the pages - /// after every scroll. Note that an empty carousel is indicated by - /// `(int)index == -1`. + /// after every scroll. + /// + /// ::: note + /// An empty carousel is indicated by `(int)index == -1`. var pageChanged: (() -> Void)? /// The dynamic widget elements. var elements: [Element] @@ -219,8 +221,10 @@ public struct Carousel: Widget where Element: Identifiable { /// This signal is emitted after a page has been changed. /// /// It can be used to implement "infinite scrolling" by amending the pages - /// after every scroll. Note that an empty carousel is indicated by - /// `(int)index == -1`. + /// after every scroll. + /// + /// ::: note + /// An empty carousel is indicated by `(int)index == -1`. public func pageChanged(_ pageChanged: @escaping () -> Void) -> Self { var newSelf = self newSelf.pageChanged = pageChanged diff --git a/Sources/Adwaita/View/Generated/CenterBox.swift b/Sources/Adwaita/View/Generated/CenterBox.swift index cccc008..6327756 100644 --- a/Sources/Adwaita/View/Generated/CenterBox.swift +++ b/Sources/Adwaita/View/Generated/CenterBox.swift @@ -2,7 +2,7 @@ // CenterBox.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/CheckButton.swift b/Sources/Adwaita/View/Generated/CheckButton.swift index ec5484b..69a22ce 100644 --- a/Sources/Adwaita/View/Generated/CheckButton.swift +++ b/Sources/Adwaita/View/Generated/CheckButton.swift @@ -2,7 +2,7 @@ // CheckButton.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/Clamp.swift b/Sources/Adwaita/View/Generated/Clamp.swift index 7d724c6..952a246 100644 --- a/Sources/Adwaita/View/Generated/Clamp.swift +++ b/Sources/Adwaita/View/Generated/Clamp.swift @@ -2,7 +2,7 @@ // Clamp.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/ComboRow.swift b/Sources/Adwaita/View/Generated/ComboRow.swift index 4b4aa8c..9c4c480 100644 --- a/Sources/Adwaita/View/Generated/ComboRow.swift +++ b/Sources/Adwaita/View/Generated/ComboRow.swift @@ -2,7 +2,7 @@ // ComboRow.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/EntryRow.swift b/Sources/Adwaita/View/Generated/EntryRow.swift index 47e57eb..9a369a7 100644 --- a/Sources/Adwaita/View/Generated/EntryRow.swift +++ b/Sources/Adwaita/View/Generated/EntryRow.swift @@ -2,7 +2,7 @@ // EntryRow.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw @@ -62,6 +62,8 @@ public struct EntryRow: Widget { /// operation, e.g. network activity, to avoid triggering it after typing every /// character. var showApplyButton: Bool? + /// The length of the text in the entry row. + var textLength: UInt? /// The title of the preference represented by this row. /// /// The title is interpreted as Pango markup unless @@ -226,6 +228,14 @@ public struct EntryRow: Widget { return newSelf } + /// The length of the text in the entry row. + public func textLength(_ textLength: UInt?) -> Self { + var newSelf = self + newSelf.textLength = textLength + + return newSelf + } + /// The title of the preference represented by this row. /// /// The title is interpreted as Pango markup unless diff --git a/Sources/Adwaita/View/Generated/ExpanderRow.swift b/Sources/Adwaita/View/Generated/ExpanderRow.swift index baa78c1..152b0e7 100644 --- a/Sources/Adwaita/View/Generated/ExpanderRow.swift +++ b/Sources/Adwaita/View/Generated/ExpanderRow.swift @@ -2,7 +2,7 @@ // ExpanderRow.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/FlowBox.swift b/Sources/Adwaita/View/Generated/FlowBox.swift index 643b226..020eb84 100644 --- a/Sources/Adwaita/View/Generated/FlowBox.swift +++ b/Sources/Adwaita/View/Generated/FlowBox.swift @@ -2,7 +2,7 @@ // FlowBox.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/HeaderBar.swift b/Sources/Adwaita/View/Generated/HeaderBar.swift index ccde274..779aeaa 100644 --- a/Sources/Adwaita/View/Generated/HeaderBar.swift +++ b/Sources/Adwaita/View/Generated/HeaderBar.swift @@ -2,7 +2,7 @@ // HeaderBar.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw @@ -16,6 +16,15 @@ import LevenshteinTransformations /// features compared to it. Refer to `GtkHeaderBar` for details. It is typically /// used as a top bar within [class@ToolbarView]. /// +/// ## Dialog Integration +/// +/// When placed inside an [class@Dialog], `AdwHeaderBar` will display the dialog +/// title intead of window title. It will also adjust the decoration layout to +/// ensure it always has a close button and nothing else. Set +/// [property@HeaderBar:show-start-title-buttons] and +/// [property@HeaderBar:show-end-title-buttons] to `FALSE` to remove it if it's +/// unwanted. +/// /// ## Navigation View Integration /// /// When placed inside an [class@NavigationPage], `AdwHeaderBar` will display the @@ -24,9 +33,10 @@ import LevenshteinTransformations /// When used together with [class@NavigationView] or [class@NavigationSplitView], /// it will also display a back button that can be used to go back to the previous /// page. The button also has a context menu, allowing to pop multiple pages at -/// once, potentially across multiple navigation views. In rare scenarios, set -/// [property@HeaderBar:show-back-button] to `FALSE` to disable the back button -/// if it's unwanted (e.g. in an extra header bar on the same page). +/// once, potentially across multiple navigation views. +/// +/// Set [property@HeaderBar:show-back-button] to `FALSE` to disable this behavior +/// in rare scenarios where it's unwanted. /// /// ## Split View Integration /// diff --git a/Sources/Adwaita/View/Generated/Label.swift b/Sources/Adwaita/View/Generated/Label.swift index 8c1bed2..d84208a 100644 --- a/Sources/Adwaita/View/Generated/Label.swift +++ b/Sources/Adwaita/View/Generated/Label.swift @@ -2,7 +2,7 @@ // Label.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw @@ -15,7 +15,7 @@ import LevenshteinTransformations /// /// ![An example GtkLabel](label.png) /// -/// # CSS nodes +/// ## CSS nodes /// /// ``` /// label @@ -36,7 +36,7 @@ import LevenshteinTransformations /// carry the link or visited state depending on whether they have been /// visited. In this case, label node also gets a .link style class. /// -/// # GtkLabel as GtkBuildable +/// ## GtkLabel as GtkBuildable /// /// The GtkLabel implementation of the GtkBuildable interface supports a /// custom `` element, which supports any number of `` @@ -45,6 +45,7 @@ import LevenshteinTransformations /// values for this label. /// /// An example of a UI definition fragment specifying Pango attributes: +/// /// ```xml /// /// ``` @@ -55,11 +56,11 @@ import LevenshteinTransformations /// sense with translatable attributes. Use markup embedded in the translatable /// content instead. /// -/// # Accessibility +/// ## Accessibility /// /// `GtkLabel` uses the %GTK_ACCESSIBLE_ROLE_LABEL role. /// -/// # Mnemonics +/// ## Mnemonics /// /// Labels may contain “mnemonics”. Mnemonics are underlined characters in the /// label, used for keyboard navigation. Mnemonics are created by providing a @@ -100,7 +101,7 @@ import LevenshteinTransformations /// gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); /// ``` /// -/// # Markup (styled text) +/// ## Markup (styled text) /// /// To make it easy to format text in a label (changing colors, /// fonts, etc.), label text can be provided in a simple @@ -130,14 +131,14 @@ import LevenshteinTransformations /// end_index for a [struct@Pango.Attribute] requires knowledge of the exact /// string being displayed, so translations will cause problems. /// -/// # Selectable labels +/// ## Selectable labels /// /// Labels can be made selectable with [method@Gtk.Label.set_selectable]. /// Selectable labels allow the user to copy the label contents to -/// the clipboard. Only labels that contain useful-to-copy information -/// — such as error messages — should be made selectable. +/// the clipboard. Only labels that contain useful-to-copy information—such +/// as error messages—should be made selectable. /// -/// # Text layout +/// ## Text layout /// /// A label can contain any number of paragraphs, but will have /// performance problems if it contains more than a small number. @@ -160,7 +161,7 @@ import LevenshteinTransformations /// is used as the natural width. Even if max-width-chars specified, wrapping /// labels will be rewrapped to use all of the available width. /// -/// # Links +/// ## Links /// /// GTK supports markup for clickable hyperlinks in addition to regular Pango /// markup. The markup for links is borrowed from HTML, using the `` with @@ -169,7 +170,7 @@ import LevenshteinTransformations /// attribute is displayed as a tooltip on the link. The “class“ attribute is /// used as style class on the CSS node for the link. /// -/// An example looks like this: +/// An example of inline links looks like this: /// /// ```c /// const char *text = diff --git a/Sources/Adwaita/View/Generated/LevelBar.swift b/Sources/Adwaita/View/Generated/LevelBar.swift index 589a197..e5f8473 100644 --- a/Sources/Adwaita/View/Generated/LevelBar.swift +++ b/Sources/Adwaita/View/Generated/LevelBar.swift @@ -2,7 +2,7 @@ // LevelBar.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/LinkButton.swift b/Sources/Adwaita/View/Generated/LinkButton.swift index 9964699..1b7d95c 100644 --- a/Sources/Adwaita/View/Generated/LinkButton.swift +++ b/Sources/Adwaita/View/Generated/LinkButton.swift @@ -2,7 +2,7 @@ // LinkButton.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/ListBox.swift b/Sources/Adwaita/View/Generated/ListBox.swift index 386dbbf..1c233ec 100644 --- a/Sources/Adwaita/View/Generated/ListBox.swift +++ b/Sources/Adwaita/View/Generated/ListBox.swift @@ -2,7 +2,7 @@ // ListBox.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/Menu.swift b/Sources/Adwaita/View/Generated/Menu.swift index 3611554..345b0c4 100644 --- a/Sources/Adwaita/View/Generated/Menu.swift +++ b/Sources/Adwaita/View/Generated/Menu.swift @@ -2,7 +2,7 @@ // Menu.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/NavigationView.swift b/Sources/Adwaita/View/Generated/NavigationView.swift index 93ed74a..fc91bc1 100644 --- a/Sources/Adwaita/View/Generated/NavigationView.swift +++ b/Sources/Adwaita/View/Generated/NavigationView.swift @@ -2,7 +2,7 @@ // NavigationView.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw @@ -51,7 +51,7 @@ import LevenshteinTransformations /// at once, potentially across multiple navigation views. /// /// Set [property@HeaderBar:show-back-button] to `FALSE` to disable this behavior -/// if it's unwanted. +/// in rare scenarios where it's unwanted. /// /// `AdwHeaderBar` will also display the title of the `AdwNavigationPage` it's /// placed into, so most applications shouldn't need to customize it at all. diff --git a/Sources/Adwaita/View/Generated/Overlay.swift b/Sources/Adwaita/View/Generated/Overlay.swift index 64054a6..818fc42 100644 --- a/Sources/Adwaita/View/Generated/Overlay.swift +++ b/Sources/Adwaita/View/Generated/Overlay.swift @@ -2,7 +2,7 @@ // Overlay.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/OverlaySplitView.swift b/Sources/Adwaita/View/Generated/OverlaySplitView.swift index fdc4caf..fb0c926 100644 --- a/Sources/Adwaita/View/Generated/OverlaySplitView.swift +++ b/Sources/Adwaita/View/Generated/OverlaySplitView.swift @@ -2,7 +2,7 @@ // OverlaySplitView.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/PasswordEntryRow.swift b/Sources/Adwaita/View/Generated/PasswordEntryRow.swift index 9538f8d..a2c7006 100644 --- a/Sources/Adwaita/View/Generated/PasswordEntryRow.swift +++ b/Sources/Adwaita/View/Generated/PasswordEntryRow.swift @@ -2,7 +2,7 @@ // PasswordEntryRow.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw @@ -47,6 +47,8 @@ public struct PasswordEntryRow: Widget { /// operation, e.g. network activity, to avoid triggering it after typing every /// character. var showApplyButton: Bool? + /// The length of the text in the entry row. + var textLength: UInt? /// The title of the preference represented by this row. /// /// The title is interpreted as Pango markup unless @@ -189,6 +191,14 @@ public struct PasswordEntryRow: Widget { return newSelf } + /// The length of the text in the entry row. + public func textLength(_ textLength: UInt?) -> Self { + var newSelf = self + newSelf.textLength = textLength + + return newSelf + } + /// The title of the preference represented by this row. /// /// The title is interpreted as Pango markup unless diff --git a/Sources/Adwaita/View/Generated/Popover.swift b/Sources/Adwaita/View/Generated/Popover.swift index c1edea7..f0a2936 100644 --- a/Sources/Adwaita/View/Generated/Popover.swift +++ b/Sources/Adwaita/View/Generated/Popover.swift @@ -2,7 +2,7 @@ // Popover.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/PreferencesGroup.swift b/Sources/Adwaita/View/Generated/PreferencesGroup.swift index 5aca657..28c390c 100644 --- a/Sources/Adwaita/View/Generated/PreferencesGroup.swift +++ b/Sources/Adwaita/View/Generated/PreferencesGroup.swift @@ -2,7 +2,7 @@ // PreferencesGroup.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw @@ -16,7 +16,7 @@ import LevenshteinTransformations /// which in turn are represented by [class@PreferencesRow]. /// /// To summarize the role of the preferences it gathers, a group can have both a -/// title and a description. The title will be used by [class@PreferencesWindow] +/// title and a description. The title will be used by [class@PreferencesDialog] /// to let the user look for a preference. /// /// ## AdwPreferencesGroup as GtkBuildable diff --git a/Sources/Adwaita/View/Generated/PreferencesPage.swift b/Sources/Adwaita/View/Generated/PreferencesPage.swift index f589a9a..08adb27 100644 --- a/Sources/Adwaita/View/Generated/PreferencesPage.swift +++ b/Sources/Adwaita/View/Generated/PreferencesPage.swift @@ -2,13 +2,13 @@ // PreferencesPage.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw import LevenshteinTransformations -/// A page from [class@PreferencesWindow]. +/// A page from [class@PreferencesDialog]. /// /// preferences-page /// diff --git a/Sources/Adwaita/View/Generated/PreferencesRow.swift b/Sources/Adwaita/View/Generated/PreferencesRow.swift index 4222799..7467c09 100644 --- a/Sources/Adwaita/View/Generated/PreferencesRow.swift +++ b/Sources/Adwaita/View/Generated/PreferencesRow.swift @@ -2,7 +2,7 @@ // PreferencesRow.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw @@ -10,7 +10,7 @@ import LevenshteinTransformations /// A [class@Gtk.ListBoxRow] used to present preferences. /// -/// The `AdwPreferencesRow` widget has a title that [class@PreferencesWindow] +/// The `AdwPreferencesRow` widget has a title that [class@PreferencesDialog] /// will use to let the user look for a preference. It doesn't present the title /// in any way and lets you present the preference as you please. /// diff --git a/Sources/Adwaita/View/Generated/ProgressBar.swift b/Sources/Adwaita/View/Generated/ProgressBar.swift index 60adb14..25195f3 100644 --- a/Sources/Adwaita/View/Generated/ProgressBar.swift +++ b/Sources/Adwaita/View/Generated/ProgressBar.swift @@ -2,7 +2,7 @@ // ProgressBar.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/ScrolledWindow.swift b/Sources/Adwaita/View/Generated/ScrolledWindow.swift index 20dbdda..9d36fb0 100644 --- a/Sources/Adwaita/View/Generated/ScrolledWindow.swift +++ b/Sources/Adwaita/View/Generated/ScrolledWindow.swift @@ -2,7 +2,7 @@ // ScrolledWindow.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/SearchBar.swift b/Sources/Adwaita/View/Generated/SearchBar.swift index 09f97be..dbbd7de 100644 --- a/Sources/Adwaita/View/Generated/SearchBar.swift +++ b/Sources/Adwaita/View/Generated/SearchBar.swift @@ -2,7 +2,7 @@ // SearchBar.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/SearchEntry.swift b/Sources/Adwaita/View/Generated/SearchEntry.swift index 21a725c..82fbace 100644 --- a/Sources/Adwaita/View/Generated/SearchEntry.swift +++ b/Sources/Adwaita/View/Generated/SearchEntry.swift @@ -2,7 +2,7 @@ // SearchEntry.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/SpinRow.swift b/Sources/Adwaita/View/Generated/SpinRow.swift index 46f6891..c2bbd65 100644 --- a/Sources/Adwaita/View/Generated/SpinRow.swift +++ b/Sources/Adwaita/View/Generated/SpinRow.swift @@ -2,7 +2,7 @@ // SpinRow.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/Spinner.swift b/Sources/Adwaita/View/Generated/Spinner.swift index bba9455..d58e1fa 100644 --- a/Sources/Adwaita/View/Generated/Spinner.swift +++ b/Sources/Adwaita/View/Generated/Spinner.swift @@ -2,7 +2,7 @@ // Spinner.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/SplitButton.swift b/Sources/Adwaita/View/Generated/SplitButton.swift index 09f5410..9c22f3c 100644 --- a/Sources/Adwaita/View/Generated/SplitButton.swift +++ b/Sources/Adwaita/View/Generated/SplitButton.swift @@ -2,7 +2,7 @@ // SplitButton.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/StatusPage.swift b/Sources/Adwaita/View/Generated/StatusPage.swift index 519d22f..acf0e90 100644 --- a/Sources/Adwaita/View/Generated/StatusPage.swift +++ b/Sources/Adwaita/View/Generated/StatusPage.swift @@ -2,7 +2,7 @@ // StatusPage.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/SwitchRow.swift b/Sources/Adwaita/View/Generated/SwitchRow.swift index 8a53d0e..5c35bce 100644 --- a/Sources/Adwaita/View/Generated/SwitchRow.swift +++ b/Sources/Adwaita/View/Generated/SwitchRow.swift @@ -2,7 +2,7 @@ // SwitchRow.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/ToastOverlay.swift b/Sources/Adwaita/View/Generated/ToastOverlay.swift index b5036f5..7f6395f 100644 --- a/Sources/Adwaita/View/Generated/ToastOverlay.swift +++ b/Sources/Adwaita/View/Generated/ToastOverlay.swift @@ -2,7 +2,7 @@ // ToastOverlay.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/ToggleButton.swift b/Sources/Adwaita/View/Generated/ToggleButton.swift index f46e147..411fd14 100644 --- a/Sources/Adwaita/View/Generated/ToggleButton.swift +++ b/Sources/Adwaita/View/Generated/ToggleButton.swift @@ -2,7 +2,7 @@ // ToggleButton.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/ToolbarView.swift b/Sources/Adwaita/View/Generated/ToolbarView.swift index 5e86e32..af895ef 100644 --- a/Sources/Adwaita/View/Generated/ToolbarView.swift +++ b/Sources/Adwaita/View/Generated/ToolbarView.swift @@ -2,7 +2,7 @@ // ToolbarView.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Adwaita/View/Generated/WindowTitle.swift b/Sources/Adwaita/View/Generated/WindowTitle.swift index 10a0558..1cbbb92 100644 --- a/Sources/Adwaita/View/Generated/WindowTitle.swift +++ b/Sources/Adwaita/View/Generated/WindowTitle.swift @@ -2,7 +2,7 @@ // WindowTitle.swift // Adwaita // -// Created by auto-generation on 17.02.24. +// Created by auto-generation on 20.03.24. // import CAdw diff --git a/Sources/Generation/GenerationConfiguration.swift b/Sources/Generation/GenerationConfiguration.swift index edd84ed..6fbd6a0 100644 --- a/Sources/Generation/GenerationConfiguration.swift +++ b/Sources/Generation/GenerationConfiguration.swift @@ -254,7 +254,11 @@ struct GenerationConfiguration { ), excludeProperties: ["selection-mode", "orientation"] ), - .init(class: "SearchEntry", bindings: [.init(property: "text")]), + .init( + class: "SearchEntry", + bindings: [.init(property: "text")], + excludeProperties: ["input-hints", "input-purpose"] + ), .init(class: "SearchBar") ] diff --git a/Tests/Demo.swift b/Tests/Demo.swift index f3f232a..a698cea 100644 --- a/Tests/Demo.swift +++ b/Tests/Demo.swift @@ -24,11 +24,6 @@ struct Demo: App { .icon(.default(icon: .applicationXExecutable)) .website(.init(string: "https://david-swift.gitbook.io/adwaita")) .issues(.init(string: "https://github.com/AparokshaUI/adwaita-swift/issues")) - Window(id: "overlay", open: 0) { window in - OverlayWindowDemo.WindowContent(window: window) - } - .keyboardShortcut("Escape") { $0.close() } - .defaultSize(width: 300, height: 200) } HelperWindows() } diff --git a/Tests/DialogDemo.swift b/Tests/DialogDemo.swift new file mode 100644 index 0000000..29c477e --- /dev/null +++ b/Tests/DialogDemo.swift @@ -0,0 +1,37 @@ +// +// DialogDemo.swift +// Adwaita +// +// Created by david-swift on 20.13.24. +// + +// swiftlint:disable missing_docs + +import Adwaita + +struct DialogDemo: View { + + @State private var dialog = false + let padding = 20 + + var view: Body { + VStack { + Button("Show Dialog") { + dialog = true + } + .style("pill") + .frame(maxSize: 100) + .padding() + } + .dialog(visible: $dialog, title: "Counter") { + CounterDemo() + .padding(padding) + .topToolbar { + HeaderBar.empty() + } + } + } + +} + +// swiftlint:enable missing_docs diff --git a/Tests/OverlayWindowDemo.swift b/Tests/OverlayWindowDemo.swift deleted file mode 100644 index ceffec9..0000000 --- a/Tests/OverlayWindowDemo.swift +++ /dev/null @@ -1,51 +0,0 @@ -// -// OverlayWindowDemo.swift -// Adwaita -// -// Created by david-swift on 09.11.23. -// - -// swiftlint:disable missing_docs implicitly_unwrapped_optional - -import Adwaita - -struct OverlayWindowDemo: View { - - var app: GTUIApp! - var window: GTUIApplicationWindow - - var view: Body { - VStack { - Button("Show Window") { - app.addWindow("overlay", parent: window) - } - .style("pill") - .frame(maxSize: 100) - .padding() - } - } - - struct WindowContent: View { - - var window: GTUIWindow - - var view: Body { - VStack { - Button("Close Window") { - window.close() - } - .style("pill") - .padding() - .frame(maxSize: 100) - } - .valign(.center) - .topToolbar { - HeaderBar.empty() - } - } - - } - -} - -// swiftlint:enable missing_docs implicitly_unwrapped_optional diff --git a/Tests/Page.swift b/Tests/Page.swift index a99b4f5..473517c 100644 --- a/Tests/Page.swift +++ b/Tests/Page.swift @@ -17,7 +17,7 @@ enum Page: String, Identifiable, CaseIterable, Codable { case toolbar case transition case dice - case overlayWindow + case dialog case toast case list case carousel @@ -33,8 +33,6 @@ enum Page: String, Identifiable, CaseIterable, Codable { var label: String { switch self { - case .overlayWindow: - return "Overlay Window" case .viewSwitcher: return "View Switcher" case .flowBox: @@ -58,35 +56,35 @@ enum Page: String, Identifiable, CaseIterable, Codable { var description: String { switch self { case .welcome: - return "This is a collection of examples for the Swift Adwaita package." + return "This is a collection of examples for the Swift Adwaita package" case .counter: - return "A simple sample view." + return "A simple sample view" case .windows: - return "Showcase window management." + return "Showcase window management" case .toolbar: - return "Toggle the bottom toolbar." + return "Toggle the bottom toolbar" case .transition: - return "A slide transition between two views." + return "A slide transition between two views" case .dice: - return "Roll the dice." - case .overlayWindow: - return "A window on top of another window." + return "Roll the dice" + case .dialog: + return "A window on top of another window" case .toast: - return "Show a notification inside of your app." + return "Show a notification inside of your app" case .list: - return "Organize content in multiple rows." + return "Organize content in multiple rows" case .carousel: - return "Scroll horizontally on a touchpad or touchscreen, or scroll down on your mouse wheel." + return "Scroll horizontally on a touchpad or touchscreen, or scroll down on your mouse wheel" case .viewSwitcher: - return "Switch the window's view." + return "Switch the window's view" case .form: - return "Group controls used for data entry." + return "Group controls used for data entry" case .popover: - return "Present content in a bubble-like context popup." + return "Present content in a bubble-like context popup" case .flowBox: - return "Display views in a reflowing grid." + return "Display views in a reflowing grid" case .navigationView: - return "A page-based navigation container." + return "A page-based navigation container" } } @@ -106,8 +104,8 @@ enum Page: String, Identifiable, CaseIterable, Codable { TransitionDemo() case .dice: DiceDemo() - case .overlayWindow: - OverlayWindowDemo(app: app, window: window) + case .dialog: + DialogDemo() case .toast: ToastDemo(toast: toast) case .list: diff --git a/user-manual/Information/Widgets.md b/user-manual/Information/Widgets.md index eea673a..08c72c3 100644 --- a/user-manual/Information/Widgets.md +++ b/user-manual/Information/Widgets.md @@ -20,7 +20,7 @@ There are many more widgets available using auto-generation. Learn [how to use t ### View Modifiers -| Syntax | Description | +| Syntax | Description | | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | | `freeze(_:)` | Prevent a view from being updated. | | `inspect(_:)` | Edit the underlying Gtk or Libadwaita widget. | @@ -31,7 +31,7 @@ There are many more widgets available using auto-generation. Learn [how to use t | `valign(_:)` | Set the vertical alignment of a view. | | `frame(minWidth:minHeight:)` | Set the view’s minimum width or height. | | `frame(maxWidth:)` | Set the view’s maximum width. | -| `frame(maxHeight:)` | Set the view’s maximum height. | +| `frame(maxHeight:)` | Set the view’s maximum height. | | `transition(_:)` | Assign a transition with the view that is used if it is a direct child of an EitherView. | | `onUpdate(_:)` | Run a function every time a view gets updated. | | `navigationTitle(_:)` | Add a title that is used if the view is a direct child of a NavigationView. | @@ -51,6 +51,7 @@ There are many more widgets available using auto-generation. Learn [how to use t | `focus(_:)` | Bind a signal that focuses the view. | | `verticalCenter()` | Wrap a view in a `VStack` and center vertically. | | `horizontalCenter()` | Wrap a view in an `HStack` and center horizontally. | +| `dialog(visible:title:content:)` | Add a dialog to the window containing the view. | ### `Button` Modifiers | Syntax | Description |