diff options
Diffstat (limited to 'src/ui/invite_contact.c')
-rw-r--r-- | src/ui/invite_contact.c | 64 |
1 files changed, 15 insertions, 49 deletions
diff --git a/src/ui/invite_contact.c b/src/ui/invite_contact.c index 4229067..272550f 100644 --- a/src/ui/invite_contact.c +++ b/src/ui/invite_contact.c | |||
@@ -44,11 +44,11 @@ handle_contacts_listbox_row_activated(GtkListBox* listbox, | |||
44 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; | 44 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
45 | 45 | ||
46 | GtkTextView *text_view = GTK_TEXT_VIEW( | 46 | GtkTextView *text_view = GTK_TEXT_VIEW( |
47 | bindings_get(app->bindings, listbox) | 47 | g_object_get_qdata(G_OBJECT(listbox), app->quarks.widget) |
48 | ); | 48 | ); |
49 | 49 | ||
50 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( | 50 | struct GNUNET_CHAT_Contact *contact = (struct GNUNET_CHAT_Contact*) ( |
51 | bindings_get(app->bindings, row) | 51 | g_object_get_qdata(G_OBJECT(row), app->quarks.data) |
52 | ); | 52 | ); |
53 | 53 | ||
54 | if ((!contact) || (!GNUNET_CHAT_contact_get_key(contact)) || | 54 | if ((!contact) || (!GNUNET_CHAT_contact_get_key(contact)) || |
@@ -57,7 +57,7 @@ handle_contacts_listbox_row_activated(GtkListBox* listbox, | |||
57 | goto close_dialog; | 57 | goto close_dialog; |
58 | 58 | ||
59 | struct GNUNET_CHAT_Context *context = (struct GNUNET_CHAT_Context*) ( | 59 | struct GNUNET_CHAT_Context *context = (struct GNUNET_CHAT_Context*) ( |
60 | bindings_get(app->bindings, text_view) | 60 | g_object_get_qdata(G_OBJECT(text_view), app->quarks.data) |
61 | ); | 61 | ); |
62 | 62 | ||
63 | if (!context) | 63 | if (!context) |
@@ -78,20 +78,20 @@ static gboolean | |||
78 | handle_contacts_listbox_filter_func(GtkListBoxRow *row, | 78 | handle_contacts_listbox_filter_func(GtkListBoxRow *row, |
79 | gpointer user_data) | 79 | gpointer user_data) |
80 | { | 80 | { |
81 | UI_INVITE_CONTACT_Handle *handle = (UI_INVITE_CONTACT_Handle*) user_data; | 81 | MESSENGER_Application *app = (MESSENGER_Application*) user_data; |
82 | 82 | ||
83 | if ((!row) || (!gtk_list_box_row_get_selectable(row))) | 83 | if ((!row) || (!gtk_list_box_row_get_selectable(row))) |
84 | return TRUE; | 84 | return TRUE; |
85 | 85 | ||
86 | const gchar *filter = gtk_entry_get_text( | 86 | const gchar *filter = gtk_entry_get_text( |
87 | GTK_ENTRY(handle->contact_search_entry) | 87 | GTK_ENTRY(app->ui.invite_contact.contact_search_entry) |
88 | ); | 88 | ); |
89 | 89 | ||
90 | if (!filter) | 90 | if (!filter) |
91 | return TRUE; | 91 | return TRUE; |
92 | 92 | ||
93 | UI_CONTACT_ENTRY_Handle *entry = (UI_CONTACT_ENTRY_Handle*) ( | 93 | UI_CONTACT_ENTRY_Handle *entry = (UI_CONTACT_ENTRY_Handle*) ( |
94 | bindings_get(handle->bindings, row) | 94 | g_object_get_qdata(G_OBJECT(row), app->quarks.ui) |
95 | ); | 95 | ); |
96 | 96 | ||
97 | if (!entry) | 97 | if (!entry) |
@@ -143,8 +143,14 @@ _iterate_contacts(void *cls, | |||
143 | gtk_widget_get_parent(entry->entry_box) | 143 | gtk_widget_get_parent(entry->entry_box) |
144 | ); | 144 | ); |
145 | 145 | ||
146 | bindings_put(app->bindings, row, contact); | 146 | g_object_set_qdata(G_OBJECT(row), app->quarks.data, contact); |
147 | bindings_put(app->ui.invite_contact.bindings, row, entry); | 147 | |
148 | g_object_set_qdata_full( | ||
149 | G_OBJECT(row), | ||
150 | app->quarks.ui, | ||
151 | entry, | ||
152 | (GDestroyNotify) ui_contact_entry_delete | ||
153 | ); | ||
148 | 154 | ||
149 | return GNUNET_YES; | 155 | return GNUNET_YES; |
150 | } | 156 | } |
@@ -153,8 +159,6 @@ void | |||
153 | ui_invite_contact_dialog_init(MESSENGER_Application *app, | 159 | ui_invite_contact_dialog_init(MESSENGER_Application *app, |
154 | UI_INVITE_CONTACT_Handle *handle) | 160 | UI_INVITE_CONTACT_Handle *handle) |
155 | { | 161 | { |
156 | handle->bindings = bindings_create(); | ||
157 | |||
158 | handle->builder = gtk_builder_new_from_resource( | 162 | handle->builder = gtk_builder_new_from_resource( |
159 | application_get_resource_path(app, "ui/invite_contact.ui") | 163 | application_get_resource_path(app, "ui/invite_contact.ui") |
160 | ); | 164 | ); |
@@ -179,7 +183,7 @@ ui_invite_contact_dialog_init(MESSENGER_Application *app, | |||
179 | gtk_list_box_set_filter_func( | 183 | gtk_list_box_set_filter_func( |
180 | handle->contacts_listbox, | 184 | handle->contacts_listbox, |
181 | handle_contacts_listbox_filter_func, | 185 | handle_contacts_listbox_filter_func, |
182 | handle, | 186 | app, |
183 | NULL | 187 | NULL |
184 | ); | 188 | ); |
185 | 189 | ||
@@ -224,48 +228,10 @@ ui_invite_contact_dialog_init(MESSENGER_Application *app, | |||
224 | gtk_list_box_invalidate_filter(handle->contacts_listbox); | 228 | gtk_list_box_invalidate_filter(handle->contacts_listbox); |
225 | } | 229 | } |
226 | 230 | ||
227 | static void | ||
228 | _clear_contacts_listbox_rows(UI_INVITE_CONTACT_Handle *handle, | ||
229 | gboolean bindings_only) | ||
230 | { | ||
231 | GList *list = gtk_container_get_children( | ||
232 | GTK_CONTAINER(handle->contacts_listbox) | ||
233 | ); | ||
234 | |||
235 | while (list) | ||
236 | { | ||
237 | GtkListBoxRow *row = GTK_LIST_BOX_ROW(list->data); | ||
238 | |||
239 | if ((!row) || (!gtk_list_box_row_get_selectable(row))) | ||
240 | goto skip_row; | ||
241 | |||
242 | if (!bindings_only) | ||
243 | gtk_container_remove( | ||
244 | GTK_CONTAINER(handle->contacts_listbox), | ||
245 | GTK_WIDGET(row) | ||
246 | ); | ||
247 | |||
248 | bindings_remove( | ||
249 | handle->bindings, | ||
250 | row, | ||
251 | NULL, | ||
252 | (GDestroyNotify) ui_contact_entry_delete | ||
253 | ); | ||
254 | |||
255 | skip_row: | ||
256 | list = list->next; | ||
257 | } | ||
258 | } | ||
259 | |||
260 | void | 231 | void |
261 | ui_invite_contact_dialog_cleanup(UI_INVITE_CONTACT_Handle *handle) | 232 | ui_invite_contact_dialog_cleanup(UI_INVITE_CONTACT_Handle *handle) |
262 | { | 233 | { |
263 | _clear_contacts_listbox_rows(handle, TRUE); | ||
264 | |||
265 | g_object_unref(handle->builder); | 234 | g_object_unref(handle->builder); |
266 | 235 | ||
267 | bindings_destroy(handle->bindings); | ||
268 | handle->bindings = NULL; | ||
269 | |||
270 | handle->contacts_listbox = NULL; | 236 | handle->contacts_listbox = NULL; |
271 | } | 237 | } |