From b99575d8d0b6e94146557bd96522b5d37793e254 Mon Sep 17 00:00:00 2001 From: Dexter Reed Date: Mon, 12 Feb 2024 12:08:20 +0000 Subject: [PATCH] feat: Port about window to `adw::Dialog` (Adw.Dialog) Other Changes: Change window height to 294 to fit the HIG: https://developer.gnome.org/hig/guidelines/adaptive.html#small-size-handling Change adw features version in `Cargo.toml` from `v1_4` to `v1_5` to use the new dialog widget(s) --- Cargo.toml | 2 +- src/about.rs | 4 ++-- src/application.rs | 9 +++------ src/window.ui | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d9a4f20..855fd9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,7 @@ features = ["v2_74"] [dependencies.adw] package = "libadwaita" version = "0.6.0" -features = ["v1_4"] +features = ["v1_5"] [dependencies.gettext-rs] version = "0.7.0" diff --git a/src/about.rs b/src/about.rs index 6365ac1..a8b2bd8 100644 --- a/src/about.rs +++ b/src/about.rs @@ -21,11 +21,11 @@ use gettextrs::gettext; use crate::config; -pub async fn window() -> adw::AboutWindow { +pub async fn dialog() -> adw::AboutDialog { // Builders are a pattern that allow you to create // an object and set all relevant properties very // easily in a way that's idiomatic to Rust. - adw::AboutWindow::builder() + adw::AboutDialog::builder() .application_name(gettext("Image Viewer")) .application_icon(config::APP_ID) .version(config::VERSION) diff --git a/src/application.rs b/src/application.rs index 6513078..f3b8612 100644 --- a/src/application.rs +++ b/src/application.rs @@ -207,13 +207,10 @@ impl LpApplication { } pub async fn show_about(&self) { - let about = about::window().await; + let about = about::dialog().await; + let window = self.active_window().unwrap(); - if let Some(window) = self.active_window() { - about.set_transient_for(Some(&window)); - } - - about.present(); + about.present(&window); } pub fn show_help(&self) { diff --git a/src/window.ui b/src/window.ui index 634662e..8ac0798 100644 --- a/src/window.ui +++ b/src/window.ui @@ -60,7 +60,7 @@ 600 498 360 - 360 + 294 max-width: 590sp @@ -220,4 +220,4 @@ - \ No newline at end of file +