diff --git a/data/resources/style.css b/data/resources/style.css index bccaeb5..50b3531 100644 --- a/data/resources/style.css +++ b/data/resources/style.css @@ -30,21 +30,3 @@ dragoverlay .drag-area-highlight { margin-top: 3px; margin-bottom: 3px; } - -/* SaveChangesDialog */ - -.save-changes-dialog > windowhandle > box.vertical > box.message-area.vertical { - padding-bottom: 0; -} - -.save-changes-dialog > windowhandle > box.vertical > box.message-area.vertical > preferencespage { - margin-left: -30px; - margin-right: -30px; -} - -.save-changes-dialog > windowhandle > box.vertical > box.message-area.vertical > preferencespage > scrolledwindow > viewport { - padding-left: 30px; - padding-right: 30px; - padding-bottom: 10px; -} - diff --git a/data/resources/ui/window.ui b/data/resources/ui/window.ui index 24a0f5e..62fe43a 100644 --- a/data/resources/ui/window.ui +++ b/data/resources/ui/window.ui @@ -98,7 +98,7 @@ raised - + Open diff --git a/src/about.rs b/src/about.rs index d5daebb..5de2acc 100644 --- a/src/about.rs +++ b/src/about.rs @@ -1,5 +1,6 @@ +use adw::prelude::*; use gettextrs::gettext; -use gtk::{glib, prelude::*}; +use gtk::glib; use std::{env, path::Path}; @@ -8,9 +9,8 @@ use crate::{ utils, }; -pub fn present_window(transient_for: Option<&impl IsA>) { - let win = adw::AboutWindow::builder() - .modal(true) +pub fn present_window(parent: &impl IsA) { + let win = adw::AboutDialog::builder() .application_icon(APP_ID) .application_name(utils::application_name()) .developer_name(gettext("Dave Patrick Caberto")) @@ -38,8 +38,7 @@ pub fn present_window(transient_for: Option<&impl IsA>) { "https://hosted.weblate.org/projects/seadve/delineate", ); - win.set_transient_for(transient_for); - win.present(); + win.present(parent); } fn debug_info() -> String { diff --git a/src/application.rs b/src/application.rs index c921534..575ce69 100644 --- a/src/application.rs +++ b/src/application.rs @@ -171,7 +171,11 @@ impl Application { .build(); let action_about = gio::ActionEntry::builder("about") .activate(|obj: &Self, _, _| { - about::present_window(obj.active_window().as_ref()); + if let Some(window) = obj.active_window() { + about::present_window(&window); + } else { + tracing::warn!("Can't present about dialog without an active window"); + } }) .build(); self.add_action_entries([action_new_window, action_quit, action_about]); diff --git a/src/save_changes_dialog.rs b/src/save_changes_dialog.rs index 1d5b61d..0fd3e4d 100644 --- a/src/save_changes_dialog.rs +++ b/src/save_changes_dialog.rs @@ -50,18 +50,15 @@ pub async fn run(window: &Window, unsaved: &[Document]) -> glib::Propagation { /// Returns `Ok` if unsaved changes are handled and can proceed, `Err` if /// the next operation should be aborted. -async fn run_inner(parent: &impl IsA, unsaved: &[Document]) -> Result<()> { +async fn run_inner(parent: &impl IsA, unsaved: &[Document]) -> Result<()> { debug_assert!(!unsaved.is_empty()); - let dialog = adw::MessageDialog::builder() - .modal(true) - .transient_for(parent) + let dialog = adw::AlertDialog::builder() .heading(gettext("Save Changes?")) .body(gettext("Open documents contain unsaved changes. Changes which are not saved will be permanently lost.")) .close_response(CANCEL_RESPONSE_ID) .default_response(SAVE_RESPONSE_ID) .build(); - dialog.add_css_class("save-changes-dialog"); dialog.add_response(CANCEL_RESPONSE_ID, &gettext("Cancel")); dialog.add_response( @@ -76,11 +73,9 @@ async fn run_inner(parent: &impl IsA, unsaved: &[Document]) -> Resu dialog.set_response_appearance(DISCARD_RESPONSE_ID, adw::ResponseAppearance::Destructive); dialog.set_response_appearance(SAVE_RESPONSE_ID, adw::ResponseAppearance::Suggested); - let page = adw::PreferencesPage::new(); - dialog.set_extra_child(Some(&page)); - - let group = adw::PreferencesGroup::new(); - page.add(&group); + let list_box = gtk::ListBox::new(); + list_box.add_css_class("boxed-list"); + dialog.set_extra_child(Some(&list_box)); let mut items = Vec::new(); let check_buttons = Rc::new(RefCell::new(Vec::new())); @@ -88,7 +83,7 @@ async fn run_inner(parent: &impl IsA, unsaved: &[Document]) -> Resu debug_assert!(document.is_modified()); let row = adw::ActionRow::new(); - group.add(&row); + list_box.append(&row); let check_button = gtk::CheckButton::builder() .valign(gtk::Align::Center) @@ -149,7 +144,7 @@ async fn run_inner(parent: &impl IsA, unsaved: &[Document]) -> Resu })); } - match dialog.choose_future().await.as_str() { + match dialog.choose_future(parent).await.as_str() { CANCEL_RESPONSE_ID => Err(Cancelled.into()), DISCARD_RESPONSE_ID => Ok(()), SAVE_RESPONSE_ID => {