Пример #1
0
static void
gnc_main_window_cmd_file_save (GtkAction *action, GncMainWindowActionData *data)
{
    g_return_if_fail (data != NULL);

    if (!gnc_main_window_all_finish_pending())
        return;

    gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
    gnc_file_save (GTK_WINDOW (data->window));
    gnc_window_set_progressbar_window (NULL);
}
Пример #2
0
static gboolean
ap_close_period (GnomeDruidPage *druidpage,
                 GtkWidget *druid,
                 gpointer user_data)
{
    AcctPeriodInfo *info = user_data;
    QofBook *closed_book = NULL, *current_book;
    const char *btitle;
    char *bnotes;
    Timespec closing_date;
    KvpFrame *book_frame;
    gboolean really_do_close_books = FALSE;

    ENTER("info=%p", info);

    current_book = gnc_get_current_book ();

    btitle = gtk_entry_get_text (info->book_title);
    bnotes = xxxgtk_textview_get_text (info->book_notes);
    PINFO("book title=%s\n", btitle);

    timespecFromTime_t (&closing_date,
                        gnc_timet_get_day_end_gdate (&info->closing_date));

#define REALLY_DO_CLOSE_BOOKS
#ifdef REALLY_DO_CLOSE_BOOKS
    really_do_close_books = TRUE;
#endif /* REALLY_DO_CLOSE_BOOKS */

    if (really_do_close_books)
    {
        /* Close the books ! */
        qof_event_suspend ();
        gnc_suspend_gui_refresh ();

        scrub_all();
        closed_book = gnc_book_close_period (current_book, closing_date, NULL, btitle);

        book_frame = qof_book_get_slots(closed_book);
        kvp_frame_set_str (book_frame, "/book/title", btitle);
        kvp_frame_set_str (book_frame, "/book/notes", bnotes);

        qof_session_add_book (gnc_get_current_session(), closed_book);

        /* We must save now; if we don't, and the user bails without saving,
         * then opening account balances will be incorrect, and this can only
         * lead to unhappiness.
         */
        gnc_file_save ();
        gnc_resume_gui_refresh ();
        qof_event_resume ();
        gnc_gui_refresh_all ();  /* resume above should have been enough ??? */
    }
    g_free(bnotes);

    /* Report the status back to the user. */
    info->close_status = 0;  /* XXX fixme success or failure? */

    /* Find the next closing date ... */
    info->prev_closing_date = info->closing_date;
    recurrenceListNextInstance(info->period, &info->prev_closing_date, &info->closing_date);

    /* If the next closing date is in the future, then we are done. */
    if (time(NULL) < gnc_timet_get_day_end_gdate (&info->closing_date))
    {
        return FALSE;
    }

    /* Load up the GUI for the next closing period. */
    gnc_frequency_setup_recurrence(info->period_menu, NULL, &info->closing_date);

    show_book_details (info);
    return TRUE;
}