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,
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
-/* Get the string for the last updated time. Result must be g_freed */
-static gchar*
+/* Get the string for the last updated time. Result must NOT be g_freed */
+static const gchar*
get_last_updated_string(ModestAccountMgr* account_mgr, ModestAccountData *account_data)
{
/* FIXME: let's assume that 'last update' applies to the store account... */
- gchar* last_updated_string;
+ const 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)) {
if (last_updated > 0)
last_updated_string = modest_text_utils_get_display_date(last_updated);
else
- last_updated_string = g_strdup (_("mcen_va_never"));
+ last_updated_string = _("mcen_va_never");
} else {
/* FIXME: There should be a logical name in the UI specs */
- last_updated_string = g_strdup(_("mcen_va_refreshing"));
+ last_updated_string = _("mcen_va_refreshing");
}
+
return last_updated_string;
}
if (account_data->store_account) {
GtkTreeIter iter;
-
- gchar *last_updated_string = get_last_updated_string(account_mgr, account_data);
+
+ /* don't free */
+ const gchar *last_updated_string = get_last_updated_string(account_mgr, account_data);
if (account_data->is_enabled) {
const gchar *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_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, account_data);
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);
found = TRUE;
}
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);
}
}
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)
{
-1);
/* Update the default account column */
- if (!strcmp (name, default_account_name))
+ 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