void csv_import_assistant_summary_page_prepare (GtkAssistant *assistant, gpointer user_data) { CsvImportInfo *info = user_data; gchar *text, *errtext, *mtext; /* Before creating accounts, if this is a new book, let user specify * book options, since they affect how transactions are created */ if (info->new_book) info->new_book = gnc_new_book_option_display(); if (!g_strcmp0(info->error, "") == 0) { GtkTextBuffer *buffer; buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (info->summary_error_view)); text = g_strdup_printf(gettext ("Import completed but with errors!\n\nThe number of Accounts added was %u and " "updated was %u.\n\nSee below for errors..." ), info->num_new, info->num_updates ); errtext = g_strdup_printf ( "%s", info->error); gtk_text_buffer_set_text (buffer, errtext, -1); g_free(errtext); g_free(info->error); } else text = g_strdup_printf(gettext ("Import completed successfully!\n\nThe number of Accounts added was %u and " "updated was %u.\n" ), info->num_new, info->num_updates ); mtext = g_strdup_printf("<span size=\"medium\"><b>%s</b></span>", text); gtk_label_set_markup(GTK_LABEL(info->summary_label), mtext); g_free(text); g_free(mtext); }
int ofx_proc_account_cb(struct OfxAccountData data, void * account_user_data) { gnc_commodity_table * commodity_table; gnc_commodity * default_commodity; GNCAccountType default_type = ACCT_TYPE_NONE; gchar * account_description; /* In order to trigger a book options display on the creation of a new book, * we need to detect when we are dealing with a new book. */ gboolean new_book = gnc_is_new_book(); const gchar * account_type_name = _("Unknown OFX account"); if (data.account_id_valid) { commodity_table = gnc_get_current_commodities (); if (data.currency_valid) { DEBUG("Currency from libofx: %s", data.currency); default_commodity = gnc_commodity_table_lookup(commodity_table, GNC_COMMODITY_NS_CURRENCY, data.currency); } else { default_commodity = NULL; } if (data.account_type_valid) { switch (data.account_type) { case OFX_CHECKING : default_type = ACCT_TYPE_BANK; account_type_name = _("Unknown OFX checking account"); break; case OFX_SAVINGS : default_type = ACCT_TYPE_BANK; account_type_name = _("Unknown OFX savings account"); break; case OFX_MONEYMRKT : default_type = ACCT_TYPE_MONEYMRKT; account_type_name = _("Unknown OFX money market account"); break; case OFX_CREDITLINE : default_type = ACCT_TYPE_CREDITLINE; account_type_name = _("Unknown OFX credit line account"); break; case OFX_CMA : default_type = ACCT_TYPE_NONE; account_type_name = _("Unknown OFX CMA account"); break; case OFX_CREDITCARD : default_type = ACCT_TYPE_CREDIT; account_type_name = _("Unknown OFX credit card account"); break; case OFX_INVESTMENT : default_type = ACCT_TYPE_BANK; account_type_name = _("Unknown OFX investment account"); break; default: PERR("WRITEME: ofx_proc_account() This is an unknown account type!"); break; } } /* If the OFX importer was started in Gnucash in a 'new_book' situation, * as described above, the first time the 'ofx_proc_account_cb' function * is called a book is created. (This happens after the 'new_book' flag * is set in 'gnc_get_current_commodities', called above.) So, before * calling 'gnc_import_select_account', allow the user to set book * options. */ if (new_book) new_book = gnc_new_book_option_display(); gnc_utf8_strip_invalid(data.account_name); account_description = g_strdup_printf( /* This string is a default account name. It MUST NOT contain the character ':' anywhere in it or in any translation. */ "%s \"%s\"", account_type_name, data.account_name); gnc_import_select_account(NULL, data.account_id, 1, account_description, default_commodity, default_type, NULL, NULL); g_free(account_description); } else { PERR("account online ID not available"); } return 0; }