* Fix behavior of check names for fremantle.
[modest] / src / hildon2 / modest-address-book.c
index b636c6e..845f28e 100644 (file)
@@ -40,6 +40,7 @@
 #include "modest-platform.h"
 #include "modest-runtime.h"
 #include "widgets/modest-window-mgr.h"
+#include "widgets/modest-ui-constants.h"
 #include <string.h>
 #include <gtk/gtksizegroup.h>
 #include <gtk/gtkbox.h>
@@ -115,7 +116,8 @@ open_addressbook ()
        if (!book)
                return FALSE;
 
-       e_book_async_open (book, FALSE, book_open_cb, NULL);
+       if (e_book_async_open (book, FALSE, book_open_cb, NULL) != E_BOOK_ERROR_OK)
+               return FALSE;
 
        return TRUE; /* FIXME */        
 }
@@ -127,9 +129,7 @@ open_addressbook_sync ()
        if (!book)
                return FALSE;
 
-       e_book_open (book, FALSE, NULL);
-
-       return TRUE;
+       return e_book_open (book, FALSE, NULL);
 }
 
 void
@@ -174,8 +174,9 @@ modest_address_book_select_addresses (ModestRecptEditor *recpt_editor)
 #if MODEST_ABOOK_API < 4
        GtkWidget *contact_view = NULL;
        GtkWidget *contact_dialog;
+       GtkWidget *toplevel;
 #else /* MODEST_ABOOK_API < 4 */
-       OssoABookContactChooser *contact_chooser = NULL;
+       GtkWidget *contact_chooser = NULL;
 #endif /* MODEST_ABOOK_API < 4 */
 
        GList *contacts_list = NULL;
@@ -200,7 +201,8 @@ modest_address_book_select_addresses (ModestRecptEditor *recpt_editor)
 
        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));
+       toplevel = gtk_widget_get_toplevel (GTK_WIDGET (recpt_editor));
+       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (contact_dialog), GTK_WINDOW (toplevel));
 
        gtk_widget_show (contact_dialog);
 
@@ -211,13 +213,14 @@ modest_address_book_select_addresses (ModestRecptEditor *recpt_editor)
        }
 #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);
+       contact_chooser = osso_abook_contact_chooser_new_with_capabilities (NULL,
+                                                                           _("mcen_ti_select_recipients"),
+                                                                           OSSO_ABOOK_CAPS_EMAIL, 
+                                                                           OSSO_ABOOK_CONTACT_ORDER_NAME);
 
-       if (osso_abook_contact_chooser_run (contact_chooser) == GTK_RESPONSE_OK)
-               contacts_list = osso_abook_contact_chooser_get_selection (contact_chooser);
+       if (gtk_dialog_run (GTK_DIALOG (contact_chooser)) == GTK_RESPONSE_OK)
+               contacts_list = osso_abook_contact_chooser_get_selection (OSSO_ABOOK_CONTACT_CHOOSER (contact_chooser));
+       gtk_widget_destroy (contact_chooser);
 
        g_object_unref (contact_chooser);
 #endif
@@ -314,7 +317,6 @@ static GSList *get_recipients_for_given_contact(EContact * contact)
               
                abook_contact = osso_abook_contact_new_from_template (contact);
                display_name = osso_abook_contact_get_display_name(abook_contact);
-               g_object_unref (abook_contact);
 #endif
 
                emailid = get_email_addr_from_user(display_name);
@@ -322,6 +324,9 @@ static GSList *get_recipients_for_given_contact(EContact * contact)
                        e_contact_set(contact, E_CONTACT_EMAIL_1, emailid);
                        commit_contact(contact, FALSE);
                }
+#if MODEST_ABOOK_API >= 4
+               g_object_unref (abook_contact);
+#endif
        }
 
        if (emailid) {
@@ -564,7 +569,7 @@ select_email_addrs_for_contact(GList * email_addr_list)
 
        /* Make the window approximately big enough, because it doesn't resize to be big enough 
         * for the window title text: */
-       gtk_window_set_default_size (GTK_WINDOW (select_email_addr_dlg), 400, -1);
+       gtk_window_set_default_size (GTK_WINDOW (select_email_addr_dlg), MODEST_DIALOG_WINDOW_MAX_HEIGHT, -1);
 
        scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(select_email_addr_dlg)->vbox), scrolledwindow, TRUE,
@@ -626,8 +631,11 @@ add_to_address_book (const gchar* address)
        
        g_return_val_if_fail (address, FALSE);
        
-       if (!book)
-               open_addressbook ();
+       if (!book) {
+               if (!open_addressbook ()) {
+                       g_return_val_if_reached (FALSE);
+               }
+       }
        
        g_return_val_if_fail (book, FALSE);