Mercurial > pidgin
annotate plugins/gevolution/add_buddy_dialog.c @ 9824:94910b9520cf
[gaim-migrate @ 10695]
Really, someone needs to test this and tell me which of these files
need to include internal.h
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 22 Aug 2004 17:33:36 +0000 |
parents | 7a149eac59a3 |
children | c00def44d76a |
rev | line source |
---|---|
8089 | 1 /* |
2 * Evolution integration plugin for Gaim | |
3 * | |
4 * Copyright (C) 2003 Christian Hammond. | |
5 * | |
6 * This program is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation; either version 2 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
19 * 02111-1307, USA. | |
20 */ | |
21 #include "gtkblist.h" | |
9824 | 22 #include "gtkgaim.h" |
8089 | 23 #include "gtkutils.h" |
24 | |
25 #include "debug.h" | |
26 | |
27 #include "gevolution.h" | |
28 | |
29 #include <stdlib.h> | |
30 #include <bonobo/bonobo-main.h> | |
31 | |
32 enum | |
33 { | |
34 COLUMN_NAME, | |
35 COLUMN_PRPL_ICON, | |
36 COLUMN_USERNAME, | |
37 COLUMN_DATA, | |
38 NUM_COLUMNS | |
39 }; | |
40 | |
41 static gint | |
42 delete_win_cb(GtkWidget *w, GdkEvent *event, GevoAddBuddyDialog *dialog) | |
43 { | |
44 gtk_widget_destroy(dialog->win); | |
45 | |
46 g_list_foreach(dialog->contacts, (GFunc)g_object_unref, NULL); | |
47 | |
48 if (dialog->contacts != NULL) | |
49 g_list_free(dialog->contacts); | |
50 | |
51 if (dialog->book != NULL) | |
52 g_object_unref(dialog->book); | |
53 | |
54 if (dialog->username != NULL) | |
55 g_free(dialog->username); | |
56 | |
57 g_free(dialog); | |
58 | |
59 return 0; | |
60 } | |
61 | |
62 static void | |
63 new_person_cb(GtkWidget *w, GevoAddBuddyDialog *dialog) | |
64 { | |
65 const char *group_name; | |
66 | |
67 group_name = | |
68 gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(dialog->group_combo)->entry)); | |
69 | |
70 gevo_new_person_dialog_show(NULL, dialog->account, NULL, | |
71 (*group_name ? group_name : NULL), | |
72 NULL, FALSE); | |
73 | |
74 delete_win_cb(NULL, NULL, dialog); | |
75 } | |
76 | |
77 static void | |
78 cancel_cb(GtkWidget *w, GevoAddBuddyDialog *dialog) | |
79 { | |
80 delete_win_cb(NULL, NULL, dialog); | |
81 } | |
82 | |
83 static void | |
84 select_buddy_cb(GtkWidget *w, GevoAddBuddyDialog *dialog) | |
85 { | |
86 GtkTreeSelection *selection; | |
87 GtkTreeIter iter; | |
88 const char *group_name; | |
89 const char *fullname; | |
90 const char *username; | |
91 EContact *contact; | |
92 | |
93 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)); | |
94 | |
95 gtk_tree_selection_get_selected(selection, NULL, &iter); | |
96 | |
97 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter, | |
98 COLUMN_NAME, &fullname, | |
99 COLUMN_USERNAME, &username, | |
100 COLUMN_DATA, &contact, | |
101 -1); | |
102 | |
103 group_name = | |
104 gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(dialog->group_combo)->entry)); | |
105 | |
106 if (username == NULL || *username == '\0') | |
107 { | |
108 gevo_new_person_dialog_show(NULL, dialog->account, NULL, | |
109 (*group_name ? group_name : NULL), | |
110 NULL, FALSE); | |
111 } | |
112 else | |
113 { | |
114 gevo_add_buddy(dialog->account, group_name, username, fullname); | |
115 } | |
116 | |
117 delete_win_cb(NULL, NULL, dialog); | |
118 } | |
119 | |
120 static void | |
121 populate_address_books(GevoAddBuddyDialog *dialog) | |
122 { | |
123 GtkWidget *item; | |
124 GtkWidget *menu; | |
125 #if notyet | |
126 ESourceList *addressbooks; | |
9566
7a149eac59a3
[gaim-migrate @ 10409]
Christian Hammond <chipx86@chipx86.com>
parents:
9354
diff
changeset
|
127 GSList *groups, *g; |
8089 | 128 #endif |
129 | |
130 menu = | |
131 gtk_option_menu_get_menu(GTK_OPTION_MENU(dialog->addressbooks_menu)); | |
132 | |
133 item = gtk_menu_item_new_with_label(_("Local Addressbook")); | |
134 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
135 gtk_widget_show(item); | |
136 | |
137 #if notyet | |
138 if (!e_book_get_addressbooks(&addressbooks, NULL)) | |
139 { | |
140 gaim_debug_error("evolution", | |
141 "Unable to fetch list of address books.\n"); | |
142 | |
143 item = gtk_menu_item_new_with_label(_("None")); | |
144 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
145 gtk_widget_show(item); | |
146 | |
147 return; | |
148 } | |
149 | |
9566
7a149eac59a3
[gaim-migrate @ 10409]
Christian Hammond <chipx86@chipx86.com>
parents:
9354
diff
changeset
|
150 groups = e_source_list_peek_groups(addressbooks); |
8089 | 151 |
152 if (groups == NULL) | |
153 { | |
154 item = gtk_menu_item_new_with_label(_("None")); | |
155 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
156 gtk_widget_show(item); | |
157 | |
158 return; | |
159 } | |
160 | |
161 for (g = groups; g != NULL; g = g->next) | |
162 { | |
9566
7a149eac59a3
[gaim-migrate @ 10409]
Christian Hammond <chipx86@chipx86.com>
parents:
9354
diff
changeset
|
163 GSList *sources, *s; |
8089 | 164 |
165 sources = e_source_group_peek_sources(g->data); | |
166 | |
9566
7a149eac59a3
[gaim-migrate @ 10409]
Christian Hammond <chipx86@chipx86.com>
parents:
9354
diff
changeset
|
167 for (s = sources; s != NULL; s = s->next) |
8089 | 168 { |
9566
7a149eac59a3
[gaim-migrate @ 10409]
Christian Hammond <chipx86@chipx86.com>
parents:
9354
diff
changeset
|
169 ESource *source = E_SOURCE(s->data); |
8089 | 170 |
171 item = gtk_menu_item_new_with_label(e_source_peek_name(source)); | |
172 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
173 gtk_widget_show(item); | |
174 } | |
175 } | |
176 #endif | |
177 } | |
178 | |
179 static void | |
180 add_columns(GevoAddBuddyDialog *dialog) | |
181 { | |
182 GtkCellRenderer *renderer; | |
183 GtkTreeViewColumn *column; | |
184 | |
185 /* Name column */ | |
186 column = gtk_tree_view_column_new(); | |
187 gtk_tree_view_column_set_title(column, _("Name")); | |
188 gtk_tree_view_insert_column(GTK_TREE_VIEW(dialog->treeview), column, -1); | |
189 gtk_tree_view_column_set_sort_column_id(column, COLUMN_NAME); | |
190 | |
191 renderer = gtk_cell_renderer_text_new(); | |
192 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
193 gtk_tree_view_column_add_attribute(column, renderer, | |
194 "text", COLUMN_NAME); | |
195 | |
196 /* Account column */ | |
197 column = gtk_tree_view_column_new(); | |
198 gtk_tree_view_column_set_title(column, _("Instant Messaging")); | |
199 gtk_tree_view_insert_column(GTK_TREE_VIEW(dialog->treeview), column, -1); | |
200 gtk_tree_view_column_set_sort_column_id(column, COLUMN_USERNAME); | |
201 | |
202 /* Protocol icon */ | |
203 renderer = gtk_cell_renderer_pixbuf_new(); | |
204 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
205 gtk_tree_view_column_add_attribute(column, renderer, | |
206 "pixbuf", COLUMN_PRPL_ICON); | |
207 | |
208 /* Account name */ | |
209 renderer = gtk_cell_renderer_text_new(); | |
210 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
211 gtk_tree_view_column_add_attribute(column, renderer, | |
212 "text", COLUMN_USERNAME); | |
213 } | |
214 | |
215 static void | |
216 add_ims(GevoAddBuddyDialog *dialog, EContact *contact, const char *name, | |
217 GList *list, const char *id) | |
218 { | |
219 GaimAccount *account = NULL; | |
220 GList *l; | |
221 GtkTreeIter iter; | |
222 GdkPixbuf *pixbuf, *icon = NULL; | |
223 | |
224 if (list == NULL) | |
225 return; | |
226 | |
227 for (l = gaim_connections_get_all(); l != NULL; l = l->next) | |
228 { | |
229 GaimConnection *gc = (GaimConnection *)l->data; | |
230 | |
231 account = gaim_connection_get_account(gc); | |
232 | |
233 if (!strcmp(gaim_account_get_protocol_id(account), id)) | |
234 break; | |
235 | |
236 account = NULL; | |
237 } | |
238 | |
239 if (account == NULL) | |
240 return; | |
241 | |
242 pixbuf = create_prpl_icon(account); | |
243 | |
244 if (pixbuf != NULL) | |
245 icon = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
246 GDK_INTERP_BILINEAR); | |
247 | |
248 for (l = list; l != NULL; l = l->next) | |
249 { | |
250 char *account_name = (char *)l->data; | |
251 | |
252 if (account_name == NULL) | |
253 continue; | |
254 | |
255 if (gaim_find_buddy(dialog->account, account_name) != NULL) | |
256 continue; | |
257 | |
258 gtk_list_store_append(dialog->model, &iter); | |
259 | |
260 gtk_list_store_set(dialog->model, &iter, | |
261 COLUMN_NAME, name, | |
262 COLUMN_PRPL_ICON, icon, | |
263 COLUMN_USERNAME, account_name, | |
264 COLUMN_DATA, contact, | |
265 -1); | |
266 | |
267 if (!strcmp(gaim_account_get_protocol_id(account), | |
268 gaim_account_get_protocol_id(dialog->account)) && | |
269 dialog->username != NULL && | |
270 !strcmp(account_name, dialog->username)) | |
271 { | |
272 GtkTreeSelection *selection; | |
273 | |
274 /* This is it. Select it. */ | |
275 selection = gtk_tree_view_get_selection( | |
276 GTK_TREE_VIEW(dialog->treeview)); | |
277 | |
278 gtk_tree_selection_select_iter(selection, &iter); | |
279 } | |
280 } | |
281 | |
282 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); | |
283 if (icon != NULL) g_object_unref(G_OBJECT(icon)); | |
284 | |
285 g_list_foreach(list, (GFunc)g_free, NULL); | |
286 g_list_free(list); | |
287 } | |
288 | |
289 static void | |
290 populate_treeview(GevoAddBuddyDialog *dialog) | |
291 { | |
292 EBookQuery *query; | |
293 EBook *book; | |
294 gboolean status; | |
295 GList *cards, *c; | |
296 | |
297 if (!gevo_load_addressbook(&book, NULL)) | |
298 { | |
299 gaim_debug_error("evolution", | |
300 "Error retrieving default addressbook\n"); | |
301 | |
302 return; | |
303 } | |
304 | |
305 query = e_book_query_field_exists(E_CONTACT_FULL_NAME); | |
306 | |
307 if (query == NULL) | |
308 { | |
309 gaim_debug_error("evolution", "Error in creating query\n"); | |
310 | |
311 g_object_unref(book); | |
312 | |
313 return; | |
314 } | |
315 | |
316 status = e_book_get_contacts(book, query, &cards, NULL); | |
317 | |
318 e_book_query_unref(query); | |
319 | |
320 if (!status) | |
321 { | |
322 gaim_debug_error("evolution", "Error %d in getting card list\n", | |
323 status); | |
324 | |
325 g_object_unref(book); | |
326 | |
327 return; | |
328 } | |
329 | |
330 for (c = cards; c != NULL; c = c->next) | |
331 { | |
332 EContact *contact = E_CONTACT(c->data); | |
333 const char *name; | |
334 GList *aims, *jabbers, *yahoos, *msns, *icqs; | |
335 | |
336 name = e_contact_get_const(contact, E_CONTACT_FULL_NAME); | |
337 | |
338 aims = e_contact_get(contact, E_CONTACT_IM_AIM); | |
339 jabbers = e_contact_get(contact, E_CONTACT_IM_JABBER); | |
340 yahoos = e_contact_get(contact, E_CONTACT_IM_YAHOO); | |
341 msns = e_contact_get(contact, E_CONTACT_IM_MSN); | |
342 icqs = e_contact_get(contact, E_CONTACT_IM_ICQ); | |
343 | |
344 if (aims == NULL && jabbers == NULL && yahoos == NULL && | |
345 msns == NULL && icqs == NULL) | |
346 { | |
347 GtkTreeIter iter; | |
348 | |
349 gtk_list_store_append(dialog->model, &iter); | |
350 | |
351 gtk_list_store_set(dialog->model, &iter, | |
352 COLUMN_NAME, name, | |
353 COLUMN_DATA, contact, | |
354 -1); | |
355 } | |
356 else | |
357 { | |
358 add_ims(dialog, contact, name, aims, "prpl-oscar"); | |
359 add_ims(dialog, contact, name, jabbers, "prpl-jabber"); | |
360 add_ims(dialog, contact, name, yahoos, "prpl-yahoo"); | |
361 add_ims(dialog, contact, name, msns, "prpl-msn"); | |
362 add_ims(dialog, contact, name, icqs, "prpl-oscar"); | |
363 } | |
364 } | |
365 | |
366 dialog->contacts = cards; | |
367 dialog->book = book; | |
368 } | |
369 | |
370 static void | |
371 selected_cb(GtkTreeSelection *sel, GevoAddBuddyDialog *dialog) | |
372 { | |
373 gtk_widget_set_sensitive(dialog->select_button, TRUE); | |
374 } | |
375 | |
376 static void | |
377 search_changed_cb(GtkEntry *entry, GevoAddBuddyDialog *dialog) | |
378 { | |
379 const char *text = gtk_entry_get_text(entry); | |
380 GList *l; | |
381 | |
382 gtk_list_store_clear(dialog->model); | |
383 | |
384 for (l = dialog->contacts; l != NULL; l = l->next) | |
385 { | |
386 EContact *contact = E_CONTACT(l->data); | |
387 const char *name; | |
388 GList *aims, *jabbers, *yahoos, *msns, *icqs; | |
389 | |
390 name = e_contact_get_const(contact, E_CONTACT_FULL_NAME); | |
391 | |
392 if (text != NULL && *text != '\0' && name != NULL && | |
393 g_ascii_strncasecmp(name, text, strlen(text))) | |
394 { | |
395 continue; | |
396 } | |
397 | |
398 aims = e_contact_get(contact, E_CONTACT_IM_AIM); | |
399 jabbers = e_contact_get(contact, E_CONTACT_IM_JABBER); | |
400 yahoos = e_contact_get(contact, E_CONTACT_IM_YAHOO); | |
401 msns = e_contact_get(contact, E_CONTACT_IM_MSN); | |
402 icqs = e_contact_get(contact, E_CONTACT_IM_ICQ); | |
403 | |
404 if (aims == NULL && jabbers == NULL && yahoos == NULL && | |
405 msns == NULL && icqs == NULL) | |
406 { | |
407 GtkTreeIter iter; | |
408 | |
409 gtk_list_store_append(dialog->model, &iter); | |
410 | |
411 gtk_list_store_set(dialog->model, &iter, | |
412 COLUMN_NAME, name, | |
413 COLUMN_DATA, contact, | |
414 -1); | |
415 } | |
416 else | |
417 { | |
418 add_ims(dialog, contact, name, aims, "prpl-oscar"); | |
419 add_ims(dialog, contact, name, jabbers, "prpl-jabber"); | |
420 add_ims(dialog, contact, name, yahoos, "prpl-yahoo"); | |
421 add_ims(dialog, contact, name, msns, "prpl-msn"); | |
422 add_ims(dialog, contact, name, icqs, "prpl-oscar"); | |
423 } | |
424 } | |
425 } | |
426 | |
427 static void | |
428 clear_cb(GtkWidget *w, GevoAddBuddyDialog *dialog) | |
429 { | |
430 static gboolean lock = FALSE; | |
431 | |
432 if (lock) | |
433 return; | |
434 | |
435 lock = TRUE; | |
436 gtk_entry_set_text(GTK_ENTRY(dialog->search_field), ""); | |
437 lock = FALSE; | |
438 } | |
439 | |
440 void | |
441 gevo_add_buddy_dialog_show(GaimAccount *account, const char *username, | |
442 const char *group, const char *alias) | |
443 { | |
444 GevoAddBuddyDialog *dialog; | |
445 GtkWidget *button; | |
446 GtkWidget *sw; | |
447 GtkWidget *label; | |
448 GtkWidget *vbox; | |
449 GtkWidget *hbox; | |
450 GtkWidget *bbox; | |
451 GtkWidget *menu; | |
452 GtkWidget *sep; | |
453 GtkTreeSelection *selection; | |
454 | |
455 dialog = g_new0(GevoAddBuddyDialog, 1); | |
456 | |
457 dialog->account = | |
458 (account != NULL | |
459 ? account | |
460 : gaim_connection_get_account(gaim_connections_get_all()->data)); | |
461 | |
462 if (username != NULL) | |
463 dialog->username = g_strdup(username); | |
464 | |
465 dialog->win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
466 gtk_window_set_role(GTK_WINDOW(dialog->win), "add_buddy"); | |
467 gtk_container_set_border_width(GTK_CONTAINER(dialog->win), 12); | |
468 gtk_widget_set_size_request(dialog->win, -1, 400); | |
469 | |
470 g_signal_connect(G_OBJECT(dialog->win), "delete_event", | |
471 G_CALLBACK(delete_win_cb), dialog); | |
472 | |
473 /* Setup the vbox */ | |
474 vbox = gtk_vbox_new(FALSE, 12); | |
475 gtk_container_add(GTK_CONTAINER(dialog->win), vbox); | |
476 gtk_widget_show(vbox); | |
477 | |
478 /* Add the label. */ | |
479 label = gtk_label_new(_("Select a person from your address book below, " | |
480 "or add a new person.")); | |
481 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
482 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
483 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); | |
484 gtk_widget_show(label); | |
485 | |
486 /* Add the search hbox */ | |
487 hbox = gtk_hbox_new(FALSE, 6); | |
488 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); | |
489 gtk_widget_show(hbox); | |
490 | |
491 /* "Search" */ | |
492 label = gtk_label_new(_("Search")); | |
493 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
494 gtk_widget_show(label); | |
495 | |
496 /* Addressbooks */ | |
497 dialog->addressbooks_menu = gtk_option_menu_new(); | |
498 menu = gtk_menu_new(); | |
499 gtk_option_menu_set_menu(GTK_OPTION_MENU(dialog->addressbooks_menu), menu); | |
500 | |
501 populate_address_books(dialog); | |
502 | |
503 gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->addressbooks_menu), 0); | |
504 | |
505 gtk_box_pack_start(GTK_BOX(hbox), dialog->addressbooks_menu, | |
506 FALSE, FALSE, 0); | |
507 gtk_widget_show(dialog->addressbooks_menu); | |
508 | |
509 /* Search field */ | |
510 dialog->search_field = gtk_entry_new(); | |
511 gtk_box_pack_start(GTK_BOX(hbox), dialog->search_field, TRUE, TRUE, 0); | |
512 gtk_widget_show(dialog->search_field); | |
513 | |
514 g_signal_connect(G_OBJECT(dialog->search_field), "changed", | |
515 G_CALLBACK(search_changed_cb), dialog); | |
516 | |
517 /* Clear button */ | |
518 button = gtk_button_new_from_stock(GTK_STOCK_CLEAR); | |
519 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
520 gtk_widget_show(button); | |
521 | |
522 g_signal_connect(G_OBJECT(button), "clicked", | |
523 G_CALLBACK(clear_cb), dialog); | |
524 | |
525 /* Scrolled Window */ | |
526 sw = gtk_scrolled_window_new(0, 0); | |
527 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
528 GTK_POLICY_AUTOMATIC, | |
529 GTK_POLICY_ALWAYS); | |
530 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), | |
531 GTK_SHADOW_IN); | |
532 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
533 gtk_widget_show(sw); | |
534 | |
535 /* Create the list model for the treeview. */ | |
536 dialog->model = gtk_list_store_new(NUM_COLUMNS, | |
537 G_TYPE_STRING, GDK_TYPE_PIXBUF, | |
538 G_TYPE_STRING, G_TYPE_POINTER); | |
539 | |
540 /* Now for the treeview */ | |
541 dialog->treeview = | |
542 gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model)); | |
543 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(dialog->treeview), TRUE); | |
544 gtk_container_add(GTK_CONTAINER(sw), dialog->treeview); | |
545 gtk_widget_show(dialog->treeview); | |
546 | |
547 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview)); | |
548 | |
549 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); | |
550 | |
551 g_signal_connect(G_OBJECT(selection), "changed", | |
552 G_CALLBACK(selected_cb), dialog); | |
553 | |
554 add_columns(dialog); | |
555 | |
556 populate_treeview(dialog); | |
557 | |
558 /* Group box */ | |
559 hbox = gtk_hbox_new(FALSE, 6); | |
560 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
561 gtk_widget_show(hbox); | |
562 | |
563 label = gtk_label_new(_("Group:")); | |
564 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
565 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
566 gtk_widget_show(label); | |
567 | |
568 dialog->group_combo = gtk_combo_new(); | |
569 gtk_combo_set_popdown_strings(GTK_COMBO(dialog->group_combo), | |
570 gevo_get_groups()); | |
571 gtk_box_pack_start(GTK_BOX(hbox), dialog->group_combo, TRUE, TRUE, 0); | |
572 gtk_widget_show(dialog->group_combo); | |
573 | |
574 /* Cool. Now we only have a little left... */ | |
575 | |
576 /* Separator. */ | |
577 sep = gtk_hseparator_new(); | |
578 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
579 gtk_widget_show(sep); | |
580 | |
581 /* Button box */ | |
582 bbox = gtk_hbutton_box_new(); | |
583 gtk_box_set_spacing(GTK_BOX(bbox), 6); | |
584 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
585 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); | |
586 gtk_widget_show(bbox); | |
587 | |
588 /* "New Person" button */ | |
589 button = gaim_pixbuf_button_from_stock(_("New Person"), GTK_STOCK_NEW, | |
590 GAIM_BUTTON_HORIZONTAL); | |
591 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
592 gtk_widget_show(button); | |
593 | |
594 g_signal_connect(G_OBJECT(button), "clicked", | |
595 G_CALLBACK(new_person_cb), dialog); | |
596 | |
597 /* "Cancel" button */ | |
598 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
599 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
600 gtk_widget_show(button); | |
601 | |
602 g_signal_connect(G_OBJECT(button), "clicked", | |
603 G_CALLBACK(cancel_cb), dialog); | |
604 | |
605 /* "Select Buddy" button */ | |
606 button = gaim_pixbuf_button_from_stock(_("Select Buddy"), GTK_STOCK_APPLY, | |
607 GAIM_BUTTON_HORIZONTAL); | |
608 dialog->select_button = button; | |
609 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
610 gtk_widget_set_sensitive(button, FALSE); | |
611 gtk_widget_show(button); | |
612 | |
613 g_signal_connect(G_OBJECT(button), "clicked", | |
614 G_CALLBACK(select_buddy_cb), dialog); | |
615 | |
616 /* Show it. */ | |
617 gtk_widget_show(dialog->win); | |
618 } | |
619 | |
620 void | |
621 gevo_add_buddy_dialog_add_person(GevoAddBuddyDialog *dialog, | |
622 EContact *contact, const char *name, | |
623 GaimAccount *account, const char *screenname) | |
624 { | |
625 GdkPixbuf *pixbuf, *icon = NULL; | |
626 GtkTreeIter iter; | |
627 | |
628 pixbuf = create_prpl_icon(account); | |
629 | |
630 if (pixbuf != NULL) | |
631 icon = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); | |
632 | |
633 gtk_list_store_append(dialog->model, &iter); | |
634 | |
635 gtk_list_store_set(dialog->model, &iter, | |
636 COLUMN_NAME, name, | |
637 COLUMN_PRPL_ICON, icon, | |
638 COLUMN_DATA, contact, | |
639 COLUMN_USERNAME, screenname, | |
640 -1); | |
641 | |
642 if (contact != NULL) | |
643 dialog->contacts = g_list_append(dialog->contacts, contact); | |
644 | |
645 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); | |
646 if (icon != NULL) g_object_unref(G_OBJECT(icon)); | |
647 } |