aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/accounts.c73
-rw-r--r--src/ui/accounts.h4
2 files changed, 62 insertions, 15 deletions
diff --git a/src/ui/accounts.c b/src/ui/accounts.c
index 1817180..fcd4ad9 100644
--- a/src/ui/accounts.c
+++ b/src/ui/accounts.c
@@ -181,18 +181,11 @@ ui_accounts_dialog_init(MESSENGER_Application *app,
181 G_CALLBACK(handle_dialog_destroy), 181 G_CALLBACK(handle_dialog_destroy),
182 app 182 app
183 ); 183 );
184
185 GNUNET_CHAT_iterate_accounts(
186 app->chat.messenger.handle,
187 _iterate_accounts,
188 app
189 );
190
191 gtk_list_box_unselect_all(handle->accounts_listbox);
192} 184}
193 185
194void 186static void
195ui_accounts_dialog_cleanup(UI_ACCOUNTS_Handle *handle) 187_clear_accounts_listbox_rows(UI_ACCOUNTS_Handle *handle,
188 gboolean bindings_only)
196{ 189{
197 GList *list = gtk_container_get_children( 190 GList *list = gtk_container_get_children(
198 GTK_CONTAINER(handle->accounts_listbox) 191 GTK_CONTAINER(handle->accounts_listbox)
@@ -200,15 +193,28 @@ ui_accounts_dialog_cleanup(UI_ACCOUNTS_Handle *handle)
200 193
201 while (list) 194 while (list)
202 { 195 {
203 if (list->data) 196 GtkListBoxRow *row = GTK_LIST_BOX_ROW(list->data);
204 g_hash_table_remove(handle->bindings, list->data);
205 197
198 if ((!row) || (!gtk_list_box_row_get_selectable(row)))
199 goto skip_row;
200
201 g_hash_table_remove(handle->bindings, row);
202
203 if (!bindings_only)
204 gtk_container_remove(
205 GTK_CONTAINER(handle->accounts_listbox),
206 GTK_WIDGET(row)
207 );
208
209 skip_row:
206 list = list->next; 210 list = list->next;
207 } 211 }
212}
208 213
209 g_object_unref(handle->builder); 214static void
210 215_clear_accounts_entries(UI_ACCOUNTS_Handle *handle)
211 list = handle->account_entries; 216{
217 GList *list = handle->account_entries;
212 218
213 while (list) { 219 while (list) {
214 if (list->data) 220 if (list->data)
@@ -219,4 +225,41 @@ ui_accounts_dialog_cleanup(UI_ACCOUNTS_Handle *handle)
219 225
220 if (handle->account_entries) 226 if (handle->account_entries)
221 g_list_free(handle->account_entries); 227 g_list_free(handle->account_entries);
228
229 handle->account_entries = NULL;
230}
231
232void
233ui_accounts_dialog_refresh(MESSENGER_Application *app,
234 UI_ACCOUNTS_Handle *handle)
235{
236 if (!(handle->accounts_listbox))
237 return;
238
239 if (!(handle->account_entries))
240 goto add_account_entries;
241
242 _clear_accounts_listbox_rows(handle, FALSE);
243 _clear_accounts_entries(handle);
244
245add_account_entries:
246 GNUNET_CHAT_iterate_accounts(
247 app->chat.messenger.handle,
248 _iterate_accounts,
249 app
250 );
251
252 gtk_list_box_unselect_all(handle->accounts_listbox);
253}
254
255void
256ui_accounts_dialog_cleanup(UI_ACCOUNTS_Handle *handle)
257{
258 _clear_accounts_listbox_rows(handle, TRUE);
259
260 g_object_unref(handle->builder);
261
262 _clear_accounts_entries(handle);
263
264 handle->accounts_listbox = NULL;
222} 265}
diff --git a/src/ui/accounts.h b/src/ui/accounts.h
index 254c861..6a098d8 100644
--- a/src/ui/accounts.h
+++ b/src/ui/accounts.h
@@ -46,6 +46,10 @@ ui_accounts_dialog_init(MESSENGER_Application *app,
46 UI_ACCOUNTS_Handle *handle); 46 UI_ACCOUNTS_Handle *handle);
47 47
48void 48void
49ui_accounts_dialog_refresh(MESSENGER_Application *app,
50 UI_ACCOUNTS_Handle *handle);
51
52void
49ui_accounts_dialog_cleanup(UI_ACCOUNTS_Handle *handle); 53ui_accounts_dialog_cleanup(UI_ACCOUNTS_Handle *handle);
50 54
51#endif /* UI_ACCOUNTS_H_ */ 55#endif /* UI_ACCOUNTS_H_ */