static void
gnc_main_window_cmd_actions_since_last_run (GtkAction *action, GncMainWindowActionData *data)
{
    GtkWindow *window;
    GncSxInstanceModel *sx_instances;
    GncSxSummary summary;
    GList *auto_created_txns = NULL;
    const char *nothing_to_do_msg =
        _( "There are no Scheduled Transactions to be entered at this time." );

    g_return_if_fail (data != NULL);

    window = GTK_WINDOW (data->window);

    if (qof_book_is_readonly(gnc_get_current_book()))
    {
        /* Is the book read-only? Then don't change anything here. */
        return;
    }

    sx_instances = gnc_sx_get_current_instances();
    gnc_sx_instance_model_summarize(sx_instances, &summary);
    gnc_sx_instance_model_effect_change(sx_instances, TRUE, &auto_created_txns, NULL);
    if (summary.need_dialog)
    {
        gnc_ui_sx_since_last_run_dialog (window, sx_instances, auto_created_txns);
        auto_created_txns = NULL;
    }
    else
    {
        if (summary.num_auto_create_no_notify_instances == 0)
        {
            gnc_info_dialog (window, "%s", nothing_to_do_msg);
        }
        else
        {
            gnc_info_dialog(window, ngettext
                            /* Translators: %d is the number of transactions. This is a
                               ngettext(3) message. */
                            ("There are no Scheduled Transactions to be entered at this time. "
                             "(%d transaction automatically created)",
                             "There are no Scheduled Transactions to be entered at this time. "
                             "(%d transactions automatically created)",
                             summary.num_auto_create_no_notify_instances),
                            summary.num_auto_create_no_notify_instances);
        }
    }
    g_list_free(auto_created_txns);
    g_object_unref(G_OBJECT(sx_instances));
}
void
gnc_sx_sxsincelast_book_opened(void)
{
    GList *auto_created_txns = NULL;
    GncSxInstanceModel *inst_model;
    GncSxSummary summary;

    if (!gnc_prefs_get_bool (GNC_PREFS_GROUP_STARTUP, GNC_PREF_RUN_AT_FOPEN))
        return;

    if (qof_book_is_readonly(gnc_get_current_book()))
    {
        /* Is the book read-only? Then don't change anything here. */
        return;
    }

    inst_model = gnc_sx_get_current_instances();
    gnc_sx_instance_model_summarize(inst_model, &summary);
    gnc_sx_summary_print(&summary);
    gnc_sx_instance_model_effect_change(inst_model, TRUE, &auto_created_txns, NULL);

    if (summary.need_dialog)
    {
        gnc_ui_sx_since_last_run_dialog(inst_model, auto_created_txns);
        auto_created_txns = NULL;
    }
    else
    {
        if (summary.num_auto_create_no_notify_instances != 0)
        {
            if (!gnc_prefs_get_bool(GNC_PREFS_GROUP_STARTUP, GNC_PREF_SHOW_AT_FOPEN))
                return;

            gnc_info_dialog
            (NULL,
             ngettext
             ("There are no Scheduled Transactions to be entered at this time. "
              "(One transaction automatically created)",
              "There are no Scheduled Transactions to be entered at this time. "
              "(%d transactions automatically created)",
              summary.num_auto_create_no_notify_instances),
             summary.num_auto_create_no_notify_instances);
        }
    }
    g_list_free(auto_created_txns);
    g_object_unref(G_OBJECT(inst_model));
}
void
gnc_sx_sxsincelast_book_opened(void)
{
    GList *auto_created_txns = NULL;
    GncSxInstanceModel *inst_model;
    GncSxSummary summary;

    if (!gnc_gconf_get_bool(GCONF_SECTION, "show_at_file_open", NULL))
        return;

    inst_model = gnc_sx_get_current_instances();
    gnc_sx_instance_model_summarize(inst_model, &summary);
    gnc_sx_summary_print(&summary);
    gnc_sx_instance_model_effect_change(inst_model, TRUE, &auto_created_txns, NULL);

    if (summary.need_dialog)
    {
        gnc_ui_sx_since_last_run_dialog(inst_model, auto_created_txns);
        auto_created_txns = NULL;
    }
    else
    {
        if (summary.num_auto_create_no_notify_instances != 0)
        {
            gnc_info_dialog
            (NULL,
             ngettext
             ("There are no Scheduled Transactions to be entered at this time. "
              "(%d transaction automatically created)",
              "There are no Scheduled Transactions to be entered at this time. "
              "(%d transactions automatically created)",
              summary.num_auto_create_no_notify_instances),
             summary.num_auto_create_no_notify_instances);
        }
    }
    g_list_free(auto_created_txns);
    g_object_unref(G_OBJECT(inst_model));
}