The menu items of message viewer popup menu are not finger-sized
[modest] / src / hildon2 / modest-address-book.c
index 30ccccb..1256dd6 100644 (file)
@@ -104,7 +104,8 @@ open_addressbook ()
 }
 
 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;
@@ -115,10 +116,11 @@ modest_address_book_add_address (const gchar *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);
@@ -740,8 +742,6 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor,
        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;
@@ -926,6 +926,7 @@ get_contacts_for_name (const gchar *name)
        return result;
 }
 
+#ifdef HAVE_OSSO_ABOOK_CONTACT_CHOOSER_SET_VISIBLE_FUNC
 static gboolean
 filter_by_name (OssoABookContactChooser *chooser,
                OssoABookContact        *contact,
@@ -941,15 +942,25 @@ filter_by_name (OssoABookContactChooser *chooser,
        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"),
@@ -960,7 +971,6 @@ select_contacts_for_name_dialog (const gchar *name)
        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);
@@ -969,6 +979,34 @@ select_contacts_for_name_dialog (const gchar *name)
                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);