[gnome-builder/gnome-builder-3-32] notification: remove xdg notification when build starts



commit d1b2aa599640a542d4ffba3f7109db3af038b834
Author: Christian Hergert <chergert redhat com>
Date:   Fri May 10 10:21:48 2019 -0700

    notification: remove xdg notification when build starts
    
    If we get a non-supressed build (something we will be later notifying
    about), then we should cancel any current notification for the project
    since it's out of date.

 src/plugins/notification/ide-notification-addin.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/src/plugins/notification/ide-notification-addin.c 
b/src/plugins/notification/ide-notification-addin.c
index bebbf5ad4..ad4d8e998 100644
--- a/src/plugins/notification/ide-notification-addin.c
+++ b/src/plugins/notification/ide-notification-addin.c
@@ -170,12 +170,27 @@ ide_notification_addin_build_started (IdeNotificationAddin *self,
   self->requested_phase = phase;
   self->supress = phase < IDE_PIPELINE_PHASE_BUILD;
 
+  g_assert (self->notif == NULL);
+
   if (self->requested_phase)
     {
       self->notif = ide_notification_new ();
       g_object_bind_property (pipeline, "message", self->notif, "title", G_BINDING_SYNC_CREATE);
       ide_notification_attach (self->notif, IDE_OBJECT (self));
     }
+
+  if (!self->supress)
+    {
+      g_autoptr(IdeContext) context = NULL;
+      g_autofree gchar *id = NULL;
+
+      /* Withdraw previous notification as it is now invalid because we will be
+       * notifying about this build soon.
+       */
+      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


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