Skip to content

Commit

Permalink
Add AdwDialog entry
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Feb 11, 2024
1 parent cb5bf98 commit 0bb9ee6
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 0 deletions.
44 changes: 44 additions & 0 deletions demos/Dialog/image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions demos/Dialog/main.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using Gtk 4.0;
using Adw 1;

Adw.StatusPage {
title: _("Dialog");
description: _("An adaptive dialog container");

Box {
orientation: vertical;
halign: center;
spacing: 28;

ListBox {
width-request: 320;
selection-mode: none;

styles [
"boxed-list"
]

Adw.ComboRow combo_row {
title: _("Presentation Mode");

model: StringList list {
strings [
_("Auto"),
_("Floating"),
_("Bottom Sheet")
]
};
}
}

Button button {
label: _("Open Dialog");
halign: center;

styles [
"suggested-action",
"pill"
]
}

Box {
orientation: vertical;

LinkButton {
label: _("API Reference");
uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.Dialog.html";
}

LinkButton {
label: _("Human Interface Guidelines");
uri: "https://developer.gnome.org/hig/patterns/feedback/dialogs.html";
}
}
}
}

Adw.Dialog dialog {
can-close: false;
presentation-mode: bind combo_row.selected;

Adw.ToolbarView {
[top]
Adw.HeaderBar {}

Image image {
pixel-size: 320;
}
}
}
24 changes: 24 additions & 0 deletions demos/Dialog/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Gio from "gi://Gio";

const dialog = workbench.builder.get_object("dialog");
const button = workbench.builder.get_object("button");
const image = workbench.builder.get_object("image");

image.file = Gio.File.new_for_uri(workbench.resolve("image.svg")).get_path();

async function openDialog() {
dialog.present(workbench.window);
}

button.connect("clicked", () => {
openDialog().catch(console.error);
});

dialog.connect("close-attempt", () => {
console.log("Close Attempt");
dialog.force_close();
});

dialog.connect("closed", () => {
console.log("Closed");
});
6 changes: 6 additions & 0 deletions demos/Dialog/main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"category": "feedback",
"description": "An adaptive dialog container",
"panels": ["code", "ui", "preview"],
"autorun": true
}

0 comments on commit 0bb9ee6

Please sign in to comment.