elementary / notifications

Gtk Notifications Server
https://elementary.io
GNU General Public License v3.0
38 stars 6 forks source link

Notifications are not withdrawn when using GLib.Application.withdraw_notification #154

Closed avojak closed 2 years ago

avojak commented 2 years ago

Prerequisites

Describe the bug

If I send a notification and provide an ID, then later attempt to withdraw the notification using the same ID, the notification is not removed from the notification area.

To Reproduce

Here's a quick MCVE to demonstrate the issue:

public class MyApp : Gtk.Application {

    public MyApp () {
        Object (
            application_id: "com.github.avojak.elementary-mcve",
            flags: ApplicationFlags.FLAGS_NONE
        );
    }

    protected override void activate () {
        var main_window = new Gtk.ApplicationWindow (this) {
            default_height = 300,
            default_width = 300,
            title = "Hello World"
        };
        var id = "com.github.avojak.elementary-mcve";
        var send_button = new Gtk.Button.with_label ("Send notification") {
            margin = 12
        };
        send_button.clicked.connect (() => {
            var notification = new GLib.Notification ("Hello World");
            notification.set_body ("This is a test");
            send_notification (id, notification);
        });
        var withdraw_button = new Gtk.Button.with_label ("Withdraw notification") {
            margin = 12
        };
        withdraw_button.clicked.connect (() => {
            withdraw_notification (id);
        });
        var button_grid = new Gtk.Grid ();
        button_grid.add (send_button);
        button_grid.add (withdraw_button);
        main_window.add (button_grid);
        main_window.show_all ();
    }

    public static int main (string[] args) {
        return new MyApp ().run (args);
    }

}

Expected behavior

The notification should be withdrawn from the notification area.

Screenshots or screen recordings

Logs

N/A - no log messages generated when running the example above

Platform Information

image

Additional context

danirabbit commented 2 years ago

Closing as a duplicate of https://github.com/elementary/wingpanel-indicator-notifications/issues/204