[gnome-builder] notification: remove notifications when pipeline changes
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] notification: remove notifications when pipeline changes
- Date: Fri, 10 May 2019 18:54:12 +0000 (UTC)
commit 1ae5b7b1a8a9e1ba89eaef30353a34584a0983f3
Author: Christian Hergert <chergert redhat com>
Date: Fri May 10 10:20:53 2019 -0700
notification: remove notifications when pipeline changes
src/plugins/notification/ide-notification-addin.c | 30 +++++++++++++++++++++++
1 file changed, 30 insertions(+)
---
diff --git a/src/plugins/notification/ide-notification-addin.c
b/src/plugins/notification/ide-notification-addin.c
index c0a1f8a2b..e21b4d5bc 100644
--- a/src/plugins/notification/ide-notification-addin.c
+++ b/src/plugins/notification/ide-notification-addin.c
@@ -118,6 +118,30 @@ ide_notification_addin_notify (IdeNotificationAddin *self,
g_application_send_notification (g_application_get_default (), id, notification);
}
+static void
+ide_notification_addin_notify_pipeline (IdeNotificationAddin *self,
+ GParamSpec *pspec,
+ IdeBuildManager *build_manager)
+{
+ g_assert (IDE_IS_NOTIFICATION_ADDIN (self));
+ g_assert (IDE_IS_BUILD_MANAGER (build_manager));
+
+ if (self->notif != NULL)
+ {
+ g_autoptr(IdeContext) context = NULL;
+ g_autofree gchar *id = NULL;
+
+ /* Remove notification, it is now invalid */
+ ide_notification_withdraw (self->notif);
+ g_clear_object (&self->notif);
+
+ /* Also withdraw from the shell */
+ context = ide_object_ref_context (IDE_OBJECT (build_manager));
+ id = ide_context_dup_project_id (context);
+ g_application_withdraw_notification (g_application_get_default (), id);
+ }
+}
+
static void
ide_notification_addin_build_started (IdeNotificationAddin *self,
IdePipeline *pipeline,
@@ -213,6 +237,12 @@ ide_notification_addin_load (IdePipelineAddin *addin,
build_manager = ide_build_manager_from_context (context);
g_assert (IDE_IS_BUILD_MANAGER (build_manager));
+ g_signal_connect_object (build_manager,
+ "notify::pipeline",
+ G_CALLBACK (ide_notification_addin_notify_pipeline),
+ self,
+ G_CONNECT_SWAPPED);
+
g_signal_connect_object (build_manager,
"build-started",
G_CALLBACK (ide_notification_addin_build_started),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]