[gnome-builder/gnome-builder-3-32] notification: remove notifications when pipeline changes



commit 9046070dc92ce13485ca6c16810b827a02417722
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 e32aab866..bebbf5ad4 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]