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)
This commit is contained in:
Dexter Reed 2024-02-12 12:08:20 +00:00 • committed by Sophie Herold
parent 74482bf6b6
commit b99575d8d0
4 changed files with 8 additions and 11 deletions

View file

@ -47,7 +47,7 @@ features = ["v2_74"]
[dependencies.adw] [dependencies.adw]
package = "libadwaita" package = "libadwaita"
version = "0.6.0" version = "0.6.0"
features = ["v1_4"] features = ["v1_5"]
[dependencies.gettext-rs] [dependencies.gettext-rs]
version = "0.7.0" version = "0.7.0"

View file

@ -21,11 +21,11 @@ use gettextrs::gettext;
use crate::config; use crate::config;
pub async fn window() -> adw::AboutWindow { pub async fn dialog() -> adw::AboutDialog {
// Builders are a pattern that allow you to create // Builders are a pattern that allow you to create
// an object and set all relevant properties very // an object and set all relevant properties very
// easily in a way that's idiomatic to Rust. // easily in a way that's idiomatic to Rust.
adw::AboutWindow::builder() adw::AboutDialog::builder()
.application_name(gettext("Image Viewer")) .application_name(gettext("Image Viewer"))
.application_icon(config::APP_ID) .application_icon(config::APP_ID)
.version(config::VERSION) .version(config::VERSION)

View file

@ -207,13 +207,10 @@ impl LpApplication {
} }
pub async fn show_about(&self) { 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.present(&window);
about.set_transient_for(Some(&window));
}
about.present();
} }
pub fn show_help(&self) { pub fn show_help(&self) {

View file

@ -60,7 +60,7 @@
<property name="default-width">600</property> <property name="default-width">600</property>
<property name="default-height">498</property> <property name="default-height">498</property>
<property name="width-request">360</property> <property name="width-request">360</property>
<property name="height-request">360</property> <property name="height-request">294</property>
<child> <child>
<object class="AdwBreakpoint"> <object class="AdwBreakpoint">
<condition>max-width: 590sp</condition> <condition>max-width: 590sp</condition>
@ -220,4 +220,4 @@
</object> </object>
</property> </property>
</template> </template>
</interface> </interface>