* add new addresses to the addressbook automatically when sending.
[modest] / src / widgets / modest-account-view.c
index 236760e..fbac3d9 100644 (file)
@@ -144,7 +144,8 @@ modest_account_view_finalize (GObject *obj)
 
        if (priv->account_mgr) {
                if (priv->sig1)
-                       g_signal_handler_disconnect (priv->account_mgr, priv->sig1);
+                       g_signal_handler_disconnect (modest_runtime_get_account_store (), 
+                                                    priv->sig1);
 
                if (priv->sig2)
                        g_signal_handler_disconnect (priv->account_mgr, priv->sig2);
@@ -207,10 +208,8 @@ update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view)
        cursor = account_names = modest_account_mgr_account_names (account_mgr,
                TRUE /* only enabled accounts. */);
        
-       if(account_names == NULL)
-       {
-         printf ("debug: modest_account_mgr_account_names() returned  NULL\n");
-       }
+       if (!account_names)
+               g_warning ("debug: modest_account_mgr_account_names() returned  NULL\n");
 
        while (cursor) {
                gchar *account_name;
@@ -251,7 +250,9 @@ update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view)
                modest_account_mgr_free_account_data (account_mgr, account_data);
                cursor = cursor->next;
        }
-       g_slist_free (account_names);
+
+       modest_account_mgr_free_account_names (account_names);
+       account_names = NULL;
        
        /* Try to re-select the same account: */
        if (selected_name) {
@@ -285,6 +286,7 @@ on_account_busy_changed(ModestAccountMgr *account_mgr, const gchar *account_name
 {
        GtkListStore *model = GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(self)));
        GtkTreeIter iter;
+       g_message(__FUNCTION__);
        if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter))
                return;
        do
@@ -300,8 +302,8 @@ on_account_busy_changed(ModestAccountMgr *account_mgr, const gchar *account_name
                                return;
                        gchar* last_updated_string = get_last_updated_string(account_mgr, account_data);
                        gtk_list_store_set(model, &iter, 
-                                                                                                MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN,  last_updated_string,
-                                                                                                -1);
+                                          MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, last_updated_string,
+                                          -1);
                        g_free (last_updated_string);
                        modest_account_mgr_free_account_data (account_mgr, account_data);
                        return;
@@ -311,11 +313,17 @@ on_account_busy_changed(ModestAccountMgr *account_mgr, const gchar *account_name
 }
 
 static void
-on_account_removed (ModestAccountMgr *account_mgr,
-                   const gchar* account, gboolean server_account,
-                   ModestAccountView *self)
-{               
-       update_account_view (account_mgr, self);
+on_account_removed (TnyAccountStore *account_store, 
+                   TnyAccount *account,
+                   gpointer user_data)
+{
+       ModestAccountView *self;
+       ModestAccountViewPrivate *priv;
+
+       self = MODEST_ACCOUNT_VIEW (user_data);
+       priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self);
+
+       update_account_view (priv->account_mgr, MODEST_ACCOUNT_VIEW (user_data));
 }
 
 
@@ -490,7 +498,7 @@ init_view (ModestAccountView *self)
         */                     
        gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(self), TRUE);
 
-       priv->sig1 = g_signal_connect (G_OBJECT(priv->account_mgr),"account_removed",
+       priv->sig1 = g_signal_connect (G_OBJECT (modest_runtime_get_account_store ()),"account_removed",
                                       G_CALLBACK(on_account_removed), self);
        priv->sig2 = g_signal_connect (G_OBJECT(priv->account_mgr), "account_changed",
                                       G_CALLBACK(on_account_changed), self);