[gnome-builder] plugins/notification: add default message for notification title
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/notification: add default message for notification title
- Date: Tue, 20 Sep 2022 21:29:50 +0000 (UTC)
commit 7cc161eb6369009367a10f7a12398c945afed63b
Author: Christian Hergert <chergert redhat com>
Date: Tue Sep 20 14:29:21 2022 -0700
plugins/notification: add default message for notification title
This should fix an "empty notification title" in the omnibar when building
with not message received from the workers.
src/plugins/notification/ide-notification-addin.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/notification/ide-notification-addin.c
b/src/plugins/notification/ide-notification-addin.c
index 73484fcfd..b3a76701c 100644
--- a/src/plugins/notification/ide-notification-addin.c
+++ b/src/plugins/notification/ide-notification-addin.c
@@ -50,6 +50,22 @@ G_DEFINE_FINAL_TYPE_WITH_CODE (IdeNotificationAddin,
IDE_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (IDE_TYPE_PIPELINE_ADDIN, addin_iface_init))
+static gboolean
+title_with_default (GBinding *binding,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data)
+{
+ g_autofree char *str = g_strstrip (g_value_dup_string (from_value));
+
+ if (ide_str_empty0 (str))
+ g_value_set_static_string (to_value, _("Building…"));
+ else
+ g_value_take_string (to_value, g_steal_pointer (&str));
+
+ return TRUE;
+}
+
static gboolean
should_supress_message (IdeNotificationAddin *self,
const gchar *message)
@@ -162,7 +178,9 @@ ide_notification_addin_pipeline_started (IdeNotificationAddin *self,
{
/* Setup new in-app notification */
self->notif = ide_notification_new ();
- g_object_bind_property (pipeline, "message", self->notif, "title", G_BINDING_SYNC_CREATE);
+ g_object_bind_property_full (pipeline, "message", self->notif, "title",
+ G_BINDING_SYNC_CREATE,
+ title_with_default, NULL, NULL, NULL);
ide_notification_attach (self->notif, IDE_OBJECT (pipeline));
/* Withdraw previous shell notification (it's now invalid) */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]