diff options
Diffstat (limited to 'src/ui/messenger.c')
-rw-r--r-- | src/ui/messenger.c | 68 |
1 files changed, 30 insertions, 38 deletions
diff --git a/src/ui/messenger.c b/src/ui/messenger.c index aff450e..246bb9c 100644 --- a/src/ui/messenger.c +++ b/src/ui/messenger.c | |||
@@ -106,7 +106,7 @@ handle_accounts_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
106 | } | 106 | } |
107 | 107 | ||
108 | struct GNUNET_CHAT_Account *account = (struct GNUNET_CHAT_Account*) ( | 108 | struct GNUNET_CHAT_Account *account = (struct GNUNET_CHAT_Account*) ( |
109 | bindings_get(app->bindings, row) | 109 | g_object_get_qdata(G_OBJECT(row), app->quarks.data) |
110 | ); | 110 | ); |
111 | 111 | ||
112 | if (!account) | 112 | if (!account) |
@@ -188,20 +188,20 @@ handle_chats_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
188 | GtkListBoxRow* row, | 188 | GtkListBoxRow* row, |
189 | gpointer user_data) | 189 | gpointer user_data) |
190 | { | 190 | { |
191 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; | 191 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
192 | 192 | ||
193 | if (!gtk_list_box_row_get_selectable(row)) | 193 | if (!gtk_list_box_row_get_selectable(row)) |
194 | return; | 194 | return; |
195 | 195 | ||
196 | UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) ( | 196 | UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) ( |
197 | bindings_get(handle->app->bindings, row) | 197 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) |
198 | ); | 198 | ); |
199 | 199 | ||
200 | if ((!entry) || (!(entry->chat)) || (!(entry->chat->chat_box))) | 200 | if ((!entry) || (!(entry->chat)) || (!(entry->chat->chat_box))) |
201 | return; | 201 | return; |
202 | 202 | ||
203 | GtkStack *stack = handle->chats_stack; | 203 | GtkStack *stack = app->ui.messenger.chats_stack; |
204 | HdyLeaflet *leaflet = handle->leaflet_chat; | 204 | HdyLeaflet *leaflet = app->ui.messenger.leaflet_chat; |
205 | 205 | ||
206 | GList *children = gtk_container_get_children(GTK_CONTAINER(leaflet)); | 206 | GList *children = gtk_container_get_children(GTK_CONTAINER(leaflet)); |
207 | 207 | ||
@@ -216,21 +216,21 @@ static gboolean | |||
216 | handle_chats_listbox_filter_func(GtkListBoxRow *row, | 216 | handle_chats_listbox_filter_func(GtkListBoxRow *row, |
217 | gpointer user_data) | 217 | gpointer user_data) |
218 | { | 218 | { |
219 | UI_MESSENGER_Handle *handle = (UI_MESSENGER_Handle*) user_data; | 219 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
220 | 220 | ||
221 | if ((!row) || (!gtk_list_box_row_get_selectable(row)) || | 221 | if ((!row) || (!gtk_list_box_row_get_selectable(row)) || |
222 | (gtk_list_box_row_is_selected(row))) | 222 | (gtk_list_box_row_is_selected(row))) |
223 | return TRUE; | 223 | return TRUE; |
224 | 224 | ||
225 | const gchar *filter = gtk_entry_get_text( | 225 | const gchar *filter = gtk_entry_get_text( |
226 | GTK_ENTRY(handle->chats_search) | 226 | GTK_ENTRY(app->ui.messenger.chats_search) |
227 | ); | 227 | ); |
228 | 228 | ||
229 | if (!filter) | 229 | if (!filter) |
230 | return TRUE; | 230 | return TRUE; |
231 | 231 | ||
232 | UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) ( | 232 | UI_CHAT_ENTRY_Handle *entry = (UI_CHAT_ENTRY_Handle*) ( |
233 | bindings_get(handle->app->bindings, row) | 233 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) |
234 | ); | 234 | ); |
235 | 235 | ||
236 | if ((!entry) || (!(entry->title_label))) | 236 | if ((!entry) || (!(entry->title_label))) |
@@ -457,7 +457,7 @@ ui_messenger_init(MESSENGER_Application *app, | |||
457 | gtk_list_box_set_filter_func( | 457 | gtk_list_box_set_filter_func( |
458 | handle->chats_listbox, | 458 | handle->chats_listbox, |
459 | handle_chats_listbox_filter_func, | 459 | handle_chats_listbox_filter_func, |
460 | handle, | 460 | app, |
461 | NULL | 461 | NULL |
462 | ); | 462 | ); |
463 | 463 | ||
@@ -472,7 +472,7 @@ ui_messenger_init(MESSENGER_Application *app, | |||
472 | handle->chats_listbox, | 472 | handle->chats_listbox, |
473 | "row-activated", | 473 | "row-activated", |
474 | G_CALLBACK(handle_chats_listbox_row_activated), | 474 | G_CALLBACK(handle_chats_listbox_row_activated), |
475 | handle | 475 | app |
476 | ); | 476 | ); |
477 | 477 | ||
478 | handle->chats_stack = GTK_STACK( | 478 | handle->chats_stack = GTK_STACK( |
@@ -491,32 +491,6 @@ ui_messenger_init(MESSENGER_Application *app, | |||
491 | ); | 491 | ); |
492 | } | 492 | } |
493 | 493 | ||
494 | static void | ||
495 | _messenger_clear_accounts_listbox_rows(UI_MESSENGER_Handle *handle) | ||
496 | { | ||
497 | GList *list = gtk_container_get_children( | ||
498 | GTK_CONTAINER(handle->accounts_listbox) | ||
499 | ); | ||
500 | |||
501 | while (list) | ||
502 | { | ||
503 | GtkListBoxRow *row = GTK_LIST_BOX_ROW(list->data); | ||
504 | |||
505 | if ((!row) || (!gtk_list_box_row_get_selectable(row))) | ||
506 | goto skip_row; | ||
507 | |||
508 | bindings_remove(handle->app->bindings, row, NULL, NULL); | ||
509 | |||
510 | gtk_container_remove( | ||
511 | GTK_CONTAINER(handle->accounts_listbox), | ||
512 | GTK_WIDGET(row) | ||
513 | ); | ||
514 | |||
515 | skip_row: | ||
516 | list = list->next; | ||
517 | } | ||
518 | } | ||
519 | |||
520 | static int | 494 | static int |
521 | _messenger_iterate_accounts(void *cls, | 495 | _messenger_iterate_accounts(void *cls, |
522 | const struct GNUNET_CHAT_Handle *handle, | 496 | const struct GNUNET_CHAT_Handle *handle, |
@@ -538,7 +512,7 @@ _messenger_iterate_accounts(void *cls, | |||
538 | gtk_widget_get_parent(entry->entry_box) | 512 | gtk_widget_get_parent(entry->entry_box) |
539 | ); | 513 | ); |
540 | 514 | ||
541 | bindings_put(app->bindings, row, account); | 515 | g_object_set_qdata(G_OBJECT(row), app->quarks.data, account); |
542 | 516 | ||
543 | if ((account == GNUNET_CHAT_get_connected(handle)) || | 517 | if ((account == GNUNET_CHAT_get_connected(handle)) || |
544 | ((app->chat.identity) && (0 == g_strcmp0(app->chat.identity, name)))) | 518 | ((app->chat.identity) && (0 == g_strcmp0(app->chat.identity, name)))) |
@@ -555,7 +529,25 @@ ui_messenger_refresh(MESSENGER_Application *app, | |||
555 | if (!(handle->accounts_listbox)) | 529 | if (!(handle->accounts_listbox)) |
556 | return; | 530 | return; |
557 | 531 | ||
558 | _messenger_clear_accounts_listbox_rows(handle); | 532 | GList *list = gtk_container_get_children( |
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 | |||
543 | gtk_container_remove( | ||
544 | GTK_CONTAINER(handle->accounts_listbox), | ||
545 | GTK_WIDGET(row) | ||
546 | ); | ||
547 | |||
548 | skip_row: | ||
549 | list = list->next; | ||
550 | } | ||
559 | 551 | ||
560 | GNUNET_CHAT_iterate_accounts( | 552 | GNUNET_CHAT_iterate_accounts( |
561 | app->chat.messenger.handle, | 553 | app->chat.messenger.handle, |