#include <libosso-abook/osso-abook.h>
#include "modest-hildon-includes.h"
#include "modest-platform.h"
+#include "modest-runtime.h"
+#include "widgets/modest-window-mgr.h"
#include <string.h>
#include <gtk/gtksizegroup.h>
#include <gtk/gtkbox.h>
book_view = bookview;
if (contact_model)
+#if MODEST_ABOOK_API < 4
osso_abook_tree_model_set_book_view (OSSO_ABOOK_TREE_MODEL (contact_model),
book_view);
+#else /* MODEST_ABOOK_API < 4 */
+ osso_abook_list_store_set_book_view (OSSO_ABOOK_LIST_STORE (contact_model),
+ book_view);
+#endif /* MODEST_ABOOK_API < 4 */
e_book_view_start (book_view);
}
void
modest_address_book_select_addresses (ModestRecptEditor *recpt_editor)
{
+#if MODEST_ABOOK_API < 4
GtkWidget *contact_view = NULL;
- GList *contacts_list = NULL;
GtkWidget *contact_dialog;
+#else /* MODEST_ABOOK_API < 4 */
+ OssoABookContactChooser *contact_chooser = NULL;
+#endif /* MODEST_ABOOK_API < 4 */
+
+ GList *contacts_list = NULL;
GSList *email_addrs_per_contact = NULL;
gchar *econtact_id;
gboolean focus_recpt_editor = FALSE;
g_return_if_fail (MODEST_IS_RECPT_EDITOR (recpt_editor));
+#if MODEST_ABOOK_API < 4
if (!open_addressbook ()) {
if (contact_model) {
g_object_unref (contact_model);
contact_dialog = osso_abook_select_dialog_new (OSSO_ABOOK_TREE_VIEW (contact_view));
gtk_window_set_title (GTK_WINDOW (contact_dialog), _("mcen_ti_select_recipients"));
+ modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (contact_dialog));
gtk_widget_show (contact_dialog);
osso_abook_contact_selector_get_extended_selection (OSSO_ABOOK_CONTACT_SELECTOR
(contact_view));
}
+#else /* MODEST_ABOOK_API < 4 */
+ /* TODO: figure out how to make the contact chooser modal */
+ contact_chooser = osso_abook_contact_chooser_new
+ ("title", _("mcen_ti_select_recipients"),
+ "help-topic", "",
+ "minimum-selection", 1, NULL);
+
+ if (osso_abook_contact_chooser_run (contact_chooser) == GTK_RESPONSE_OK)
+ contacts_list = osso_abook_contact_chooser_get_selection (contact_chooser);
+
+ g_object_unref (contact_chooser);
+#endif
if (contacts_list) {
GList *node;
g_list_free (contacts_list);
}
+#if MODEST_ABOOK_API < 4
if (contact_model) {
g_object_unref (contact_model);
contact_model = NULL;
}
gtk_widget_destroy (contact_dialog);
+#endif
if (focus_recpt_editor)
modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (recpt_editor));
if (!contact || !book)
return;
-#ifdef MODEST_HAVE_OLD_ABOOK
+#if MODEST_ABOOK_API < 2
osso_abook_contact_commit(contact, is_new, book);
#else
osso_abook_contact_commit(contact, is_new, book, NULL);
-#endif /* MODEST_HILDON_VERSION_0 */
+#endif /* MODEST_ABOOK_API < 2 */
}
/**
return FALSE;
}
+static void
+hide_check_names_banner (GtkWidget **banner, guint banner_timeout)
+{
+ if (*banner != NULL) {
+ gtk_widget_destroy (*banner);
+ *banner = NULL;
+ } else {
+ g_source_remove (banner_timeout);
+ }
+
+}
+
gboolean
modest_address_book_check_names (ModestRecptEditor *recpt_editor, gboolean update_addressbook)
{
gint offset_delta = 0;
gint last_length;
GtkTextIter start_iter, end_iter;
- guint banner_timeout;
- GtkWidget *banner = NULL;
g_return_val_if_fail (MODEST_IS_RECPT_EDITOR (recpt_editor), FALSE);
}
}
- banner_timeout = g_timeout_add (500, show_check_names_banner, &banner);
-
current_start = start_indexes;
current_end = end_indexes;
buffer = modest_recpt_editor_get_buffer (recpt_editor);
/* here goes searching in addressbook */
gchar *contact_id = NULL;
GSList *resolved_addresses = NULL;
+
result = resolve_address (address, &resolved_addresses, &contact_id);
if (result) {
g_slist_free (start_indexes);
g_slist_free (end_indexes);
- g_source_remove (banner_timeout);
- if (banner != NULL) {
- gtk_widget_destroy (banner);
- banner = NULL;
- } else {
- g_source_remove (banner_timeout);
- }
-
return result;
}
if (book_view) {
GtkWidget *contact_view = NULL;
GtkWidget *contact_dialog = NULL;
+#if MODEST_ABOOK_API < 4
osso_abook_tree_model_set_book_view (OSSO_ABOOK_TREE_MODEL (contact_model), book_view);
+#else /* MODEST_ABOOK_API < 4 */
+ osso_abook_list_store_set_book_view (OSSO_ABOOK_LIST_STORE (contact_model), book_view);
+#endif /* MODEST_ABOOK_API < 4 */
e_book_view_start (book_view);
contact_view = osso_abook_contact_view_new_basic (contact_model);
resolve_address (const gchar *address, GSList **resolved_addresses, gchar **contact_id)
{
GList *resolved_contacts;
+ guint banner_timeout;
+ GtkWidget *banner = NULL;
+
+ banner_timeout = g_timeout_add (500, show_check_names_banner, &banner);
contact_model = osso_abook_contact_model_new ();
if (!open_addressbook_sync ()) {
if (resolved_contacts == NULL) {
/* no matching contacts for the search string */
modest_platform_run_information_dialog (NULL, _("mcen_nc_no_matching_contacts"), FALSE);
+ hide_check_names_banner (&banner, banner_timeout);
+
return FALSE;
}
/* show a dialog to select the contact from the resolved ones */
g_list_free (resolved_contacts);
+ hide_check_names_banner (&banner, banner_timeout);
resolved_contacts = select_contacts_for_name_dialog (address);
+ banner_timeout = g_timeout_add (500, show_check_names_banner, &banner);
+
}
/* get the resolved contacts (can be no contact) */
EContact *contact = (EContact *) resolved_contacts->data;
*resolved_addresses = get_recipients_for_given_contact (contact);
+ hide_check_names_banner (&banner, banner_timeout);
if (*resolved_addresses) {
*contact_id = g_strdup (e_contact_get_const (contact, E_CONTACT_UID));
found = TRUE;
} else {
/* cancelled dialog to select more than one contact or
* selected no contact */
+ hide_check_names_banner (&banner, banner_timeout);
return FALSE;
}