Expire notifications from notification tray
1 unresolved thread
1 unresolved thread
This makes sure notifications get removed from notification-source when expired (which then removes them from the notification-list in the settings-menu.
@zbrown is that the place to intended for this our should that be done by the notification-list itself to have some leeway whether to auto expire notifications?
Closes: #351
Edited by Guido Gunther
Merge request reports
Activity
Filter activity
added 4 commits
-
c177f508...c172d910 - 2 commits from branch
Librem5:master
- bddd16d3 - notification-source: Split out code to remove notificatons
- f34e3190 - notification-source: Also remove notifications when expired
-
c177f508...c172d910 - 2 commits from branch
but it doesn't happen atm (the removal from source)
Edited by Guido GuntherI'm fairly certain it does
g_signal_connect_object (notification, "expired", G_CALLBACK (on_notification_expired), self, G_CONNECT_SWAPPED);
static void on_notification_expired (PhoshNotifyManager *self, PhoshNotification *notification) { guint id = 0; g_return_if_fail (PHOSH_IS_NOTIFY_MANAGER (self)); g_return_if_fail (PHOSH_IS_NOTIFICATION (notification)); id = phosh_notification_get_id (notification); g_debug ("Notification %u expired", id); /* Transient notifications are closed rather than staying in the tray */ if (phosh_notification_get_transient (notification)) { phosh_notification_close (notification, PHOSH_NOTIFICATION_REASON_EXPIRED); } }
void phosh_notification_close (PhoshNotification *self, PhoshNotificationReason reason) { g_return_if_fail (PHOSH_IS_NOTIFICATION (self)); // No point running the timeout, we're already closing if (self->timeout != 0) { g_source_remove (self->timeout); self->timeout = 0; } g_signal_emit (self, signals[SIGNAL_CLOSED], 0, reason); }
g_signal_connect_object (notification, "closed", G_CALLBACK (on_notification_closed), self, G_CONNECT_SWAPPED);
static void on_notification_closed (PhoshNotifyManager *self, PhoshNotificationReason reason, PhoshNotification *notification) { guint id; g_return_if_fail (PHOSH_IS_NOTIFY_MANAGER (self)); g_return_if_fail (PHOSH_IS_NOTIFICATION (notification)); id = phosh_notification_get_id (notification); g_debug ("Emitting NotificationClosed: %d, %d", id, reason); phosh_notify_dbus_notifications_emit_notification_closed ( PHOSH_NOTIFY_DBUS_NOTIFICATIONS (self), id, reason); }
g_signal_connect_object (notification, "closed", G_CALLBACK (closed), self, G_CONNECT_SWAPPED);
static void closed (PhoshNotificationSource *self, PhoshNotificationReason reason, PhoshNotification *notification) { int i = 0; gpointer item = NULL; gboolean found = FALSE; g_return_if_fail (PHOSH_IS_NOTIFICATION_SOURCE (self)); g_return_if_fail (PHOSH_IS_NOTIFICATION (notification)); while ((item = g_list_model_get_item (G_LIST_MODEL (self->list), i))) { if (item == notification) { g_list_store_remove (self->list, i); g_clear_object (&item); found = TRUE; g_clear_object (&item); break; } g_clear_object (&item); i++; g_clear_object (&item); } if (!found) { g_critical ("Can't remove unknown notification %p", notification); } }
Please register or sign in to reply