2007-05-09 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Wed, 9 May 2007 13:26:48 +0000 (13:26 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Wed, 9 May 2007 13:26:48 +0000 (13:26 +0000)
* 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.

pmo-trunk-r1802

ChangeLog2
src/maemo/modest-account-settings-dialog.c
src/maemo/modest-account-view-window.c
src/modest-account-mgr-helpers.c
src/modest-account-mgr-priv.c
src/modest-account-mgr.c
src/widgets/modest-account-view.c

index 2f4195b..42526c3 100644 (file)
@@ -1,5 +1,21 @@
 2007-05-09  Murray Cumming  <murrayc@murrayc.com>
 
 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.
        * 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.
index ffb5a13..cf1d812 100644 (file)
@@ -1275,7 +1275,6 @@ modest_account_settings_dialog_class_init (ModestAccountSettingsDialogClass *kla
 static void
 show_error (GtkWindow *parent_window, const gchar* text)
 {
 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,
        GtkDialog *dialog = GTK_DIALOG (hildon_note_new_information (parent_window, text));
        /*
        GtkDialog *dialog = GTK_DIALOG (gtk_message_dialog_new (parent_window,
@@ -1292,7 +1291,6 @@ show_error (GtkWindow *parent_window, const gchar* text)
 static void
 show_ok (GtkWindow *parent_window, const gchar* text)
 {
 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,
        GtkDialog *dialog = GTK_DIALOG (hildon_note_new_information (parent_window, text));
        /*
        GtkDialog *dialog = GTK_DIALOG (gtk_message_dialog_new (parent_window,
index 61f50ae..eba9ad3 100644 (file)
@@ -151,12 +151,16 @@ on_delete_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
 {
        ModestAccountViewWindowPrivate *priv;
        ModestAccountMgr *account_mgr;
 {
        ModestAccountViewWindowPrivate *priv;
        ModestAccountMgr *account_mgr;
-       gchar *account_name;
+       
        
        priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
 
        account_mgr = modest_runtime_get_account_mgr(); 
        
        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;
 
        if (account_name) {
                gboolean removed;
@@ -171,7 +175,10 @@ on_delete_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
                                                      GTK_STOCK_OK,
                                                      GTK_RESPONSE_ACCEPT,
                                                      NULL);
                                                      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_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));
@@ -204,6 +211,7 @@ on_delete_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
                        }
                }
                gtk_widget_destroy (dialog);
                        }
                }
                gtk_widget_destroy (dialog);
+               g_free (account_title);
                g_free (account_name);
        }
 }
                g_free (account_name);
        }
 }
index 86e07dc..927105e 100644 (file)
@@ -644,14 +644,23 @@ modest_account_mgr_unset_default_account  (ModestAccountMgr *self)
 
 }
 
 
 }
 
+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 */);
 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);
        }
                if (account_name)
                        result = modest_account_mgr_set_default_account (self, account_name);
        }
index 653149e..a3607e7 100644 (file)
 gchar*
 _modest_account_mgr_account_from_key (const gchar *key, gboolean *is_account_key, gboolean *is_server_account)
 {
 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;
        const gchar* account_ns        = MODEST_ACCOUNT_NAMESPACE "/";
        const gchar* server_account_ns = MODEST_SERVER_ACCOUNT_NAMESPACE "/";
        gchar *cursor;
index ba553d8..abe555f 100644 (file)
@@ -53,15 +53,8 @@ static guint signals[LAST_SIGNAL] = {0};
 static void
 on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event, gpointer user_data)
 {
 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 */
 
        /* there is only one not-really-account key which will still emit
         * a signal: a change in MODEST_CONF_DEFAULT_ACCOUNT */
@@ -74,7 +67,9 @@ on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event, gpoint
                return;
        }
        
                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)
        
        /* if this is not an account-related key change, ignore */
        if (!account)
@@ -89,6 +84,7 @@ on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event, gpoint
        }
 
        /* is this account enabled? */
        }
 
        /* is this account enabled? */
+       gboolean enabled = FALSE;
        if (is_server_account)
                enabled = TRUE;
        else 
        if (is_server_account)
                enabled = TRUE;
        else 
index 529b321..896712b 100644 (file)
@@ -332,6 +332,10 @@ init_view (ModestAccountView *self)
                                    G_TYPE_STRING,  /* account proto (pop, imap,...) */
                                    G_TYPE_STRING   /* last updated (time_t) */
                ); 
                                    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));
 
        gtk_tree_view_set_model (GTK_TREE_VIEW(self), GTK_TREE_MODEL(model));
        g_object_unref (G_OBJECT (model));