From: Felipe Erias Morandeira Date: Thu, 15 Nov 2007 14:56:27 +0000 (+0000) Subject: Fixes NB#66410 X-Git-Tag: git_migration_finished~2082 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=96d0d173e287c0453ba53589fe7f407136590b9d;hp=28c01004d2ca5f62ba5409bdd7a469f1d73b931d Fixes NB#66410 pmo-trunk-r3745 --- diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index b338b4f..dfd859d 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -1323,7 +1323,7 @@ modest_tny_account_store_get_server_account (ModestTnyAccountStore *self, modest_acc_name = modest_tny_account_get_parent_modest_account_name_for_server_account (tmp_account); - if (!strcmp (account_name, modest_acc_name)) { + if (account_name && modest_acc_name && !strcmp (account_name, modest_acc_name)) { found = TRUE; retval = g_object_ref (tmp_account); } diff --git a/src/widgets/modest-account-view.c b/src/widgets/modest-account-view.c index 8fa5421..a5ebda0 100644 --- a/src/widgets/modest-account-view.c +++ b/src/widgets/modest-account-view.c @@ -58,6 +58,8 @@ static void on_display_name_changed (ModestAccountMgr *self, const gchar *account, gpointer user_data); +static void modest_account_view_select_first_account (ModestAccountView *account_view); + typedef enum { MODEST_ACCOUNT_VIEW_NAME_COLUMN, MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN, @@ -310,7 +312,15 @@ on_account_removed (TnyAccountStore *account_store, self = MODEST_ACCOUNT_VIEW (user_data); priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self); - + + gchar *selected_name = modest_account_view_get_selected_account (self); + if (selected_name == NULL) { + /* we select the first account if none is selected */ + modest_account_view_select_first_account (self); + } else { + g_free (selected_name); + } + update_account_view (priv->account_mgr, self); } @@ -588,6 +598,21 @@ modest_account_view_select_account (ModestAccountView *account_view, } static void +modest_account_view_select_first_account (ModestAccountView *account_view) +{ + GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (account_view)); + g_return_if_fail (model != NULL); + + GtkTreeIter iter; + gtk_tree_model_get_iter_first (model, &iter); + + GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (account_view)); + g_return_if_fail (selection != NULL); + + gtk_tree_selection_select_iter (selection, &iter); +} + +static void on_default_account_changed (ModestAccountMgr *mgr, gpointer user_data) {