annotate plugins/gevolution/new_person_dialog.c @ 10597:0e886a234d92

[gaim-migrate @ 12012] This is a nontrivial change to the way signal handlers are implemented and used in Tcl. This changes signal handlers to being standard Tcl functions by way of a little bit of namespace glue. In addition, in/out arguments to signals are now implemented via variables which should be upvar'd; this is a little more verbose than the old method, but it should fit people's Tcl expectations a little better, since normally Tcl function arguments are not call-by-reference. This still isn't 64-bit safe, and the documentation wasn't updated. I expect there will be more nontrivial changes to Tcl before 2.0, so those things are pending. Ethan committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Mon, 14 Feb 2005 03:11:23 +0000
parents ff4be2d1401d
children bc700cc98b82
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
10081
ff4be2d1401d [gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents: 9825
diff changeset
57 g_object_unref(dialog->book);
8089
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 g_free(dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 return 0;
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
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 static void
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 cancel_cb(GtkWidget *w, GevoNewPersonDialog *dialog)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 delete_win_cb(NULL, NULL, dialog);
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
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 static void
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 screenname_changed_cb(GtkEntry *entry, GevoNewPersonDialog *dialog)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 gtk_widget_set_sensitive(dialog->add_button,
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 *gtk_entry_get_text(entry) != '\0');
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
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 static void
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 person_info_changed_cb(GtkEntry *entry, GevoNewPersonDialog *dialog)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 gtk_widget_set_sensitive(dialog->add_button,
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 (*gtk_entry_get_text(GTK_ENTRY(dialog->firstname)) != '\0' ||
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 *gtk_entry_get_text(GTK_ENTRY(dialog->lastname)) != '\0'));
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
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 static void
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 add_cb(GtkWidget *w, GevoNewPersonDialog *dialog)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 EContact *contact = NULL;
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 (dialog->contact == 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 char *file_as;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 dialog->contact = e_contact_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 if (lastname != NULL && firstname != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 file_as = g_strdup_printf("%s, %s", lastname, firstname);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 else if (lastname != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 file_as = g_strdup(lastname);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 else
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 file_as = g_strdup(firstname);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121
8474
8b62cc40069b [gaim-migrate @ 9207]
Christian Hammond <chipx86@chipx86.com>
parents: 8089
diff changeset
122 e_contact_set(dialog->contact, E_CONTACT_FILE_AS, file_as);
8089
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 g_free(file_as);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 new_contact = TRUE;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 contact = dialog->contact;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 name = e_contact_name_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 name->given = g_strdup(firstname);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 name->family = g_strdup(lastname);
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 full_name = e_contact_name_to_string(name);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 e_contact_set(contact, E_CONTACT_FULL_NAME, full_name);
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 im_service = gaim_account_get_protocol_id(dialog->account);
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 if (*email)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 e_contact_set(contact, E_CONTACT_EMAIL_1, (gpointer)email);
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 if (!strcmp(im_service, "prpl-oscar"))
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 if (isdigit(*screenname))
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 field = E_CONTACT_IM_ICQ;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 else
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 field = E_CONTACT_IM_AIM;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 else if (!strcmp(im_service, "prpl-yahoo"))
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 field = E_CONTACT_IM_YAHOO;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 else if (!strcmp(im_service, "prpl-jabber"))
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 field = E_CONTACT_IM_JABBER;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 else if (!strcmp(im_service, "prpl-msn"))
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 field = E_CONTACT_IM_MSN;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 if (field > 0)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 GList *list = g_list_append(NULL, g_strdup(screenname));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 e_contact_set(contact, field, list);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 g_free(list->data);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 g_list_free(list);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 }
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 if (new_contact)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 {
10081
ff4be2d1401d [gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents: 9825
diff changeset
170 if (!e_book_add_contact(dialog->book, contact, NULL))
8089
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 gaim_debug_error("evolution", "Error adding contact to book\n");
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 g_object_unref(contact);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 delete_win_cb(NULL, NULL, dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 return;
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 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 else
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 {
10081
ff4be2d1401d [gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents: 9825
diff changeset
181 if (!e_book_commit_contact(dialog->book, contact, NULL))
8089
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 gaim_debug_error("evolution", "Error adding contact to book\n");
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 g_object_unref(contact);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 delete_win_cb(NULL, NULL, dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 return;
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 }
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 g_object_unref(contact);
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
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 if (!dialog->person_only)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 GtkWidget *entry = GTK_COMBO(dialog->group_combo)->entry;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 const char *group_name;
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 group_name = gtk_entry_get_text(GTK_ENTRY(entry));
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 gevo_add_buddy(dialog->account, group_name, screenname, full_name);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 }
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 if (name != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 e_contact_name_free(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 if (full_name != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 g_free(full_name);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 delete_win_cb(NULL, NULL, dialog);
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
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 static void
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 select_account_cb(GObject *w, GaimAccount *account,
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 GevoNewPersonDialog *dialog)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 dialog->account = account;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 }
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 void
10081
ff4be2d1401d [gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents: 9825
diff changeset
221 gevo_new_person_dialog_show(EBook *book, EContact *contact,
ff4be2d1401d [gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents: 9825
diff changeset
222 GaimAccount *account, const char *username,
ff4be2d1401d [gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents: 9825
diff changeset
223 const char *group, GaimBuddy *buddy,
ff4be2d1401d [gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents: 9825
diff changeset
224 gboolean person_only)
8089
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 GevoNewPersonDialog *dialog;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 GtkWidget *vbox, *vbox2;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 GtkWidget *hbox;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 GtkWidget *bbox;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 GtkWidget *label;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 GtkWidget *button;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 GtkWidget *sep;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 GtkSizeGroup *sg, *sg2;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 const char *str;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235
10081
ff4be2d1401d [gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents: 9825
diff changeset
236 g_return_if_fail(book);
8089
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 g_return_if_fail(!person_only || (person_only && buddy));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 dialog = g_new0(GevoNewPersonDialog, 1);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 dialog->account = account;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 dialog->person_only = person_only;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 dialog->buddy = buddy;
10081
ff4be2d1401d [gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents: 9825
diff changeset
244 dialog->book = book;
ff4be2d1401d [gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents: 9825
diff changeset
245 g_object_ref(book);
8089
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->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 gtk_window_set_role(GTK_WINDOW(dialog->win), "new_person");
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 gtk_window_set_resizable(GTK_WINDOW(dialog->win), FALSE);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 gtk_container_set_border_width(GTK_CONTAINER(dialog->win), 12);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 g_signal_connect(G_OBJECT(dialog->win), "delete_event",
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 G_CALLBACK(delete_win_cb), dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 /* Setup the vbox */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 vbox = gtk_vbox_new(FALSE, 12);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 gtk_container_add(GTK_CONTAINER(dialog->win), vbox);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 gtk_widget_show(vbox);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 /* Label */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 if (person_only)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 label = gtk_label_new(
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 _("Please enter the person's information below."));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 else
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 label = gtk_label_new(_("Please enter the buddy's screen name and "
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 "account type below."));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 }
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 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 gtk_widget_show(label);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 /* Setup the size groups */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 sg2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
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 if (!person_only)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 /* Add the account type stuff. */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 dialog->accounts_menu =
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 gaim_gtk_account_option_menu_new(account, FALSE,
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 G_CALLBACK(select_account_cb),
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 NULL, dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 add_pref_box(sg, vbox, _("Account type:"), dialog->accounts_menu);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 /* Screen Name */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 dialog->screenname = gtk_entry_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 add_pref_box(sg, vbox, _("Screenname:"), dialog->screenname);
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 if (username != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 gtk_entry_set_text(GTK_ENTRY(dialog->screenname), username);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 g_signal_connect(G_OBJECT(dialog->screenname), "changed",
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 G_CALLBACK(screenname_changed_cb), dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 /* Group */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 dialog->group_combo = gtk_combo_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 gtk_combo_set_popdown_strings(GTK_COMBO(dialog->group_combo),
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 gevo_get_groups());
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 add_pref_box(sg, vbox, _("Group:"), dialog->group_combo);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 /* Separator */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 sep = gtk_hseparator_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 gtk_widget_show(sep);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 /* Optional Information section */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 label = gtk_label_new(_("Optional information:"));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 gtk_widget_show(label);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 /* Create the parent hbox for this whole thing. */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 hbox = gtk_hbox_new(FALSE, 12);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 gtk_widget_show(hbox);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 #if 0
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 /* Now the left side of the hbox */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 vbox2 = gtk_vbox_new(FALSE, 12);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 gtk_widget_show(vbox2);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 /* Buddy icon button */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 gtk_box_pack_start(GTK_BOX(vbox2), button, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 gtk_widget_show(button);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 /* Label */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 label = gtk_label_new(_("Buddy Icon"));
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 gtk_widget_show(label);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 #endif
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 /* Now the right side. */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 vbox2 = gtk_vbox_new(FALSE, 12);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 gtk_widget_show(vbox2);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 /* First Name field */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 dialog->firstname = gtk_entry_new();
9044
23bcfdcd530d [gaim-migrate @ 9820]
Christian Hammond <chipx86@chipx86.com>
parents: 9039
diff changeset
347 add_pref_box(sg2, vbox2, _("First name:"), dialog->firstname);
8089
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 if (contact != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 str = e_contact_get_const(contact, E_CONTACT_GIVEN_NAME);
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 (str != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 gtk_entry_set_text(GTK_ENTRY(dialog->firstname), str);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 }
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 /* Last Name field */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 dialog->lastname = gtk_entry_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 add_pref_box(sg2, vbox2, _("Last name:"), dialog->lastname);
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 if (contact != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 str = e_contact_get_const(contact, E_CONTACT_FAMILY_NAME);
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 (str != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 gtk_entry_set_text(GTK_ENTRY(dialog->lastname), str);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 }
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 (person_only)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 g_signal_connect(G_OBJECT(dialog->firstname), "changed",
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 G_CALLBACK(person_info_changed_cb), dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 g_signal_connect(G_OBJECT(dialog->lastname), "changed",
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 G_CALLBACK(person_info_changed_cb), dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 }
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 /* E-Mail address field */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 dialog->email = gtk_entry_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 add_pref_box(sg2, vbox2, _("E-mail:"), dialog->email);
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 if (contact != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 {
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 str = e_contact_get_const(contact, E_CONTACT_EMAIL_1);
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 (str != NULL)
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 gtk_entry_set_text(GTK_ENTRY(dialog->email), str);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 }
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 /* Separator */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 sep = gtk_hseparator_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 gtk_widget_show(sep);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 /* Button box */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 bbox = gtk_hbutton_box_new();
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 gtk_box_set_spacing(GTK_BOX(bbox), 6);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 gtk_widget_show(bbox);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 /* Cancel button */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 gtk_widget_show(button);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 g_signal_connect(G_OBJECT(button), "clicked",
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 G_CALLBACK(cancel_cb), dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 /* Add button */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 button = gtk_button_new_from_stock(GTK_STOCK_ADD);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 dialog->add_button = button;
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412 gtk_widget_set_sensitive(button, FALSE);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 gtk_widget_show(button);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 g_signal_connect(G_OBJECT(button), "clicked",
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 G_CALLBACK(add_cb), dialog);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 /* Show it. */
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 gtk_widget_show(dialog->win);
35db601609e3 [gaim-migrate @ 8788]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 }