Implement notification dismiss

This commit is contained in:
bleakgrey 2018-04-17 15:10:57 +03:00
parent f0bf2cfcce
commit e0de712c04
2 changed files with 17 additions and 0 deletions

View File

@ -64,5 +64,7 @@ public class Tootle.NotificationsView : Tootle.AbstractView {
}
});
}
}

View File

@ -22,6 +22,11 @@ public class Tootle.NotificationWidget : Gtk.Grid {
label.use_markup = true;
dismiss = new Gtk.Button.from_icon_name ("close-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
dismiss.tooltip_text = _("Dismiss");
dismiss.clicked.connect (() => {
var parent = this.get_parent () as Gtk.Box;
parent.remove (this);
dismiss_notification (this.notification);
});
attach(image, 0, 0, 1, 1);
attach(label, 1, 0, 1, 1);
@ -41,5 +46,15 @@ public class Tootle.NotificationWidget : Gtk.Grid {
attach(status_widget, 0, 1, 3, 1);
}
}
public static Soup.Message dismiss_notification (Notification notification){
var url = Settings.instance.instance_url;
url += "api/v1/notifications/dismiss";
url += "?id=" + notification.id.to_string ();
var msg = new Soup.Message("POST", url);
NetManager.instance.queue(msg, (sess, mess) => {});
return msg;
}
}