diff --git a/demos/About Dialog/code.rs b/demos/About Dialog/code.rs index 0f1a952e..5ed8b407 100644 --- a/demos/About Dialog/code.rs +++ b/demos/About Dialog/code.rs @@ -15,7 +15,7 @@ fn on_button_clicked() { .application_name("Typeset") .developer_name("Angela Avery") .version("1.2.3") - .comments("Typeset is an app that doesn’t exist and is used as an example content for About Window.") + .comments("Typeset is an app that doesn’t exist and is used as an example content for About Dialog.") .website("https://example.org") .issue_url("https://example.org") .support_url("https://example.org") @@ -40,5 +40,5 @@ fn on_button_clicked() { dialog.add_acknowledgement_section(Some("Special thanks to"), &["My cat"]); - dialog.present(workbench::window); + dialog.present(workbench::window()); } diff --git a/demos/About Dialog/main.js b/demos/About Dialog/main.js index ece7f02d..d9e2bcdb 100644 --- a/demos/About Dialog/main.js +++ b/demos/About Dialog/main.js @@ -11,7 +11,7 @@ function openAboutDialog() { developer_name: "Angela Avery", version: "1.2.3", comments: _( - "Typeset is an app that doesn’t exist and is used as an example content for About Window.", + "Typeset is an app that doesn’t exist and is used as an example content for About Dialog.", ), website: "https://example.org", issue_url: "https://example.org", diff --git a/demos/About Dialog/main.py b/demos/About Dialog/main.py index 5c963e73..ebd764ae 100644 --- a/demos/About Dialog/main.py +++ b/demos/About Dialog/main.py @@ -14,7 +14,7 @@ def open_about_window(_widget): developer_name="Angela Avery", version="1.2.3", comments=_( - "Typeset is an app that doesn’t exist and is used as an example content for About Window.", + "Typeset is an app that doesn’t exist and is used as an example content for About Dialog.", ), website="https://example.org", issue_url="https://example.org", diff --git a/demos/About Dialog/main.vala b/demos/About Dialog/main.vala index bc0cfe64..ae4cebe3 100644 --- a/demos/About Dialog/main.vala +++ b/demos/About Dialog/main.vala @@ -8,13 +8,12 @@ public void main () { } public void on_button_clicked () { - // https://valadoc.org/libadwaita-1/Adw.AboutWindow.html var dialog = new Adw.AboutDialog () { application_icon = "application-x-executable", application_name = "Typeset", developer_name = "Angela Avery", version = "1.2.3", - comments = "Typeset is an app that doesn’t exist and is used as an example content for About Window.", + comments = "Typeset is an app that doesn’t exist and is used as an example content for About Dialog.", website = "https://example.org", issue_url = "https://example.org", support_url = "https://example.org", diff --git a/demos/Preferences Window/main.blp b/demos/Preferences Dialog/main.blp similarity index 66% rename from demos/Preferences Window/main.blp rename to demos/Preferences Dialog/main.blp index c0cee69c..b9f39d5a 100644 --- a/demos/Preferences Window/main.blp +++ b/demos/Preferences Dialog/main.blp @@ -1,9 +1,56 @@ using Gtk 4.0; using Adw 1; -Adw.PreferencesWindow pref_window { - default-width: 800; - default-height: 600; +Adw.StatusPage { + title: _("Preferences Dialog"); + description: _("A dialog showing application’s preferences"); + + Box { + spacing: 12; + halign: center; + orientation: vertical; + + Button button { + label: _("Open"); + + styles [ + "suggested-action", + "pill" + ] + } + + FlowBox { + orientation: horizontal; + margin-top: 12; + max-children-per-line: 2; + min-children-per-line: 2; + + LinkButton { + label: _("PreferencesDialog"); + uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.PreferencesDialog.html"; + } + + LinkButton { + label: _("PreferencesPage"); + uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.PreferencesPage.html"; + } + + LinkButton { + label: _("PreferencesGroup"); + uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.PreferencesGroup.html"; + } + + LinkButton { + label: _("PreferencesRow"); + uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.PreferencesRow.html"; + } + } + } +} + +Adw.PreferencesDialog dialog { + content-width: 800; + content-height: 600; title: _("Preferences"); Adw.PreferencesPage appearance_page { @@ -46,37 +93,6 @@ Adw.PreferencesWindow pref_window { } } } - - Adw.PreferencesGroup { - title: _("API References"); - - FlowBox { - orientation: horizontal; - margin-top: 12; - max-children-per-line: 2; - min-children-per-line: 2; - - LinkButton { - label: _("PreferencesWindow"); - uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.PreferencesWindow.html"; - } - - LinkButton { - label: _("PreferencesPage"); - uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.PreferencesPage.html"; - } - - LinkButton { - label: _("PreferencesGroup"); - uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.PreferencesGroup.html"; - } - - LinkButton { - label: _("PreferencesRow"); - uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.PreferencesRow.html"; - } - } - } } Adw.PreferencesPage { @@ -118,11 +134,11 @@ Adw.PreferencesWindow pref_window { description: _("Manage user data related settings."); Adw.SwitchRow { - title: _("Enable Telemetry"); + title: _("Enable Debug"); } Adw.SwitchRow { - title: _("Enable Auto-Updates"); + title: _("Check for updates"); } Adw.ActionRow subpage_row { diff --git a/demos/Preferences Window/main.js b/demos/Preferences Dialog/main.js similarity index 70% rename from demos/Preferences Window/main.js rename to demos/Preferences Dialog/main.js index e135fb52..7723a061 100644 --- a/demos/Preferences Window/main.js +++ b/demos/Preferences Dialog/main.js @@ -1,12 +1,13 @@ import Adw from "gi://Adw"; -const pref_window = workbench.builder.get_object("pref_window"); +const dialog = workbench.builder.get_object("dialog"); const dm_switch = workbench.builder.get_object("dm_switch"); const subpage = workbench.builder.get_object("subpage"); const subpage_row = workbench.builder.get_object("subpage_row"); const subpage_button = workbench.builder.get_object("subpage_button"); const toast_button = workbench.builder.get_object("toast_button"); const style_manager = Adw.StyleManager.get_default(); +const button = workbench.builder.get_object("button"); dm_switch.active = style_manager.dark; @@ -19,19 +20,23 @@ dm_switch.connect("notify::active", () => { } }); -// Preferences windows can display subpages +// Preferences dialogs can display subpages subpage_row.connect("activated", () => { - pref_window.push_subpage(subpage); + dialog.push_subpage(subpage); }); subpage_button.connect("clicked", () => { - pref_window.pop_subpage(); + dialog.pop_subpage(); }); toast_button.connect("clicked", () => { const toast = new Adw.Toast({ - title: "Preferences windows can display toasts", + title: "Preferences dialogs can display toasts", }); - pref_window.add_toast(toast); + dialog.add_toast(toast); +}); + +button.connect("clicked", () => { + dialog.present(workbench.window); }); diff --git a/demos/Preferences Window/main.json b/demos/Preferences Dialog/main.json similarity index 55% rename from demos/Preferences Window/main.json rename to demos/Preferences Dialog/main.json index 26dc0197..faeee1f3 100644 --- a/demos/Preferences Window/main.json +++ b/demos/Preferences Dialog/main.json @@ -1,6 +1,6 @@ { "category": "user_interface", - "description": "A window containing an application's preferences", + "description": "A dialog showing application’s preferences", "panels": ["ui", "preview"], "autorun": true } diff --git a/demos/Preferences Window/main.py b/demos/Preferences Dialog/main.py similarity index 64% rename from demos/Preferences Window/main.py rename to demos/Preferences Dialog/main.py index c682464e..2a7b1d92 100644 --- a/demos/Preferences Window/main.py +++ b/demos/Preferences Dialog/main.py @@ -4,12 +4,14 @@ from gi.repository import Adw import workbench -pref_window = workbench.builder.get_object("pref_window") +dialog = workbench.builder.get_object("dialog") dm_switch = workbench.builder.get_object("dm_switch") subpage = workbench.builder.get_object("subpage") subpage_row = workbench.builder.get_object("subpage_row") subpage_button = workbench.builder.get_object("subpage_button") toast_button = workbench.builder.get_object("toast_button") +button = workbench.builder.get_object("button") + style_manager = Adw.StyleManager.get_default() dm_switch.set_active(style_manager.get_dark()) @@ -24,16 +26,18 @@ ), ) -# Preferences windows can display subpages -subpage_row.connect("activated", lambda *_: pref_window.push_subpage(subpage)) +# Preferences dialogs can display subpages +subpage_row.connect("activated", lambda *_: dialog.push_subpage(subpage)) -subpage_button.connect("clicked", lambda *_: pref_window.pop_subpage()) +subpage_button.connect("clicked", lambda *_: dialog.pop_subpage()) toast_button.connect( "clicked", - lambda *_: pref_window.add_toast( + lambda *_: dialog.add_toast( Adw.Toast( - title="Preferences windows can display toasts", + title="Preferences dialogs can display toasts", ) ), ) + +button.connect("clicked", lambda *_: dialog.present(workbench.window)) diff --git a/demos/Preferences Window/main.vala b/demos/Preferences Dialog/main.vala similarity index 65% rename from demos/Preferences Window/main.vala rename to demos/Preferences Dialog/main.vala index c9879da0..f070d7bf 100644 --- a/demos/Preferences Window/main.vala +++ b/demos/Preferences Dialog/main.vala @@ -1,12 +1,13 @@ #! /usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1 public void main () { - var pref_window = (Adw.PreferencesWindow) workbench.builder.get_object ("pref_window"); + var dialog = (Adw.PreferencesDialog) workbench.builder.get_object ("dialog"); var dm_switch = (Adw.SwitchRow) workbench.builder.get_object ("dm_switch"); var subpage = (Adw.NavigationPage) workbench.builder.get_object ("subpage"); var subpage_row = (Adw.ActionRow) workbench.builder.get_object ("subpage_row"); var subpage_button = (Gtk.Button) workbench.builder.get_object ("subpage_button"); var toast_button = (Gtk.Button) workbench.builder.get_object ("toast_button"); + var button = (Gtk.Button) workbench.builder.get_object ("button"); var style_manager = Adw.StyleManager.get_default (); dm_switch.active = style_manager.dark; @@ -20,14 +21,18 @@ public void main () { } }); - // Preferences windows can display subpages - subpage_row.activated.connect (() => pref_window.push_subpage (subpage)); + // Preferences dialogs can display subpages + subpage_row.activated.connect (() => dialog.push_subpage (subpage)); - subpage_button.clicked.connect (() => pref_window.pop_subpage ()); + subpage_button.clicked.connect (() => dialog.pop_subpage ()); toast_button.clicked.connect (() => { - var toast = new Adw.Toast ("Preferences windows can display toasts"); + var toast = new Adw.Toast ("Preferences dialogs can display toasts"); - pref_window.add_toast (toast); + dialog.add_toast (toast); + }); + + button.clicked.connect (() => { + dialog.present (workbench.window); }); }