diff options
Diffstat (limited to 'src/ui/messenger.c')
-rw-r--r-- | src/ui/messenger.c | 327 |
1 files changed, 166 insertions, 161 deletions
diff --git a/src/ui/messenger.c b/src/ui/messenger.c index c72f8cf..ac341d5 100644 --- a/src/ui/messenger.c +++ b/src/ui/messenger.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 6 | under the terms of the GNU Affero General Public License as published |
@@ -58,21 +58,21 @@ _flap_user_details_reveal_switch(gpointer user_data) | |||
58 | 58 | ||
59 | static void | 59 | static void |
60 | handle_user_details_via_button_click(UNUSED GtkButton* button, | 60 | handle_user_details_via_button_click(UNUSED GtkButton* button, |
61 | gpointer user_data) | 61 | gpointer user_data) |
62 | { | 62 | { |
63 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; | 63 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; |
64 | 64 | ||
65 | gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_search), FALSE); | 65 | gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_search), FALSE); |
66 | gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_listbox), FALSE); | 66 | gtk_widget_set_sensitive(GTK_WIDGET(handle->chats_listbox), FALSE); |
67 | g_idle_add( | 67 | g_idle_add( |
68 | G_SOURCE_FUNC(_flap_user_details_reveal_switch), | 68 | G_SOURCE_FUNC(_flap_user_details_reveal_switch), |
69 | handle | 69 | handle |
70 | ); | 70 | ); |
71 | } | 71 | } |
72 | 72 | ||
73 | static void | 73 | static void |
74 | handle_lobby_button_click(UNUSED GtkButton* button, | 74 | handle_lobby_button_click(UNUSED GtkButton* button, |
75 | gpointer user_data) | 75 | gpointer user_data) |
76 | { | 76 | { |
77 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 77 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
78 | 78 | ||
@@ -85,24 +85,24 @@ handle_lobby_button_click(UNUSED GtkButton* button, | |||
85 | 85 | ||
86 | static void | 86 | static void |
87 | _switch_details_revealer_visibility(UI_MESSENGER_Handle *handle, | 87 | _switch_details_revealer_visibility(UI_MESSENGER_Handle *handle, |
88 | gboolean state) | 88 | gboolean state) |
89 | { | 89 | { |
90 | GtkRevealer *revealer = handle->account_details_revealer; | 90 | GtkRevealer *revealer = handle->account_details_revealer; |
91 | GtkImage *symbol = handle->account_details_symbol; | 91 | GtkImage *symbol = handle->account_details_symbol; |
92 | 92 | ||
93 | gtk_revealer_set_reveal_child(revealer, state); | 93 | gtk_revealer_set_reveal_child(revealer, state); |
94 | gtk_image_set_from_icon_name( | 94 | gtk_image_set_from_icon_name( |
95 | symbol, | 95 | symbol, |
96 | state? | 96 | state? |
97 | "go-up-symbolic" : | 97 | "go-up-symbolic" : |
98 | "go-down-symbolic", | 98 | "go-down-symbolic", |
99 | GTK_ICON_SIZE_BUTTON | 99 | GTK_ICON_SIZE_BUTTON |
100 | ); | 100 | ); |
101 | } | 101 | } |
102 | 102 | ||
103 | static void | 103 | static void |
104 | handle_account_details_button_click(UNUSED GtkButton* button, | 104 | handle_account_details_button_click(UNUSED GtkButton* button, |
105 | gpointer user_data) | 105 | gpointer user_data) |
106 | { | 106 | { |
107 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; | 107 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; |
108 | 108 | ||
@@ -115,8 +115,8 @@ handle_account_details_button_click(UNUSED GtkButton* button, | |||
115 | 115 | ||
116 | static void | 116 | static void |
117 | handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | 117 | handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, |
118 | GtkListBoxRow* row, | 118 | GtkListBoxRow* row, |
119 | gpointer user_data) | 119 | gpointer user_data) |
120 | { | 120 | { |
121 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 121 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
122 | 122 | ||
@@ -132,7 +132,7 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
132 | } | 132 | } |
133 | 133 | ||
134 | struct GNUNET_CHAT_Account *account = (struct GNUNET_CHAT_Account*) ( | 134 | struct GNUNET_CHAT_Account *account = (struct GNUNET_CHAT_Account*) ( |
135 | g_object_get_qdata(G_OBJECT(row), app->quarks.data) | 135 | g_object_get_qdata(G_OBJECT(row), app->quarks.data) |
136 | ); | 136 | ); |
137 | 137 | ||
138 | if (!account) | 138 | if (!account) |
@@ -146,7 +146,7 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
146 | 146 | ||
147 | static void | 147 | static void |
148 | handle_new_contact_button_click(UNUSED GtkButton* button, | 148 | handle_new_contact_button_click(UNUSED GtkButton* button, |
149 | gpointer user_data) | 149 | gpointer user_data) |
150 | { | 150 | { |
151 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 151 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
152 | 152 | ||
@@ -157,7 +157,7 @@ handle_new_contact_button_click(UNUSED GtkButton* button, | |||
157 | 157 | ||
158 | static void | 158 | static void |
159 | handle_new_group_button_click(UNUSED GtkButton* button, | 159 | handle_new_group_button_click(UNUSED GtkButton* button, |
160 | gpointer user_data) | 160 | gpointer user_data) |
161 | { | 161 | { |
162 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 162 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
163 | 163 | ||
@@ -168,7 +168,7 @@ handle_new_group_button_click(UNUSED GtkButton* button, | |||
168 | 168 | ||
169 | static void | 169 | static void |
170 | handle_new_platform_button_click(UNUSED GtkButton* button, | 170 | handle_new_platform_button_click(UNUSED GtkButton* button, |
171 | gpointer user_data) | 171 | gpointer user_data) |
172 | { | 172 | { |
173 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 173 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
174 | 174 | ||
@@ -179,7 +179,7 @@ handle_new_platform_button_click(UNUSED GtkButton* button, | |||
179 | 179 | ||
180 | static void | 180 | static void |
181 | handle_contacts_button_click(UNUSED GtkButton* button, | 181 | handle_contacts_button_click(UNUSED GtkButton* button, |
182 | gpointer user_data) | 182 | gpointer user_data) |
183 | { | 183 | { |
184 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 184 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
185 | 185 | ||
@@ -190,7 +190,7 @@ handle_contacts_button_click(UNUSED GtkButton* button, | |||
190 | 190 | ||
191 | static void | 191 | static void |
192 | handle_settings_button_click(UNUSED GtkButton* button, | 192 | handle_settings_button_click(UNUSED GtkButton* button, |
193 | gpointer user_data) | 193 | gpointer user_data) |
194 | { | 194 | { |
195 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 195 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
196 | 196 | ||
@@ -201,7 +201,7 @@ handle_settings_button_click(UNUSED GtkButton* button, | |||
201 | 201 | ||
202 | static void | 202 | static void |
203 | handle_about_button_click(UNUSED GtkButton* button, | 203 | handle_about_button_click(UNUSED GtkButton* button, |
204 | gpointer user_data) | 204 | gpointer user_data) |
205 | { | 205 | { |
206 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 206 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
207 | 207 | ||
@@ -212,8 +212,8 @@ handle_about_button_click(UNUSED GtkButton* button, | |||
212 | 212 | ||
213 | static void | 213 | static void |
214 | handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, | 214 | handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, |
215 | GtkListBoxRow* row, | 215 | GtkListBoxRow* row, |
216 | gpointer user_data) | 216 | gpointer user_data) |
217 | { | 217 | { |
218 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 218 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
219 | 219 | ||
@@ -221,7 +221,7 @@ handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
221 | return; | 221 | return; |
222 | 222 | ||
223 | UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) ( | 223 | UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) ( |
224 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) | 224 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) |
225 | ); | 225 | ); |
226 | 226 | ||
227 | if ((!entry) || (!(entry->chat)) || (!(entry->chat->chat_box))) | 227 | if ((!entry) || (!(entry->chat)) || (!(entry->chat->chat_box))) |
@@ -241,8 +241,8 @@ handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
241 | 241 | ||
242 | static gint | 242 | static gint |
243 | handle_chats_listbox_sort_func(GtkListBoxRow* row0, | 243 | handle_chats_listbox_sort_func(GtkListBoxRow* row0, |
244 | GtkListBoxRow* row1, | 244 | GtkListBoxRow* row1, |
245 | gpointer user_data) | 245 | gpointer user_data) |
246 | { | 246 | { |
247 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 247 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
248 | 248 | ||
@@ -252,11 +252,11 @@ handle_chats_listbox_sort_func(GtkListBoxRow* row0, | |||
252 | return 0; | 252 | return 0; |
253 | 253 | ||
254 | UI_CHAT_ENTRY_Handle *entry0 = (UI_CHAT_ENTRY_Handle*) ( | 254 | UI_CHAT_ENTRY_Handle *entry0 = (UI_CHAT_ENTRY_Handle*) ( |
255 | g_object_get_qdata(G_OBJECT(row0), app->quarks.ui) | 255 | g_object_get_qdata(G_OBJECT(row0), app->quarks.ui) |
256 | ); | 256 | ); |
257 | 257 | ||
258 | UI_CHAT_ENTRY_Handle *entry1 = (UI_CHAT_ENTRY_Handle*) ( | 258 | UI_CHAT_ENTRY_Handle *entry1 = (UI_CHAT_ENTRY_Handle*) ( |
259 | g_object_get_qdata(G_OBJECT(row1), app->quarks.ui) | 259 | g_object_get_qdata(G_OBJECT(row1), app->quarks.ui) |
260 | ); | 260 | ); |
261 | 261 | ||
262 | if ((!entry0) || (!entry1)) | 262 | if ((!entry0) || (!entry1)) |
@@ -275,7 +275,7 @@ handle_chats_listbox_sort_func(GtkListBoxRow* row0, | |||
275 | 275 | ||
276 | static gboolean | 276 | static gboolean |
277 | handle_chats_listbox_filter_func(GtkListBoxRow *row, | 277 | handle_chats_listbox_filter_func(GtkListBoxRow *row, |
278 | gpointer user_data) | 278 | gpointer user_data) |
279 | { | 279 | { |
280 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 280 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
281 | 281 | ||
@@ -284,14 +284,14 @@ handle_chats_listbox_filter_func(GtkListBoxRow *row, | |||
284 | return TRUE; | 284 | return TRUE; |
285 | 285 | ||
286 | const gchar *filter = gtk_entry_get_text( | 286 | const gchar *filter = gtk_entry_get_text( |
287 | GTK_ENTRY(app->ui.messenger.chats_search) | 287 | GTK_ENTRY(app->ui.messenger.chats_search) |
288 | ); | 288 | ); |
289 | 289 | ||
290 | if (!filter) | 290 | if (!filter) |
291 | return TRUE; | 291 | return TRUE; |
292 | 292 | ||
293 | UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) ( | 293 | UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) ( |
294 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) | 294 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) |
295 | ); | 295 | ); |
296 | 296 | ||
297 | if ((!entry) || (!(entry->title_label))) | 297 | if ((!entry) || (!(entry->title_label))) |
@@ -307,7 +307,7 @@ handle_chats_listbox_filter_func(GtkListBoxRow *row, | |||
307 | 307 | ||
308 | static void | 308 | static void |
309 | handle_chats_search_changed(UNUSED GtkSearchEntry *search, | 309 | handle_chats_search_changed(UNUSED GtkSearchEntry *search, |
310 | gpointer user_data) | 310 | gpointer user_data) |
311 | { | 311 | { |
312 | GtkListBox *listbox = GTK_LIST_BOX(user_data); | 312 | GtkListBox *listbox = GTK_LIST_BOX(user_data); |
313 | 313 | ||
@@ -316,10 +316,15 @@ handle_chats_search_changed(UNUSED GtkSearchEntry *search, | |||
316 | 316 | ||
317 | static void | 317 | static void |
318 | handle_main_window_destroy(UNUSED GtkWidget *window, | 318 | handle_main_window_destroy(UNUSED GtkWidget *window, |
319 | gpointer user_data) | 319 | gpointer user_data) |
320 | { | 320 | { |
321 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 321 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
322 | 322 | ||
323 | if (app->parent) | ||
324 | xdp_parent_free(app->parent); | ||
325 | |||
326 | app->parent = NULL; | ||
327 | |||
323 | ui_messenger_cleanup(&(app->ui.messenger)); | 328 | ui_messenger_cleanup(&(app->ui.messenger)); |
324 | ui_accounts_dialog_cleanup(&(app->ui.accounts)); | 329 | ui_accounts_dialog_cleanup(&(app->ui.accounts)); |
325 | 330 | ||
@@ -328,85 +333,85 @@ handle_main_window_destroy(UNUSED GtkWidget *window, | |||
328 | 333 | ||
329 | void | 334 | void |
330 | ui_messenger_init(MESSENGER_Application *app, | 335 | ui_messenger_init(MESSENGER_Application *app, |
331 | UI_MESSENGER_Handle *handle) | 336 | UI_MESSENGER_Handle *handle) |
332 | { | 337 | { |
333 | memset(handle, 0, sizeof(*handle)); | 338 | memset(handle, 0, sizeof(*handle)); |
334 | handle->app = app; | 339 | handle->app = app; |
335 | 340 | ||
336 | handle->builder = gtk_builder_new_from_resource( | 341 | handle->builder = gtk_builder_new_from_resource( |
337 | application_get_resource_path(app, "ui/messenger.ui") | 342 | application_get_resource_path(app, "ui/messenger.ui") |
338 | ); | 343 | ); |
339 | 344 | ||
340 | handle->main_window = GTK_APPLICATION_WINDOW( | 345 | handle->main_window = GTK_APPLICATION_WINDOW( |
341 | gtk_builder_get_object(handle->builder, "main_window") | 346 | gtk_builder_get_object(handle->builder, "main_window") |
342 | ); | 347 | ); |
343 | 348 | ||
344 | gtk_window_set_startup_id( | 349 | gtk_window_set_startup_id( |
345 | GTK_WINDOW(handle->main_window), | 350 | GTK_WINDOW(handle->main_window), |
346 | MESSENGER_APPLICATION_ID | 351 | MESSENGER_APPLICATION_ID |
347 | ); | 352 | ); |
348 | 353 | ||
349 | gtk_window_set_icon_name( | 354 | gtk_window_set_icon_name( |
350 | GTK_WINDOW(handle->main_window), | 355 | GTK_WINDOW(handle->main_window), |
351 | MESSENGER_APPLICATION_ID | 356 | MESSENGER_APPLICATION_ID |
352 | ); | 357 | ); |
353 | 358 | ||
354 | gtk_application_add_window( | 359 | gtk_application_add_window( |
355 | app->application, | 360 | app->application, |
356 | GTK_WINDOW(handle->main_window) | 361 | GTK_WINDOW(handle->main_window) |
357 | ); | 362 | ); |
358 | 363 | ||
359 | gtk_window_set_default_size( | 364 | gtk_window_set_default_size( |
360 | GTK_WINDOW(handle->main_window), | 365 | GTK_WINDOW(handle->main_window), |
361 | 1100, 700 | 366 | 1100, 700 |
362 | ); | 367 | ); |
363 | 368 | ||
364 | handle->leaflet_chat = HDY_LEAFLET( | 369 | handle->leaflet_chat = HDY_LEAFLET( |
365 | gtk_builder_get_object(handle->builder, "leaflet_chat") | 370 | gtk_builder_get_object(handle->builder, "leaflet_chat") |
366 | ); | 371 | ); |
367 | 372 | ||
368 | handle->flap_user_details = HDY_FLAP( | 373 | handle->flap_user_details = HDY_FLAP( |
369 | gtk_builder_get_object(handle->builder, "flap_user_details") | 374 | gtk_builder_get_object(handle->builder, "flap_user_details") |
370 | ); | 375 | ); |
371 | 376 | ||
372 | handle->title_bar = HDY_HEADER_BAR( | 377 | handle->title_bar = HDY_HEADER_BAR( |
373 | gtk_builder_get_object(handle->builder, "title_bar") | 378 | gtk_builder_get_object(handle->builder, "title_bar") |
374 | ); | 379 | ); |
375 | 380 | ||
376 | GtkLabel* application_name_label = GTK_LABEL( | 381 | GtkLabel* application_name_label = GTK_LABEL( |
377 | gtk_builder_get_object(handle->builder, "application-name-label") | 382 | gtk_builder_get_object(handle->builder, "application-name-label") |
378 | ); | 383 | ); |
379 | 384 | ||
380 | GtkLabel* application_version_label = GTK_LABEL( | 385 | GtkLabel* application_version_label = GTK_LABEL( |
381 | gtk_builder_get_object(handle->builder, "application-version-label") | 386 | gtk_builder_get_object(handle->builder, "application-version-label") |
382 | ); | 387 | ); |
383 | 388 | ||
384 | hdy_header_bar_set_title( | 389 | hdy_header_bar_set_title( |
385 | handle->title_bar, | 390 | handle->title_bar, |
386 | MESSENGER_APPLICATION_TITLE | 391 | MESSENGER_APPLICATION_TITLE |
387 | ); | 392 | ); |
388 | 393 | ||
389 | hdy_header_bar_set_subtitle( | 394 | hdy_header_bar_set_subtitle( |
390 | handle->title_bar, | 395 | handle->title_bar, |
391 | MESSENGER_APPLICATION_SUBTITLE | 396 | MESSENGER_APPLICATION_SUBTITLE |
392 | ); | 397 | ); |
393 | 398 | ||
394 | gtk_label_set_text( | 399 | gtk_label_set_text( |
395 | application_name_label, | 400 | application_name_label, |
396 | MESSENGER_APPLICATION_APPNAME | 401 | MESSENGER_APPLICATION_APPNAME |
397 | ); | 402 | ); |
398 | 403 | ||
399 | gtk_label_set_text( | 404 | gtk_label_set_text( |
400 | application_version_label, | 405 | application_version_label, |
401 | MESSENGER_APPLICATION_VERSION | 406 | MESSENGER_APPLICATION_VERSION |
402 | ); | 407 | ); |
403 | 408 | ||
404 | g_object_bind_property( | 409 | g_object_bind_property( |
405 | handle->leaflet_chat, | 410 | handle->leaflet_chat, |
406 | "folded", | 411 | "folded", |
407 | handle->title_bar, | 412 | handle->title_bar, |
408 | "show-close-button", | 413 | "show-close-button", |
409 | G_BINDING_INVERT_BOOLEAN | 414 | G_BINDING_INVERT_BOOLEAN |
410 | ); | 415 | ); |
411 | 416 | ||
412 | if (app->settings.mobile_design) | 417 | if (app->settings.mobile_design) |
@@ -420,206 +425,206 @@ ui_messenger_init(MESSENGER_Application *app, | |||
420 | ); | 425 | ); |
421 | 426 | ||
422 | handle->profile_avatar = HDY_AVATAR( | 427 | handle->profile_avatar = HDY_AVATAR( |
423 | gtk_builder_get_object(handle->builder, "profile_avatar") | 428 | gtk_builder_get_object(handle->builder, "profile_avatar") |
424 | ); | 429 | ); |
425 | 430 | ||
426 | handle->profile_label = GTK_LABEL( | 431 | handle->profile_label = GTK_LABEL( |
427 | gtk_builder_get_object(handle->builder, "profile_label") | 432 | gtk_builder_get_object(handle->builder, "profile_label") |
428 | ); | 433 | ); |
429 | 434 | ||
430 | handle->profile_key_label = GTK_LABEL( | 435 | handle->profile_key_label = GTK_LABEL( |
431 | gtk_builder_get_object(handle->builder, "profile_key_label") | 436 | gtk_builder_get_object(handle->builder, "profile_key_label") |
432 | ); | 437 | ); |
433 | 438 | ||
434 | handle->hide_user_details_button = GTK_BUTTON( | 439 | handle->hide_user_details_button = GTK_BUTTON( |
435 | gtk_builder_get_object(handle->builder, "hide_user_details_button") | 440 | gtk_builder_get_object(handle->builder, "hide_user_details_button") |
436 | ); | 441 | ); |
437 | 442 | ||
438 | g_signal_connect( | 443 | g_signal_connect( |
439 | handle->hide_user_details_button, | 444 | handle->hide_user_details_button, |
440 | "clicked", | 445 | "clicked", |
441 | G_CALLBACK(handle_user_details_via_button_click), | 446 | G_CALLBACK(handle_user_details_via_button_click), |
442 | handle | 447 | handle |
443 | ); | 448 | ); |
444 | 449 | ||
445 | handle->lobby_button = GTK_BUTTON( | 450 | handle->lobby_button = GTK_BUTTON( |
446 | gtk_builder_get_object(handle->builder, "lobby_button") | 451 | gtk_builder_get_object(handle->builder, "lobby_button") |
447 | ); | 452 | ); |
448 | 453 | ||
449 | g_signal_connect( | 454 | g_signal_connect( |
450 | handle->lobby_button, | 455 | handle->lobby_button, |
451 | "clicked", | 456 | "clicked", |
452 | G_CALLBACK(handle_lobby_button_click), | 457 | G_CALLBACK(handle_lobby_button_click), |
453 | app | 458 | app |
454 | ); | 459 | ); |
455 | 460 | ||
456 | handle->account_details_button = GTK_BUTTON( | 461 | handle->account_details_button = GTK_BUTTON( |
457 | gtk_builder_get_object(handle->builder, "account_details_button") | 462 | gtk_builder_get_object(handle->builder, "account_details_button") |
458 | ); | 463 | ); |
459 | 464 | ||
460 | handle->account_details_symbol = GTK_IMAGE( | 465 | handle->account_details_symbol = GTK_IMAGE( |
461 | gtk_builder_get_object(handle->builder, "account_details_symbol") | 466 | gtk_builder_get_object(handle->builder, "account_details_symbol") |
462 | ); | 467 | ); |
463 | 468 | ||
464 | handle->account_details_revealer = GTK_REVEALER( | 469 | handle->account_details_revealer = GTK_REVEALER( |
465 | gtk_builder_get_object(handle->builder, "account_details_revealer") | 470 | gtk_builder_get_object(handle->builder, "account_details_revealer") |
466 | ); | 471 | ); |
467 | 472 | ||
468 | g_signal_connect( | 473 | g_signal_connect( |
469 | handle->account_details_button, | 474 | handle->account_details_button, |
470 | "clicked", | 475 | "clicked", |
471 | G_CALLBACK(handle_account_details_button_click), | 476 | G_CALLBACK(handle_account_details_button_click), |
472 | handle | 477 | handle |
473 | ); | 478 | ); |
474 | 479 | ||
475 | handle->accounts_listbox = GTK_LIST_BOX( | 480 | handle->accounts_listbox = GTK_LIST_BOX( |
476 | gtk_builder_get_object(handle->builder, "accounts_listbox") | 481 | gtk_builder_get_object(handle->builder, "accounts_listbox") |
477 | ); | 482 | ); |
478 | 483 | ||
479 | handle->add_account_listbox_row = GTK_LIST_BOX_ROW( | 484 | handle->add_account_listbox_row = GTK_LIST_BOX_ROW( |
480 | gtk_builder_get_object(handle->builder, "add_account_listbox_row") | 485 | gtk_builder_get_object(handle->builder, "add_account_listbox_row") |
481 | ); | 486 | ); |
482 | 487 | ||
483 | g_signal_connect( | 488 | g_signal_connect( |
484 | handle->accounts_listbox, | 489 | handle->accounts_listbox, |
485 | "row-activated", | 490 | "row-activated", |
486 | G_CALLBACK(handle_accounts_listbox_row_activated), | 491 | G_CALLBACK(handle_accounts_listbox_row_activated), |
487 | app | 492 | app |
488 | ); | 493 | ); |
489 | 494 | ||
490 | handle->new_contact_button = GTK_BUTTON( | 495 | handle->new_contact_button = GTK_BUTTON( |
491 | gtk_builder_get_object(handle->builder, "new_contact_button") | 496 | gtk_builder_get_object(handle->builder, "new_contact_button") |
492 | ); | 497 | ); |
493 | 498 | ||
494 | handle->new_group_button = GTK_BUTTON( | 499 | handle->new_group_button = GTK_BUTTON( |
495 | gtk_builder_get_object(handle->builder, "new_group_button") | 500 | gtk_builder_get_object(handle->builder, "new_group_button") |
496 | ); | 501 | ); |
497 | 502 | ||
498 | handle->new_platform_button = GTK_BUTTON( | 503 | handle->new_platform_button = GTK_BUTTON( |
499 | gtk_builder_get_object(handle->builder, "new_platform_button") | 504 | gtk_builder_get_object(handle->builder, "new_platform_button") |
500 | ); | 505 | ); |
501 | 506 | ||
502 | g_signal_connect( | 507 | g_signal_connect( |
503 | handle->new_contact_button, | 508 | handle->new_contact_button, |
504 | "clicked", | 509 | "clicked", |
505 | G_CALLBACK(handle_new_contact_button_click), | 510 | G_CALLBACK(handle_new_contact_button_click), |
506 | app | 511 | app |
507 | ); | 512 | ); |
508 | 513 | ||
509 | g_signal_connect( | 514 | g_signal_connect( |
510 | handle->new_group_button, | 515 | handle->new_group_button, |
511 | "clicked", | 516 | "clicked", |
512 | G_CALLBACK(handle_new_group_button_click), | 517 | G_CALLBACK(handle_new_group_button_click), |
513 | app | 518 | app |
514 | ); | 519 | ); |
515 | 520 | ||
516 | g_signal_connect( | 521 | g_signal_connect( |
517 | handle->new_platform_button, | 522 | handle->new_platform_button, |
518 | "clicked", | 523 | "clicked", |
519 | G_CALLBACK(handle_new_platform_button_click), | 524 | G_CALLBACK(handle_new_platform_button_click), |
520 | app | 525 | app |
521 | ); | 526 | ); |
522 | 527 | ||
523 | handle->contacts_button = GTK_BUTTON( | 528 | handle->contacts_button = GTK_BUTTON( |
524 | gtk_builder_get_object(handle->builder, "contacts_button") | 529 | gtk_builder_get_object(handle->builder, "contacts_button") |
525 | ); | 530 | ); |
526 | 531 | ||
527 | handle->settings_button = GTK_BUTTON( | 532 | handle->settings_button = GTK_BUTTON( |
528 | gtk_builder_get_object(handle->builder, "settings_button") | 533 | gtk_builder_get_object(handle->builder, "settings_button") |
529 | ); | 534 | ); |
530 | 535 | ||
531 | g_signal_connect( | 536 | g_signal_connect( |
532 | handle->contacts_button, | 537 | handle->contacts_button, |
533 | "clicked", | 538 | "clicked", |
534 | G_CALLBACK(handle_contacts_button_click), | 539 | G_CALLBACK(handle_contacts_button_click), |
535 | app | 540 | app |
536 | ); | 541 | ); |
537 | 542 | ||
538 | g_signal_connect( | 543 | g_signal_connect( |
539 | handle->settings_button, | 544 | handle->settings_button, |
540 | "clicked", | 545 | "clicked", |
541 | G_CALLBACK(handle_settings_button_click), | 546 | G_CALLBACK(handle_settings_button_click), |
542 | app | 547 | app |
543 | ); | 548 | ); |
544 | 549 | ||
545 | handle->about_button = GTK_BUTTON( | 550 | handle->about_button = GTK_BUTTON( |
546 | gtk_builder_get_object(handle->builder, "about_button") | 551 | gtk_builder_get_object(handle->builder, "about_button") |
547 | ); | 552 | ); |
548 | 553 | ||
549 | g_signal_connect( | 554 | g_signal_connect( |
550 | handle->about_button, | 555 | handle->about_button, |
551 | "clicked", | 556 | "clicked", |
552 | G_CALLBACK(handle_about_button_click), | 557 | G_CALLBACK(handle_about_button_click), |
553 | app | 558 | app |
554 | ); | 559 | ); |
555 | 560 | ||
556 | handle->user_details_button = GTK_BUTTON( | 561 | handle->user_details_button = GTK_BUTTON( |
557 | gtk_builder_get_object(handle->builder, "user_details_button") | 562 | gtk_builder_get_object(handle->builder, "user_details_button") |
558 | ); | 563 | ); |
559 | 564 | ||
560 | g_signal_connect( | 565 | g_signal_connect( |
561 | handle->user_details_button, | 566 | handle->user_details_button, |
562 | "clicked", | 567 | "clicked", |
563 | G_CALLBACK(handle_user_details_via_button_click), | 568 | G_CALLBACK(handle_user_details_via_button_click), |
564 | handle | 569 | handle |
565 | ); | 570 | ); |
566 | 571 | ||
567 | handle->chats_search = GTK_SEARCH_ENTRY( | 572 | handle->chats_search = GTK_SEARCH_ENTRY( |
568 | gtk_builder_get_object(handle->builder, "chats_search") | 573 | gtk_builder_get_object(handle->builder, "chats_search") |
569 | ); | 574 | ); |
570 | 575 | ||
571 | handle->chats_listbox = GTK_LIST_BOX( | 576 | handle->chats_listbox = GTK_LIST_BOX( |
572 | gtk_builder_get_object(handle->builder, "chats_listbox") | 577 | gtk_builder_get_object(handle->builder, "chats_listbox") |
573 | ); | 578 | ); |
574 | 579 | ||
575 | gtk_list_box_set_sort_func( | 580 | gtk_list_box_set_sort_func( |
576 | handle->chats_listbox, | 581 | handle->chats_listbox, |
577 | handle_chats_listbox_sort_func, | 582 | handle_chats_listbox_sort_func, |
578 | app, | 583 | app, |
579 | NULL | 584 | NULL |
580 | ); | 585 | ); |
581 | 586 | ||
582 | gtk_list_box_set_filter_func( | 587 | gtk_list_box_set_filter_func( |
583 | handle->chats_listbox, | 588 | handle->chats_listbox, |
584 | handle_chats_listbox_filter_func, | 589 | handle_chats_listbox_filter_func, |
585 | app, | 590 | app, |
586 | NULL | 591 | NULL |
587 | ); | 592 | ); |
588 | 593 | ||
589 | g_signal_connect( | 594 | g_signal_connect( |
590 | handle->chats_search, | 595 | handle->chats_search, |
591 | "search-changed", | 596 | "search-changed", |
592 | G_CALLBACK(handle_chats_search_changed), | 597 | G_CALLBACK(handle_chats_search_changed), |
593 | handle->chats_listbox | 598 | handle->chats_listbox |
594 | ); | 599 | ); |
595 | 600 | ||
596 | g_signal_connect( | 601 | g_signal_connect( |
597 | handle->chats_listbox, | 602 | handle->chats_listbox, |
598 | "row-activated", | 603 | "row-activated", |
599 | G_CALLBACK(handle_chats_listbox_row_activated), | 604 | G_CALLBACK(handle_chats_listbox_row_activated), |
600 | app | 605 | app |
601 | ); | 606 | ); |
602 | 607 | ||
603 | handle->chats_stack = GTK_STACK( | 608 | handle->chats_stack = GTK_STACK( |
604 | gtk_builder_get_object(handle->builder, "chats_stack") | 609 | gtk_builder_get_object(handle->builder, "chats_stack") |
605 | ); | 610 | ); |
606 | 611 | ||
607 | handle->no_chat_box = GTK_WIDGET( | 612 | handle->no_chat_box = GTK_WIDGET( |
608 | gtk_builder_get_object(handle->builder, "no_chat_box") | 613 | gtk_builder_get_object(handle->builder, "no_chat_box") |
609 | ); | 614 | ); |
610 | 615 | ||
611 | g_signal_connect( | 616 | g_signal_connect( |
612 | handle->main_window, | 617 | handle->main_window, |
613 | "destroy", | 618 | "destroy", |
614 | G_CALLBACK(handle_main_window_destroy), | 619 | G_CALLBACK(handle_main_window_destroy), |
615 | app | 620 | app |
616 | ); | 621 | ); |
617 | } | 622 | } |
618 | 623 | ||
619 | static int | 624 | static int |
620 | _messenger_iterate_accounts(void *cls, | 625 | _messenger_iterate_accounts(void *cls, |
621 | const struct GNUNET_CHAT_Handle *handle, | 626 | const struct GNUNET_CHAT_Handle *handle, |
622 | struct GNUNET_CHAT_Account *account) | 627 | struct GNUNET_CHAT_Account *account) |
623 | { | 628 | { |
624 | MESSENGER_Application *app = (MESSENGER_Application*) cls; | 629 | MESSENGER_Application *app = (MESSENGER_Application*) cls; |
625 | UI_MESSENGER_Handle *ui = &(app->ui.messenger); | 630 | UI_MESSENGER_Handle *ui = &(app->ui.messenger); |
@@ -647,7 +652,7 @@ _messenger_iterate_accounts(void *cls, | |||
647 | 652 | ||
648 | static void | 653 | static void |
649 | _clear_accounts_listbox(GtkWidget *widget, | 654 | _clear_accounts_listbox(GtkWidget *widget, |
650 | gpointer data) | 655 | gpointer data) |
651 | { | 656 | { |
652 | GtkListBoxRow *row = GTK_LIST_BOX_ROW(widget); | 657 | GtkListBoxRow *row = GTK_LIST_BOX_ROW(widget); |
653 | GtkListBox *listbox = GTK_LIST_BOX(data); | 658 | GtkListBox *listbox = GTK_LIST_BOX(data); |
@@ -656,34 +661,34 @@ _clear_accounts_listbox(GtkWidget *widget, | |||
656 | return; | 661 | return; |
657 | 662 | ||
658 | gtk_container_remove( | 663 | gtk_container_remove( |
659 | GTK_CONTAINER(listbox), | 664 | GTK_CONTAINER(listbox), |
660 | widget | 665 | widget |
661 | ); | 666 | ); |
662 | } | 667 | } |
663 | 668 | ||
664 | void | 669 | void |
665 | ui_messenger_refresh(MESSENGER_Application *app, | 670 | ui_messenger_refresh(MESSENGER_Application *app, |
666 | UI_MESSENGER_Handle *handle) | 671 | UI_MESSENGER_Handle *handle) |
667 | { | 672 | { |
668 | if (!(handle->accounts_listbox)) | 673 | if (!(handle->accounts_listbox)) |
669 | return; | 674 | return; |
670 | 675 | ||
671 | gtk_container_foreach( | 676 | gtk_container_foreach( |
672 | GTK_CONTAINER(handle->accounts_listbox), | 677 | GTK_CONTAINER(handle->accounts_listbox), |
673 | _clear_accounts_listbox, | 678 | _clear_accounts_listbox, |
674 | handle->accounts_listbox | 679 | handle->accounts_listbox |
675 | ); | 680 | ); |
676 | 681 | ||
677 | GNUNET_CHAT_iterate_accounts( | 682 | GNUNET_CHAT_iterate_accounts( |
678 | app->chat.messenger.handle, | 683 | app->chat.messenger.handle, |
679 | _messenger_iterate_accounts, | 684 | _messenger_iterate_accounts, |
680 | app | 685 | app |
681 | ); | 686 | ); |
682 | } | 687 | } |
683 | 688 | ||
684 | gboolean | 689 | gboolean |
685 | ui_messenger_is_context_active(UI_MESSENGER_Handle *handle, | 690 | ui_messenger_is_context_active(UI_MESSENGER_Handle *handle, |
686 | struct GNUNET_CHAT_Context *context) | 691 | struct GNUNET_CHAT_Context *context) |
687 | { | 692 | { |
688 | if (!gtk_window_is_active(GTK_WINDOW(handle->main_window))) | 693 | if (!gtk_window_is_active(GTK_WINDOW(handle->main_window))) |
689 | return FALSE; | 694 | return FALSE; |
@@ -694,7 +699,7 @@ ui_messenger_is_context_active(UI_MESSENGER_Handle *handle, | |||
694 | return FALSE; | 699 | return FALSE; |
695 | 700 | ||
696 | GtkListBoxRow *row = GTK_LIST_BOX_ROW( | 701 | GtkListBoxRow *row = GTK_LIST_BOX_ROW( |
697 | gtk_widget_get_parent(entry->entry_box) | 702 | gtk_widget_get_parent(entry->entry_box) |
698 | ); | 703 | ); |
699 | 704 | ||
700 | if (!row) | 705 | if (!row) |