aboutsummaryrefslogtreecommitdiff
path: root/src/ui/chat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/chat.c')
-rw-r--r--src/ui/chat.c112
1 files changed, 111 insertions, 1 deletions
diff --git a/src/ui/chat.c b/src/ui/chat.c
index b96ecd5..c0ea685 100644
--- a/src/ui/chat.c
+++ b/src/ui/chat.c
@@ -27,6 +27,7 @@
27#include <gdk/gdkkeysyms.h> 27#include <gdk/gdkkeysyms.h>
28#include <stdlib.h> 28#include <stdlib.h>
29 29
30#include "chat_entry.h"
30#include "file_load_entry.h" 31#include "file_load_entry.h"
31#include "message.h" 32#include "message.h"
32#include "messenger.h" 33#include "messenger.h"
@@ -154,6 +155,55 @@ handle_back_button_click(UNUSED GtkButton *button,
154 } 155 }
155} 156}
156 157
158static void
159handle_reveal_identity_button_click(UNUSED GtkButton *button,
160 gpointer user_data)
161{
162 UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data;
163
164 // TODO
165}
166
167static void
168handle_leave_chat_button_click(UNUSED GtkButton *button,
169 gpointer user_data)
170{
171 UI_CHAT_Handle *handle = (UI_CHAT_Handle*) user_data;
172
173 if ((!handle) || (!(handle->send_text_view)))
174 return;
175
176 struct GNUNET_CHAT_Context *context = (struct GNUNET_CHAT_Context*) (
177 g_object_get_qdata(
178 G_OBJECT(handle->send_text_view),
179 handle->app->quarks.data
180 )
181 );
182
183 if (!context)
184 return;
185
186 struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_context_get_contact(
187 context
188 );
189
190 struct GNUNET_CHAT_Group *group = GNUNET_CHAT_context_get_group(
191 context
192 );
193
194 if (contact)
195 GNUNET_CHAT_contact_delete(contact);
196 else if (group)
197 GNUNET_CHAT_group_leave(group);
198
199 UI_CHAT_ENTRY_Handle *entry = GNUNET_CHAT_context_get_user_pointer(context);
200
201 if ((!entry) || (!(handle->app)))
202 return;
203
204 ui_chat_entry_dispose(entry, handle->app);
205}
206
157static gint 207static gint
158handle_chat_messages_sort(GtkListBoxRow* row0, 208handle_chat_messages_sort(GtkListBoxRow* row0,
159 GtkListBoxRow* row1, 209 GtkListBoxRow* row1,
@@ -1089,6 +1139,40 @@ ui_chat_new(MESSENGER_Application *app)
1089 gtk_builder_get_object(handle->builder, "chat_details_contacts_box") 1139 gtk_builder_get_object(handle->builder, "chat_details_contacts_box")
1090 ); 1140 );
1091 1141
1142 handle->chat_details_files_box = GTK_BOX(
1143 gtk_builder_get_object(handle->builder, "chat_details_files_box")
1144 );
1145
1146 handle->chat_details_avatar = HDY_AVATAR(
1147 gtk_builder_get_object(handle->builder, "chat_details_avatar")
1148 );
1149
1150 handle->reveal_identity_button = GTK_BUTTON(
1151 gtk_builder_get_object(handle->builder, "reveal_identity_button")
1152 );
1153
1154 g_signal_connect(
1155 handle->reveal_identity_button,
1156 "clicked",
1157 G_CALLBACK(handle_reveal_identity_button_click),
1158 handle
1159 );
1160
1161 handle->leave_chat_button = GTK_BUTTON(
1162 gtk_builder_get_object(handle->builder, "leave_chat_button")
1163 );
1164
1165 g_signal_connect(
1166 handle->leave_chat_button,
1167 "clicked",
1168 G_CALLBACK(handle_leave_chat_button_click),
1169 handle
1170 );
1171
1172 handle->chat_notifications_switch = GTK_SWITCH(
1173 gtk_builder_get_object(handle->builder, "chat_notifications_switch")
1174 );
1175
1092 handle->selection_close_button = GTK_BUTTON( 1176 handle->selection_close_button = GTK_BUTTON(
1093 gtk_builder_get_object(handle->builder, "selection_close_button") 1177 gtk_builder_get_object(handle->builder, "selection_close_button")
1094 ); 1178 );
@@ -1355,7 +1439,7 @@ iterate_ui_chat_update_group_contacts(void *cls,
1355void 1439void
1356ui_chat_update(UI_CHAT_Handle *handle, 1440ui_chat_update(UI_CHAT_Handle *handle,
1357 MESSENGER_Application *app, 1441 MESSENGER_Application *app,
1358 const struct GNUNET_CHAT_Context* context) 1442 struct GNUNET_CHAT_Context* context)
1359{ 1443{
1360 GNUNET_assert((handle) && (app) && (context)); 1444 GNUNET_assert((handle) && (app) && (context));
1361 1445
@@ -1366,14 +1450,24 @@ ui_chat_update(UI_CHAT_Handle *handle,
1366 group = GNUNET_CHAT_context_get_group(context); 1450 group = GNUNET_CHAT_context_get_group(context);
1367 1451
1368 const char *title = NULL; 1452 const char *title = NULL;
1453 const char *icon = "action-unavailable-symbolic";
1454
1369 GString *subtitle = g_string_new(""); 1455 GString *subtitle = g_string_new("");
1370 1456
1371 if (contact) 1457 if (contact)
1458 {
1372 title = GNUNET_CHAT_contact_get_name(contact); 1459 title = GNUNET_CHAT_contact_get_name(contact);
1460 icon = "avatar-default-symbolic";
1461 }
1373 else if (group) 1462 else if (group)
1374 { 1463 {
1375 title = GNUNET_CHAT_group_get_name(group); 1464 title = GNUNET_CHAT_group_get_name(group);
1376 1465
1466 if ((title) && ('#' == *title))
1467 icon = "network-wired-symbolic";
1468 else
1469 icon = "system-users-symbolic";
1470
1377 g_string_append_printf( 1471 g_string_append_printf(
1378 subtitle, 1472 subtitle,
1379 _("%d members"), 1473 _("%d members"),
@@ -1381,6 +1475,12 @@ ui_chat_update(UI_CHAT_Handle *handle,
1381 ); 1475 );
1382 } 1476 }
1383 1477
1478 hdy_avatar_set_text(handle->chat_avatar, title? title : "");
1479 hdy_avatar_set_icon_name(handle->chat_avatar, icon);
1480
1481 hdy_avatar_set_text(handle->chat_details_avatar, title? title : "");
1482 hdy_avatar_set_icon_name(handle->chat_details_avatar, icon);
1483
1384 if (title) 1484 if (title)
1385 { 1485 {
1386 gtk_label_set_text(handle->chat_title, title); 1486 gtk_label_set_text(handle->chat_title, title);
@@ -1424,6 +1524,16 @@ ui_chat_update(UI_CHAT_Handle *handle,
1424 group? TRUE : FALSE 1524 group? TRUE : FALSE
1425 ); 1525 );
1426 1526
1527 gtk_widget_set_visible(
1528 GTK_WIDGET(handle->reveal_identity_button),
1529 contact? TRUE : FALSE
1530 );
1531
1532 gtk_widget_set_sensitive(
1533 GTK_WIDGET(handle->leave_chat_button),
1534 (contact) || (group)? TRUE : FALSE
1535 );
1536
1427 const int status = GNUNET_CHAT_context_get_status(context); 1537 const int status = GNUNET_CHAT_context_get_status(context);
1428 const gboolean activated = (GNUNET_OK == status? TRUE : FALSE); 1538 const gboolean activated = (GNUNET_OK == status? TRUE : FALSE);
1429 1539