}
void
-modest_address_book_add_address (const gchar *address)
+modest_address_book_add_address (const gchar *address,
+ GtkWindow *parent)
{
GtkWidget *dialog = NULL;
gchar *email_address;
}
email_address = modest_text_utils_get_email_address (address);
-
+
attribute = e_vcard_attribute_new (NULL, EVC_EMAIL);
e_vcard_attribute_add_value (attribute, email_address);
- dialog = osso_abook_temporary_contact_dialog_new (NULL, book, attribute, NULL);
+ dialog = osso_abook_temporary_contact_dialog_new (parent, book, attribute, NULL);
+
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
current_start = start_indexes;
current_end = end_indexes;
buffer = modest_recpt_editor_get_buffer (recpt_editor);
- if (address_list)
- *address_list = NULL;
while (current_start != NULL) {
gchar *address;
return result;
}
+#ifdef HAVE_OSSO_ABOOK_CONTACT_CHOOSER_SET_VISIBLE_FUNC
static gboolean
filter_by_name (OssoABookContactChooser *chooser,
OssoABookContact *contact,
else
return FALSE;
}
+#endif
static GList *
select_contacts_for_name_dialog (const gchar *name)
{
+#ifdef HAVE_OSSO_ABOOK_CONTACT_CHOOSER_SET_VISIBLE_FUNC
GtkWidget *contact_view;
OssoABookContactChooser *contact_dialog;
+#else
+ EBookQuery *full_name_book_query = NULL;
+ EBookView *book_view = NULL;
+#endif
+
GList *result = NULL;
gchar *unquoted;
+ unquoted = unquote_string (name);
+
+#ifdef HAVE_OSSO_ABOOK_CONTACT_CHOOSER_SET_VISIBLE_FUNC
contact_dialog = (OssoABookContactChooser *)
osso_abook_contact_chooser_new_with_capabilities (NULL,
_AB("addr_ti_dia_select_contacts"),
osso_abook_contact_chooser_set_maximum_selection (contact_dialog, G_MAXUINT);
/* Set up the filtering */
- unquoted = unquote_string (name);
contact_view = osso_abook_contact_chooser_get_contact_view (contact_dialog);
osso_abook_contact_chooser_set_model (contact_dialog, contact_model);
osso_abook_contact_chooser_set_visible_func (contact_dialog, filter_by_name, unquoted, NULL);
result = osso_abook_contact_chooser_get_selection (contact_dialog);
gtk_widget_destroy ((GtkWidget *) contact_dialog);
+#else
+ full_name_book_query = e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_CONTAINS, unquoted);
+ e_book_get_book_view (book, full_name_book_query, NULL, -1, &book_view, NULL);
+ e_book_query_unref (full_name_book_query);
+
+ if (book_view) {
+ GtkWidget *contact_dialog = NULL;
+ osso_abook_list_store_set_book_view (OSSO_ABOOK_LIST_STORE (contact_model), book_view);
+ e_book_view_start (book_view);
+
+ /* TODO: figure out how to make the contact chooser modal */
+ contact_dialog = osso_abook_contact_chooser_new_with_capabilities (NULL,
+ _AB("addr_ti_dia_select_contacts"),
+ OSSO_ABOOK_CAPS_EMAIL,
+ OSSO_ABOOK_CONTACT_ORDER_NAME);
+ /* Enable multiselection */
+ osso_abook_contact_chooser_set_maximum_selection (OSSO_ABOOK_CONTACT_CHOOSER (contact_dialog),
+ G_MAXUINT);
+ osso_abook_contact_chooser_set_model (OSSO_ABOOK_CONTACT_CHOOSER (contact_dialog),
+ contact_model);
+
+ if (gtk_dialog_run (GTK_DIALOG (contact_dialog)) == GTK_RESPONSE_OK)
+ result = osso_abook_contact_chooser_get_selection (OSSO_ABOOK_CONTACT_CHOOSER (contact_dialog));
+ e_book_view_stop (book_view);
+ g_object_unref (book_view);
+ gtk_widget_destroy (contact_dialog);
+ }
+#endif
g_free (unquoted);