aboutsummaryrefslogtreecommitdiff
path: root/src/ui/messenger.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/messenger.c')
-rw-r--r--src/ui/messenger.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/src/ui/messenger.c b/src/ui/messenger.c
index 633920c..45da0cd 100644
--- a/src/ui/messenger.c
+++ b/src/ui/messenger.c
@@ -280,31 +280,12 @@ handle_main_window_destroy(UNUSED GtkWidget *window,
280 application_exit(app, MESSENGER_QUIT); 280 application_exit(app, MESSENGER_QUIT);
281} 281}
282 282
283static void
284_switch_accounts_listbox_connection(MESSENGER_Application *app,
285 UI_MESSENGER_Handle *handle,
286 gboolean enabled)
287{
288 if (enabled)
289 handle->accounts_signal = g_signal_connect(
290 handle->accounts_listbox,
291 "row-activated",
292 G_CALLBACK(handle_accounts_listbox_row_activated),
293 app
294 );
295 else
296 g_signal_handler_disconnect(
297 handle->accounts_listbox,
298 handle->accounts_signal
299 );
300}
301
302void 283void
303ui_messenger_init(MESSENGER_Application *app, 284ui_messenger_init(MESSENGER_Application *app,
304 UI_MESSENGER_Handle *handle) 285 UI_MESSENGER_Handle *handle)
305{ 286{
287 memset(handle, 0, sizeof(*handle));
306 handle->app = app; 288 handle->app = app;
307 handle->chat_entries = NULL;
308 289
309 handle->builder = gtk_builder_new_from_resource( 290 handle->builder = gtk_builder_new_from_resource(
310 application_get_resource_path(app, "ui/messenger.ui") 291 application_get_resource_path(app, "ui/messenger.ui")
@@ -415,7 +396,12 @@ ui_messenger_init(MESSENGER_Application *app,
415 gtk_builder_get_object(handle->builder, "add_account_listbox_row") 396 gtk_builder_get_object(handle->builder, "add_account_listbox_row")
416 ); 397 );
417 398
418 _switch_accounts_listbox_connection(app, handle, TRUE); 399 g_signal_connect(
400 handle->accounts_listbox,
401 "row-activated",
402 G_CALLBACK(handle_accounts_listbox_row_activated),
403 app
404 );
419 405
420 handle->new_contact_button = GTK_BUTTON( 406 handle->new_contact_button = GTK_BUTTON(
421 gtk_builder_get_object(handle->builder, "new_contact_button") 407 gtk_builder_get_object(handle->builder, "new_contact_button")
@@ -582,8 +568,6 @@ ui_messenger_refresh(MESSENGER_Application *app,
582 if (!(handle->accounts_listbox)) 568 if (!(handle->accounts_listbox))
583 return; 569 return;
584 570
585 _switch_accounts_listbox_connection(app, handle, FALSE);
586
587 gtk_container_foreach( 571 gtk_container_foreach(
588 GTK_CONTAINER(handle->accounts_listbox), 572 GTK_CONTAINER(handle->accounts_listbox),
589 _clear_accounts_listbox, 573 _clear_accounts_listbox,
@@ -595,8 +579,6 @@ ui_messenger_refresh(MESSENGER_Application *app,
595 _messenger_iterate_accounts, 579 _messenger_iterate_accounts,
596 app 580 app
597 ); 581 );
598
599 _switch_accounts_listbox_connection(app, handle, TRUE);
600} 582}
601 583
602gboolean 584gboolean
@@ -626,5 +608,11 @@ ui_messenger_cleanup(UI_MESSENGER_Handle *handle)
626 if (handle->chat_entries) 608 if (handle->chat_entries)
627 g_list_free_full(handle->chat_entries, (GDestroyNotify) ui_chat_entry_delete); 609 g_list_free_full(handle->chat_entries, (GDestroyNotify) ui_chat_entry_delete);
628 610
611 if (handle->chat_selection)
612 g_source_remove(handle->chat_selection);
613
614 if (handle->account_refresh)
615 g_source_remove(handle->account_refresh);
616
629 memset(handle, 0, sizeof(*handle)); 617 memset(handle, 0, sizeof(*handle));
630} 618}