2007-04-05 Murray Cumming <murrayc@murrayc.com>
+ * src/maemo/easysetup/modest-easysetup-wizard.c:
+ (set_default_custom_servernames): Avoid a dereference of a destroyed widget.
+ (create_account): Do a sanity check, showing that modest_account_mgr_account_names()
+ returns NULL after modest_account_mgr_add_server_account() returned TRUE,
+ which seems wrong.
+
+ * src/maemo/modest-main-window-ui.h: Specify the callback for the Accounts menu item.
+ * src/modest-ui-actions.c: (modest_ui_actions_on_accounts): Open the wizard if no
+ accounts exist yet, as in the UI spec.
+
+ * src/modest-account-mgr.h: Add TODO comment about a possible memory leak.
+
+2007-04-05 Murray Cumming <murrayc@murrayc.com>
+
* src/maemo/Makefile.am:
* src/maemo/modest-connection-specific-smtp-edit-window.c:
* src/maemo/modest-connection-specific-smtp-edit-window.h:
static void set_default_custom_servernames (ModestEasysetupWizardDialog *account_wizard)
{
+ if (!account_wizard->entry_incomingserver)
+ return;
+
/* Set a default domain for the server, based on the email address,
* if no server name was already specified.
*/
return FALSE;
}
+ /* Sanity check: */
+ /* There must be at least one account now: */
+ GSList *account_names = modest_account_mgr_account_names (self->account_manager);
+ if(account_names != NULL)
+ {
+ g_warning ("modest_account_mgr_account_names() returned NULL after adding an account.");
+ }
+ g_slist_free (account_names);
+
+
/* Outgoing server: */
gchar* servername_outgoing = NULL;
ModestProtocol protocol_outgoing = MODEST_PROTOCOL_STORE_POP;
/* Tools */
{ "ToolsSettings", NULL, N_("Settings..."), NULL, NULL, NULL },
- { "ToolsAccounts", NULL, N_("Accounts..."), NULL, NULL, NULL },
+ { "ToolsAccounts", NULL, N_("Accounts..."), NULL, NULL, G_CALLBACK (modest_ui_actions_on_accounts) },
{ "ToolsSMTPServers", NULL, N_("SMTP servers..."), NULL, NULL, NULL },
{ "ToolsSendReceive", NULL, N_("Send & receive") }, /* submenu */
{ "ToolsSendReceiveAll", NULL, N_("All"), NULL, NULL, NULL },
* list all account names
*
* Returns: a newly allocated list of account names, or NULL in case of error or
- * if there are no accounts. The caller must free the returned GSList
+ * if there are no accounts. The caller must free the returned GSList.
+ *
+ * TODO: I believe that the caller must free the strings in the GSList items too,
+ * because this is implemented via gconf_client_all_dirs() which also requires a deep free,
+ * though that's not documented. murrayc.
*/
GSList* modest_account_mgr_account_names (ModestAccountMgr *self);
void
modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win)
{
+ GSList *account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr());
+ const gboolean accounts_exist = account_names != NULL;
+ g_slist_free (account_names);
+
/* This is currently only implemented for Maemo,
* because it requires a providers preset file which is not publically available.
*/
#ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */
- GtkDialog *account_win = GTK_DIALOG(modest_account_view_window_new ());
- gtk_window_set_transient_for (GTK_WINDOW (account_win), GTK_WINDOW(win));
- gtk_dialog_run (account_win);
- gtk_widget_destroy (GTK_WIDGET(account_win));
+ if (!accounts_exist) {
+ printf ("debug: modest_account_mgr_account_names() returned NULL.\n");
+ /* If there are no accounts yet, just show the easy-setup wizard, as per the UI spec: */
+ ModestEasysetupWizardDialog *wizard = modest_easysetup_wizard_dialog_new ();
+ gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));
+ gtk_dialog_run (GTK_DIALOG (wizard));
+ gtk_widget_destroy (GTK_WIDGET (wizard));
+ }
+ else
+ {
+ /* Show the list of accounts: */
+ GtkDialog *account_win = GTK_DIALOG(modest_account_view_window_new ());
+ gtk_window_set_transient_for (GTK_WINDOW (account_win), GTK_WINDOW(win));
+ gtk_dialog_run (account_win);
+ gtk_widget_destroy (GTK_WIDGET(account_win));
+ }
#else
GtkWidget *dialog, *label;
}
void
-modest_ui_actions_on_new_account (GtkAction *action, ModestWindow *win)
-{
- /* This is currently only implemented for Maemo,
- * because it requires a providers preset file which is not publically available.
- */
-#ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */
- ModestEasysetupWizardDialog *wizard = modest_easysetup_wizard_dialog_new ();
- gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));
- gtk_dialog_run (GTK_DIALOG (wizard));
- gtk_widget_destroy (GTK_WIDGET (wizard));
-#endif /* MODEST_PLATFORM_MAEMO */
-}
-
-void
modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win)
{
ModestWindow *msg_win;