aboutsummaryrefslogtreecommitdiff
path: root/src/event.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/event.c')
-rw-r--r--src/event.c81
1 files changed, 21 insertions, 60 deletions
diff --git a/src/event.c b/src/event.c
index c1f7502..71701db 100644
--- a/src/event.c
+++ b/src/event.c
@@ -93,57 +93,11 @@ _clear_each_selectable_widget(GtkWidget *widget,
93 gtk_container_remove(container, widget); 93 gtk_container_remove(container, widget);
94} 94}
95 95
96static int
97_iterate_accounts(void *cls,
98 const struct GNUNET_CHAT_Handle *handle,
99 struct GNUNET_CHAT_Account *account)
100{
101 MESSENGER_Application *app = (MESSENGER_Application*) cls;
102 UI_MESSENGER_Handle *ui = &(app->ui.messenger);
103
104 const gchar *name = GNUNET_CHAT_account_get_name(account);
105
106 UI_ACCOUNT_ENTRY_Handle *entry = ui_account_entry_new(app);
107
108 hdy_avatar_set_text(entry->entry_avatar, name);
109 gtk_label_set_text(entry->entry_label, name);
110
111 gtk_list_box_prepend(ui->accounts_listbox, entry->entry_box);
112
113 GtkListBoxRow *row = GTK_LIST_BOX_ROW(
114 gtk_widget_get_parent(entry->entry_box)
115 );
116
117 g_hash_table_insert(ui->bindings, row, account);
118
119 if ((account == GNUNET_CHAT_get_connected(handle)) ||
120 ((app->chat.identity) && (0 == g_strcmp0(app->chat.identity, name))))
121 gtk_widget_activate(GTK_WIDGET(row));
122
123 ui_account_entry_delete(entry);
124 return GNUNET_YES;
125}
126
127void 96void
128event_refresh_accounts(MESSENGER_Application *app) 97event_refresh_accounts(MESSENGER_Application *app)
129{ 98{
130 UI_MESSENGER_Handle *ui = &(app->ui.messenger);
131 CHAT_MESSENGER_Handle *chat = &(app->chat.messenger);
132
133 ui_accounts_dialog_refresh(app, &(app->ui.accounts)); 99 ui_accounts_dialog_refresh(app, &(app->ui.accounts));
134 100 ui_messenger_refresh(app, &(app->ui.messenger));
135 if (!(ui->accounts_listbox))
136 return;
137
138 gtk_list_box_unselect_all(ui->accounts_listbox);
139
140 gtk_container_foreach(
141 GTK_CONTAINER(ui->accounts_listbox),
142 _clear_each_selectable_widget,
143 ui->accounts_listbox
144 );
145
146 GNUNET_CHAT_iterate_accounts(chat->handle, _iterate_accounts, app);
147} 101}
148 102
149static void 103static void
@@ -163,11 +117,7 @@ _add_new_chat_entry(MESSENGER_Application *app,
163 entry->chat->chat_box 117 entry->chat->chat_box
164 ); 118 );
165 119
166 g_hash_table_insert( 120 bindings_put(app->bindings, entry->chat->send_text_view, context);
167 app->ui.bindings,
168 entry->chat->send_text_view,
169 context
170 );
171 121
172 ui->chat_entries = g_list_append(ui->chat_entries, entry); 122 ui->chat_entries = g_list_append(ui->chat_entries, entry);
173 123
@@ -175,11 +125,7 @@ _add_new_chat_entry(MESSENGER_Application *app,
175 gtk_widget_get_parent(entry->entry_box) 125 gtk_widget_get_parent(entry->entry_box)
176 ); 126 );
177 127
178 g_hash_table_insert( 128 bindings_put(app->bindings, row, entry);
179 app->ui.bindings,
180 row,
181 entry
182 );
183 129
184 gtk_list_box_select_row(ui->chats_listbox, row); 130 gtk_list_box_select_row(ui->chats_listbox, row);
185 gtk_list_box_invalidate_filter(ui->chats_listbox); 131 gtk_list_box_invalidate_filter(ui->chats_listbox);
@@ -298,13 +244,23 @@ event_joining_contact(MESSENGER_Application *app,
298 if (!handle) 244 if (!handle)
299 return; 245 return;
300 246
301 UI_MESSAGE_Handle *message = ui_message_new(app, UI_MESSAGE_STATUS);
302 ui_message_update(message, app, msg);
303
304 struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( 247 struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender(
305 msg 248 msg
306 ); 249 );
307 250
251 if (!contact)
252 return;
253
254 UI_MESSAGE_Handle *message = (UI_MESSAGE_Handle*) (
255 bindings_get(handle->joining, contact)
256 );
257
258 if (message)
259 ui_chat_remove_message(handle->chat, app, message);
260
261 message = ui_message_new(app, UI_MESSAGE_STATUS);
262 ui_message_update(message, app, msg);
263
308 contact_create_info(contact); 264 contact_create_info(contact);
309 _update_contact_context(app, contact); 265 _update_contact_context(app, contact);
310 266
@@ -332,6 +288,8 @@ event_joining_contact(MESSENGER_Application *app,
332 gtk_label_set_text(message->timestamp_label, time? time : ""); 288 gtk_label_set_text(message->timestamp_label, time? time : "");
333 289
334 ui_chat_add_message(handle->chat, app, message); 290 ui_chat_add_message(handle->chat, app, message);
291 bindings_put(handle->joining, contact, message);
292
335 ui_chat_entry_update(handle, app, context); 293 ui_chat_entry_update(handle, app, context);
336} 294}
337 295
@@ -344,6 +302,9 @@ event_update_contacts(MESSENGER_Application *app,
344 msg 302 msg
345 ); 303 );
346 304
305 if (!contact)
306 return;
307
347 contact_update_info(contact); 308 contact_update_info(contact);
348 _update_contact_context(app, contact); 309 _update_contact_context(app, contact);
349 310