From 930d842d9edae70e594d47591aa15b2e6b8ae817 Mon Sep 17 00:00:00 2001 From: AkshayWarrier Date: Sat, 10 Jun 2023 20:32:12 +0530 Subject: [PATCH 1/2] library: Add AdwBanner entry --- src/Library/demos/Banner/main.blp | 48 ++++++++++++++++++++++++++++++ src/Library/demos/Banner/main.js | 23 ++++++++++++++ src/Library/demos/Banner/main.json | 10 +++++++ 3 files changed, 81 insertions(+) create mode 100644 src/Library/demos/Banner/main.blp create mode 100644 src/Library/demos/Banner/main.js create mode 100644 src/Library/demos/Banner/main.json diff --git a/src/Library/demos/Banner/main.blp b/src/Library/demos/Banner/main.blp new file mode 100644 index 000000000..9da36f2af --- /dev/null +++ b/src/Library/demos/Banner/main.blp @@ -0,0 +1,48 @@ +using Gtk 4.0; +using Adw 1; + +Box { + orientation: vertical; + + Adw.Banner banner { + button-label: "Troubleshoot"; + title: "An error occurred: Could not resolve host"; + revealed: true; + } + + Adw.ToastOverlay overlay { + Adw.StatusPage { + title: "Banner"; + description: "An attention-grabbing notification that is used to communicate important information"; + vexpand: true; + + Box { + orientation: vertical; + halign: center; + + Button button_show_banner { + halign: center; + label: "Show Banner"; + + styles ["pill"] + } + + Box { + margin-top: 24; + margin-bottom: 24; + orientation: vertical; + + LinkButton { + label: "API Reference"; + uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.3/class.Banner.html"; + } + + LinkButton { + label: "Human Interface Guidelines"; + uri: "https://developer.gnome.org/hig/patterns/feedback/banners.html"; + } + } + } + } + } +} diff --git a/src/Library/demos/Banner/main.js b/src/Library/demos/Banner/main.js new file mode 100644 index 000000000..040c318c4 --- /dev/null +++ b/src/Library/demos/Banner/main.js @@ -0,0 +1,23 @@ +import Adw from "gi://Adw"; + +const banner = workbench.builder.get_object("banner"); +const overlay = workbench.builder.get_object("overlay"); +const button_show_banner = workbench.builder.get_object("button_show_banner"); + +function alert() { + const toast = new Adw.Toast({ + title: "Troubleshoot successful!", + timeout: 3, + }); + + overlay.add_toast(toast); +} + +banner.connect("button-clicked", () => { + alert(); + banner.revealed = false; +}); + +button_show_banner.connect("clicked", () => { + banner.revealed = true; +}); diff --git a/src/Library/demos/Banner/main.json b/src/Library/demos/Banner/main.json new file mode 100644 index 000000000..233149cc3 --- /dev/null +++ b/src/Library/demos/Banner/main.json @@ -0,0 +1,10 @@ +{ + "name": "Banner", + "category": "feedback", + "description": "An attention-grabbing notification that is used to communicate important information", + "panels": [ + "ui", + "preview" + ], + "autorun": true +} From 7f711c8eec86f7d7446f21354e227a026c8b6e32 Mon Sep 17 00:00:00 2001 From: AkshayWarrier Date: Wed, 14 Jun 2023 12:38:15 +0530 Subject: [PATCH 2/2] Banner: Translate strings --- src/Library/demos/Banner/main.blp | 10 +++++----- src/Library/demos/Banner/main.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Library/demos/Banner/main.blp b/src/Library/demos/Banner/main.blp index 9da36f2af..d34039f1a 100644 --- a/src/Library/demos/Banner/main.blp +++ b/src/Library/demos/Banner/main.blp @@ -5,15 +5,15 @@ Box { orientation: vertical; Adw.Banner banner { - button-label: "Troubleshoot"; - title: "An error occurred: Could not resolve host"; + button-label: _("Troubleshoot"); + title: _("An error occurred: Could not resolve host"); revealed: true; } Adw.ToastOverlay overlay { Adw.StatusPage { - title: "Banner"; - description: "An attention-grabbing notification that is used to communicate important information"; + title: _("Banner"); + description: _("A bar with contextual information"); vexpand: true; Box { @@ -22,7 +22,7 @@ Box { Button button_show_banner { halign: center; - label: "Show Banner"; + label: _("Show Banner"); styles ["pill"] } diff --git a/src/Library/demos/Banner/main.json b/src/Library/demos/Banner/main.json index 233149cc3..9b8c26228 100644 --- a/src/Library/demos/Banner/main.json +++ b/src/Library/demos/Banner/main.json @@ -1,7 +1,7 @@ { "name": "Banner", "category": "feedback", - "description": "An attention-grabbing notification that is used to communicate important information", + "description": "A bar with contextual information", "panels": [ "ui", "preview"