diff options
Diffstat (limited to 'src/ui/contacts.c')
-rw-r--r-- | src/ui/contacts.c | 60 |
1 files changed, 13 insertions, 47 deletions
diff --git a/src/ui/contacts.c b/src/ui/contacts.c index 21d2f2f..68d18b4 100644 --- a/src/ui/contacts.c +++ b/src/ui/contacts.c | |||
@@ -61,7 +61,7 @@ handle_contacts_listbox_row_activated(UNUSED GtkListBox* listbox, | |||
61 | } | 61 | } |
62 | 62 | ||
63 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( | 63 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( |
64 | bindings_get(app->bindings, row) | 64 | g_object_get_qdata(G_OBJECT(row), app->quarks.data) |
65 | ); | 65 | ); |
66 | 66 | ||
67 | if ((!contact) || (!GNUNET_CHAT_contact_get_key(contact)) || | 67 | if ((!contact) || (!GNUNET_CHAT_contact_get_key(contact)) || |
@@ -86,20 +86,20 @@ static gboolean | |||
86 | handle_contacts_listbox_filter_func(GtkListBoxRow *row, | 86 | handle_contacts_listbox_filter_func(GtkListBoxRow *row, |
87 | gpointer user_data) | 87 | gpointer user_data) |
88 | { | 88 | { |
89 | UI_CONTACTS_Handle *handle = (UI_CONTACTS_Handle*) user_data; | 89 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
90 | 90 | ||
91 | if ((!row) || (!gtk_list_box_row_get_selectable(row))) | 91 | if ((!row) || (!gtk_list_box_row_get_selectable(row))) |
92 | return TRUE; | 92 | return TRUE; |
93 | 93 | ||
94 | const gchar *filter = gtk_entry_get_text( | 94 | const gchar *filter = gtk_entry_get_text( |
95 | GTK_ENTRY(handle->contact_search_entry) | 95 | GTK_ENTRY(app->ui.contacts.contact_search_entry) |
96 | ); | 96 | ); |
97 | 97 | ||
98 | if (!filter) | 98 | if (!filter) |
99 | return TRUE; | 99 | return TRUE; |
100 | 100 | ||
101 | UI_CONTACT_ENTRY_Handle *entry = (UI_CONTACT_ENTRY_Handle*) ( | 101 | UI_CONTACT_ENTRY_Handle *entry = (UI_CONTACT_ENTRY_Handle*) ( |
102 | bindings_get(handle->bindings, row) | 102 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) |
103 | ); | 103 | ); |
104 | 104 | ||
105 | if (!entry) | 105 | if (!entry) |
@@ -151,8 +151,14 @@ _iterate_contacts(void *cls, | |||
151 | gtk_widget_get_parent(entry->entry_box) | 151 | gtk_widget_get_parent(entry->entry_box) |
152 | ); | 152 | ); |
153 | 153 | ||
154 | bindings_put(app->bindings, row, contact); | 154 | g_object_set_qdata(G_OBJECT(row), app->quarks.data, contact); |
155 | bindings_put(app->ui.contacts.bindings, row, entry); | 155 | |
156 | g_object_set_qdata_full( | ||
157 | G_OBJECT(row), | ||
158 | app->quarks.ui, | ||
159 | entry, | ||
160 | (GDestroyNotify) ui_contact_entry_delete | ||
161 | ); | ||
156 | 162 | ||
157 | return GNUNET_YES; | 163 | return GNUNET_YES; |
158 | } | 164 | } |
@@ -161,8 +167,6 @@ void | |||
161 | ui_contacts_dialog_init(MESSENGER_Application *app, | 167 | ui_contacts_dialog_init(MESSENGER_Application *app, |
162 | UI_CONTACTS_Handle *handle) | 168 | UI_CONTACTS_Handle *handle) |
163 | { | 169 | { |
164 | handle->bindings = bindings_create(); | ||
165 | |||
166 | handle->builder = gtk_builder_new_from_resource( | 170 | handle->builder = gtk_builder_new_from_resource( |
167 | application_get_resource_path(app, "ui/contacts.ui") | 171 | application_get_resource_path(app, "ui/contacts.ui") |
168 | ); | 172 | ); |
@@ -187,7 +191,7 @@ ui_contacts_dialog_init(MESSENGER_Application *app, | |||
187 | gtk_list_box_set_filter_func( | 191 | gtk_list_box_set_filter_func( |
188 | handle->contacts_listbox, | 192 | handle->contacts_listbox, |
189 | handle_contacts_listbox_filter_func, | 193 | handle_contacts_listbox_filter_func, |
190 | handle, | 194 | app, |
191 | NULL | 195 | NULL |
192 | ); | 196 | ); |
193 | 197 | ||
@@ -232,48 +236,10 @@ ui_contacts_dialog_init(MESSENGER_Application *app, | |||
232 | gtk_list_box_invalidate_filter(handle->contacts_listbox); | 236 | gtk_list_box_invalidate_filter(handle->contacts_listbox); |
233 | } | 237 | } |
234 | 238 | ||
235 | static void | ||
236 | _clear_contacts_listbox_rows(UI_CONTACTS_Handle *handle, | ||
237 | gboolean bindings_only) | ||
238 | { | ||
239 | GList *list = gtk_container_get_children( | ||
240 | GTK_CONTAINER(handle->contacts_listbox) | ||
241 | ); | ||
242 | |||
243 | while (list) | ||
244 | { | ||
245 | GtkListBoxRow *row = GTK_LIST_BOX_ROW(list->data); | ||
246 | |||
247 | if ((!row) || (!gtk_list_box_row_get_selectable(row))) | ||
248 | goto skip_row; | ||
249 | |||
250 | if (!bindings_only) | ||
251 | gtk_container_remove( | ||
252 | GTK_CONTAINER(handle->contacts_listbox), | ||
253 | GTK_WIDGET(row) | ||
254 | ); | ||
255 | |||
256 | bindings_remove( | ||
257 | handle->bindings, | ||
258 | row, | ||
259 | NULL, | ||
260 | (GDestroyNotify) ui_contact_entry_delete | ||
261 | ); | ||
262 | |||
263 | skip_row: | ||
264 | list = list->next; | ||
265 | } | ||
266 | } | ||
267 | |||
268 | void | 239 | void |
269 | ui_contacts_dialog_cleanup(UI_CONTACTS_Handle *handle) | 240 | ui_contacts_dialog_cleanup(UI_CONTACTS_Handle *handle) |
270 | { | 241 | { |
271 | _clear_contacts_listbox_rows(handle, TRUE); | ||
272 | |||
273 | g_object_unref(handle->builder); | 242 | g_object_unref(handle->builder); |
274 | 243 | ||
275 | bindings_destroy(handle->bindings); | ||
276 | handle->bindings = NULL; | ||
277 | |||
278 | handle->contacts_listbox = NULL; | 244 | handle->contacts_listbox = NULL; |
279 | } | 245 | } |