annotate plugins/gevolution/new_person_dialog.c @ 9826:6f2a90c36ee2

[gaim-migrate @ 10697] Kevin pointed out that the error message for AIM when you couldn't send a message to someone could be better. So I made it better. Also renamed AIM_IMCHARSET_bleh to AIM_CHARSET_bleh, since they're used in direct connect stuff, too. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 22 Aug 2004 17:59:17 +0000
parents c00def44d76a
children ff4be2d1401d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8089
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * Evolution integration plugin for Gaim
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2003 Christian Hammond.
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation; either version 2 of the
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * General Public License for more details.
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * 02111-1307, USA.
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 */
9825
c00def44d76a [gaim-migrate @ 10696]
Christian Hammond <chipx86@chipx86.com>
parents: 9824
diff changeset
21 #include "internal.h"
9824
94910b9520cf [gaim-migrate @ 10695]
Mark Doliner <mark@kingant.net>
parents: 9354
diff changeset
22 #include "gtkgaim.h"
8089
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "gtkutils.h"
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "debug.h"
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "gevolution.h"
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 static GtkWidget *
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 add_pref_box(GtkSizeGroup *sg, GtkWidget *parent, const char *text,
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 GtkWidget *widget)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 GtkWidget *hbox;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 GtkWidget *label;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 hbox = gtk_hbox_new(FALSE, 6);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 gtk_box_pack_start(GTK_BOX(parent), hbox, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 gtk_widget_show(hbox);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 label = gtk_label_new_with_mnemonic(text);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 gtk_size_group_add_widget(sg, label);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 gtk_widget_show(label);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 gtk_widget_show(widget);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 return hbox;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 static gint
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 delete_win_cb(GtkWidget *w, GdkEvent *event, GevoNewPersonDialog *dialog)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 gtk_widget_destroy(dialog->win);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 g_free(dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 return 0;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 static void
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 cancel_cb(GtkWidget *w, GevoNewPersonDialog *dialog)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 delete_win_cb(NULL, NULL, dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 static void
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 screenname_changed_cb(GtkEntry *entry, GevoNewPersonDialog *dialog)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 gtk_widget_set_sensitive(dialog->add_button,
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 *gtk_entry_get_text(entry) != '\0');
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 static void
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 person_info_changed_cb(GtkEntry *entry, GevoNewPersonDialog *dialog)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 gtk_widget_set_sensitive(dialog->add_button,
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 (*gtk_entry_get_text(GTK_ENTRY(dialog->firstname)) != '\0' ||
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 *gtk_entry_get_text(GTK_ENTRY(dialog->lastname)) != '\0'));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 static void
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 add_cb(GtkWidget *w, GevoNewPersonDialog *dialog)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 EContact *contact = NULL;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 EBook *book;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 const char *screenname;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 const char *firstname;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 const char *lastname;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 const char *email;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 const char *im_service;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 gboolean new_contact = FALSE;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 EContactField field = 0;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 EContactName *name = NULL;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 char *full_name = NULL;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 if (dialog->person_only)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 screenname = dialog->buddy->name;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 else
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 screenname = gtk_entry_get_text(GTK_ENTRY(dialog->screenname));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 firstname = gtk_entry_get_text(GTK_ENTRY(dialog->firstname));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 lastname = gtk_entry_get_text(GTK_ENTRY(dialog->lastname));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 email = gtk_entry_get_text(GTK_ENTRY(dialog->email));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 if (*firstname || *lastname)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 if (!gevo_load_addressbook(&book, NULL))
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 gaim_debug_error("evolution",
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 "Error retrieving default addressbook\n");
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 return;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 if (dialog->contact == NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 char *file_as;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 dialog->contact = e_contact_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 if (lastname != NULL && firstname != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 file_as = g_strdup_printf("%s, %s", lastname, firstname);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 else if (lastname != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 file_as = g_strdup(lastname);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 else
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 file_as = g_strdup(firstname);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129
8474
8b62cc40069b [gaim-migrate @ 9207]
Christian Hammond <chipx86@chipx86.com>
parents: 8089
diff changeset
130 e_contact_set(dialog->contact, E_CONTACT_FILE_AS, file_as);
8089
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 g_free(file_as);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 new_contact = TRUE;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 contact = dialog->contact;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 name = e_contact_name_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 name->given = g_strdup(firstname);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 name->family = g_strdup(lastname);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 full_name = e_contact_name_to_string(name);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 e_contact_set(contact, E_CONTACT_FULL_NAME, full_name);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 im_service = gaim_account_get_protocol_id(dialog->account);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 if (*email)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 e_contact_set(contact, E_CONTACT_EMAIL_1, (gpointer)email);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 if (!strcmp(im_service, "prpl-oscar"))
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 if (isdigit(*screenname))
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 field = E_CONTACT_IM_ICQ;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 else
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 field = E_CONTACT_IM_AIM;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 else if (!strcmp(im_service, "prpl-yahoo"))
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 field = E_CONTACT_IM_YAHOO;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 else if (!strcmp(im_service, "prpl-jabber"))
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 field = E_CONTACT_IM_JABBER;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 else if (!strcmp(im_service, "prpl-msn"))
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 field = E_CONTACT_IM_MSN;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 if (field > 0)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 GList *list = g_list_append(NULL, g_strdup(screenname));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 e_contact_set(contact, field, list);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 g_free(list->data);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 g_list_free(list);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 if (new_contact)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 if (!e_book_add_contact(book, contact, NULL))
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 gaim_debug_error("evolution", "Error adding contact to book\n");
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 g_object_unref(contact);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 delete_win_cb(NULL, NULL, dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 return;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 else
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 if (!e_book_commit_contact(book, contact, NULL))
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 gaim_debug_error("evolution", "Error adding contact to book\n");
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 g_object_unref(contact);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 delete_win_cb(NULL, NULL, dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 return;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 g_object_unref(contact);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 if (!dialog->person_only)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 GtkWidget *entry = GTK_COMBO(dialog->group_combo)->entry;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 const char *group_name;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 group_name = gtk_entry_get_text(GTK_ENTRY(entry));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 gevo_add_buddy(dialog->account, group_name, screenname, full_name);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 if (name != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 e_contact_name_free(name);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 if (full_name != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 g_free(full_name);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 delete_win_cb(NULL, NULL, dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 static void
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 select_account_cb(GObject *w, GaimAccount *account,
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 GevoNewPersonDialog *dialog)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 dialog->account = account;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 void
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 gevo_new_person_dialog_show(EContact *contact, GaimAccount *account,
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 const char *username, const char *group,
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 GaimBuddy *buddy, gboolean person_only)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 GevoNewPersonDialog *dialog;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 GtkWidget *vbox, *vbox2;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 GtkWidget *hbox;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 GtkWidget *bbox;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 GtkWidget *label;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 GtkWidget *button;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 GtkWidget *sep;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 GtkSizeGroup *sg, *sg2;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 const char *str;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 g_return_if_fail(!person_only || (person_only && buddy));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 dialog = g_new0(GevoNewPersonDialog, 1);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 dialog->account = account;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 dialog->person_only = person_only;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 dialog->buddy = buddy;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 dialog->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 gtk_window_set_role(GTK_WINDOW(dialog->win), "new_person");
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 gtk_window_set_resizable(GTK_WINDOW(dialog->win), FALSE);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 gtk_container_set_border_width(GTK_CONTAINER(dialog->win), 12);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 g_signal_connect(G_OBJECT(dialog->win), "delete_event",
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 G_CALLBACK(delete_win_cb), dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 /* Setup the vbox */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 vbox = gtk_vbox_new(FALSE, 12);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 gtk_container_add(GTK_CONTAINER(dialog->win), vbox);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 gtk_widget_show(vbox);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 /* Label */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 if (person_only)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 label = gtk_label_new(
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 _("Please enter the person's information below."));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 else
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 label = gtk_label_new(_("Please enter the buddy's screen name and "
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 "account type below."));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 gtk_widget_show(label);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 /* Setup the size groups */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 sg2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 if (!person_only)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 /* Add the account type stuff. */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 dialog->accounts_menu =
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 gaim_gtk_account_option_menu_new(account, FALSE,
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 G_CALLBACK(select_account_cb),
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 NULL, dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 add_pref_box(sg, vbox, _("Account type:"), dialog->accounts_menu);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 /* Screen Name */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 dialog->screenname = gtk_entry_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 add_pref_box(sg, vbox, _("Screenname:"), dialog->screenname);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 if (username != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 gtk_entry_set_text(GTK_ENTRY(dialog->screenname), username);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 g_signal_connect(G_OBJECT(dialog->screenname), "changed",
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 G_CALLBACK(screenname_changed_cb), dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 /* Group */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 dialog->group_combo = gtk_combo_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 gtk_combo_set_popdown_strings(GTK_COMBO(dialog->group_combo),
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 gevo_get_groups());
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 add_pref_box(sg, vbox, _("Group:"), dialog->group_combo);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 /* Separator */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 sep = gtk_hseparator_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 gtk_widget_show(sep);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 /* Optional Information section */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 label = gtk_label_new(_("Optional information:"));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 gtk_widget_show(label);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 /* Create the parent hbox for this whole thing. */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 hbox = gtk_hbox_new(FALSE, 12);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 gtk_widget_show(hbox);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 #if 0
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 /* Now the left side of the hbox */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 vbox2 = gtk_vbox_new(FALSE, 12);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 gtk_widget_show(vbox2);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 /* Buddy icon button */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 gtk_box_pack_start(GTK_BOX(vbox2), button, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 gtk_widget_show(button);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 /* Label */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 label = gtk_label_new(_("Buddy Icon"));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 gtk_widget_show(label);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 #endif
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 /* Now the right side. */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 vbox2 = gtk_vbox_new(FALSE, 12);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 gtk_widget_show(vbox2);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 /* First Name field */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 dialog->firstname = gtk_entry_new();
9044
23bcfdcd530d [gaim-migrate @ 9820]
Christian Hammond <chipx86@chipx86.com>
parents: 9039
diff changeset
351 add_pref_box(sg2, vbox2, _("First name:"), dialog->firstname);
8089
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 if (contact != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 str = e_contact_get_const(contact, E_CONTACT_GIVEN_NAME);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 if (str != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 gtk_entry_set_text(GTK_ENTRY(dialog->firstname), str);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 /* Last Name field */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 dialog->lastname = gtk_entry_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 add_pref_box(sg2, vbox2, _("Last name:"), dialog->lastname);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 if (contact != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 str = e_contact_get_const(contact, E_CONTACT_FAMILY_NAME);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 if (str != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 gtk_entry_set_text(GTK_ENTRY(dialog->lastname), str);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 if (person_only)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 g_signal_connect(G_OBJECT(dialog->firstname), "changed",
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 G_CALLBACK(person_info_changed_cb), dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 g_signal_connect(G_OBJECT(dialog->lastname), "changed",
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 G_CALLBACK(person_info_changed_cb), dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 /* E-Mail address field */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 dialog->email = gtk_entry_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 add_pref_box(sg2, vbox2, _("E-mail:"), dialog->email);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 if (contact != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 str = e_contact_get_const(contact, E_CONTACT_EMAIL_1);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 if (str != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 gtk_entry_set_text(GTK_ENTRY(dialog->email), str);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 /* Separator */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 sep = gtk_hseparator_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 gtk_widget_show(sep);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 /* Button box */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 bbox = gtk_hbutton_box_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 gtk_box_set_spacing(GTK_BOX(bbox), 6);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 gtk_widget_show(bbox);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 /* Cancel button */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 gtk_widget_show(button);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 g_signal_connect(G_OBJECT(button), "clicked",
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 G_CALLBACK(cancel_cb), dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 /* Add button */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 button = gtk_button_new_from_stock(GTK_STOCK_ADD);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 dialog->add_button = button;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 gtk_widget_set_sensitive(button, FALSE);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 gtk_widget_show(button);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 g_signal_connect(G_OBJECT(button), "clicked",
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 G_CALLBACK(add_cb), dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 /* Show it. */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 gtk_widget_show(dialog->win);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 }