messenger-gtk

Gtk+3 graphical user interfaces for GNUnet Messenger
Log | Files | Refs | Submodules | README | LICENSE

commit adb48d1537549e35a4164a975785d1b946f54488
parent beaa1080606c0ce173cd61afd0b6ac25ffd94116
Author: TheJackiMonster <thejackimonster@gmail.com>
Date:   Wed, 22 Dec 2021 11:45:36 +0100

Added cleanup for notifications

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>

Diffstat:
Msrc/application.c | 13+++++++++++++
Msrc/application.h | 5+++--
Msrc/contact.c | 3---
Msrc/contact.h | 1-
Msrc/event.c | 15++++++++++++---
5 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/src/application.c b/src/application.c @@ -70,6 +70,7 @@ application_init(MESSENGER_Application *app, ); notify_init("Messenger-GTK"); + app->notifications = NULL; _load_ui_stylesheets(); @@ -163,6 +164,18 @@ application_run(MESSENGER_Application *app) pthread_mutex_destroy(&(app->chat.mutex)); + GList *list = app->notifications; + + while (list) { + if (list->data) + notify_notification_close(NOTIFY_NOTIFICATION(list->data), NULL); + + list = list->next; + } + + if (app->notifications) + g_list_free(app->notifications); + notify_uninit(); g_object_unref(app->application); diff --git a/src/application.h b/src/application.h @@ -51,10 +51,11 @@ typedef enum MESSENGER_ApplicationSignal typedef struct MESSENGER_Application { - char** argv; + char **argv; int argc; - GtkApplication* application; + GtkApplication *application; + GList *notifications; struct { int status; diff --git a/src/contact.c b/src/contact.c @@ -52,9 +52,6 @@ contact_destroy_info(struct GNUNET_CHAT_Contact *contact) if (info->name_avatars) g_list_free(info->name_avatars); - if (info->name_notifications) - g_list_free(info->name_notifications); - g_free(info); GNUNET_CHAT_contact_set_user_pointer(contact, NULL); diff --git a/src/contact.h b/src/contact.h @@ -31,7 +31,6 @@ typedef struct MESSENGER_ContactInfo { GList *name_labels; GList *name_avatars; - GList *name_notifications; } MESSENGER_ContactInfo; void diff --git a/src/event.c b/src/event.c @@ -33,8 +33,12 @@ static void _close_notification(NotifyNotification* notification, - UNUSED gpointer user_data) + gpointer user_data) { + MESSENGER_Application *app = (MESSENGER_Application*) user_data; + + app->notifications = g_list_remove(app->notifications, notification); + notify_notification_clear_actions(notification); notify_notification_clear_hints(notification); @@ -42,7 +46,7 @@ _close_notification(NotifyNotification* notification, } static void -_show_notification(UNUSED MESSENGER_Application *app, +_show_notification(MESSENGER_Application *app, UNUSED struct GNUNET_CHAT_Context *context, const struct GNUNET_CHAT_Contact *contact, const gchar *text, @@ -54,6 +58,11 @@ _show_notification(UNUSED MESSENGER_Application *app, sender? sender : "(unknown)", text, icon ); + if (!notification) + return; + + app->notifications = g_list_append(app->notifications, notification); + if (0 == g_strcmp0(icon, "avatar-default-symbolic")) notify_notification_set_category(notification, "presence.online"); else @@ -63,7 +72,7 @@ _show_notification(UNUSED MESSENGER_Application *app, notification, "closed", G_CALLBACK(_close_notification), - NULL + app ); notify_notification_show(notification, NULL);