[gnome-software/859-app-has-been-installed-notifications-sit-around-indefinitely: 25/25] gs-common: Auto-withdraw install/restart notifications after 24 hours
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/859-app-has-been-installed-notifications-sit-around-indefinitely: 25/25] gs-common: Auto-withdraw install/restart notifications after 24 hours
- Date: Mon, 16 May 2022 15:13:19 +0000 (UTC)
commit b87b5783fa01aab5f4a7657782505e7e95893835
Author: Milan Crha <mcrha redhat com>
Date: Fri May 13 09:59:59 2022 +0200
gs-common: Auto-withdraw install/restart notifications after 24 hours
That's for "app had been installed" and "requires restart" notifications
only at the moment.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/859
src/gs-common.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
---
diff --git a/src/gs-common.c b/src/gs-common.c
index 18bd7fadb..8c4e737a1 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -50,6 +50,27 @@ gs_grab_focus_when_mapped (GtkWidget *widget)
G_CALLBACK (grab_focus), NULL);
}
+static guint withdraw_notifications_id = 0;
+
+static gboolean
+gs_common_withdraw_notifications_cb (gpointer user_data)
+{
+ withdraw_notifications_id = 0;
+
+ gs_utils_withdraw_notifications (NULL);
+
+ return G_SOURCE_REMOVE;
+}
+
+static void
+gs_common_schedule_withdraw_notifications (void)
+{
+ if (withdraw_notifications_id)
+ g_source_remove (withdraw_notifications_id);
+ withdraw_notifications_id = g_timeout_add_seconds (24 * 60 * 60,
+ gs_common_withdraw_notifications_cb, NULL);
+}
+
void
gs_app_notify_installed (GsApp *app)
{
@@ -113,6 +134,7 @@ gs_app_notify_installed (GsApp *app)
g_notification_set_default_action_and_target (n, "app.details", "(ss)",
gs_app_get_unique_id (app), "");
g_application_send_notification (g_application_get_default (), "installed", n);
+ gs_common_schedule_withdraw_notifications ();
}
typedef enum {
@@ -768,6 +790,7 @@ gs_utils_reboot_notify (GsAppList *list,
g_notification_set_default_action_and_target (n, "app.set-mode", "s", "updates");
g_notification_set_priority (n, G_NOTIFICATION_PRIORITY_URGENT);
g_application_send_notification (g_application_get_default (), "restart-required", n);
+ gs_common_schedule_withdraw_notifications ();
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]