Add system notification support for crashes and updates
This commit is contained in:
@@ -1,6 +1,23 @@
|
||||
use gtk::gio;
|
||||
use gtk::prelude::*;
|
||||
|
||||
use super::database::Database;
|
||||
use super::security;
|
||||
|
||||
/// Send a desktop notification via gio.
|
||||
pub fn send_system_notification(
|
||||
app: &gio::Application,
|
||||
id: &str,
|
||||
title: &str,
|
||||
body: &str,
|
||||
priority: gio::NotificationPriority,
|
||||
) {
|
||||
let notification = gio::Notification::new(title);
|
||||
notification.set_body(Some(body));
|
||||
notification.set_priority(priority);
|
||||
app.send_notification(Some(id), ¬ification);
|
||||
}
|
||||
|
||||
/// A CVE notification to send to the user.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CveNotification {
|
||||
|
||||
@@ -11,6 +11,7 @@ use crate::core::footprint;
|
||||
use crate::core::fuse::{self, FuseStatus};
|
||||
use crate::core::integrator;
|
||||
use crate::core::launcher::{self, SandboxMode};
|
||||
use crate::core::notification;
|
||||
use crate::core::security;
|
||||
use crate::core::updater;
|
||||
use crate::core::wayland::{self, WaylandStatus};
|
||||
@@ -148,6 +149,15 @@ pub fn build_detail_page(record: &AppImageRecord, db: &Rc<Database>) -> adw::Nav
|
||||
Ok(launcher::LaunchResult::Crashed { exit_code, stderr, method }) => {
|
||||
log::error!("App crashed on launch (exit {}, method: {}): {}", exit_code.unwrap_or(-1), method.as_str(), stderr);
|
||||
widgets::show_crash_dialog(&btn_ref, &app_name, exit_code, &stderr);
|
||||
if let Some(app) = gtk::gio::Application::default() {
|
||||
notification::send_system_notification(
|
||||
&app,
|
||||
&format!("crash-{}", record_id),
|
||||
&format!("{} crashed", app_name),
|
||||
&stderr.chars().take(200).collect::<String>(),
|
||||
gtk::gio::NotificationPriority::Urgent,
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(launcher::LaunchResult::Failed(msg)) => {
|
||||
log::error!("Failed to launch: {}", msg);
|
||||
|
||||
Reference in New Issue
Block a user