Ejemplo n.º 1
0
/* Constructor */
GNCImportSettings *
gnc_import_Settings_new (void)
{
    GNCImportSettings * settings;

    settings = g_new0 ( GNCImportSettings, 1);


    settings->action_skip_enabled =
        gnc_prefs_get_bool (GNC_PREFS_GROUP_IMPORT, GNC_PREF_ENABLE_SKIP);
    settings->action_update_enabled =
        gnc_prefs_get_bool (GNC_PREFS_GROUP_IMPORT, GNC_PREF_ENABLE_UPDATE);
    settings->action_add_enabled = DEFAULT_ACTION_ADD_ENABLED;
    settings->action_clear_enabled = DEFAULT_ACTION_CLEAR_ENABLED;
    settings->clear_threshold =
        (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_AUTO_CLEAR_THRESHOLD);
    settings->add_threshold =
        (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_AUTO_ADD_THRESHOLD);
    settings->display_threshold =
        (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_MATCH_THRESHOLD);

    settings->fuzzy_amount =
        gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_ATM_FEE_THRESHOLD);

    settings->match_date_hardlimit = 42; /* 6 weeks */
    return settings;
}
Ejemplo n.º 2
0
/***************************************************************
 * Initialization                                              *
 ***************************************************************/
static void
file_retain_changed_cb(gpointer gsettings, gchar *key, gpointer user_data)
{
    if (gnc_prefs_is_set_up())
    {
        gint days = (int)gnc_prefs_get_float(GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_DAYS);
        gnc_prefs_set_file_retention_days (days);
    }
}
Ejemplo n.º 3
0
/* gnc_configure_date_completion
 *    sets dateCompletion to the current value on the scheme side.
 *    QOF_DATE_COMPLETION_THISYEAR: use current year
 *    QOF_DATE_COMPLETION_SLIDING: use a sliding 12-month window
 *    backmonths 0-11: windows starts this many months before current month
 *
 * Args: Nothing
 * Returns: Nothing
 */
static void
gnc_configure_date_completion (void)
{
    QofDateCompletion dc = QOF_DATE_COMPLETION_THISYEAR;
    int backmonths = gnc_prefs_get_float(GNC_PREFS_GROUP_GENERAL,
                                         GNC_PREF_DATE_BACKMONTHS);

    if (backmonths < 0)
        backmonths = 0;
    else if (backmonths > 11)
        backmonths = 11;

    if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_DATE_COMPL_SLIDING))
        dc = QOF_DATE_COMPLETION_SLIDING;

    qof_date_completion_set(dc, backmonths);
}
Ejemplo n.º 4
0
static guint
sxftd_compute_sx(SXFromTransInfo *sxfti)
{
    gchar *name;
    GDate date;
    GList *schedule = NULL;
    getEndTuple end_info;
    guint sxftd_errno = 0; /* 0 == OK, > 0 means dialog needs to be run again */

    SchedXaction *sx = sxfti->sx;

    /* get the name */
    name = gtk_editable_get_chars(GTK_EDITABLE(sxfti->name), 0, -1);

    xaccSchedXactionSetName(sx, name);
    g_free(name);

    gnc_gdate_set_time64( &date, gnc_date_edit_get_date( sxfti->startDateGDE ) );

    sxftd_update_schedule(sxfti, &date, &schedule);
    if (sxftd_errno == 0)
    {
        gnc_sx_set_schedule(sx, schedule);
        xaccSchedXactionSetStartDate( sx, &date );
    }

    end_info = sxftd_get_end_info(sxfti);

    switch (end_info.type)
    {
    case NEVER_END:
        break;

    case END_ON_DATE:
        xaccSchedXactionSetEndDate(sx, &(end_info.end_date));
        break;

    case END_AFTER_N_OCCS:
        xaccSchedXactionSetNumOccur(sx, end_info.n_occurrences);
        break;

    default:
        sxftd_errno = 2;
        break;
    }

    gnc_sx_set_instance_count( sx, 1 );

    /* Set the autocreate, days-in-advance and remind-in-advance values from
     * options. */
    {
        gboolean autoCreateState, notifyState;
        gint daysInAdvance;

        autoCreateState =
            gnc_prefs_get_bool (GNC_PREFS_GROUP_SXED, GNC_PREF_CREATE_AUTO);
        notifyState =
            gnc_prefs_get_bool (GNC_PREFS_GROUP_SXED, GNC_PREF_NOTIFY);
        xaccSchedXactionSetAutoCreate( sx,
                                       autoCreateState,
                                       (autoCreateState & notifyState) );

        daysInAdvance =
            gnc_prefs_get_float (GNC_PREFS_GROUP_SXED, GNC_PREF_CREATE_DAYS);
        xaccSchedXactionSetAdvanceCreation( sx, daysInAdvance );

        daysInAdvance =
            gnc_prefs_get_float (GNC_PREFS_GROUP_SXED, GNC_PREF_REMIND_DAYS);
        xaccSchedXactionSetAdvanceReminder( sx, daysInAdvance );
    }

    if ( sxftd_add_template_trans( sxfti ) != 0 )
    {
        sxftd_errno = SXFTD_ERRNO_UNBALANCED_XACTION;
    }

    return sxftd_errno;
}
Ejemplo n.º 5
0
static GNCLedgerDisplay *
gnc_ledger_display_internal (Account *lead_account, Query *q,
                             GNCLedgerDisplayType ld_type,
                             SplitRegisterType reg_type,
                             SplitRegisterStyle style,
                             gboolean use_double_line,
                             gboolean is_template )
{
    GNCLedgerDisplay *ld;
    gint limit;
    const char *klass;
    GList *splits;

    switch (ld_type)
    {
    case LD_SINGLE:
        klass = REGISTER_SINGLE_CM_CLASS;

        if (reg_type >= NUM_SINGLE_REGISTER_TYPES)
        {
            PERR ("single-account register with wrong split register type");
            return NULL;
        }

        if (!lead_account)
        {
            PERR ("single-account register with no account specified");
            return NULL;
        }

        if (q)
        {
            PWARN ("single-account register with external query");
            q = NULL;
        }

        ld = gnc_find_first_gui_component (klass, find_by_leader, lead_account);
        if (ld)
            return ld;

        break;

    case LD_SUBACCOUNT:
        klass = REGISTER_SUBACCOUNT_CM_CLASS;

        if (!lead_account)
        {
            PERR ("sub-account register with no lead account");
            return NULL;
        }

        if (q)
        {
            PWARN ("account register with external query");
            q = NULL;
        }

        ld = gnc_find_first_gui_component (klass, find_by_leader, lead_account);
        if (ld)
            return ld;

        break;

    case LD_GL:
        klass = REGISTER_GL_CM_CLASS;

        if (!q)
        {
            PWARN ("general journal with no query");
        }

        break;

    default:
        PERR ("bad ledger type: %d", ld_type);
        return NULL;

    }

    ld = g_new (GNCLedgerDisplay, 1);

    ld->leader = *xaccAccountGetGUID (lead_account);
    ld->query = NULL;
    ld->ld_type = ld_type;
    ld->loading = FALSE;
    ld->destroy = NULL;
    ld->get_parent = NULL;
    ld->user_data = NULL;

    limit = gnc_prefs_get_float(GNC_PREFS_GROUP_GENERAL_REGISTER, GNC_PREF_MAX_TRANS);

    /* set up the query filter */
    if (q)
        ld->query = qof_query_copy (q);
    else
        gnc_ledger_display_make_query (ld, limit, reg_type);

    ld->component_id = gnc_register_gui_component (klass,
                       refresh_handler,
                       close_handler, ld);

    /******************************************************************\
     * The main register window itself                                *
    \******************************************************************/

    ld->use_double_line_default = use_double_line;
    ld->reg = gnc_split_register_new (reg_type, style, use_double_line,
                                      is_template);

    gnc_split_register_set_data (ld->reg, ld, gnc_ledger_display_parent);

    splits = qof_query_run (ld->query);

    gnc_ledger_display_set_watches (ld, splits);

    gnc_ledger_display_refresh_internal (ld, splits);

    return ld;
}
Ejemplo n.º 6
0
static GNCLedgerDisplay2 *
gnc_ledger_display2_internal (Account *lead_account, Query *q,
                             GNCLedgerDisplay2Type ld_type,
                             SplitRegisterType2 reg_type,
                             SplitRegisterStyle2 style,
                             gboolean use_double_line,
                             gboolean is_template )
{
    GNCLedgerDisplay2 *ld;
    gint limit;
    const char *klass;
//    GList *splits;
    gboolean display_subaccounts = FALSE;
    gboolean is_gl = FALSE;

    switch (ld_type)
    {
    case LD2_SINGLE:
        klass = REGISTER_SINGLE_CM_CLASS;

        if (reg_type >= NUM_SINGLE_REGISTER_TYPES2)
        {
            PERR ("single-account register with wrong split register type");
            return NULL;
        }

        if (!lead_account)
        {
            PERR ("single-account register with no account specified");
            return NULL;
        }

        if (q)
        {
            PWARN ("single-account register with external query");
            q = NULL;
        }

        ld = gnc_find_first_gui_component (klass, find_by_leader, lead_account);
        if (ld)
            return ld;

        break;

    case LD2_SUBACCOUNT:
        klass = REGISTER_SUBACCOUNT_CM_CLASS;

        if (!lead_account)
        {
            PERR ("sub-account register with no lead account");
            return NULL;
        }

        if (q)
        {
            PWARN ("account register with external query");
            q = NULL;
        }

        ld = gnc_find_first_gui_component (klass, find_by_leader, lead_account);
        if (ld)
            return ld;

        display_subaccounts = TRUE;
        break;

    case LD2_GL:
        klass = REGISTER_GL_CM_CLASS;

        if (!q)
        {
            PWARN ("general journal with no query");
        }

        is_gl = TRUE;
        break;

    default:
        PERR ("bad ledger type: %d", ld_type);
        return NULL;

    }

    ld = g_new (GNCLedgerDisplay2, 1);

    ld->leader = *xaccAccountGetGUID (lead_account);
    ld->query = NULL;
    ld->ld_type = ld_type;
    ld->loading = FALSE;
    ld->refresh_ok = FALSE;
    ld->destroy = NULL;
    ld->get_parent = NULL;
    ld->user_data = NULL;

    limit = gnc_prefs_get_float(GNC_PREFS_GROUP_GENERAL_REGISTER, GNC_PREF_MAX_TRANS);

    /* set up the query filter */
    if (q)
        ld->query = qof_query_copy (q);
    else
        gnc_ledger_display2_make_query (ld, limit, reg_type);

    ld->component_id = gnc_register_gui_component (klass,
                       refresh_handler,
                       close_handler, ld);

    /******************************************************************\
     * The main register window itself                                *
    \******************************************************************/

    ld->use_double_line_default = use_double_line;

    ld->model = gnc_tree_model_split_reg_new (reg_type, style, use_double_line, is_template);

    gnc_tree_model_split_reg_set_data (ld->model, ld, gnc_ledger_display2_parent);
    gnc_tree_model_split_reg_set_display (ld->model, display_subaccounts, is_gl);

    // This sets up a call back to reload after changes
    g_signal_connect (G_OBJECT (ld->model), "refresh_trans",
                      G_CALLBACK (gnc_ledger_display2_refresh_cb), ld );

//FIXME Not Needed ?    gnc_ledger_display2_set_watches (ld, splits);
//    gnc_ledger_display2_set_watches (ld, splits);

    // Populate the model with an empty split
    // An empty model could cause our gui callbacks to crash
    gnc_ledger_display2_refresh_internal (ld, NULL);

    return ld;
}
Ejemplo n.º 7
0
static void
gnc_search_dialog_display_results (GNCSearchWindow *sw)
{
    gdouble max_count;

    /* Check if this is the first time this is called for this window.
     * If so, then build the results sub-window, the scrolled treeview,
     * and the active buttons.
     */
    if (sw->result_view == NULL)
    {
        GtkWidget *scroller, *frame, *button_box, *button;

        /* Create the view */
        gnc_search_dialog_init_result_view (sw);

        frame = gtk_frame_new(NULL);

        /* Create the scroller and add the view to the scroller */
        scroller = gtk_scrolled_window_new (NULL, NULL);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroller),
                                        GTK_POLICY_AUTOMATIC,
                                        GTK_POLICY_AUTOMATIC);
        gtk_widget_set_size_request(GTK_WIDGET(scroller), 300, 100);
        gtk_container_add (GTK_CONTAINER (scroller), sw->result_view);
        gtk_container_add(GTK_CONTAINER(frame), scroller);

        /* Create the button_box */
        button_box = gtk_vbox_new (FALSE, 3);

        /* ... and add all the buttons */
        if (sw->buttons)
        {
            int i;

            button = gtk_button_new_with_label (_("Select"));
            g_signal_connect (G_OBJECT (button), "clicked",
                              G_CALLBACK (gnc_search_dialog_select_cb), sw);
            gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 3);
            sw->select_button = button;

            for (i = 0; sw->buttons[i].label; i++)
            {
                GNCSearchCallbackButton* button_spec = sw->buttons + i;
                button = gtk_button_new_with_label (_(button_spec->label));
                g_object_set_data (G_OBJECT (button), "data", button_spec);

                if (qof_book_is_readonly (gnc_get_current_book ()))
                    gtk_widget_set_sensitive (GTK_WIDGET(button), button_spec->sensitive_if_readonly);

                /* Save the button pointer */
                sw->button_list = g_list_append(sw->button_list, button);

                g_signal_connect (G_OBJECT (button), "clicked",
                                  G_CALLBACK (gnc_search_dialog_result_clicked), sw);
                gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 3);
            }
        }

        /* Add the scrolled-view and button-box to the results_box */
        gtk_box_pack_end (GTK_BOX (sw->result_hbox), button_box, FALSE, FALSE, 3);
        gtk_box_pack_end (GTK_BOX (sw->result_hbox), frame, TRUE, TRUE, 3);

        /* And show the results */
        gtk_widget_show_all (sw->result_hbox);

        /* But may be hide the select button */
        if (!sw->selected_cb)
            gtk_widget_hide (sw->select_button);
    }
    else
        /* Update the query in the view */
        gnc_query_view_reset_query (GNC_QUERY_VIEW(sw->result_view), sw->q);

    /* Deselect all the select buttons and any items */
    gnc_search_dialog_select_buttons_enable (sw, 0);
    gnc_query_view_unselect_all (GNC_QUERY_VIEW(sw->result_view));

    /* set 'new search' if fewer than max_count items is returned. */
    max_count = gnc_prefs_get_float(GNC_PREFS_GROUP_SEARCH_GENERAL, GNC_PREF_NEW_SEARCH_LIMIT);
    if (gnc_query_view_get_num_entries(GNC_QUERY_VIEW(sw->result_view)) < max_count)
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (sw->new_rb), TRUE);
}