コード例 #1
0
static void
ap_druid_create (AcctPeriodInfo *info)
{
    GladeXML *xml;
    GtkWidget *w;

    xml = gnc_glade_xml_new ("acctperiod.glade", "Acct Period Druid");

    info->window = glade_xml_get_widget (xml, "Acct Period Druid");

    info->druid = GNOME_DRUID (glade_xml_get_widget (xml, "acct_period_druid"));
    gnc_druid_set_colors (info->druid);

    info->start_page =
        GNOME_DRUID_PAGE(glade_xml_get_widget (xml, "start page"));
    info->menu_page =
        GNOME_DRUID_PAGE(glade_xml_get_widget (xml, "menu page"));
    info->book_page =
        GNOME_DRUID_PAGE(glade_xml_get_widget (xml, "book page"));
    info->finish_page =
        GNOME_DRUID_PAGE(glade_xml_get_widget (xml, "finish page"));

    info->close_status = -1;

    /* Find the date of the earliest transaction in the book.
     * Add a year minus a day as the first guess for book closing,
     * and use that to set up the freq spec widget. */
    info->earliest = get_earliest_in_book (gnc_get_current_book());
    info->earliest_str = qof_print_date(info->earliest);
    PINFO ("date of earliest transaction is %ld %s",
           info->earliest, ctime (&info->earliest));

    g_date_clear (&info->closing_date, 1);
    g_date_set_time_t (&info->closing_date, info->earliest);
    g_date_clear (&info->prev_closing_date, 1);
    info->prev_closing_date = info->closing_date;
    g_date_add_years (&info->closing_date, 1);

    {
        Recurrence *r = g_new0(Recurrence, 1);
        recurrenceSet(r, 1, PERIOD_MONTH, &info->closing_date, WEEKEND_ADJ_NONE);
        info->period = NULL;
        info->period = g_list_append(info->period, r);
    }

    info->period_menu = GNC_FREQUENCY(
                            gnc_frequency_new_from_recurrence(info->period, &info->closing_date));

    /* Change the text so that its more mainingful for this druid */
    gnc_frequency_set_frequency_label_text(info->period_menu, _("Period:"));
    gnc_frequency_set_date_label_text(info->period_menu, _("Closing Date:"));

    /* Reparent to the correct location */
    w = glade_xml_get_widget (xml, "period box");
    gtk_box_pack_start (GTK_BOX (w), GTK_WIDGET (info->period_menu),
                        TRUE, TRUE, 0);

    /* Get handles to all of the other widgets we'll need */
    info->period_remarks =
        GTK_LABEL (glade_xml_get_widget (xml, "remarks label"));

    info->close_results =
        GTK_LABEL (glade_xml_get_widget (xml, "results label"));

    info->book_details =
        GTK_LABEL (glade_xml_get_widget (xml, "book label"));

    info->book_title =
        GTK_ENTRY (glade_xml_get_widget (xml, "book title entry"));

    info->book_notes =
        GTK_TEXT_VIEW (glade_xml_get_widget (xml, "book notes text"));

    /* generic finished/close/abort signals */
    g_signal_connect (info->window, "destroy",
                      G_CALLBACK (ap_window_destroy_cb), info);

    g_signal_connect (info->druid, "cancel",
                      G_CALLBACK (ap_druid_cancel), info);

    g_signal_connect (info->menu_page, "prepare",
                      G_CALLBACK (ap_show_menu), info);

    g_signal_connect (info->menu_page, "next",
                      G_CALLBACK (ap_validate_menu), info);

    g_signal_connect (info->book_page, "prepare",
                      G_CALLBACK (ap_show_book), info);

    g_signal_connect (info->book_page, "next",
                      G_CALLBACK (ap_close_period), info);

    g_signal_connect (info->finish_page, "prepare",
                      G_CALLBACK (ap_show_done), info);

    g_signal_connect (info->finish_page, "finish",
                      G_CALLBACK (ap_finish), info);

    /* User changes the accouting period or date signals */
    g_signal_connect (info->period_menu, "changed",
                      G_CALLBACK (ap_changed), info);
}
コード例 #2
0
ファイル: druid-ab-initial.c プロジェクト: cstim/gnucash-svn
void
gnc_ab_initial_druid(void)
{
    ABInitialInfo *info;
    GladeXML *xml;
    GtkTreeViewColumn *column;
    GtkTreeSelection *selection;
    gint component_id;

    info = g_new0(ABInitialInfo, 1);

    xml = gnc_glade_xml_new("aqbanking.glade", "AqBanking Init Druid");

    info->window = glade_xml_get_widget(xml, "AqBanking Init Druid");
    g_object_set_data_full(G_OBJECT(info->window), "xml", xml, g_object_unref);
    glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
                                      info);

    info->druid = glade_xml_get_widget(xml, "ab_init_druid");
    gnc_druid_set_colors(GNOME_DRUID(info->druid));

    info->api = gnc_AB_BANKING_new();
    info->deferred_info = NULL;
    info->gnc_hash = NULL;

    info->match_page_prepared = FALSE;
    info->account_view =
        GTK_TREE_VIEW(glade_xml_get_widget(xml, "account_page_view"));
    info->account_store = gtk_list_store_new(NUM_ACCOUNT_LIST_COLS,
                          G_TYPE_INT, G_TYPE_STRING,
                          G_TYPE_POINTER, G_TYPE_STRING,
                          G_TYPE_BOOLEAN);
    gtk_tree_view_set_model(info->account_view,
                            GTK_TREE_MODEL(info->account_store));
    g_object_unref(info->account_store);

    column = gtk_tree_view_column_new_with_attributes(
                 _("Online Banking Account Name"), gtk_cell_renderer_text_new(),
                 "text", ACCOUNT_LIST_COL_AB_NAME, (gchar*) NULL);
    gtk_tree_view_append_column(info->account_view, column);

    column = gtk_tree_view_column_new_with_attributes(
                 _("GnuCash Account Name"), gtk_cell_renderer_text_new(),
                 "text", ACCOUNT_LIST_COL_GNC_NAME, (gchar*) NULL);
    gtk_tree_view_column_set_expand(column, TRUE);
    gtk_tree_view_append_column(info->account_view, column);

    column = gtk_tree_view_column_new_with_attributes(
                 _("New?"), gtk_cell_renderer_toggle_new(),
                 "active", ACCOUNT_LIST_COL_CHECKED, (gchar*) NULL);
    gtk_tree_view_append_column(info->account_view, column);

    selection = gtk_tree_view_get_selection(info->account_view);
    g_signal_connect(selection, "changed",
                     G_CALLBACK(account_list_changed_cb), info);

    component_id = gnc_register_gui_component(DRUID_AB_INITIAL_CM_CLASS,
                   NULL, cm_close_handler, info);
    gnc_gui_component_set_session(component_id, gnc_get_current_session());

    gtk_widget_show(info->window);
}