2020-07-30 18:57:21 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <tllist.h>
|
|
|
|
|
|
2021-02-12 09:25:29 +01:00
|
|
|
#include "macros.h"
|
|
|
|
|
|
2020-08-01 09:00:18 +02:00
|
|
|
enum user_notification_kind {
|
|
|
|
|
USER_NOTIFICATION_DEPRECATED,
|
|
|
|
|
USER_NOTIFICATION_WARNING,
|
|
|
|
|
USER_NOTIFICATION_ERROR,
|
|
|
|
|
};
|
|
|
|
|
|
2020-07-30 18:57:21 +02:00
|
|
|
struct user_notification {
|
2020-08-01 09:00:18 +02:00
|
|
|
enum user_notification_kind kind;
|
2020-07-30 18:57:21 +02:00
|
|
|
char *text;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef tll(struct user_notification) user_notifications_t;
|
2020-09-08 19:17:29 +02:00
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
user_notifications_free(user_notifications_t *notifications)
|
|
|
|
|
{
|
|
|
|
|
tll_foreach(*notifications, it)
|
|
|
|
|
free(it->item.text);
|
|
|
|
|
tll_free(*notifications);
|
|
|
|
|
}
|
2021-02-12 09:25:29 +01:00
|
|
|
|
2021-11-14 15:08:47 +00:00
|
|
|
static inline void
|
|
|
|
|
user_notification_add(user_notifications_t *notifications,
|
|
|
|
|
enum user_notification_kind kind, char *text)
|
|
|
|
|
{
|
|
|
|
|
struct user_notification notification = {
|
|
|
|
|
.kind = kind,
|
|
|
|
|
.text = text
|
|
|
|
|
};
|
|
|
|
|
tll_push_back(*notifications, notification);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void user_notification_add_fmt(user_notifications_t *notifications,
|
2021-02-12 09:25:29 +01:00
|
|
|
enum user_notification_kind kind,
|
|
|
|
|
const char *fmt, ...) PRINTF(3);
|