[gnome-software/859-app-has-been-installed-notifications-sit-around-indefinitely: 23/25] gs-common: Introduce gs_utils_withdraw_notifications()




commit ed95879bac91137beaeecbade37be97031a645f5
Author: Milan Crha <mcrha redhat com>
Date:   Fri May 13 09:56:00 2022 +0200

    gs-common: Introduce gs_utils_withdraw_notifications()
    
    It can be used to remove notifications, which lose their meaning
    after some time.

 src/gs-common.c | 24 ++++++++++++++++++++++++
 src/gs-common.h |  1 +
 2 files changed, 25 insertions(+)
---
diff --git a/src/gs-common.c b/src/gs-common.c
index f97a8c570..18bd7fadb 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -974,3 +974,27 @@ gs_utils_format_size (guint64 size_bytes,
        return g_format_size (size_bytes);
 #endif /* HAVE_G_FORMAT_SIZE_ONLY_VALUE */
 }
+
+/**
+ * gs_utils_withdraw_notifications:
+ * @application: (nullable): a #GApplication, or %NULL
+ *
+ * Withdraws notifications, which are relevant only for some time, like
+ * when an application was installed or when a restart is required
+ * to be able to use an application.
+ *
+ * When the @application is %NULL, the default %GApplication is used
+ * to do the withdraw.
+ *
+ * Since: 43
+ **/
+void
+gs_utils_withdraw_notifications (GApplication *application)
+{
+       if (!application)
+               application = g_application_get_default ();
+       if (application) {
+               g_application_withdraw_notification (application, "installed");
+               g_application_withdraw_notification (application, "restart-required");
+       }
+}
diff --git a/src/gs-common.h b/src/gs-common.h
index 8d60d46d3..8a30cf37f 100644
--- a/src/gs-common.h
+++ b/src/gs-common.h
@@ -64,5 +64,6 @@ gboolean      gs_utils_split_time_difference  (gint64 unix_time_seconds,
                                                 gint *out_years_ago);
 gchar          *gs_utils_format_size           (guint64 size_bytes,
                                                 gboolean *out_is_markup);
+void           gs_utils_withdraw_notifications (GApplication *application);
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]