aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-utils.c
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 /mail/em-utils.c
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 'mail/em-utils.c')
-rw-r--r--mail/em-utils.c73
1 files changed, 54 insertions, 19 deletions
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 0c81fbe8bd..94d4fdc6ef 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -666,39 +666,51 @@ emu_add_address_cb(BonoboListener *listener, const char *name, const CORBA_any *
g_free(type);
}
-/**
- * em_utils_add_address:
- * @parent:
- * @email:
- *
- * Add address @email to the addressbook.
- **/
-void em_utils_add_address(struct _GtkWidget *parent, const char *email)
+/* one of email or vcard should be always NULL, never both of them */
+static void
+emu_add_address_or_vcard (struct _GtkWidget *parent, const char *email, const char *vcard)
{
- CamelInternetAddress *cia;
GtkWidget *win;
GtkWidget *control;
/*GtkWidget *socket;*/
- char *buf;
+ char *email_buf = NULL;
- cia = camel_internet_address_new ();
- if (camel_address_decode ((CamelAddress *) cia, email) == -1) {
+ if (email) {
+ CamelInternetAddress *cia;
+
+ cia = camel_internet_address_new ();
+ if (camel_address_decode ((CamelAddress *) cia, email) == -1) {
+ camel_object_unref (cia);
+ return;
+ }
+
+ email_buf = camel_address_format ((CamelAddress *) cia);
camel_object_unref (cia);
- return;
}
- buf = camel_address_format ((CamelAddress *) cia);
- camel_object_unref (cia);
-
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title((GtkWindow *)win, _("Add address"));
- gtk_window_set_transient_for((GtkWindow *)win, ((GtkWindow *)parent));
+
+ if (parent && !GTK_IS_WINDOW (parent)) {
+ parent = gtk_widget_get_toplevel (parent);
+ if (!parent || !(GTK_WIDGET_TOPLEVEL (parent)))
+ parent = NULL;
+ }
+
+ if (parent)
+ gtk_window_set_transient_for((GtkWindow *)win, ((GtkWindow *)parent));
+
gtk_window_set_position((GtkWindow *)win, GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_type_hint((GtkWindow *)win, GDK_WINDOW_TYPE_HINT_DIALOG);
control = bonobo_widget_new_control("OAFIID:GNOME_Evolution_Addressbook_AddressPopup:" BASE_VERSION, CORBA_OBJECT_NIL);
- bonobo_widget_set_property((BonoboWidget *)control, "email", TC_CORBA_string, buf, NULL);
- g_free (buf);
+
+ if (email_buf)
+ bonobo_widget_set_property ((BonoboWidget *) control, "email", TC_CORBA_string, email_buf, NULL);
+ else
+ bonobo_widget_set_property ((BonoboWidget *) control, "vcard", TC_CORBA_string, vcard, NULL);
+
+ g_free (email_buf);
bonobo_event_source_client_add_listener(bonobo_widget_get_objref((BonoboWidget *)control), emu_add_address_cb, NULL, NULL, win);
@@ -709,6 +721,29 @@ void em_utils_add_address(struct _GtkWidget *parent, const char *email)
gtk_widget_show_all(win);
}
+/**
+ * em_utils_add_address:
+ * @parent:
+ * @email:
+ *
+ * Add address @email to the addressbook.
+ **/
+void
+em_utils_add_address (struct _GtkWidget *parent, const char *email)
+{
+ emu_add_address_or_vcard (parent, email, NULL);
+}
+
+/**
+ * em_utils_add_vcard:
+ * Adds whole vCard to the addressbook.
+ **/
+void
+em_utils_add_vcard (struct _GtkWidget *parent, const char *vcard)
+{
+ emu_add_address_or_vcard (parent, NULL, vcard);
+}
+
/* ********************************************************************** */
/* Flag-for-Followup... */