diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2021-12-22 11:45:36 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2021-12-22 11:45:36 +0100 |
commit | adb48d1537549e35a4164a975785d1b946f54488 (patch) | |
tree | 95f2e04cae6d1089e599d6e962d5deaf67b4f4cb | |
parent | beaa1080606c0ce173cd61afd0b6ac25ffd94116 (diff) | |
download | messenger-gtk-adb48d1537549e35a4164a975785d1b946f54488.tar.gz messenger-gtk-adb48d1537549e35a4164a975785d1b946f54488.zip |
Added cleanup for notifications
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | src/application.c | 13 | ||||
-rw-r--r-- | src/application.h | 5 | ||||
-rw-r--r-- | src/contact.c | 3 | ||||
-rw-r--r-- | src/contact.h | 1 | ||||
-rw-r--r-- | src/event.c | 15 |
5 files changed, 28 insertions, 9 deletions
diff --git a/src/application.c b/src/application.c index 24b6490..7c78de0 100644 --- a/src/application.c +++ b/src/application.c | |||
@@ -70,6 +70,7 @@ application_init(MESSENGER_Application *app, | |||
70 | ); | 70 | ); |
71 | 71 | ||
72 | notify_init("Messenger-GTK"); | 72 | notify_init("Messenger-GTK"); |
73 | app->notifications = NULL; | ||
73 | 74 | ||
74 | _load_ui_stylesheets(); | 75 | _load_ui_stylesheets(); |
75 | 76 | ||
@@ -163,6 +164,18 @@ application_run(MESSENGER_Application *app) | |||
163 | 164 | ||
164 | pthread_mutex_destroy(&(app->chat.mutex)); | 165 | pthread_mutex_destroy(&(app->chat.mutex)); |
165 | 166 | ||
167 | GList *list = app->notifications; | ||
168 | |||
169 | while (list) { | ||
170 | if (list->data) | ||
171 | notify_notification_close(NOTIFY_NOTIFICATION(list->data), NULL); | ||
172 | |||
173 | list = list->next; | ||
174 | } | ||
175 | |||
176 | if (app->notifications) | ||
177 | g_list_free(app->notifications); | ||
178 | |||
166 | notify_uninit(); | 179 | notify_uninit(); |
167 | 180 | ||
168 | g_object_unref(app->application); | 181 | g_object_unref(app->application); |
diff --git a/src/application.h b/src/application.h index 825b140..3c51a87 100644 --- a/src/application.h +++ b/src/application.h | |||
@@ -51,10 +51,11 @@ typedef enum MESSENGER_ApplicationSignal | |||
51 | 51 | ||
52 | typedef struct MESSENGER_Application | 52 | typedef struct MESSENGER_Application |
53 | { | 53 | { |
54 | char** argv; | 54 | char **argv; |
55 | int argc; | 55 | int argc; |
56 | 56 | ||
57 | GtkApplication* application; | 57 | GtkApplication *application; |
58 | GList *notifications; | ||
58 | 59 | ||
59 | struct { | 60 | struct { |
60 | int status; | 61 | int status; |
diff --git a/src/contact.c b/src/contact.c index e1ae097..e87e87b 100644 --- a/src/contact.c +++ b/src/contact.c | |||
@@ -52,9 +52,6 @@ contact_destroy_info(struct GNUNET_CHAT_Contact *contact) | |||
52 | if (info->name_avatars) | 52 | if (info->name_avatars) |
53 | g_list_free(info->name_avatars); | 53 | g_list_free(info->name_avatars); |
54 | 54 | ||
55 | if (info->name_notifications) | ||
56 | g_list_free(info->name_notifications); | ||
57 | |||
58 | g_free(info); | 55 | g_free(info); |
59 | 56 | ||
60 | GNUNET_CHAT_contact_set_user_pointer(contact, NULL); | 57 | GNUNET_CHAT_contact_set_user_pointer(contact, NULL); |
diff --git a/src/contact.h b/src/contact.h index 4ff1d7e..15c7c9f 100644 --- a/src/contact.h +++ b/src/contact.h | |||
@@ -31,7 +31,6 @@ typedef struct MESSENGER_ContactInfo | |||
31 | { | 31 | { |
32 | GList *name_labels; | 32 | GList *name_labels; |
33 | GList *name_avatars; | 33 | GList *name_avatars; |
34 | GList *name_notifications; | ||
35 | } MESSENGER_ContactInfo; | 34 | } MESSENGER_ContactInfo; |
36 | 35 | ||
37 | void | 36 | void |
diff --git a/src/event.c b/src/event.c index 4540567..9bbc064 100644 --- a/src/event.c +++ b/src/event.c | |||
@@ -33,8 +33,12 @@ | |||
33 | 33 | ||
34 | static void | 34 | static void |
35 | _close_notification(NotifyNotification* notification, | 35 | _close_notification(NotifyNotification* notification, |
36 | UNUSED gpointer user_data) | 36 | gpointer user_data) |
37 | { | 37 | { |
38 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | ||
39 | |||
40 | app->notifications = g_list_remove(app->notifications, notification); | ||
41 | |||
38 | notify_notification_clear_actions(notification); | 42 | notify_notification_clear_actions(notification); |
39 | notify_notification_clear_hints(notification); | 43 | notify_notification_clear_hints(notification); |
40 | 44 | ||
@@ -42,7 +46,7 @@ _close_notification(NotifyNotification* notification, | |||
42 | } | 46 | } |
43 | 47 | ||
44 | static void | 48 | static void |
45 | _show_notification(UNUSED MESSENGER_Application *app, | 49 | _show_notification(MESSENGER_Application *app, |
46 | UNUSED struct GNUNET_CHAT_Context *context, | 50 | UNUSED struct GNUNET_CHAT_Context *context, |
47 | const struct GNUNET_CHAT_Contact *contact, | 51 | const struct GNUNET_CHAT_Contact *contact, |
48 | const gchar *text, | 52 | const gchar *text, |
@@ -54,6 +58,11 @@ _show_notification(UNUSED MESSENGER_Application *app, | |||
54 | sender? sender : "(unknown)", text, icon | 58 | sender? sender : "(unknown)", text, icon |
55 | ); | 59 | ); |
56 | 60 | ||
61 | if (!notification) | ||
62 | return; | ||
63 | |||
64 | app->notifications = g_list_append(app->notifications, notification); | ||
65 | |||
57 | if (0 == g_strcmp0(icon, "avatar-default-symbolic")) | 66 | if (0 == g_strcmp0(icon, "avatar-default-symbolic")) |
58 | notify_notification_set_category(notification, "presence.online"); | 67 | notify_notification_set_category(notification, "presence.online"); |
59 | else | 68 | else |
@@ -63,7 +72,7 @@ _show_notification(UNUSED MESSENGER_Application *app, | |||
63 | notification, | 72 | notification, |
64 | "closed", | 73 | "closed", |
65 | G_CALLBACK(_close_notification), | 74 | G_CALLBACK(_close_notification), |
66 | NULL | 75 | app |
67 | ); | 76 | ); |
68 | 77 | ||
69 | notify_notification_show(notification, NULL); | 78 | notify_notification_show(notification, NULL); |