mod imp { use crate::ui; use adw::{prelude::*, subclass::prelude::*}; use gtk::glib; use tracing::{event, Level}; #[derive(Default)] pub struct Application {} #[glib::object_subclass] impl ObjectSubclass for Application { const NAME: &'static str = "AudreyApplication"; type Type = super::Application; type ParentType = adw::Application; } impl ObjectImpl for Application {} impl ApplicationImpl for Application { fn activate(&self) { self.parent_activate(); match self.obj().active_window() { None => { let window = ui::Window::new(self.obj().as_ref()); window.present(); } Some(win) => win.present(), } } } impl GtkApplicationImpl for Application {} impl AdwApplicationImpl for Application {} impl Application {} impl Drop for Application { fn drop(&mut self) { event!(Level::DEBUG, "dropping AudreyApplication"); } } } use gtk::{gio, glib}; glib::wrapper! { pub struct Application(ObjectSubclass) @extends adw::Application, gtk::Application, gio::Application, @implements gio::ActionGroup, gio::ActionMap; } impl Default for Application { fn default() -> Self { glib::Object::builder::() .property("application-id", crate::APP_ID) .property("flags", gio::ApplicationFlags::default()) .build() } } impl Application { pub fn new() -> Self { Self::default() } }