aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/chat.c24
-rw-r--r--src/ui/contacts.c5
-rw-r--r--src/ui/message.c11
-rw-r--r--src/ui/message.h3
-rw-r--r--src/ui/messenger.c15
-rw-r--r--src/ui/new_group.c15
6 files changed, 34 insertions, 39 deletions
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
147ui_contacts_dialog_init(MESSENGER_Application *app, 147ui_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
29UI_MESSAGE_Handle* 29UI_MESSAGE_Handle*
30ui_message_new(MESSENGER_Application *app, 30ui_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
61UI_MESSAGE_Handle* 61UI_MESSAGE_Handle*
62ui_message_new(MESSENGER_Application *app, 62ui_message_new(UI_MESSAGE_Type type);
63 UI_MESSAGE_Type type);
64 63
65void 64void
66ui_message_delete(UI_MESSAGE_Handle *handle); 65ui_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
192ui_messenger_init(MESSENGER_Application *app, 192ui_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
207ui_new_group_dialog_init(MESSENGER_Application *app, 207ui_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}