diff options
Diffstat (limited to 'src/event.c')
-rw-r--r-- | src/event.c | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/src/event.c b/src/event.c index 851536f..e04fe5c 100644 --- a/src/event.c +++ b/src/event.c | |||
@@ -24,16 +24,73 @@ | |||
24 | 24 | ||
25 | #include "event.h" | 25 | #include "event.h" |
26 | 26 | ||
27 | #include "ui/chat_entry.h" | ||
28 | |||
29 | static int | ||
30 | _iterate_profile_contacts(void *cls, | ||
31 | UNUSED struct GNUNET_CHAT_Handle *handle, | ||
32 | UNUSED struct GNUNET_CHAT_Contact *contact) | ||
33 | { | ||
34 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | ||
35 | |||
36 | UI_MESSENGER_Handle *ui = &(app->ui.messenger); | ||
37 | |||
38 | UI_CHAT_ENTRY_Handle *entry = ui_chat_entry_new(); | ||
39 | |||
40 | gtk_container_add(GTK_CONTAINER(ui->chats_listbox), entry->entry_box); | ||
41 | |||
42 | g_free(entry); //TODO: add to a list or similar? | ||
43 | |||
44 | return GNUNET_YES; | ||
45 | } | ||
46 | |||
47 | static int | ||
48 | _iterate_profile_groups(void *cls, | ||
49 | UNUSED struct GNUNET_CHAT_Handle *handle, | ||
50 | UNUSED struct GNUNET_CHAT_Group *group) | ||
51 | { | ||
52 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | ||
53 | |||
54 | UI_MESSENGER_Handle *ui = &(app->ui.messenger); | ||
55 | |||
56 | UI_CHAT_ENTRY_Handle *entry = ui_chat_entry_new(); | ||
57 | |||
58 | gtk_container_add(GTK_CONTAINER(ui->chats_listbox), entry->entry_box); | ||
59 | |||
60 | g_free(entry); //TODO: add to a list or similar? | ||
61 | |||
62 | return GNUNET_YES; | ||
63 | } | ||
64 | |||
65 | static void | ||
66 | _clear_each_widget(GtkWidget *widget, | ||
67 | gpointer user_data) | ||
68 | { | ||
69 | GtkContainer *container = GTK_CONTAINER(user_data); | ||
70 | |||
71 | gtk_container_remove(container, widget); | ||
72 | } | ||
73 | |||
27 | void | 74 | void |
28 | event_update_profile(MESSENGER_Application *app) | 75 | event_update_profile(MESSENGER_Application *app) |
29 | { | 76 | { |
30 | UI_MESSENGER_Handle* ui = &(app->ui.messenger); | 77 | UI_MESSENGER_Handle *ui = &(app->ui.messenger); |
78 | CHAT_MESSENGER_Handle *chat = &(app->chat.messenger); | ||
31 | 79 | ||
32 | const char *name = GNUNET_CHAT_get_name(app->chat.messenger.handle); | 80 | const char *name = GNUNET_CHAT_get_name(chat->handle); |
33 | 81 | ||
34 | if (name) | 82 | if (name) |
35 | { | 83 | { |
36 | hdy_avatar_set_text(ui->profile_avatar, name); | 84 | hdy_avatar_set_text(ui->profile_avatar, name); |
37 | gtk_label_set_text(ui->profile_label, name); | 85 | gtk_label_set_text(ui->profile_label, name); |
38 | } | 86 | } |
87 | |||
88 | gtk_container_foreach( | ||
89 | GTK_CONTAINER(ui->chats_listbox), | ||
90 | _clear_each_widget, | ||
91 | ui->chats_listbox | ||
92 | ); | ||
93 | |||
94 | GNUNET_CHAT_iterate_contacts(chat->handle, _iterate_profile_contacts, app); | ||
95 | GNUNET_CHAT_iterate_groups(chat->handle, _iterate_profile_groups, app); | ||
39 | } | 96 | } |