diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2021-12-15 01:11:43 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2021-12-15 01:11:43 +0100 |
commit | 22504147521a36c513c200f9ed3f413b679d3f75 (patch) | |
tree | 1c6f11351f1c753c4bb92be4d9375ca9d8941ce9 | |
parent | cbefefb69b4db53fad2c01d45b66d9056bc98fdb (diff) | |
download | messenger-gtk-22504147521a36c513c200f9ed3f413b679d3f75.tar.gz messenger-gtk-22504147521a36c513c200f9ed3f413b679d3f75.zip |
Implemented updating of labels regarding contact names in chats
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | resources/ui/chat.ui | 77 | ||||
-rw-r--r-- | src/chat/messenger.c | 25 | ||||
-rw-r--r-- | src/contact.c | 87 | ||||
-rw-r--r-- | src/contact.h | 48 | ||||
-rw-r--r-- | src/event.c | 47 | ||||
-rw-r--r-- | src/event.h | 5 | ||||
-rw-r--r-- | src/ui/chat.c | 66 | ||||
-rw-r--r-- | src/ui/chat.h | 1 | ||||
-rw-r--r-- | src/ui/chat_entry.c | 4 | ||||
-rw-r--r-- | src/ui/chat_entry.h | 1 |
11 files changed, 315 insertions, 47 deletions
@@ -5,6 +5,7 @@ INSTALL_DIR ?= /usr/local/ | |||
5 | BINARY = messenger-gtk | 5 | BINARY = messenger-gtk |
6 | SOURCES = messenger_gtk.c\ | 6 | SOURCES = messenger_gtk.c\ |
7 | application.c\ | 7 | application.c\ |
8 | contact.c\ | ||
8 | event.c\ | 9 | event.c\ |
9 | chat/messenger.c\ | 10 | chat/messenger.c\ |
10 | ui/chat.c\ | 11 | ui/chat.c\ |
diff --git a/resources/ui/chat.ui b/resources/ui/chat.ui index 9b89023..8d9cb02 100644 --- a/resources/ui/chat.ui +++ b/resources/ui/chat.ui | |||
@@ -389,44 +389,6 @@ Author: Tobias Frisch | |||
389 | <property name="can-focus">False</property> | 389 | <property name="can-focus">False</property> |
390 | <property name="orientation">vertical</property> | 390 | <property name="orientation">vertical</property> |
391 | <child> | 391 | <child> |
392 | <object class="GtkBox"> | ||
393 | <property name="visible">True</property> | ||
394 | <property name="can-focus">False</property> | ||
395 | <child> | ||
396 | <object class="GtkLabel"> | ||
397 | <property name="visible">True</property> | ||
398 | <property name="can-focus">False</property> | ||
399 | <property name="label" translatable="yes">Notifications</property> | ||
400 | </object> | ||
401 | <packing> | ||
402 | <property name="expand">False</property> | ||
403 | <property name="fill">True</property> | ||
404 | <property name="position">0</property> | ||
405 | </packing> | ||
406 | </child> | ||
407 | <child> | ||
408 | <object class="GtkSwitch"> | ||
409 | <property name="visible">True</property> | ||
410 | <property name="can-focus">True</property> | ||
411 | </object> | ||
412 | <packing> | ||
413 | <property name="expand">False</property> | ||
414 | <property name="fill">True</property> | ||
415 | <property name="pack-type">end</property> | ||
416 | <property name="position">1</property> | ||
417 | </packing> | ||
418 | </child> | ||
419 | <style> | ||
420 | <class name="details-entry"/> | ||
421 | </style> | ||
422 | </object> | ||
423 | <packing> | ||
424 | <property name="expand">False</property> | ||
425 | <property name="fill">True</property> | ||
426 | <property name="position">0</property> | ||
427 | </packing> | ||
428 | </child> | ||
429 | <child> | ||
430 | <object class="GtkBox" id="chat_details_contacts_box"> | 392 | <object class="GtkBox" id="chat_details_contacts_box"> |
431 | <property name="visible">True</property> | 393 | <property name="visible">True</property> |
432 | <property name="can-focus">False</property> | 394 | <property name="can-focus">False</property> |
@@ -459,6 +421,7 @@ Author: Tobias Frisch | |||
459 | <object class="GtkListBoxRow"> | 421 | <object class="GtkListBoxRow"> |
460 | <property name="visible">True</property> | 422 | <property name="visible">True</property> |
461 | <property name="can-focus">True</property> | 423 | <property name="can-focus">True</property> |
424 | <property name="selectable">False</property> | ||
462 | <child> | 425 | <child> |
463 | <object class="GtkBox"> | 426 | <object class="GtkBox"> |
464 | <property name="visible">True</property> | 427 | <property name="visible">True</property> |
@@ -512,6 +475,44 @@ Author: Tobias Frisch | |||
512 | <packing> | 475 | <packing> |
513 | <property name="expand">False</property> | 476 | <property name="expand">False</property> |
514 | <property name="fill">True</property> | 477 | <property name="fill">True</property> |
478 | <property name="position">0</property> | ||
479 | </packing> | ||
480 | </child> | ||
481 | <child> | ||
482 | <object class="GtkBox"> | ||
483 | <property name="visible">True</property> | ||
484 | <property name="can-focus">False</property> | ||
485 | <child> | ||
486 | <object class="GtkLabel"> | ||
487 | <property name="visible">True</property> | ||
488 | <property name="can-focus">False</property> | ||
489 | <property name="label" translatable="yes">Notifications</property> | ||
490 | </object> | ||
491 | <packing> | ||
492 | <property name="expand">False</property> | ||
493 | <property name="fill">True</property> | ||
494 | <property name="position">0</property> | ||
495 | </packing> | ||
496 | </child> | ||
497 | <child> | ||
498 | <object class="GtkSwitch"> | ||
499 | <property name="visible">True</property> | ||
500 | <property name="can-focus">True</property> | ||
501 | </object> | ||
502 | <packing> | ||
503 | <property name="expand">False</property> | ||
504 | <property name="fill">True</property> | ||
505 | <property name="pack-type">end</property> | ||
506 | <property name="position">1</property> | ||
507 | </packing> | ||
508 | </child> | ||
509 | <style> | ||
510 | <class name="details-entry"/> | ||
511 | </style> | ||
512 | </object> | ||
513 | <packing> | ||
514 | <property name="expand">False</property> | ||
515 | <property name="fill">True</property> | ||
515 | <property name="position">1</property> | 516 | <property name="position">1</property> |
516 | </packing> | 517 | </packing> |
517 | </child> | 518 | </child> |
diff --git a/src/chat/messenger.c b/src/chat/messenger.c index 9bfe11b..27ba1bd 100644 --- a/src/chat/messenger.c +++ b/src/chat/messenger.c | |||
@@ -24,8 +24,19 @@ | |||
24 | 24 | ||
25 | #include "messenger.h" | 25 | #include "messenger.h" |
26 | 26 | ||
27 | #include "../contact.h" | ||
27 | #include "../event.h" | 28 | #include "../event.h" |
28 | 29 | ||
30 | int | ||
31 | _chat_messenger_iterate_contacts(UNUSED void *cls, | ||
32 | UNUSED struct GNUNET_CHAT_Handle *handle, | ||
33 | struct GNUNET_CHAT_Contact *contact) | ||
34 | { | ||
35 | if (contact) | ||
36 | contact_destroy_info(contact); | ||
37 | return GNUNET_YES; | ||
38 | } | ||
39 | |||
29 | static void | 40 | static void |
30 | _chat_messenger_idle(void *cls) | 41 | _chat_messenger_idle(void *cls) |
31 | { | 42 | { |
@@ -43,6 +54,12 @@ _chat_messenger_idle(void *cls) | |||
43 | return; | 54 | return; |
44 | } | 55 | } |
45 | 56 | ||
57 | GNUNET_CHAT_iterate_contacts( | ||
58 | app->chat.messenger.handle, | ||
59 | _chat_messenger_iterate_contacts, | ||
60 | NULL | ||
61 | ); | ||
62 | |||
46 | GNUNET_CHAT_stop(app->chat.messenger.handle); | 63 | GNUNET_CHAT_stop(app->chat.messenger.handle); |
47 | app->chat.messenger.handle = NULL; | 64 | app->chat.messenger.handle = NULL; |
48 | 65 | ||
@@ -98,8 +115,12 @@ _chat_messenger_message(void *cls, | |||
98 | } | 115 | } |
99 | case GNUNET_CHAT_KIND_CONTACT: | 116 | case GNUNET_CHAT_KIND_CONTACT: |
100 | { | 117 | { |
101 | // TODO: update messages and content related to a contacts information | 118 | application_call_message_event( |
102 | // (name and key) | 119 | app, |
120 | event_update_contacts, | ||
121 | context, | ||
122 | message | ||
123 | ); | ||
103 | break; | 124 | break; |
104 | } | 125 | } |
105 | case GNUNET_CHAT_KIND_INVITATION: | 126 | case GNUNET_CHAT_KIND_INVITATION: |
diff --git a/src/contact.c b/src/contact.c new file mode 100644 index 0000000..08d273d --- /dev/null +++ b/src/contact.c | |||
@@ -0,0 +1,87 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /* | ||
21 | * @author Tobias Frisch | ||
22 | * @file contact.c | ||
23 | */ | ||
24 | |||
25 | #include "contact.h" | ||
26 | |||
27 | void | ||
28 | contact_create_info(struct GNUNET_CHAT_Contact *contact) | ||
29 | { | ||
30 | if (GNUNET_CHAT_contact_get_user_pointer(contact)) | ||
31 | return; | ||
32 | |||
33 | MESSENGER_ContactInfo* info = g_malloc(sizeof(MESSENGER_ContactInfo)); | ||
34 | |||
35 | info->name_labels = g_list_alloc(); | ||
36 | |||
37 | GNUNET_CHAT_contact_set_user_pointer(contact, info); | ||
38 | } | ||
39 | |||
40 | void | ||
41 | contact_destroy_info(struct GNUNET_CHAT_Contact *contact) | ||
42 | { | ||
43 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); | ||
44 | |||
45 | if (!info) | ||
46 | return; | ||
47 | |||
48 | g_list_free(info->name_labels); | ||
49 | g_free(info); | ||
50 | |||
51 | GNUNET_CHAT_contact_set_user_pointer(contact, NULL); | ||
52 | } | ||
53 | |||
54 | void | ||
55 | contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, | ||
56 | GtkLabel *label) | ||
57 | { | ||
58 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); | ||
59 | |||
60 | if (!info) | ||
61 | return; | ||
62 | |||
63 | info->name_labels = g_list_append(info->name_labels, label); | ||
64 | } | ||
65 | |||
66 | void | ||
67 | contact_update_info(const struct GNUNET_CHAT_Contact *contact) | ||
68 | { | ||
69 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); | ||
70 | |||
71 | if (!info) | ||
72 | return; | ||
73 | |||
74 | const char *name = GNUNET_CHAT_contact_get_name(contact); | ||
75 | |||
76 | GList* name_label = info->name_labels; | ||
77 | |||
78 | while (name_label) | ||
79 | { | ||
80 | GtkLabel *label = GTK_LABEL(name_label->data); | ||
81 | |||
82 | if (label) | ||
83 | gtk_label_set_text(label, name? name : ""); | ||
84 | |||
85 | name_label = name_label->next; | ||
86 | } | ||
87 | } | ||
diff --git a/src/contact.h b/src/contact.h new file mode 100644 index 0000000..1672c65 --- /dev/null +++ b/src/contact.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /* | ||
21 | * @author Tobias Frisch | ||
22 | * @file contact.h | ||
23 | */ | ||
24 | |||
25 | #ifndef CONTACT_H_ | ||
26 | #define CONTACT_H_ | ||
27 | |||
28 | #include "application.h" | ||
29 | |||
30 | typedef struct MESSENGER_ContactInfo | ||
31 | { | ||
32 | GList *name_labels; | ||
33 | } MESSENGER_ContactInfo; | ||
34 | |||
35 | void | ||
36 | contact_create_info(struct GNUNET_CHAT_Contact *contact); | ||
37 | |||
38 | void | ||
39 | contact_destroy_info(struct GNUNET_CHAT_Contact *contact); | ||
40 | |||
41 | void | ||
42 | contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, | ||
43 | GtkLabel *label); | ||
44 | |||
45 | void | ||
46 | contact_update_info(const struct GNUNET_CHAT_Contact *contact); | ||
47 | |||
48 | #endif /* CONTACT_H_ */ | ||
diff --git a/src/event.c b/src/event.c index f63598d..66ead2d 100644 --- a/src/event.c +++ b/src/event.c | |||
@@ -24,6 +24,8 @@ | |||
24 | 24 | ||
25 | #include "event.h" | 25 | #include "event.h" |
26 | 26 | ||
27 | #include "contact.h" | ||
28 | |||
27 | #include "ui/chat_entry.h" | 29 | #include "ui/chat_entry.h" |
28 | #include "ui/contact_entry.h" | 30 | #include "ui/contact_entry.h" |
29 | #include "ui/message.h" | 31 | #include "ui/message.h" |
@@ -37,7 +39,7 @@ _add_new_chat_entry(MESSENGER_Application *app, | |||
37 | 39 | ||
38 | UI_CHAT_ENTRY_Handle *entry = ui_chat_entry_new(app); | 40 | UI_CHAT_ENTRY_Handle *entry = ui_chat_entry_new(app); |
39 | 41 | ||
40 | ui_chat_entry_update(entry, context); | 42 | ui_chat_entry_update(entry, app, context); |
41 | 43 | ||
42 | gtk_container_add(GTK_CONTAINER(ui->chats_listbox), entry->entry_box); | 44 | gtk_container_add(GTK_CONTAINER(ui->chats_listbox), entry->entry_box); |
43 | GNUNET_CHAT_context_set_user_pointer(context, entry); | 45 | GNUNET_CHAT_context_set_user_pointer(context, entry); |
@@ -153,6 +155,25 @@ event_update_chats(MESSENGER_Application *app, | |||
153 | _add_new_chat_entry(app, context); | 155 | _add_new_chat_entry(app, context); |
154 | } | 156 | } |
155 | 157 | ||
158 | static void | ||
159 | _update_contact_context(MESSENGER_Application *app, | ||
160 | struct GNUNET_CHAT_Contact *contact) | ||
161 | { | ||
162 | struct GNUNET_CHAT_Context *context = GNUNET_CHAT_contact_get_context( | ||
163 | contact | ||
164 | ); | ||
165 | |||
166 | if (!context) | ||
167 | return; | ||
168 | |||
169 | UI_CHAT_ENTRY_Handle *handle = GNUNET_CHAT_context_get_user_pointer(context); | ||
170 | |||
171 | if (!handle) | ||
172 | return; | ||
173 | |||
174 | ui_chat_entry_update(handle, app, context); | ||
175 | } | ||
176 | |||
156 | void | 177 | void |
157 | event_joining_contact(MESSENGER_Application *app, | 178 | event_joining_contact(MESSENGER_Application *app, |
158 | struct GNUNET_CHAT_Context *context, | 179 | struct GNUNET_CHAT_Context *context, |
@@ -163,19 +184,24 @@ event_joining_contact(MESSENGER_Application *app, | |||
163 | if (!handle) | 184 | if (!handle) |
164 | return; | 185 | return; |
165 | 186 | ||
166 | ui_chat_entry_update(handle, context); | 187 | ui_chat_entry_update(handle, app, context); |
167 | 188 | ||
168 | UI_MESSAGE_Handle *message = ui_message_new(app, UI_MESSAGE_STATUS); | 189 | UI_MESSAGE_Handle *message = ui_message_new(app, UI_MESSAGE_STATUS); |
169 | 190 | ||
170 | const struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( | 191 | struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( |
171 | msg | 192 | msg |
172 | ); | 193 | ); |
173 | 194 | ||
195 | contact_create_info(contact); | ||
196 | _update_contact_context(app, contact); | ||
197 | |||
174 | const char *sender = GNUNET_CHAT_contact_get_name(contact); | 198 | const char *sender = GNUNET_CHAT_contact_get_name(contact); |
175 | 199 | ||
176 | hdy_avatar_set_text(message->sender_avatar, sender? sender : ""); | 200 | hdy_avatar_set_text(message->sender_avatar, sender? sender : ""); |
177 | gtk_label_set_text(message->sender_label, sender? sender : ""); | 201 | gtk_label_set_text(message->sender_label, sender? sender : ""); |
178 | 202 | ||
203 | contact_add_name_label_to_info(contact, message->sender_label); | ||
204 | |||
179 | gtk_label_set_text(message->text_label, "joined the chat"); | 205 | gtk_label_set_text(message->text_label, "joined the chat"); |
180 | 206 | ||
181 | gtk_container_add( | 207 | gtk_container_add( |
@@ -186,6 +212,19 @@ event_joining_contact(MESSENGER_Application *app, | |||
186 | ui_message_delete(message); | 212 | ui_message_delete(message); |
187 | } | 213 | } |
188 | 214 | ||
215 | void | ||
216 | event_update_contacts(UNUSED MESSENGER_Application *app, | ||
217 | UNUSED struct GNUNET_CHAT_Context *context, | ||
218 | const struct GNUNET_CHAT_Message *msg) | ||
219 | { | ||
220 | struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( | ||
221 | msg | ||
222 | ); | ||
223 | |||
224 | contact_update_info(contact); | ||
225 | _update_contact_context(app, contact); | ||
226 | } | ||
227 | |||
189 | static void | 228 | static void |
190 | _event_invitation_accept_click(UNUSED GtkButton *button, | 229 | _event_invitation_accept_click(UNUSED GtkButton *button, |
191 | gpointer user_data) | 230 | gpointer user_data) |
diff --git a/src/event.h b/src/event.h index 38890b2..71a85ac 100644 --- a/src/event.h +++ b/src/event.h | |||
@@ -41,6 +41,11 @@ event_joining_contact(MESSENGER_Application *app, | |||
41 | const struct GNUNET_CHAT_Message *msg); | 41 | const struct GNUNET_CHAT_Message *msg); |
42 | 42 | ||
43 | void | 43 | void |
44 | event_update_contacts(MESSENGER_Application *app, | ||
45 | struct GNUNET_CHAT_Context *context, | ||
46 | const struct GNUNET_CHAT_Message *msg); | ||
47 | |||
48 | void | ||
44 | event_invitation(MESSENGER_Application *app, | 49 | event_invitation(MESSENGER_Application *app, |
45 | struct GNUNET_CHAT_Context *context, | 50 | struct GNUNET_CHAT_Context *context, |
46 | const struct GNUNET_CHAT_Message *msg); | 51 | const struct GNUNET_CHAT_Message *msg); |
diff --git a/src/ui/chat.c b/src/ui/chat.c index 0ddd59c..67080bb 100644 --- a/src/ui/chat.c +++ b/src/ui/chat.c | |||
@@ -27,7 +27,9 @@ | |||
27 | #include "messenger.h" | 27 | #include "messenger.h" |
28 | #include "picker.h" | 28 | #include "picker.h" |
29 | #include "profile_entry.h" | 29 | #include "profile_entry.h" |
30 | |||
30 | #include "../application.h" | 31 | #include "../application.h" |
32 | #include "../contact.h" | ||
31 | 33 | ||
32 | static void | 34 | static void |
33 | handle_flap_via_button_click(UNUSED GtkButton* button, | 35 | handle_flap_via_button_click(UNUSED GtkButton* button, |
@@ -43,6 +45,37 @@ handle_flap_via_button_click(UNUSED GtkButton* button, | |||
43 | } | 45 | } |
44 | 46 | ||
45 | static void | 47 | static void |
48 | handle_chat_contacts_listbox_row_activated(UNUSED GtkListBox* listbox, | ||
49 | GtkListBoxRow* row, | ||
50 | gpointer user_data) | ||
51 | { | ||
52 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | ||
53 | |||
54 | if (!gtk_list_box_row_get_selectable(row)) | ||
55 | { | ||
56 | //g_idle_add(G_SOURCE_FUNC(_open_new_contact_dialog), app); | ||
57 | return; | ||
58 | } | ||
59 | |||
60 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( | ||
61 | g_hash_table_lookup(app->ui.bindings, row) | ||
62 | ); | ||
63 | |||
64 | if ((!contact) || (!GNUNET_CHAT_contact_get_key(contact))) | ||
65 | return; | ||
66 | |||
67 | struct GNUNET_CHAT_Context *context = GNUNET_CHAT_contact_get_context( | ||
68 | contact | ||
69 | ); | ||
70 | |||
71 | if (!context) | ||
72 | return; | ||
73 | |||
74 | if (GNUNET_SYSERR == GNUNET_CHAT_context_get_status(context)) | ||
75 | GNUNET_CHAT_context_request(context); | ||
76 | } | ||
77 | |||
78 | static void | ||
46 | handle_back_button_click(UNUSED GtkButton* button, | 79 | handle_back_button_click(UNUSED GtkButton* button, |
47 | gpointer user_data) | 80 | gpointer user_data) |
48 | { | 81 | { |
@@ -223,6 +256,13 @@ ui_chat_new(MESSENGER_Application *app) | |||
223 | gtk_builder_get_object(handle->builder, "chat_contacts_listbox") | 256 | gtk_builder_get_object(handle->builder, "chat_contacts_listbox") |
224 | ); | 257 | ); |
225 | 258 | ||
259 | g_signal_connect( | ||
260 | handle->chat_contacts_listbox, | ||
261 | "row-activated", | ||
262 | G_CALLBACK(handle_chat_contacts_listbox_row_activated), | ||
263 | app | ||
264 | ); | ||
265 | |||
226 | handle->messages_listbox = GTK_LIST_BOX( | 266 | handle->messages_listbox = GTK_LIST_BOX( |
227 | gtk_builder_get_object(handle->builder, "messages_listbox") | 267 | gtk_builder_get_object(handle->builder, "messages_listbox") |
228 | ); | 268 | ); |
@@ -299,12 +339,21 @@ ui_chat_new(MESSENGER_Application *app) | |||
299 | return handle; | 339 | return handle; |
300 | } | 340 | } |
301 | 341 | ||
342 | struct IterateChatGroupClosure { | ||
343 | GHashTable *bindings; | ||
344 | GtkListBox *listbox; | ||
345 | }; | ||
346 | |||
302 | static int | 347 | static int |
303 | iterate_ui_chat_update_group_contacts(void *cls, | 348 | iterate_ui_chat_update_group_contacts(void *cls, |
304 | UNUSED const struct GNUNET_CHAT_Group *group, | 349 | UNUSED const struct GNUNET_CHAT_Group *group, |
305 | struct GNUNET_CHAT_Contact *contact) | 350 | struct GNUNET_CHAT_Contact *contact) |
306 | { | 351 | { |
307 | GtkListBox *listbox = GTK_LIST_BOX(cls); | 352 | struct IterateChatGroupClosure *closure = ( |
353 | (struct IterateChatGroupClosure*) cls | ||
354 | ); | ||
355 | |||
356 | GtkListBox *listbox = closure->listbox; | ||
308 | UI_PROFILE_ENTRY_Handle* entry = ui_profile_entry_new(); | 357 | UI_PROFILE_ENTRY_Handle* entry = ui_profile_entry_new(); |
309 | 358 | ||
310 | const char *name = GNUNET_CHAT_contact_get_name(contact); | 359 | const char *name = GNUNET_CHAT_contact_get_name(contact); |
@@ -317,12 +366,19 @@ iterate_ui_chat_update_group_contacts(void *cls, | |||
317 | 366 | ||
318 | gtk_list_box_prepend(listbox, entry->entry_box); | 367 | gtk_list_box_prepend(listbox, entry->entry_box); |
319 | 368 | ||
369 | GtkListBoxRow *row = GTK_LIST_BOX_ROW( | ||
370 | gtk_widget_get_parent(entry->entry_box) | ||
371 | ); | ||
372 | |||
373 | g_hash_table_insert(closure->bindings, row, contact); | ||
374 | |||
320 | ui_profile_entry_delete(entry); | 375 | ui_profile_entry_delete(entry); |
321 | return GNUNET_YES; | 376 | return GNUNET_YES; |
322 | } | 377 | } |
323 | 378 | ||
324 | void | 379 | void |
325 | ui_chat_update(UI_CHAT_Handle *handle, | 380 | ui_chat_update(UI_CHAT_Handle *handle, |
381 | MESSENGER_Application *app, | ||
326 | const struct GNUNET_CHAT_Context* context) | 382 | const struct GNUNET_CHAT_Context* context) |
327 | { | 383 | { |
328 | const struct GNUNET_CHAT_Contact* contact; | 384 | const struct GNUNET_CHAT_Contact* contact; |
@@ -359,11 +415,17 @@ ui_chat_update(UI_CHAT_Handle *handle, | |||
359 | } | 415 | } |
360 | 416 | ||
361 | if (group) | 417 | if (group) |
418 | { | ||
419 | struct IterateChatGroupClosure closure; | ||
420 | closure.bindings = app->ui.bindings; | ||
421 | closure.listbox = handle->chat_contacts_listbox; | ||
422 | |||
362 | GNUNET_CHAT_group_iterate_contacts( | 423 | GNUNET_CHAT_group_iterate_contacts( |
363 | group, | 424 | group, |
364 | iterate_ui_chat_update_group_contacts, | 425 | iterate_ui_chat_update_group_contacts, |
365 | handle->chat_contacts_listbox | 426 | &closure |
366 | ); | 427 | ); |
428 | } | ||
367 | 429 | ||
368 | gtk_widget_set_visible( | 430 | gtk_widget_set_visible( |
369 | GTK_WIDGET(handle->chat_details_contacts_box), | 431 | GTK_WIDGET(handle->chat_details_contacts_box), |
diff --git a/src/ui/chat.h b/src/ui/chat.h index ce1df94..ae0880e 100644 --- a/src/ui/chat.h +++ b/src/ui/chat.h | |||
@@ -70,6 +70,7 @@ ui_chat_new(MESSENGER_Application *app); | |||
70 | 70 | ||
71 | void | 71 | void |
72 | ui_chat_update(UI_CHAT_Handle *handle, | 72 | ui_chat_update(UI_CHAT_Handle *handle, |
73 | MESSENGER_Application *app, | ||
73 | const struct GNUNET_CHAT_Context* context); | 74 | const struct GNUNET_CHAT_Context* context); |
74 | 75 | ||
75 | void | 76 | void |
diff --git a/src/ui/chat_entry.c b/src/ui/chat_entry.c index c7f07ff..a3c7892 100644 --- a/src/ui/chat_entry.c +++ b/src/ui/chat_entry.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "chat_entry.h" | 25 | #include "chat_entry.h" |
26 | 26 | ||
27 | #include "../application.h" | 27 | #include "../application.h" |
28 | #include "../contact.h" | ||
28 | 29 | ||
29 | UI_CHAT_ENTRY_Handle* | 30 | UI_CHAT_ENTRY_Handle* |
30 | ui_chat_entry_new(MESSENGER_Application *app) | 31 | ui_chat_entry_new(MESSENGER_Application *app) |
@@ -63,6 +64,7 @@ ui_chat_entry_new(MESSENGER_Application *app) | |||
63 | 64 | ||
64 | void | 65 | void |
65 | ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, | 66 | ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, |
67 | MESSENGER_Application *app, | ||
66 | const struct GNUNET_CHAT_Context *context) | 68 | const struct GNUNET_CHAT_Context *context) |
67 | { | 69 | { |
68 | const struct GNUNET_CHAT_Contact* contact; | 70 | const struct GNUNET_CHAT_Contact* contact; |
@@ -85,7 +87,7 @@ ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, | |||
85 | } | 87 | } |
86 | 88 | ||
87 | if (handle->chat) | 89 | if (handle->chat) |
88 | ui_chat_update(handle->chat, context); | 90 | ui_chat_update(handle->chat, app, context); |
89 | } | 91 | } |
90 | 92 | ||
91 | void | 93 | void |
diff --git a/src/ui/chat_entry.h b/src/ui/chat_entry.h index 82b431a..cdf19d7 100644 --- a/src/ui/chat_entry.h +++ b/src/ui/chat_entry.h | |||
@@ -48,6 +48,7 @@ ui_chat_entry_new(MESSENGER_Application *app); | |||
48 | 48 | ||
49 | void | 49 | void |
50 | ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, | 50 | ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, |
51 | MESSENGER_Application *app, | ||
51 | const struct GNUNET_CHAT_Context *context); | 52 | const struct GNUNET_CHAT_Context *context); |
52 | 53 | ||
53 | void | 54 | void |