diff options
author | Gabriel Brand <gabr.brand@gmail.com> | 2024-05-03 15:02:22 +0200 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2025-01-02 02:41:43 +0300 |
commit | 987f3d96c087231efb96aefafed688d9944f94ed (patch) | |
tree | 5cedafa585f7403272019180fddf40bda4099b73 /src | |
parent | 23c6aa557a68f6907088fcbc0cced3cd191c2824 (diff) | |
download | Furtherance-987f3d96c087231efb96aefafed688d9944f94ed.tar.zst |
Port AdwPreferencesWindow to AdwPreferencesDialog
Diffstat (limited to 'src')
-rw-r--r-- | src/application.rs | 5 | ||||
-rw-r--r-- | src/furtherance.gresource.xml | 2 | ||||
-rw-r--r-- | src/gtk/preferences_dialog.ui (renamed from src/gtk/preferences_window.ui) | 2 | ||||
-rw-r--r-- | src/meson.build | 2 | ||||
-rw-r--r-- | src/ui.rs | 4 | ||||
-rw-r--r-- | src/ui/preferences_dialog.rs (renamed from src/ui/preferences_window.rs) | 43 |
6 files changed, 26 insertions, 32 deletions
diff --git a/src/application.rs b/src/application.rs index 8484b91..d03fe97 100644 --- a/src/application.rs +++ b/src/application.rs @@ -25,7 +25,7 @@ use std::sync::Mutex; use crate::config; use crate::database; use crate::settings_manager; -use crate::ui::{FurPreferencesWindow, FurReport, FurtheranceWindow}; +use crate::ui::{FurPreferencesDialog, FurReport, FurtheranceWindow}; mod imp { use super::*; @@ -117,7 +117,8 @@ impl FurtheranceApplication { let preferences_action = gio::SimpleAction::new("preferences", None); preferences_action.connect_activate(clone!(@weak self as app => move |_, _| { - FurPreferencesWindow::new().show(); + let window = FurtheranceWindow::default(); + FurPreferencesDialog::new().present(&window); })); self.set_accels_for_action("app.preferences", &["<primary>comma"]); self.add_action(&preferences_action); diff --git a/src/furtherance.gresource.xml b/src/furtherance.gresource.xml index bd94858..96f7f67 100644 --- a/src/furtherance.gresource.xml +++ b/src/furtherance.gresource.xml @@ -2,7 +2,7 @@ <gresources> <gresource prefix="/com/lakoliu/Furtherance"> <file>gtk/history_box.ui</file> - <file>gtk/preferences_window.ui</file> + <file>gtk/preferences_dialog.ui</file> <file>gtk/report.ui</file> <file>gtk/style.css</file> <file>gtk/task_details.ui</file> diff --git a/src/gtk/preferences_window.ui b/src/gtk/preferences_dialog.ui index 4649c9e..2971d88 100644 --- a/src/gtk/preferences_window.ui +++ b/src/gtk/preferences_dialog.ui @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <template class="FurPreferencesWindow" parent="AdwPreferencesWindow"> + <template class="FurPreferencesDialog" parent="AdwPreferencesDialog"> <child> <object class="AdwPreferencesPage"> <property name="icon_name">emblem-system-symbolic</property> diff --git a/src/meson.build b/src/meson.build index b2bde7b..d7afa7a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -31,7 +31,7 @@ run_command( rust_sources = files( 'ui.rs', - 'ui/preferences_window.rs', + 'ui/preferences_dialog.rs', 'ui/report.rs', 'ui/task_details.rs', 'ui/task_row.rs', diff --git a/src/ui.rs b/src/ui.rs index d1ef0d3..ffc2431 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -15,7 +15,7 @@ // along with this program. If not, see <https://www.gnu.org/licenses/>. mod history_box; -mod preferences_window; +mod preferences_dialog; mod report; mod task_details; mod task_row; @@ -24,7 +24,7 @@ mod tasks_page; pub mod window; pub use history_box::FurHistoryBox; -pub use preferences_window::FurPreferencesWindow; +pub use preferences_dialog::FurPreferencesDialog; pub use report::FurReport; pub use task_details::FurTaskDetails; pub use task_row::FurTaskRow; diff --git a/src/ui/preferences_window.rs b/src/ui/preferences_dialog.rs index 90a28ff..2396aef 100644 --- a/src/ui/preferences_window.rs +++ b/src/ui/preferences_dialog.rs @@ -31,8 +31,8 @@ mod imp { use glib::subclass; #[derive(Default, Debug, CompositeTemplate)] - #[template(resource = "/com/lakoliu/Furtherance/gtk/preferences_window.ui")] - pub struct FurPreferencesWindow { + #[template(resource = "/com/lakoliu/Furtherance/gtk/preferences_dialog.ui")] + pub struct FurPreferencesDialog { // General Page // Appearance Group #[template_child] @@ -90,10 +90,10 @@ mod imp { } #[glib::object_subclass] - impl ObjectSubclass for FurPreferencesWindow { - const NAME: &'static str = "FurPreferencesWindow"; - type ParentType = adw::PreferencesWindow; - type Type = super::FurPreferencesWindow; + impl ObjectSubclass for FurPreferencesDialog { + const NAME: &'static str = "FurPreferencesDialog"; + type ParentType = adw::PreferencesDialog; + type Type = super::FurPreferencesDialog; fn class_init(klass: &mut Self::Class) { Self::bind_template(klass); @@ -104,12 +104,9 @@ mod imp { } } - impl ObjectImpl for FurPreferencesWindow { + impl ObjectImpl for FurPreferencesDialog { fn constructed(&self) { - let window = FurtheranceWindow::default(); let obj = self.obj(); - obj.set_transient_for(Some(&window)); - obj.setup_signals(); obj.setup_widgets(); @@ -117,31 +114,27 @@ mod imp { } } - impl WidgetImpl for FurPreferencesWindow {} + impl WidgetImpl for FurPreferencesDialog {} - impl WindowImpl for FurPreferencesWindow {} + impl AdwDialogImpl for FurPreferencesDialog {} - impl AdwWindowImpl for FurPreferencesWindow {} - - impl PreferencesWindowImpl for FurPreferencesWindow {} + impl PreferencesDialogImpl for FurPreferencesDialog {} } glib::wrapper! { - pub struct FurPreferencesWindow( - ObjectSubclass<imp::FurPreferencesWindow>) - @extends gtk::Widget, gtk::Window, adw::Window, adw::PreferencesWindow; + pub struct FurPreferencesDialog( + ObjectSubclass<imp::FurPreferencesDialog>) + @extends gtk::Widget, adw::Dialog, adw::PreferencesDialog; } -impl FurPreferencesWindow { +impl FurPreferencesDialog { pub fn new() -> Self { - glib::Object::new::<FurPreferencesWindow>() + glib::Object::new::<FurPreferencesDialog>() } fn setup_widgets(&self) { - self.set_search_enabled(false); - - let imp = imp::FurPreferencesWindow::from_obj(self); + let imp = imp::FurPreferencesDialog::from_obj(self); let manager = adw::StyleManager::default(); let support_darkmode = manager.system_supports_color_schemes(); @@ -152,7 +145,7 @@ impl FurPreferencesWindow { } fn setup_signals(&self) { - let imp = imp::FurPreferencesWindow::from_obj(self); + let imp = imp::FurPreferencesDialog::from_obj(self); settings_manager::bind_property("dark-mode", &*imp.dark_theme_switch, "active"); @@ -281,7 +274,7 @@ impl FurPreferencesWindow { let settings = settings_manager::get_settings(); let _ = settings.set_string("database-loc", &path.to_string()); - let imp2 = imp::FurPreferencesWindow::from_obj(&this2); + let imp2 = imp::FurPreferencesDialog::from_obj(&this2); imp2.database_loc_row.set_subtitle(&path.to_string()); let window = FurtheranceWindow::default(); |