Skip to content
Snippets Groups Projects

Expire notifications from notification tray

Closed Guido Gunther requested to merge guido.gunther/phosh:notification-expire into master
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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Guido Gunther added 2 commits

    added 2 commits

    • 301f07b2 - notification-source: Split out code to remove notificatons
    • c177f508 - notification-source: Also remove notifications when expired

    Compare with previous version

  • Guido Gunther added 4 commits

    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

    Compare with previous version

    • Notify manager is supposed to be listening for expired and call close(EXPIRED) for non-transient notifications, which should already remove it from the source

    • but it doesn't happen atm (the removal from source)

      Edited by Guido Gunther
    • I'm fairly certain it does

          g_signal_connect_object (notification,
                                   "expired",
                                   G_CALLBACK (on_notification_expired),
                                   self,
                                   G_CONNECT_SWAPPED);

      notify-manager.c#L423-427

      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);
        }
      }

      notify-manager.c#L126-144

      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);
      }

      notification.c#L866-879

         g_signal_connect_object (notification,
                                  "closed",
                                  G_CALLBACK (on_notification_closed),
                                  self,
                                  G_CONNECT_SWAPPED);

      notify-manager.c#L433-437

      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);
      }

      notify-manager.c#L174-190

        g_signal_connect_object (notification,
                                 "closed",
                                 G_CALLBACK (closed),
                                 self,
                                 G_CONNECT_SWAPPED);

      notification-source.c#L248-252

      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);
        }
      }

      notification-source.c#L208-236

    • Please register or sign in to reply
  • Guido Gunther changed the description

    changed the description

  • closed

  • Guido Gunther changed the description

    changed the description

Please register or sign in to reply
Loading