2007-05-09 Murray Cumming <murrayc@murrayc.com>
+ * src/modest-account-mgr-helpers.c:
+ (modest_account_mgr_set_first_account_as_default):
+ Sort the list of names alphabetically-by-title, so we choose the first one
+ based on that.
+ * src/widgets/modest-account-view.c: (init_view): Sort the TreeModel
+ alphabetically by the title.
+
+ This fixes projects.maemo.org bug NB#56418 .
+
+ * src/modest-account-mgr-priv.c:
+ (_modest_account_mgr_account_from_key):
+ * src/modest-account-mgr.c: (on_key_change): Initialize variables to
+ avoid a valgrind error, and possible random behaviour.
+
+2007-05-09 Murray Cumming <murrayc@murrayc.com>
+
* src/modest-tny-account-store.c: (modest_tny_account_store_alert):
Handle the new TNY_ACCOUNT_STORE_ERROR error domain. I will update the
tinymail documentation to say that this can be expected.
static void
show_error (GtkWindow *parent_window, const gchar* text)
{
- printf("debug: show_error\n");
GtkDialog *dialog = GTK_DIALOG (hildon_note_new_information (parent_window, text));
/*
GtkDialog *dialog = GTK_DIALOG (gtk_message_dialog_new (parent_window,
static void
show_ok (GtkWindow *parent_window, const gchar* text)
{
- printf("debug: show_ok\n");
GtkDialog *dialog = GTK_DIALOG (hildon_note_new_information (parent_window, text));
/*
GtkDialog *dialog = GTK_DIALOG (gtk_message_dialog_new (parent_window,
{
ModestAccountViewWindowPrivate *priv;
ModestAccountMgr *account_mgr;
- gchar *account_name;
+
priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
account_mgr = modest_runtime_get_account_mgr();
- account_name = modest_account_view_get_selected_account (priv->account_view);
+ gchar *account_name = modest_account_view_get_selected_account (priv->account_view);
+ if(!account_name)
+ return;
+
+ gchar *account_title = modest_account_mgr_get_display_name(account_mgr, account_name);
if (account_name) {
gboolean removed;
GTK_STOCK_OK,
GTK_RESPONSE_ACCEPT,
NULL);
- txt = g_strdup_printf (_("Do you really want to delete the account %s?"), account_name);
+ /* TODO: This confirmation dialog is not specified in the Maemo UI spec,
+ * but we really need one: */
+ txt = g_strdup_printf (_("Do you really want to delete the account %s?"),
+ account_title);
gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
gtk_label_new (txt), FALSE, FALSE, 0);
gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
}
}
gtk_widget_destroy (dialog);
+ g_free (account_title);
g_free (account_name);
}
}
}
+gint on_accounts_list_sort_by_title(gconstpointer a, gconstpointer b)
+{
+ return g_utf8_collate((const gchar*)a, (const gchar*)b);
+}
+
gboolean
modest_account_mgr_set_first_account_as_default (ModestAccountMgr *self)
{
gboolean result = FALSE;
GSList *account_names = modest_account_mgr_account_names (self, TRUE /* only enabled */);
- if(account_names)
+
+ /* Get the first one, alphabetically, by title: */
+ GSList* list_sorted = g_slist_sort (account_names,
+ on_accounts_list_sort_by_title);
+ if(list_sorted)
{
- const gchar* account_name = (const gchar*)account_names->data;
+ const gchar* account_name = (const gchar*)list_sorted->data;
if (account_name)
result = modest_account_mgr_set_default_account (self, account_name);
}
gchar*
_modest_account_mgr_account_from_key (const gchar *key, gboolean *is_account_key, gboolean *is_server_account)
{
+ /* Initialize input parameters: */
+ if (is_account_key)
+ *is_account_key = FALSE;
+
+ if (is_server_account)
+ *is_server_account = FALSE;
+
const gchar* account_ns = MODEST_ACCOUNT_NAMESPACE "/";
const gchar* server_account_ns = MODEST_SERVER_ACCOUNT_NAMESPACE "/";
gchar *cursor;
static void
on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event, gpointer user_data)
{
- ModestAccountMgr *self;
- ModestAccountMgrPrivate *priv;
-
- gchar *account;
- gboolean is_account_key, is_server_account;
- gboolean enabled;
-
- self = MODEST_ACCOUNT_MGR (user_data);
- priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ ModestAccountMgr *self = MODEST_ACCOUNT_MGR (user_data);
+ /* ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); */
/* there is only one not-really-account key which will still emit
* a signal: a change in MODEST_CONF_DEFAULT_ACCOUNT */
return;
}
- account = _modest_account_mgr_account_from_key (key, &is_account_key, &is_server_account);
+ gboolean is_account_key = FALSE;
+ gboolean is_server_account = FALSE;
+ gchar* account = _modest_account_mgr_account_from_key (key, &is_account_key, &is_server_account);
/* if this is not an account-related key change, ignore */
if (!account)
}
/* is this account enabled? */
+ gboolean enabled = FALSE;
if (is_server_account)
enabled = TRUE;
else
G_TYPE_STRING, /* account proto (pop, imap,...) */
G_TYPE_STRING /* last updated (time_t) */
);
+
+ gtk_tree_sortable_set_sort_column_id (
+ GTK_TREE_SORTABLE (model), MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN,
+ GTK_SORT_ASCENDING);
gtk_tree_view_set_model (GTK_TREE_VIEW(self), GTK_TREE_MODEL(model));
g_object_unref (G_OBJECT (model));