aboutsummaryrefslogtreecommitdiff
path: root/src/ui/chat_entry.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/chat_entry.c')
-rw-r--r--src/ui/chat_entry.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/src/ui/chat_entry.c b/src/ui/chat_entry.c
index a3c7892..7de4064 100644
--- a/src/ui/chat_entry.c
+++ b/src/ui/chat_entry.c
@@ -27,6 +27,8 @@
27#include "../application.h" 27#include "../application.h"
28#include "../contact.h" 28#include "../contact.h"
29 29
30#include "message.h"
31
30UI_CHAT_ENTRY_Handle* 32UI_CHAT_ENTRY_Handle*
31ui_chat_entry_new(MESSENGER_Application *app) 33ui_chat_entry_new(MESSENGER_Application *app)
32{ 34{
@@ -62,6 +64,16 @@ ui_chat_entry_new(MESSENGER_Application *app)
62 return handle; 64 return handle;
63} 65}
64 66
67/*static int
68_iterate_message_read_receipt(UNUSED void *cls,
69 UNUSED const struct GNUNET_CHAT_Message *message,
70 const struct GNUNET_CHAT_Contact *contact,
71 int read_receipt)
72{
73 printf("read_receipt: %s %d\n", GNUNET_CHAT_contact_get_name(contact), read_receipt);
74 return GNUNET_YES;
75}*/
76
65void 77void
66ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle, 78ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle,
67 MESSENGER_Application *app, 79 MESSENGER_Application *app,
@@ -86,8 +98,47 @@ ui_chat_entry_update(UI_CHAT_ENTRY_Handle *handle,
86 hdy_avatar_set_text(handle->entry_avatar, title); 98 hdy_avatar_set_text(handle->entry_avatar, title);
87 } 99 }
88 100
89 if (handle->chat) 101 if (!handle->chat)
90 ui_chat_update(handle->chat, app, context); 102 return;
103
104 ui_chat_update(handle->chat, app, context);
105
106 if (!handle->chat->messages)
107 return;
108
109 UI_MESSAGE_Handle *message = (
110 (UI_MESSAGE_Handle*) handle->chat->messages->data
111 );
112
113 const gchar *text = gtk_label_get_text(message->text_label);
114 const gchar *time = gtk_label_get_text(message->timestamp_label);
115
116 if (group)
117 {
118 GString *message_text = g_string_new(
119 gtk_label_get_text(message->sender_label)
120 );
121
122 g_string_append_printf(
123 message_text,
124 _(": %s"),
125 text
126 );
127
128 gtk_label_set_text(handle->text_label, message_text->str);
129 g_string_free(message_text, TRUE);
130 }
131 else
132 gtk_label_set_text(handle->text_label, text);
133
134 gtk_label_set_text(handle->timestamp_label, time);
135
136 gtk_widget_set_visible(
137 GTK_WIDGET(handle->read_receipt_image),
138 message->read_receipt_image? gtk_widget_is_visible(
139 GTK_WIDGET(message->read_receipt_image)
140 ) : FALSE
141 );
91} 142}
92 143
93void 144void