diff options
Diffstat (limited to 'src/ui/messenger.c')
-rw-r--r-- | src/ui/messenger.c | 94 |
1 files changed, 68 insertions, 26 deletions
diff --git a/src/ui/messenger.c b/src/ui/messenger.c index 246bb9c..270360d 100644 --- a/src/ui/messenger.c +++ b/src/ui/messenger.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #include "contacts.h" | 31 | #include "contacts.h" |
32 | #include "message.h" | 32 | #include "message.h" |
33 | #include "new_contact.h" | 33 | #include "new_contact.h" |
34 | #include "new_group.h" | ||
35 | #include "new_lobby.h" | ||
34 | #include "new_platform.h" | 36 | #include "new_platform.h" |
35 | #include "settings.h" | 37 | #include "settings.h" |
36 | 38 | ||
@@ -58,6 +60,19 @@ handle_flap_via_button_click(UNUSED GtkButton* button, | |||
58 | } | 60 | } |
59 | 61 | ||
60 | static void | 62 | static void |
63 | handle_lobby_button_click(UNUSED GtkButton* button, | ||
64 | gpointer user_data) | ||
65 | { | ||
66 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | ||
67 | |||
68 | hdy_flap_set_reveal_flap(HDY_FLAP(app->ui.messenger.flap_user_details), FALSE); | ||
69 | |||
70 | ui_new_lobby_dialog_init(app, &(app->ui.new_lobby)); | ||
71 | |||
72 | gtk_widget_show(GTK_WIDGET(app->ui.new_lobby.dialog)); | ||
73 | } | ||
74 | |||
75 | static void | ||
61 | _switch_details_revealer_visibility(UI_MESSENGER_Handle *handle, | 76 | _switch_details_revealer_visibility(UI_MESSENGER_Handle *handle, |
62 | gboolean state) | 77 | gboolean state) |
63 | { | 78 | { |
@@ -264,6 +279,25 @@ handle_main_window_destroy(UNUSED GtkWidget *window, | |||
264 | application_exit(app, MESSENGER_QUIT); | 279 | application_exit(app, MESSENGER_QUIT); |
265 | } | 280 | } |
266 | 281 | ||
282 | static void | ||
283 | _switch_accounts_listbox_connection(MESSENGER_Application *app, | ||
284 | UI_MESSENGER_Handle *handle, | ||
285 | gboolean enabled) | ||
286 | { | ||
287 | if (enabled) | ||
288 | handle->accounts_signal = g_signal_connect( | ||
289 | handle->accounts_listbox, | ||
290 | "row-activated", | ||
291 | G_CALLBACK(handle_accounts_listbox_row_activated), | ||
292 | app | ||
293 | ); | ||
294 | else | ||
295 | g_signal_handler_disconnect( | ||
296 | handle->accounts_listbox, | ||
297 | handle->accounts_signal | ||
298 | ); | ||
299 | } | ||
300 | |||
267 | void | 301 | void |
268 | ui_messenger_init(MESSENGER_Application *app, | 302 | ui_messenger_init(MESSENGER_Application *app, |
269 | UI_MESSENGER_Handle *handle) | 303 | UI_MESSENGER_Handle *handle) |
@@ -342,8 +376,15 @@ ui_messenger_init(MESSENGER_Application *app, | |||
342 | handle->flap_user_details | 376 | handle->flap_user_details |
343 | ); | 377 | ); |
344 | 378 | ||
345 | handle->favourites_button = GTK_BUTTON( | 379 | handle->lobby_button = GTK_BUTTON( |
346 | gtk_builder_get_object(handle->builder, "favourites_button") | 380 | gtk_builder_get_object(handle->builder, "lobby_button") |
381 | ); | ||
382 | |||
383 | g_signal_connect( | ||
384 | handle->lobby_button, | ||
385 | "clicked", | ||
386 | G_CALLBACK(handle_lobby_button_click), | ||
387 | app | ||
347 | ); | 388 | ); |
348 | 389 | ||
349 | handle->account_details_button = GTK_BUTTON( | 390 | handle->account_details_button = GTK_BUTTON( |
@@ -373,12 +414,7 @@ ui_messenger_init(MESSENGER_Application *app, | |||
373 | gtk_builder_get_object(handle->builder, "add_account_listbox_row") | 414 | gtk_builder_get_object(handle->builder, "add_account_listbox_row") |
374 | ); | 415 | ); |
375 | 416 | ||
376 | g_signal_connect( | 417 | _switch_accounts_listbox_connection(app, handle, TRUE); |
377 | handle->accounts_listbox, | ||
378 | "row-activated", | ||
379 | G_CALLBACK(handle_accounts_listbox_row_activated), | ||
380 | app | ||
381 | ); | ||
382 | 418 | ||
383 | handle->new_contact_button = GTK_BUTTON( | 419 | handle->new_contact_button = GTK_BUTTON( |
384 | gtk_builder_get_object(handle->builder, "new_contact_button") | 420 | gtk_builder_get_object(handle->builder, "new_contact_button") |
@@ -522,6 +558,22 @@ _messenger_iterate_accounts(void *cls, | |||
522 | return GNUNET_YES; | 558 | return GNUNET_YES; |
523 | } | 559 | } |
524 | 560 | ||
561 | static void | ||
562 | _clear_accounts_listbox(GtkWidget *widget, | ||
563 | gpointer data) | ||
564 | { | ||
565 | GtkListBoxRow *row = GTK_LIST_BOX_ROW(widget); | ||
566 | GtkListBox *listbox = GTK_LIST_BOX(data); | ||
567 | |||
568 | if ((!row) || (!listbox) || (!gtk_list_box_row_get_selectable(row))) | ||
569 | return; | ||
570 | |||
571 | gtk_container_remove( | ||
572 | GTK_CONTAINER(listbox), | ||
573 | widget | ||
574 | ); | ||
575 | } | ||
576 | |||
525 | void | 577 | void |
526 | ui_messenger_refresh(MESSENGER_Application *app, | 578 | ui_messenger_refresh(MESSENGER_Application *app, |
527 | UI_MESSENGER_Handle *handle) | 579 | UI_MESSENGER_Handle *handle) |
@@ -529,31 +581,21 @@ ui_messenger_refresh(MESSENGER_Application *app, | |||
529 | if (!(handle->accounts_listbox)) | 581 | if (!(handle->accounts_listbox)) |
530 | return; | 582 | return; |
531 | 583 | ||
532 | GList *list = gtk_container_get_children( | 584 | _switch_accounts_listbox_connection(app, handle, FALSE); |
533 | GTK_CONTAINER(handle->accounts_listbox) | ||
534 | ); | ||
535 | |||
536 | while (list) | ||
537 | { | ||
538 | GtkListBoxRow *row = GTK_LIST_BOX_ROW(list->data); | ||
539 | |||
540 | if ((!row) || (!gtk_list_box_row_get_selectable(row))) | ||
541 | goto skip_row; | ||
542 | 585 | ||
543 | gtk_container_remove( | 586 | gtk_container_foreach( |
544 | GTK_CONTAINER(handle->accounts_listbox), | 587 | GTK_CONTAINER(handle->accounts_listbox), |
545 | GTK_WIDGET(row) | 588 | _clear_accounts_listbox, |
546 | ); | 589 | handle->accounts_listbox |
547 | 590 | ); | |
548 | skip_row: | ||
549 | list = list->next; | ||
550 | } | ||
551 | 591 | ||
552 | GNUNET_CHAT_iterate_accounts( | 592 | GNUNET_CHAT_iterate_accounts( |
553 | app->chat.messenger.handle, | 593 | app->chat.messenger.handle, |
554 | _messenger_iterate_accounts, | 594 | _messenger_iterate_accounts, |
555 | app | 595 | app |
556 | ); | 596 | ); |
597 | |||
598 | _switch_accounts_listbox_connection(app, handle, TRUE); | ||
557 | } | 599 | } |
558 | 600 | ||
559 | gboolean | 601 | gboolean |