Hello,
I’m trying to develop a Rust app which runs on background when closed (by using hide_on_close property on the ApplicationWindow) and send notifications to user with gio::Notificaiton.
Here is the example of creating the Application:
use adw::{Application};
fn main() {
let application = Application::builder()
.application_id("com.example.test")
.build();
application.connect_activate(on_activate);
application.run();
}
Then I send a notification anywhere inside the program:
let notif = Notification::new(format!("{} minutes left!", total_minutes).as_str());
app.send_notification(Some("time-warning"), ¬if);
After I clicked the notification, it creates another instance of the application (calls on_activate again). This makes application create the UI windows all over again because all the UI initialized in on_activate function.
How can I handle notifications properly? Can I get an information in on_activate
function if it’s activated by a notification or not?
(it is actually not spesific a question on Rust, it is about how GTK works generally)
Thanks!