2024-10-29 13:02:29 +00:00
|
|
|
mod imp {
|
|
|
|
use crate::ui;
|
|
|
|
use adw::prelude::*;
|
|
|
|
use adw::subclass::prelude::*;
|
|
|
|
use gtk::glib;
|
2024-10-29 12:01:42 +00:00
|
|
|
|
2024-10-29 13:02:29 +00:00
|
|
|
#[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;
|
2024-10-29 12:01:42 +00:00
|
|
|
}
|
|
|
|
|
2024-10-29 13:02:29 +00:00
|
|
|
impl ObjectImpl for Application {}
|
|
|
|
|
|
|
|
impl ApplicationImpl for Application {
|
|
|
|
fn activate(&self) {
|
|
|
|
self.parent_activate();
|
|
|
|
match self.obj().active_window() {
|
|
|
|
None => ui::Window::new(self.obj().as_ref()).present(),
|
|
|
|
Some(win) => win.present(),
|
|
|
|
}
|
|
|
|
}
|
2024-10-29 12:01:42 +00:00
|
|
|
}
|
|
|
|
|
2024-10-29 13:02:29 +00:00
|
|
|
impl GtkApplicationImpl for Application {}
|
|
|
|
|
|
|
|
impl AdwApplicationImpl for Application {}
|
2024-10-29 12:01:42 +00:00
|
|
|
}
|
|
|
|
|
2024-10-29 13:02:29 +00:00
|
|
|
use gtk::{gio, glib};
|
|
|
|
|
2024-10-29 12:01:42 +00:00
|
|
|
glib::wrapper! {
|
2024-10-29 13:02:29 +00:00
|
|
|
pub struct Application(ObjectSubclass<imp::Application>)
|
2024-10-29 12:01:42 +00:00
|
|
|
@extends adw::Application, gtk::Application, gio::Application,
|
|
|
|
@implements gio::ActionGroup, gio::ActionMap;
|
|
|
|
}
|
|
|
|
|
2024-10-30 03:26:53 +00:00
|
|
|
impl Default for Application {
|
|
|
|
fn default() -> Self {
|
|
|
|
glib::Object::builder::<Application>()
|
2024-11-01 08:47:03 +00:00
|
|
|
.property("application-id", crate::APP_ID)
|
2024-10-29 13:02:29 +00:00
|
|
|
.property("flags", gio::ApplicationFlags::default())
|
|
|
|
.build()
|
2024-10-29 12:01:42 +00:00
|
|
|
}
|
|
|
|
}
|
2024-10-30 03:26:53 +00:00
|
|
|
|
|
|
|
impl Application {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
Self::default()
|
|
|
|
}
|
|
|
|
}
|