diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2021-12-15 23:17:01 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2021-12-15 23:17:01 +0100 |
commit | 446862e5869e8888f829d9b6f4893663b7470274 (patch) | |
tree | d51bb757428d09a0ceca76dbe4f6b6566c1ae442 | |
parent | 22504147521a36c513c200f9ed3f413b679d3f75 (diff) | |
download | messenger-gtk-446862e5869e8888f829d9b6f4893663b7470274.tar.gz messenger-gtk-446862e5869e8888f829d9b6f4893663b7470274.zip |
-fixed usage of lists, synced avatars to names and added member count
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | resources/ui/message-status.ui | 1 | ||||
-rw-r--r-- | src/contact.c | 46 | ||||
-rw-r--r-- | src/contact.h | 5 | ||||
-rw-r--r-- | src/event.c | 47 | ||||
-rw-r--r-- | src/ui/chat.c | 24 | ||||
-rw-r--r-- | src/ui/contacts.c | 5 | ||||
-rw-r--r-- | src/ui/message.c | 11 | ||||
-rw-r--r-- | src/ui/message.h | 3 | ||||
-rw-r--r-- | src/ui/messenger.c | 15 | ||||
-rw-r--r-- | src/ui/new_group.c | 15 |
10 files changed, 94 insertions, 78 deletions
diff --git a/resources/ui/message-status.ui b/resources/ui/message-status.ui index 7d5b233..fb2057e 100644 --- a/resources/ui/message-status.ui +++ b/resources/ui/message-status.ui | |||
@@ -66,7 +66,6 @@ Author: Tobias Frisch | |||
66 | <object class="GtkLabel" id="text_label"> | 66 | <object class="GtkLabel" id="text_label"> |
67 | <property name="visible">True</property> | 67 | <property name="visible">True</property> |
68 | <property name="can-focus">False</property> | 68 | <property name="can-focus">False</property> |
69 | <property name="label" translatable="yes">invited you to a chat</property> | ||
70 | <property name="justify">center</property> | 69 | <property name="justify">center</property> |
71 | <property name="wrap">True</property> | 70 | <property name="wrap">True</property> |
72 | <property name="xalign">0.5</property> | 71 | <property name="xalign">0.5</property> |
diff --git a/src/contact.c b/src/contact.c index 08d273d..e87e87b 100644 --- a/src/contact.c +++ b/src/contact.c | |||
@@ -32,7 +32,8 @@ contact_create_info(struct GNUNET_CHAT_Contact *contact) | |||
32 | 32 | ||
33 | MESSENGER_ContactInfo* info = g_malloc(sizeof(MESSENGER_ContactInfo)); | 33 | MESSENGER_ContactInfo* info = g_malloc(sizeof(MESSENGER_ContactInfo)); |
34 | 34 | ||
35 | info->name_labels = g_list_alloc(); | 35 | info->name_labels = NULL; |
36 | info->name_avatars = NULL; | ||
36 | 37 | ||
37 | GNUNET_CHAT_contact_set_user_pointer(contact, info); | 38 | GNUNET_CHAT_contact_set_user_pointer(contact, info); |
38 | } | 39 | } |
@@ -45,7 +46,12 @@ contact_destroy_info(struct GNUNET_CHAT_Contact *contact) | |||
45 | if (!info) | 46 | if (!info) |
46 | return; | 47 | return; |
47 | 48 | ||
48 | g_list_free(info->name_labels); | 49 | if (info->name_labels) |
50 | g_list_free(info->name_labels); | ||
51 | |||
52 | if (info->name_avatars) | ||
53 | g_list_free(info->name_avatars); | ||
54 | |||
49 | g_free(info); | 55 | g_free(info); |
50 | 56 | ||
51 | GNUNET_CHAT_contact_set_user_pointer(contact, NULL); | 57 | GNUNET_CHAT_contact_set_user_pointer(contact, NULL); |
@@ -57,13 +63,31 @@ contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, | |||
57 | { | 63 | { |
58 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); | 64 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); |
59 | 65 | ||
60 | if (!info) | 66 | if ((!info) || (!label)) |
61 | return; | 67 | return; |
62 | 68 | ||
69 | const char *name = GNUNET_CHAT_contact_get_name(contact); | ||
70 | gtk_label_set_text(label, name? name : ""); | ||
71 | |||
63 | info->name_labels = g_list_append(info->name_labels, label); | 72 | info->name_labels = g_list_append(info->name_labels, label); |
64 | } | 73 | } |
65 | 74 | ||
66 | void | 75 | void |
76 | contact_add_name_avatar_to_info(const struct GNUNET_CHAT_Contact *contact, | ||
77 | HdyAvatar *avatar) | ||
78 | { | ||
79 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); | ||
80 | |||
81 | if ((!info) || (!avatar)) | ||
82 | return; | ||
83 | |||
84 | const char *name = GNUNET_CHAT_contact_get_name(contact); | ||
85 | hdy_avatar_set_text(avatar, name? name : ""); | ||
86 | |||
87 | info->name_avatars = g_list_append(info->name_avatars, avatar); | ||
88 | } | ||
89 | |||
90 | void | ||
67 | contact_update_info(const struct GNUNET_CHAT_Contact *contact) | 91 | contact_update_info(const struct GNUNET_CHAT_Contact *contact) |
68 | { | 92 | { |
69 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); | 93 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); |
@@ -71,17 +95,15 @@ contact_update_info(const struct GNUNET_CHAT_Contact *contact) | |||
71 | if (!info) | 95 | if (!info) |
72 | return; | 96 | return; |
73 | 97 | ||
98 | GList* list; | ||
74 | const char *name = GNUNET_CHAT_contact_get_name(contact); | 99 | const char *name = GNUNET_CHAT_contact_get_name(contact); |
75 | 100 | ||
76 | GList* name_label = info->name_labels; | 101 | for (list = info->name_labels; list; list = list->next) |
102 | gtk_label_set_text(GTK_LABEL(list->data), name? name : ""); | ||
77 | 103 | ||
78 | while (name_label) | 104 | if (!name) |
79 | { | 105 | return; |
80 | GtkLabel *label = GTK_LABEL(name_label->data); | ||
81 | |||
82 | if (label) | ||
83 | gtk_label_set_text(label, name? name : ""); | ||
84 | 106 | ||
85 | name_label = name_label->next; | 107 | for (list = info->name_avatars; list; list = list->next) |
86 | } | 108 | hdy_avatar_set_text(HDY_AVATAR(list->data), name); |
87 | } | 109 | } |
diff --git a/src/contact.h b/src/contact.h index 1672c65..15c7c9f 100644 --- a/src/contact.h +++ b/src/contact.h | |||
@@ -30,6 +30,7 @@ | |||
30 | typedef struct MESSENGER_ContactInfo | 30 | typedef struct MESSENGER_ContactInfo |
31 | { | 31 | { |
32 | GList *name_labels; | 32 | GList *name_labels; |
33 | GList *name_avatars; | ||
33 | } MESSENGER_ContactInfo; | 34 | } MESSENGER_ContactInfo; |
34 | 35 | ||
35 | void | 36 | void |
@@ -43,6 +44,10 @@ contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, | |||
43 | GtkLabel *label); | 44 | GtkLabel *label); |
44 | 45 | ||
45 | void | 46 | void |
47 | contact_add_name_avatar_to_info(const struct GNUNET_CHAT_Contact *contact, | ||
48 | HdyAvatar *avatar); | ||
49 | |||
50 | void | ||
46 | contact_update_info(const struct GNUNET_CHAT_Contact *contact); | 51 | contact_update_info(const struct GNUNET_CHAT_Contact *contact); |
47 | 52 | ||
48 | #endif /* CONTACT_H_ */ | 53 | #endif /* CONTACT_H_ */ |
diff --git a/src/event.c b/src/event.c index 66ead2d..3eac66e 100644 --- a/src/event.c +++ b/src/event.c | |||
@@ -186,7 +186,7 @@ event_joining_contact(MESSENGER_Application *app, | |||
186 | 186 | ||
187 | ui_chat_entry_update(handle, app, context); | 187 | ui_chat_entry_update(handle, app, context); |
188 | 188 | ||
189 | UI_MESSAGE_Handle *message = ui_message_new(app, UI_MESSAGE_STATUS); | 189 | UI_MESSAGE_Handle *message = ui_message_new(UI_MESSAGE_STATUS); |
190 | 190 | ||
191 | struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( | 191 | struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( |
192 | msg | 192 | msg |
@@ -195,11 +195,7 @@ event_joining_contact(MESSENGER_Application *app, | |||
195 | contact_create_info(contact); | 195 | contact_create_info(contact); |
196 | _update_contact_context(app, contact); | 196 | _update_contact_context(app, contact); |
197 | 197 | ||
198 | const char *sender = GNUNET_CHAT_contact_get_name(contact); | 198 | contact_add_name_avatar_to_info(contact, message->sender_avatar); |
199 | |||
200 | hdy_avatar_set_text(message->sender_avatar, sender? sender : ""); | ||
201 | gtk_label_set_text(message->sender_label, sender? sender : ""); | ||
202 | |||
203 | contact_add_name_label_to_info(contact, message->sender_label); | 199 | contact_add_name_label_to_info(contact, message->sender_label); |
204 | 200 | ||
205 | gtk_label_set_text(message->text_label, "joined the chat"); | 201 | gtk_label_set_text(message->text_label, "joined the chat"); |
@@ -213,8 +209,8 @@ event_joining_contact(MESSENGER_Application *app, | |||
213 | } | 209 | } |
214 | 210 | ||
215 | void | 211 | void |
216 | event_update_contacts(UNUSED MESSENGER_Application *app, | 212 | event_update_contacts(MESSENGER_Application *app, |
217 | UNUSED struct GNUNET_CHAT_Context *context, | 213 | struct GNUNET_CHAT_Context *context, |
218 | const struct GNUNET_CHAT_Message *msg) | 214 | const struct GNUNET_CHAT_Message *msg) |
219 | { | 215 | { |
220 | struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( | 216 | struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( |
@@ -223,6 +219,13 @@ event_update_contacts(UNUSED MESSENGER_Application *app, | |||
223 | 219 | ||
224 | contact_update_info(contact); | 220 | contact_update_info(contact); |
225 | _update_contact_context(app, contact); | 221 | _update_contact_context(app, contact); |
222 | |||
223 | UI_CHAT_ENTRY_Handle *handle = GNUNET_CHAT_context_get_user_pointer(context); | ||
224 | |||
225 | if (!handle) | ||
226 | return; | ||
227 | |||
228 | ui_chat_entry_update(handle, app, context); | ||
226 | } | 229 | } |
227 | 230 | ||
228 | static void | 231 | static void |
@@ -237,7 +240,7 @@ _event_invitation_accept_click(UNUSED GtkButton *button, | |||
237 | } | 240 | } |
238 | 241 | ||
239 | void | 242 | void |
240 | event_invitation(MESSENGER_Application *app, | 243 | event_invitation(UNUSED MESSENGER_Application *app, |
241 | struct GNUNET_CHAT_Context *context, | 244 | struct GNUNET_CHAT_Context *context, |
242 | const struct GNUNET_CHAT_Message *msg) | 245 | const struct GNUNET_CHAT_Message *msg) |
243 | { | 246 | { |
@@ -252,16 +255,14 @@ event_invitation(MESSENGER_Application *app, | |||
252 | if (!invitation) | 255 | if (!invitation) |
253 | return; | 256 | return; |
254 | 257 | ||
255 | UI_MESSAGE_Handle *message = ui_message_new(app, UI_MESSAGE_STATUS); | 258 | UI_MESSAGE_Handle *message = ui_message_new(UI_MESSAGE_STATUS); |
256 | 259 | ||
257 | const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( | 260 | const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( |
258 | msg | 261 | msg |
259 | ); | 262 | ); |
260 | 263 | ||
261 | const char *sender = GNUNET_CHAT_contact_get_name(contact); | 264 | contact_add_name_avatar_to_info(contact, message->sender_avatar); |
262 | 265 | contact_add_name_label_to_info(contact, message->sender_label); | |
263 | hdy_avatar_set_text(message->sender_avatar, sender? sender : ""); | ||
264 | gtk_label_set_text(message->sender_label, sender? sender : ""); | ||
265 | 266 | ||
266 | gtk_label_set_text(message->text_label, "invited you to a chat"); | 267 | gtk_label_set_text(message->text_label, "invited you to a chat"); |
267 | 268 | ||
@@ -284,7 +285,7 @@ event_invitation(MESSENGER_Application *app, | |||
284 | } | 285 | } |
285 | 286 | ||
286 | void | 287 | void |
287 | event_receive_message(MESSENGER_Application *app, | 288 | event_receive_message(UNUSED MESSENGER_Application *app, |
288 | struct GNUNET_CHAT_Context *context, | 289 | struct GNUNET_CHAT_Context *context, |
289 | const struct GNUNET_CHAT_Message *msg) | 290 | const struct GNUNET_CHAT_Message *msg) |
290 | { | 291 | { |
@@ -296,21 +297,15 @@ event_receive_message(MESSENGER_Application *app, | |||
296 | const int sent = GNUNET_CHAT_message_is_sent(msg); | 297 | const int sent = GNUNET_CHAT_message_is_sent(msg); |
297 | 298 | ||
298 | UI_MESSAGE_Handle *message = ui_message_new( | 299 | UI_MESSAGE_Handle *message = ui_message_new( |
299 | app, | ||
300 | GNUNET_YES == sent? UI_MESSAGE_SENT : UI_MESSAGE_DEFAULT | 300 | GNUNET_YES == sent? UI_MESSAGE_SENT : UI_MESSAGE_DEFAULT |
301 | ); | 301 | ); |
302 | 302 | ||
303 | if (GNUNET_YES != sent) | 303 | const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( |
304 | { | 304 | msg |
305 | const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( | 305 | ); |
306 | msg | ||
307 | ); | ||
308 | |||
309 | const char *sender = GNUNET_CHAT_contact_get_name(contact); | ||
310 | 306 | ||
311 | hdy_avatar_set_text(message->sender_avatar, sender? sender : ""); | 307 | contact_add_name_avatar_to_info(contact, message->sender_avatar); |
312 | gtk_label_set_text(message->sender_label, sender? sender : ""); | 308 | contact_add_name_label_to_info(contact, message->sender_label); |
313 | } | ||
314 | 309 | ||
315 | struct GNUNET_TIME_Absolute timestamp = GNUNET_CHAT_message_get_timestamp( | 310 | struct GNUNET_TIME_Absolute timestamp = GNUNET_CHAT_message_get_timestamp( |
316 | msg | 311 | msg |
diff --git a/src/ui/chat.c b/src/ui/chat.c index 67080bb..92dbdec 100644 --- a/src/ui/chat.c +++ b/src/ui/chat.c | |||
@@ -358,11 +358,8 @@ iterate_ui_chat_update_group_contacts(void *cls, | |||
358 | 358 | ||
359 | const char *name = GNUNET_CHAT_contact_get_name(contact); | 359 | const char *name = GNUNET_CHAT_contact_get_name(contact); |
360 | 360 | ||
361 | if (name) | 361 | gtk_label_set_text(entry->entry_label, name? name : ""); |
362 | { | 362 | hdy_avatar_set_text(entry->entry_avatar, name? name : ""); |
363 | gtk_label_set_text(entry->entry_label, name); | ||
364 | hdy_avatar_set_text(entry->entry_avatar, name); | ||
365 | } | ||
366 | 363 | ||
367 | gtk_list_box_prepend(listbox, entry->entry_box); | 364 | gtk_list_box_prepend(listbox, entry->entry_box); |
368 | 365 | ||
@@ -388,18 +385,32 @@ ui_chat_update(UI_CHAT_Handle *handle, | |||
388 | group = GNUNET_CHAT_context_get_group(context); | 385 | group = GNUNET_CHAT_context_get_group(context); |
389 | 386 | ||
390 | const char *title = NULL; | 387 | const char *title = NULL; |
388 | GString *subtitle = g_string_new(""); | ||
391 | 389 | ||
392 | if (contact) | 390 | if (contact) |
393 | title = GNUNET_CHAT_contact_get_name(contact); | 391 | title = GNUNET_CHAT_contact_get_name(contact); |
394 | else if (group) | 392 | else if (group) |
393 | { | ||
395 | title = GNUNET_CHAT_group_get_name(group); | 394 | title = GNUNET_CHAT_group_get_name(group); |
396 | 395 | ||
396 | g_string_append_printf( | ||
397 | subtitle, | ||
398 | "%d members", | ||
399 | GNUNET_CHAT_group_iterate_contacts(group, NULL, NULL) | ||
400 | ); | ||
401 | } | ||
402 | |||
397 | if (title) | 403 | if (title) |
398 | { | 404 | { |
399 | gtk_label_set_text(handle->chat_title, title); | 405 | gtk_label_set_text(handle->chat_title, title); |
400 | gtk_label_set_text(handle->chat_details_label, title); | 406 | gtk_label_set_text(handle->chat_details_label, title); |
401 | } | 407 | } |
402 | 408 | ||
409 | if (subtitle->len > 0) | ||
410 | gtk_label_set_text(handle->chat_subtitle, subtitle->str); | ||
411 | |||
412 | g_string_free(subtitle, TRUE); | ||
413 | |||
403 | GList* children = gtk_container_get_children( | 414 | GList* children = gtk_container_get_children( |
404 | GTK_CONTAINER(handle->chat_contacts_listbox) | 415 | GTK_CONTAINER(handle->chat_contacts_listbox) |
405 | ); | 416 | ); |
@@ -408,6 +419,9 @@ ui_chat_update(UI_CHAT_Handle *handle, | |||
408 | GtkWidget *widget = GTK_WIDGET(children->data); | 419 | GtkWidget *widget = GTK_WIDGET(children->data); |
409 | children = children->next; | 420 | children = children->next; |
410 | 421 | ||
422 | if (g_hash_table_contains(app->ui.bindings, widget)) | ||
423 | g_hash_table_remove(app->ui.bindings, widget); | ||
424 | |||
411 | gtk_container_remove( | 425 | gtk_container_remove( |
412 | GTK_CONTAINER(handle->chat_contacts_listbox), | 426 | GTK_CONTAINER(handle->chat_contacts_listbox), |
413 | widget | 427 | widget |
diff --git a/src/ui/contacts.c b/src/ui/contacts.c index 842cfb5..8fd38e0 100644 --- a/src/ui/contacts.c +++ b/src/ui/contacts.c | |||
@@ -147,7 +147,7 @@ void | |||
147 | ui_contacts_dialog_init(MESSENGER_Application *app, | 147 | ui_contacts_dialog_init(MESSENGER_Application *app, |
148 | UI_CONTACTS_Handle *handle) | 148 | UI_CONTACTS_Handle *handle) |
149 | { | 149 | { |
150 | handle->contact_entries = g_list_alloc(); | 150 | handle->contact_entries = NULL; |
151 | 151 | ||
152 | handle->builder = gtk_builder_new_from_file("resources/ui/contacts.ui"); | 152 | handle->builder = gtk_builder_new_from_file("resources/ui/contacts.ui"); |
153 | 153 | ||
@@ -225,5 +225,6 @@ ui_contacts_dialog_cleanup(UI_CONTACTS_Handle *handle) | |||
225 | list = list->next; | 225 | list = list->next; |
226 | } | 226 | } |
227 | 227 | ||
228 | g_list_free(handle->contact_entries); | 228 | if (handle->contact_entries) |
229 | g_list_free(handle->contact_entries); | ||
229 | } | 230 | } |
diff --git a/src/ui/message.c b/src/ui/message.c index def4524..cacf666 100644 --- a/src/ui/message.c +++ b/src/ui/message.c | |||
@@ -27,8 +27,7 @@ | |||
27 | #include "../application.h" | 27 | #include "../application.h" |
28 | 28 | ||
29 | UI_MESSAGE_Handle* | 29 | UI_MESSAGE_Handle* |
30 | ui_message_new(MESSENGER_Application *app, | 30 | ui_message_new(UI_MESSAGE_Type type) |
31 | UI_MESSAGE_Type type) | ||
32 | { | 31 | { |
33 | UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); | 32 | UI_MESSAGE_Handle* handle = g_malloc(sizeof(UI_MESSAGE_Handle)); |
34 | 33 | ||
@@ -63,14 +62,6 @@ ui_message_new(MESSENGER_Application *app, | |||
63 | gtk_builder_get_object(handle->builder, "sender_label") | 62 | gtk_builder_get_object(handle->builder, "sender_label") |
64 | ); | 63 | ); |
65 | 64 | ||
66 | if (UI_MESSAGE_SENT == handle->type) | ||
67 | { | ||
68 | const char *sender = GNUNET_CHAT_get_name(app->chat.messenger.handle); | ||
69 | |||
70 | hdy_avatar_set_text(handle->sender_avatar, sender); | ||
71 | gtk_label_set_text(handle->sender_label, sender); | ||
72 | } | ||
73 | |||
74 | handle->text_label = GTK_LABEL( | 65 | handle->text_label = GTK_LABEL( |
75 | gtk_builder_get_object(handle->builder, "text_label") | 66 | gtk_builder_get_object(handle->builder, "text_label") |
76 | ); | 67 | ); |
diff --git a/src/ui/message.h b/src/ui/message.h index 333ef75..a17247c 100644 --- a/src/ui/message.h +++ b/src/ui/message.h | |||
@@ -59,8 +59,7 @@ typedef struct UI_MESSAGE_Handle | |||
59 | } UI_MESSAGE_Handle; | 59 | } UI_MESSAGE_Handle; |
60 | 60 | ||
61 | UI_MESSAGE_Handle* | 61 | UI_MESSAGE_Handle* |
62 | ui_message_new(MESSENGER_Application *app, | 62 | ui_message_new(UI_MESSAGE_Type type); |
63 | UI_MESSAGE_Type type); | ||
64 | 63 | ||
65 | void | 64 | void |
66 | ui_message_delete(UI_MESSAGE_Handle *handle); | 65 | ui_message_delete(UI_MESSAGE_Handle *handle); |
diff --git a/src/ui/messenger.c b/src/ui/messenger.c index 1d09608..afa444b 100644 --- a/src/ui/messenger.c +++ b/src/ui/messenger.c | |||
@@ -192,7 +192,7 @@ void | |||
192 | ui_messenger_init(MESSENGER_Application *app, | 192 | ui_messenger_init(MESSENGER_Application *app, |
193 | UI_MESSENGER_Handle *handle) | 193 | UI_MESSENGER_Handle *handle) |
194 | { | 194 | { |
195 | handle->chat_entries = g_list_alloc(); | 195 | handle->chat_entries = NULL; |
196 | 196 | ||
197 | handle->builder = gtk_builder_new_from_file("resources/ui/messenger.ui"); | 197 | handle->builder = gtk_builder_new_from_file("resources/ui/messenger.ui"); |
198 | 198 | ||
@@ -401,14 +401,9 @@ ui_messenger_cleanup(UI_MESSENGER_Handle *handle) | |||
401 | { | 401 | { |
402 | g_object_unref(handle->builder); | 402 | g_object_unref(handle->builder); |
403 | 403 | ||
404 | GList *list = handle->chat_entries; | 404 | for (GList *list = handle->chat_entries; list; list = list->next) |
405 | ui_chat_entry_delete((UI_CHAT_ENTRY_Handle*) list->data); | ||
405 | 406 | ||
406 | while (list) { | 407 | if (handle->chat_entries) |
407 | if (list->data) | 408 | g_list_free(handle->chat_entries); |
408 | ui_chat_entry_delete((UI_CHAT_ENTRY_Handle*) list->data); | ||
409 | |||
410 | list = list->next; | ||
411 | } | ||
412 | |||
413 | g_list_free(handle->chat_entries); | ||
414 | } | 409 | } |
diff --git a/src/ui/new_group.c b/src/ui/new_group.c index ea19371..6355fcd 100644 --- a/src/ui/new_group.c +++ b/src/ui/new_group.c | |||
@@ -207,7 +207,7 @@ void | |||
207 | ui_new_group_dialog_init(MESSENGER_Application *app, | 207 | ui_new_group_dialog_init(MESSENGER_Application *app, |
208 | UI_NEW_GROUP_Handle *handle) | 208 | UI_NEW_GROUP_Handle *handle) |
209 | { | 209 | { |
210 | handle->contact_entries = g_list_alloc(); | 210 | handle->contact_entries = NULL; |
211 | 211 | ||
212 | handle->builder = gtk_builder_new_from_file("resources/ui/new_group.ui"); | 212 | handle->builder = gtk_builder_new_from_file("resources/ui/new_group.ui"); |
213 | 213 | ||
@@ -340,14 +340,9 @@ ui_new_group_dialog_cleanup(UI_NEW_GROUP_Handle *handle) | |||
340 | { | 340 | { |
341 | g_object_unref(handle->builder); | 341 | g_object_unref(handle->builder); |
342 | 342 | ||
343 | GList *list = handle->contact_entries; | 343 | for (GList *list = handle->contact_entries; list; list = list->next) |
344 | ui_contact_entry_delete((UI_CONTACT_ENTRY_Handle*) list->data); | ||
344 | 345 | ||
345 | while (list) { | 346 | if (handle->contact_entries) |
346 | if (list->data) | 347 | g_list_free(handle->contact_entries); |
347 | ui_contact_entry_delete((UI_CONTACT_ENTRY_Handle*) list->data); | ||
348 | |||
349 | list = list->next; | ||
350 | } | ||
351 | |||
352 | g_list_free(handle->contact_entries); | ||
353 | } | 348 | } |