aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2008-03-13 18:12:49 +0800
committerMilan Crha <mcrha@src.gnome.org>2008-03-13 18:12:49 +0800
commit9bd177927d423b36a7506af4b23f5b5feccc5705 (patch)
treed54f4f15fb0e733a517dd08f3045c163cab0f55a /addressbook/gui
parentcc692562f528115284d338dea12f8809d1efd17f (diff)
downloadgsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.tar
gsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.tar.gz
gsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.tar.bz2
gsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.tar.lz
gsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.tar.xz
gsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.tar.zst
gsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.zip
** Fix for bug #273177
2008-03-13 Milan Crha <mcrha@redhat.com> ** Fix for bug #273177 * addressbook/gui/contact-editor/e-contact-quick-add.h: (e_contact_quick_add_vcard): * addressbook/gui/contact-editor/e-contact-quick-add.c: (struct _QuickAdd), (quick_add_unref), (quick_add_set_vcard), (clicked_cb), (build_quick_add_dialog), (e_contact_quick_add_vcard): Allow adding also whole vCard with this dialog. * addressbook/gui/widgets/eab-popup-control.h: (struct _EABPopupControl): * addressbook/gui/widgets/eab-popup-control.c: (eab_popup_control_set_vcard), (eab_popup_control_cleanup), (eab_popup_control_set_vcard), (eab_popup_control_no_matches), (set_prop), (get_prop), (eab_popup_control_new): New property 'vcard', if set, has higher precedence than name/email. * mail/em-utils.h: (em_utils_add_vcard): * mail/em-utils.c: (emu_add_address_or_vcard), (em_utils_add_address), (em_utils_add_vcard): New function to add whole vCard to addressbook. * mail/em-popup.c: (emp_add_vcard), (emp_standard_menu_factory): Add popup menu item to vcard attachments. svn path=/trunk/; revision=35181
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c76
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.h2
-rw-r--r--addressbook/gui/widgets/eab-popup-control.c45
-rw-r--r--addressbook/gui/widgets/eab-popup-control.h1
4 files changed, 119 insertions, 5 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index e2c06256bc..704b3ca8d2 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -49,6 +49,7 @@ typedef struct _QuickAdd QuickAdd;
struct _QuickAdd {
gchar *name;
gchar *email;
+ gchar *vcard;
EContact *contact;
EBook *book;
@@ -92,6 +93,7 @@ quick_add_unref (QuickAdd *qa)
if (qa->refs == 0) {
g_free (qa->name);
g_free (qa->email);
+ g_free (qa->vcard);
g_object_unref (qa->contact);
g_free (qa);
}
@@ -119,6 +121,16 @@ quick_add_set_email (QuickAdd *qa, const gchar *email)
}
static void
+quick_add_set_vcard (QuickAdd *qa, const gchar *vcard)
+{
+ if (vcard == qa->vcard)
+ return;
+
+ g_free (qa->vcard);
+ qa->vcard = g_strdup (vcard);
+}
+
+static void
merge_cb (EBook *book, EBookStatus status, gpointer closure)
{
QuickAdd *qa = (QuickAdd *) closure;
@@ -232,7 +244,7 @@ clicked_cb (GtkWidget *w, gint button, gpointer closure)
QuickAdd *qa = (QuickAdd *) closure;
/* Get data out of entries. */
- if (button == GTK_RESPONSE_OK || button == QUICK_ADD_RESPONSE_EDIT_FULL) {
+ if (!qa->vcard && (button == GTK_RESPONSE_OK || button == QUICK_ADD_RESPONSE_EDIT_FULL)) {
gchar *name = NULL;
gchar *email = NULL;
@@ -341,11 +353,16 @@ build_quick_add_dialog (QuickAdd *qa)
if (qa->name)
gtk_entry_set_text (GTK_ENTRY (qa->name_entry), qa->name);
-
qa->email_entry = gtk_entry_new ();
if (qa->email)
gtk_entry_set_text (GTK_ENTRY (qa->email_entry), qa->email);
+ if (qa->vcard) {
+ /* when adding vCard, then do not allow change name or email */
+ gtk_widget_set_sensitive (qa->name_entry, FALSE);
+ gtk_widget_set_sensitive (qa->email_entry, FALSE);
+ }
+
gconf_client = gconf_client_get_default ();
source_list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/addressbook/sources");
g_object_unref (gconf_client);
@@ -555,3 +572,58 @@ e_contact_quick_add_free_form (const gchar *text, EContactQuickAddCallback cb, g
g_free (name);
g_free (email);
}
+
+void
+e_contact_quick_add_vcard (const gchar *vcard, EContactQuickAddCallback cb, gpointer closure)
+{
+ QuickAdd *qa;
+ GtkWidget *dialog;
+ EContact *contact;
+
+ /* We need to have *something* to work with. */
+ if (vcard == NULL) {
+ if (cb)
+ cb (NULL, closure);
+ return;
+ }
+
+ qa = quick_add_new ();
+ qa->cb = cb;
+ qa->closure = closure;
+ quick_add_set_vcard (qa, vcard);
+
+ contact = e_contact_new_from_vcard (qa->vcard);
+
+ if (contact) {
+ GList *emails;
+ char *name;
+ EContactName *contact_name;
+
+ g_object_unref (qa->contact);
+ qa->contact = contact;
+
+ contact_name = e_contact_get (qa->contact, E_CONTACT_NAME);
+ name = e_contact_name_to_string (contact_name);
+ quick_add_set_name (qa, name);
+ g_free (name);
+ e_contact_name_free (contact_name);
+
+ emails = e_contact_get (qa->contact, E_CONTACT_EMAIL);
+ if (emails) {
+ quick_add_set_email (qa, emails->data);
+
+ g_list_foreach (emails, (GFunc)g_free, NULL);
+ g_list_free (emails);
+ }
+ } else {
+ if (cb)
+ cb (NULL, closure);
+
+ quick_add_unref (qa);
+ g_warning ("Contact's vCard parsing failed!");
+ return;
+ }
+
+ dialog = build_quick_add_dialog (qa);
+ gtk_widget_show_all (dialog);
+}
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.h b/addressbook/gui/contact-editor/e-contact-quick-add.h
index cdb539b1b0..d29ef430c1 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.h
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.h
@@ -36,5 +36,7 @@ void e_contact_quick_add (const gchar *name, const gchar *email,
void e_contact_quick_add_free_form (const gchar *text, EContactQuickAddCallback cb, gpointer closure);
+void e_contact_quick_add_vcard (const gchar *vcard, EContactQuickAddCallback cb, gpointer closure);
+
#endif /* __E_CONTACT_QUICK_ADD_H__ */
diff --git a/addressbook/gui/widgets/eab-popup-control.c b/addressbook/gui/widgets/eab-popup-control.c
index 94e46e0524..a30a4456a6 100644
--- a/addressbook/gui/widgets/eab-popup-control.c
+++ b/addressbook/gui/widgets/eab-popup-control.c
@@ -57,6 +57,7 @@
static void eab_popup_control_set_name (EABPopupControl *pop, const gchar *name);
static void eab_popup_control_set_email (EABPopupControl *pop, const gchar *email);
+static void eab_popup_control_set_vcard (EABPopupControl *pop, const gchar *vcard);
static GtkObjectClass *parent_class;
@@ -110,6 +111,9 @@ eab_popup_control_cleanup (EABPopupControl *pop)
g_free (pop->email);
pop->email = NULL;
+
+ g_free (pop->vcard);
+ pop->vcard = NULL;
}
static void
@@ -253,6 +257,26 @@ eab_popup_control_set_email (EABPopupControl *pop, const gchar *email)
eab_popup_control_schedule_refresh (pop);
}
+static void
+eab_popup_control_set_vcard (EABPopupControl *pop, const gchar *vcard)
+{
+ g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop));
+
+ /* We only allow the vcard to be set once. */
+ if (pop->vcard)
+ return;
+
+ g_free (pop->name);
+ g_free (pop->email);
+
+ pop->name = NULL;
+ pop->email = NULL;
+
+ pop->vcard = g_strdup (vcard);
+
+ eab_popup_control_schedule_refresh (pop);
+}
+
void
eab_popup_control_construct (EABPopupControl *pop)
{
@@ -332,7 +356,9 @@ emit_event (EABPopupControl *pop, const char *event)
static void
eab_popup_control_no_matches (EABPopupControl *pop)
{
- if (pop->email && *pop->email) {
+ if (pop->vcard && *pop->vcard)
+ e_contact_quick_add_vcard (pop->vcard, NULL, NULL);
+ else if (pop->email && *pop->email) {
if (pop->name && *pop->name)
e_contact_quick_add (pop->name, pop->email, NULL, NULL);
else
@@ -361,7 +387,8 @@ eab_popup_control_query (EABPopupControl *pop)
enum {
PROPERTY_NAME,
PROPERTY_EMAIL,
- PROPERTY_TRANSITORY
+ PROPERTY_TRANSITORY,
+ PROPERTY_VCARD
};
static void
@@ -379,6 +406,10 @@ set_prop (BonoboPropertyBag *bag, const BonoboArg *arg, guint arg_id, CORBA_Envi
eab_popup_control_set_email (pop, BONOBO_ARG_GET_STRING (arg));
break;
+ case PROPERTY_VCARD:
+ eab_popup_control_set_vcard (pop, BONOBO_ARG_GET_STRING (arg));
+ break;
+
default:
g_return_if_reached ();
}
@@ -403,6 +434,10 @@ get_prop (BonoboPropertyBag *bag, BonoboArg *arg, guint arg_id, CORBA_Environmen
BONOBO_ARG_SET_BOOLEAN (arg, pop->transitory);
break;
+ case PROPERTY_VCARD:
+ BONOBO_ARG_SET_STRING (arg, pop->vcard);
+ break;
+
default:
g_return_if_reached ();
}
@@ -435,7 +470,11 @@ eab_popup_control_new (void)
BONOBO_ARG_BOOLEAN, NULL, NULL,
BONOBO_PROPERTY_READABLE);
- bonobo_control_set_properties (control, bonobo_object_corba_objref (BONOBO_OBJECT (bag)), NULL);
+ bonobo_property_bag_add (bag, "vcard", PROPERTY_VCARD,
+ BONOBO_ARG_STRING, NULL, NULL,
+ BONOBO_PROPERTY_WRITEABLE | BONOBO_PROPERTY_READABLE);
+
+ bonobo_control_set_properties (control, bonobo_object_corba_objref (BONOBO_OBJECT (bag)), NULL);
bonobo_object_unref (BONOBO_OBJECT (bag));
addy->es = bonobo_event_source_new ();
diff --git a/addressbook/gui/widgets/eab-popup-control.h b/addressbook/gui/widgets/eab-popup-control.h
index 1d7ee36f0a..79e134e812 100644
--- a/addressbook/gui/widgets/eab-popup-control.h
+++ b/addressbook/gui/widgets/eab-popup-control.h
@@ -50,6 +50,7 @@ struct _EABPopupControl {
gchar *name;
gchar *email;
+ gchar *vcard;
GtkWidget *name_widget;
GtkWidget *email_widget;