X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-account-view.c;h=cf8fcb4cdc095d8b141b1ec3e21aa11f922d052c;hp=236760e6adec9819b0852b9dfa64f41a59a29c23;hb=f6d386ff93e929092ba105385a29d760aeba9ff7;hpb=6ebc23126acdfb8aec11416e4c197c6bee70bef0 diff --git a/src/widgets/modest-account-view.c b/src/widgets/modest-account-view.c index 236760e..cf8fcb4 100644 --- a/src/widgets/modest-account-view.c +++ b/src/widgets/modest-account-view.c @@ -32,14 +32,17 @@ #include #include +#include #include #include +#include #include #include #include #include #include /* For strcmp(). */ +#include /* 'private'/'protected' functions */ static void modest_account_view_class_init (ModestAccountViewClass *klass); @@ -47,7 +50,19 @@ static void modest_account_view_init (ModestAccountView *obj); static void modest_account_view_finalize (GObject *obj); static void modest_account_view_select_account (ModestAccountView *account_view, - const gchar* account_name); + const gchar* account_name); + +static void on_default_account_changed (ModestAccountMgr *mgr, + gpointer user_data); + +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); + +static void on_account_updated (ModestAccountMgr* mgr, gchar* account_name, + gpointer user_data); typedef enum { MODEST_ACCOUNT_VIEW_NAME_COLUMN, @@ -60,23 +75,12 @@ typedef enum { MODEST_ACCOUNT_VIEW_COLUMN_NUM } AccountViewColumns; - -/* list my signals */ -enum { - /* MY_SIGNAL_1, */ - /* MY_SIGNAL_2, */ - LAST_SIGNAL -}; - typedef struct _ModestAccountViewPrivate ModestAccountViewPrivate; struct _ModestAccountViewPrivate { ModestAccountMgr *account_mgr; - gulong sig1, sig2, sig3; - - /* When this is TRUE, we ignore configuration key changes. - * This is useful when making many changes. */ - gboolean block_conf_updates; - + + /* Signal handlers */ + GSList *sig_handlers; }; #define MODEST_ACCOUNT_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ MODEST_TYPE_ACCOUNT_VIEW, \ @@ -84,9 +88,6 @@ struct _ModestAccountViewPrivate { /* globals */ static GtkTreeViewClass *parent_class = NULL; -/* uncomment the following if you have defined any signals */ -/* static guint signals[LAST_SIGNAL] = {0}; */ - GType modest_account_view_get_type (void) { @@ -127,12 +128,10 @@ static void modest_account_view_init (ModestAccountView *obj) { ModestAccountViewPrivate *priv; - + priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(obj); - priv->account_mgr = NULL; - priv->sig1 = 0; - priv->sig2 = 0; + priv->sig_handlers = NULL; } static void @@ -142,16 +141,10 @@ modest_account_view_finalize (GObject *obj) priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(obj); - if (priv->account_mgr) { - if (priv->sig1) - g_signal_handler_disconnect (priv->account_mgr, priv->sig1); + /* Disconnect signals */ + modest_signal_mgr_disconnect_all_and_destroy (priv->sig_handlers); - if (priv->sig2) - g_signal_handler_disconnect (priv->account_mgr, priv->sig2); - - if (priv->sig3) - g_signal_handler_disconnect (priv->account_mgr, priv->sig3); - + if (priv->account_mgr) { g_object_unref (G_OBJECT(priv->account_mgr)); priv->account_mgr = NULL; } @@ -159,25 +152,31 @@ modest_account_view_finalize (GObject *obj) G_OBJECT_CLASS(parent_class)->finalize (obj); } -/* Get the string for the last updated time. Result must be g_freed */ -static gchar* -get_last_updated_string(ModestAccountMgr* account_mgr, ModestAccountData *account_data) +/* Get the string for the last updated time. Result must NOT be g_freed */ +static const gchar* +get_last_updated_string(ModestAccountMgr* account_mgr, ModestAccountSettings *settings) { /* FIXME: let's assume that 'last update' applies to the store account... */ - gchar* last_updated_string; - time_t last_updated = account_data->store_account->last_updated; - if (!modest_account_mgr_account_is_busy(account_mgr, account_data->account_name)) - { + const gchar *last_updated_string; + const gchar *store_account_name; + const gchar *account_name; + time_t last_updated; + ModestServerAccountSettings *server_settings; + + server_settings = modest_account_settings_get_store_settings (settings); + store_account_name = modest_server_account_settings_get_account_name (server_settings); + last_updated = modest_account_mgr_get_last_updated (account_mgr, store_account_name); + g_object_unref (server_settings); + account_name = modest_account_settings_get_account_name (settings); + if (!modest_account_mgr_account_is_busy(account_mgr, account_name)) { if (last_updated > 0) - last_updated_string = modest_text_utils_get_display_date(last_updated); + last_updated_string = modest_text_utils_get_display_date(last_updated); else - last_updated_string = g_strdup (_("mcen_va_never")); - } - else - { - /* FIXME: There should be a logical name in the UI specs */ - last_updated_string = g_strdup(_("Refreshing...")); + last_updated_string = _("mcen_va_never"); + } else { + last_updated_string = _("mcen_va_refreshing"); } + return last_updated_string; } @@ -189,7 +188,7 @@ update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view) model = GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(view))); - /* Get the ID of the currently-selected account, + /* Get the ID of the currently-selected account, * so we can select it again after rebuilding the list. * Note that the name doesn't change even when the display name changes. */ @@ -198,217 +197,211 @@ update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view) gtk_list_store_clear (model); /* Note: We do not show disabled accounts. - * Of course, this means that there is no UI to enable or disable - * accounts. That is OK for maemo where no such feature or UI is - * specified, so the "enabled" property is used internally to avoid - * showing unfinished accounts. If a user-visible "enabled" is - * needed in the future, we must use a second property for the + * Of course, this means that there is no UI to enable or disable + * accounts. That is OK for maemo where no such feature or UI is + * specified, so the "enabled" property is used internally to avoid + * showing unfinished accounts. If a user-visible "enabled" is + * needed in the future, we must use a second property for the * current use instead */ 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"); - } while (cursor) { gchar *account_name; - ModestAccountData *account_data; + ModestAccountSettings *settings; + ModestServerAccountSettings *store_settings; account_name = (gchar*)cursor->data; - account_data = modest_account_mgr_get_account_data (account_mgr, account_name); - if (!account_data) { + settings = modest_account_mgr_load_account_settings (account_mgr, account_name); + if (!settings) { g_printerr ("modest: failed to get account data for %s\n", account_name); continue; } + store_settings = modest_account_settings_get_store_settings (settings); /* don't display accounts without stores */ - if (account_data->store_account) { + if (modest_server_account_settings_get_account_name (store_settings) != NULL) { GtkTreeIter iter; + + /* don't free */ + const gchar *last_updated_string = get_last_updated_string(account_mgr, settings); - gchar *last_updated_string = get_last_updated_string(account_mgr, account_data); - - if (account_data->is_enabled) { + if (modest_account_settings_get_enabled (settings)) { + ModestProtocolType protocol_type; + ModestProtocolRegistry *protocol_registry; + ModestProtocol *protocol; + const gchar *proto_name; + + protocol_registry = modest_runtime_get_protocol_registry (); + protocol_type = modest_server_account_settings_get_protocol (store_settings); + protocol = modest_protocol_registry_get_protocol_by_type (protocol_registry, protocol_type); + proto_name = modest_protocol_get_name (protocol); gtk_list_store_insert_with_values ( model, &iter, 0, - MODEST_ACCOUNT_VIEW_NAME_COLUMN, account_name, - MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN, account_data->display_name, - MODEST_ACCOUNT_VIEW_IS_ENABLED_COLUMN, account_data->is_enabled, - MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, account_data->is_default, - - MODEST_ACCOUNT_VIEW_PROTO_COLUMN, - modest_protocol_info_get_transport_store_protocol_name (account_data->store_account->proto), - + MODEST_ACCOUNT_VIEW_NAME_COLUMN, account_name, + MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN, + modest_account_settings_get_display_name (settings), + MODEST_ACCOUNT_VIEW_IS_ENABLED_COLUMN, + modest_account_settings_get_enabled (settings), + MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, + modest_account_settings_get_is_default (settings), + MODEST_ACCOUNT_VIEW_PROTO_COLUMN, proto_name, 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); + + g_object_unref (store_settings); + g_object_unref (settings); 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) { modest_account_view_select_account (view, selected_name); g_free (selected_name); + } else { + modest_account_view_select_first_account (view); } } - -static void -on_account_changed (ModestAccountMgr *account_mgr, - const gchar* account, GSList *keys, - gboolean server_account, ModestAccountView *self) -{ - /* Never update the view in response to gconf changes. - * Always do it explicitly instead. - * This is because we have no way to avoid 10 updates when changing - * 10 items, and this blocks the UI. - * - * But this block/unblock API might be useful on platforms where the - * notification does not happen so long after the key was set. - * (We have no way to know when the last key was set, to do a final update).. - */ - - update_account_view (account_mgr, self); -} - static void -on_account_busy_changed(ModestAccountMgr *account_mgr, const gchar *account_name, - gboolean busy, ModestAccountView *self) +on_account_busy_changed(ModestAccountMgr *account_mgr, + const gchar *account_name, + gboolean busy, + ModestAccountView *self) { GtkListStore *model = GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(self))); GtkTreeIter iter; + gboolean found = FALSE; + if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) return; - do - { + + do { gchar* cur_name; - gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, MODEST_ACCOUNT_VIEW_NAME_COLUMN, - &cur_name, -1); - if (g_str_equal(cur_name, account_name)) - { - ModestAccountData* account_data = - modest_account_mgr_get_account_data (account_mgr, account_name); - if (!account_data) + gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, + MODEST_ACCOUNT_VIEW_NAME_COLUMN, + &cur_name, -1); + + if (g_str_equal(cur_name, account_name)) { + ModestAccountSettings* settings = + modest_account_mgr_load_account_settings (account_mgr, account_name); + if (!settings) { + g_free (cur_name); return; - gchar* last_updated_string = get_last_updated_string(account_mgr, account_data); + } + const gchar* last_updated_string = get_last_updated_string(account_mgr, settings); gtk_list_store_set(model, &iter, - 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; + MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, last_updated_string, + -1); + g_object_unref (settings); + found = TRUE; } - } - while (gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter)); + g_free (cur_name); + + } while (!found && gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter)); } static void -on_account_removed (ModestAccountMgr *account_mgr, - const gchar* account, gboolean server_account, - ModestAccountView *self) -{ - update_account_view (account_mgr, self); -} +on_account_inserted (TnyAccountStore *account_store, + TnyAccount *account, + gpointer user_data) +{ + ModestAccountView *self; + ModestAccountViewPrivate *priv; + g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (user_data)); + + self = MODEST_ACCOUNT_VIEW (user_data); + priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self); + + /* Do not refresh the view with transport accounts */ + if (TNY_IS_STORE_ACCOUNT (account)) + update_account_view (priv->account_mgr, self); +} -/* currently unused */ -#if 0 static void -on_account_enable_toggled (GtkCellRendererToggle *cell_renderer, gchar *path, - ModestAccountView *self) +on_account_removed (TnyAccountStore *account_store, + TnyAccount *account, + gpointer user_data) { - GtkTreeIter iter; + ModestAccountView *self; ModestAccountViewPrivate *priv; - GtkTreeModel *model; - gchar *account_name; - gboolean enabled; - - priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self); - model = gtk_tree_view_get_model (GTK_TREE_VIEW(self)); - - if (!gtk_tree_model_get_iter_from_string (model, &iter, path)) { - g_printerr ("modest: cannot find iterator\n"); + gchar *selected_name; + + g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (user_data)); + + self = MODEST_ACCOUNT_VIEW (user_data); + priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self); + + /* Do not refresh the view with transport accounts */ + if (!TNY_IS_STORE_ACCOUNT (account)) return; + + 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); } - gtk_tree_model_get (model, &iter, MODEST_ACCOUNT_VIEW_IS_ENABLED_COLUMN, &enabled, - MODEST_ACCOUNT_VIEW_NAME_COLUMN, &account_name, - -1); - /* toggle enabled / disabled */ - modest_account_mgr_set_enabled (priv->account_mgr, account_name, !enabled); - g_free (account_name); + update_account_view (priv->account_mgr, self); } -#endif -static gboolean -find_default_account(ModestAccountView *self, GtkTreeIter *iter) -{ - GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (self)); - gboolean result; - for (result = gtk_tree_model_get_iter_first(model, iter); - result == TRUE; result = gtk_tree_model_iter_next(model, iter)) - { - gboolean is_default; - gtk_tree_model_get (model, iter, MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, &is_default, -1); - if(is_default) - return TRUE; - } - - return FALSE; -} static void -on_account_default_toggled (GtkCellRendererToggle *cell_renderer, gchar *path, - ModestAccountView *self) +on_account_default_toggled (GtkCellRendererToggle *cell_renderer, + gchar *path, + ModestAccountView *self) { - gboolean is_default = gtk_cell_renderer_toggle_get_active (cell_renderer); - if (is_default) { - /* Do not allow an account to be marked non-default. - * Only allow this to be changed by setting another account to default: */ - gtk_cell_renderer_toggle_set_active (cell_renderer, TRUE); - return; - } - - ModestAccountViewPrivate *priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self); - GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW(self)); - + ModestAccountViewPrivate *priv; + GtkTreeModel *model; GtkTreeIter iter; - if (!gtk_tree_model_get_iter_from_string (model, &iter, path)) { - g_printerr ("modest: cannot find iterator\n"); - return; - } - gchar *account_name = NULL; - gtk_tree_model_get (model, &iter, MODEST_ACCOUNT_VIEW_NAME_COLUMN, &account_name, - -1); - - /* Set this previously-non-default account as the default: */ - if (modest_account_mgr_set_default_account (priv->account_mgr, account_name)) - { - /* Explicitely set default column because we are ignoring gconf changes */ - GtkTreeIter old_default_iter; - if (find_default_account (self, &old_default_iter)) { - gtk_list_store_set (GTK_LIST_STORE (model), &old_default_iter, - MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, FALSE, -1); - } else { - g_warning ("%s: Did not find old default account in view", __FUNCTION__); - } - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, TRUE, -1); - } + g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (self)); + + /* If it's active then do nothing, no need to reenable it as + default account */ + if (gtk_cell_renderer_toggle_get_active (cell_renderer)) + return; + + priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self); + model = gtk_tree_view_get_model (GTK_TREE_VIEW(self)); + gtk_tree_model_get_iter_from_string (model, &iter, path); + + gtk_tree_model_get (model, &iter, + MODEST_ACCOUNT_VIEW_NAME_COLUMN, + &account_name, -1); + + /* Set this previously-non-default account as the + default. We're not updating here the value of the + DEFAULT_COLUMN because we'll do it in the + "default_account_changed" signal handler. We do it like + this because that way the signal handler is useful also + when we're inserting a new account and there is no other + one defined, in that case the change of account is provoked + by the account mgr and not by a signal toggle.*/ + modest_account_mgr_set_default_account (priv->account_mgr, account_name); g_free (account_name); } +static void +on_account_updated (ModestAccountMgr* mgr, + gchar* account_name, + gpointer user_data) +{ + update_account_view (mgr, MODEST_ACCOUNT_VIEW (user_data)); +} + void bold_if_default_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer user_data) @@ -429,6 +422,7 @@ init_view (ModestAccountView *self) GtkListStore *model; GtkTreeViewColumn *column; + g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (self)); priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self); model = gtk_list_store_new (6, @@ -449,6 +443,8 @@ init_view (ModestAccountView *self) toggle_renderer = gtk_cell_renderer_toggle_new (); text_renderer = gtk_cell_renderer_text_new (); + g_object_set (G_OBJECT (text_renderer), "ellipsize", PANGO_ELLIPSIZE_END, + "ellipsize-set", TRUE, NULL); /* the is_default column */ g_object_set (G_OBJECT(toggle_renderer), "activatable", TRUE, "radio", TRUE, NULL); @@ -464,17 +460,23 @@ init_view (ModestAccountView *self) * * djcb: indeed, they have been removed for post-bora, i added the ifdefs... */ -#ifdef MODEST_HILDON_VERSION_0 +#ifdef MODEST_HAVE_HILDON0_WIDGETS g_object_set(G_OBJECT(self), "allow-checkbox-mode", FALSE, NULL); g_object_set(G_OBJECT(toggle_renderer), "checkbox-mode", FALSE, NULL); -#endif /*MODEST_HILDON_VERSION_0 */ - g_signal_connect (G_OBJECT(toggle_renderer), "toggled", G_CALLBACK(on_account_default_toggled), - self); +#endif /* MODEST_HAVE_HILDON0_WIDGETS */ + + priv->sig_handlers = + modest_signal_mgr_connect (priv->sig_handlers, + G_OBJECT(toggle_renderer), + "toggled", + G_CALLBACK(on_account_default_toggled), + self); /* account name */ column = gtk_tree_view_column_new_with_attributes (_("mcen_ti_account"), text_renderer, "text", MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW(self), column); + gtk_tree_view_column_set_expand (column, TRUE); gtk_tree_view_column_set_cell_data_func(column, text_renderer, bold_if_default_cell_data, NULL, NULL); @@ -482,6 +484,7 @@ init_view (ModestAccountView *self) column = gtk_tree_view_column_new_with_attributes (_("mcen_ti_lastupdated"), text_renderer,"text", MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW(self),column); + gtk_tree_view_column_set_expand (column, TRUE); gtk_tree_view_column_set_cell_data_func(column, text_renderer, bold_if_default_cell_data, NULL, NULL); @@ -490,16 +493,45 @@ 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", - G_CALLBACK(on_account_removed), self); - priv->sig2 = g_signal_connect (G_OBJECT(priv->account_mgr), "account_changed", - G_CALLBACK(on_account_changed), self); - priv->sig3 = g_signal_connect (G_OBJECT(priv->account_mgr), "account_busy_changed", - G_CALLBACK(on_account_busy_changed), self); + priv->sig_handlers = + modest_signal_mgr_connect (priv->sig_handlers, + G_OBJECT (modest_runtime_get_account_store ()), + "account_removed", + G_CALLBACK(on_account_removed), + self); + priv->sig_handlers = + modest_signal_mgr_connect (priv->sig_handlers, + G_OBJECT (modest_runtime_get_account_store ()), + "account_inserted", + G_CALLBACK(on_account_inserted), + self); + priv->sig_handlers = + modest_signal_mgr_connect (priv->sig_handlers, + G_OBJECT(priv->account_mgr), + "account_busy_changed", + G_CALLBACK(on_account_busy_changed), + self); + priv->sig_handlers = + modest_signal_mgr_connect (priv->sig_handlers, + G_OBJECT(priv->account_mgr), + "default_account_changed", + G_CALLBACK(on_default_account_changed), + self); + priv->sig_handlers = + modest_signal_mgr_connect (priv->sig_handlers, + G_OBJECT(priv->account_mgr), + "display_name_changed", + G_CALLBACK(on_display_name_changed), + self); + priv->sig_handlers = + modest_signal_mgr_connect (priv->sig_handlers, + G_OBJECT (priv->account_mgr), + "account_updated", + G_CALLBACK (on_account_updated), + self); } - ModestAccountView* modest_account_view_new (ModestAccountMgr *account_mgr) { @@ -572,8 +604,9 @@ on_model_foreach_select_account(GtkTreeModel *model, return FALSE; /* Keep walking the tree. */ } -static void modest_account_view_select_account (ModestAccountView *account_view, - const gchar* account_name) +static void +modest_account_view_select_account (ModestAccountView *account_view, + const gchar* account_name) { /* Create a state instance so we can send two items of data to the signal handler: */ ForEachData *state = g_new0 (ForEachData, 1); @@ -588,3 +621,63 @@ static void modest_account_view_select_account (ModestAccountView *account_view, g_free (state); } +static void +modest_account_view_select_first_account (ModestAccountView *account_view) +{ + GtkTreeIter iter; + GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (account_view)); + + if (gtk_tree_model_get_iter_first (model, &iter)) { + GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (account_view)); + + gtk_tree_selection_select_iter (selection, &iter); + } +} + +static void +on_default_account_changed (ModestAccountMgr *mgr, + gpointer user_data) +{ + GtkTreeIter iter; + gchar *default_account_name; + GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (user_data)); + + if (!gtk_tree_model_get_iter_first(model, &iter)) + return; + + default_account_name = modest_account_mgr_get_default_account (mgr); + + do { + gboolean is_default; + gchar *name; + + gtk_tree_model_get (model, &iter, + MODEST_ACCOUNT_VIEW_NAME_COLUMN, &name, + MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, &is_default, + -1); + + /* Update the default account column */ + if ((default_account_name != NULL) && (!strcmp (name, default_account_name))) + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, TRUE, -1); + else + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, FALSE, -1); + + g_free (name); + + } while (gtk_tree_model_iter_next(model, &iter)); + + /* Free and force a redraw */ + g_free (default_account_name); + gtk_widget_queue_draw (GTK_WIDGET (user_data)); +} + +static void +on_display_name_changed (ModestAccountMgr *mgr, + const gchar *account, + gpointer user_data) +{ + /* Update the view */ + update_account_view (mgr, MODEST_ACCOUNT_VIEW (user_data)); +}