static gboolean
sx_advCreate_handler( xmlNodePtr node, gpointer sx_pdata )
{
    struct sx_pdata *pdata = sx_pdata;
    SchedXaction *sx = pdata->sx;
    gint64 advCreate;

    if ( ! dom_tree_to_integer( node, &advCreate ) )
    {
        return FALSE;
    }

    xaccSchedXactionSetAdvanceCreation( sx, advCreate );
    return TRUE;
}
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;
}
Exemple #3
0
static void
gnc_schedxaction_set_property (GObject         *object,
                               guint            prop_id,
                               const GValue     *value,
                               GParamSpec      *pspec)
{
    SchedXaction *sx;

    g_return_if_fail(GNC_IS_SCHEDXACTION(object));

    sx = GNC_SCHEDXACTION(object);
    g_assert (qof_instance_get_editlevel(sx));

    switch (prop_id)
    {
    case PROP_NAME:
        xaccSchedXactionSetName(sx, g_value_get_string(value));
        break;
    case PROP_ENABLED:
        xaccSchedXactionSetEnabled(sx, g_value_get_boolean(value));
        break;
    case PROP_NUM_OCCURANCE:
        xaccSchedXactionSetNumOccur(sx, g_value_get_int(value));
        break;
    case PROP_REM_OCCURANCE:
        xaccSchedXactionSetRemOccur(sx, g_value_get_int(value));
        break;
    case PROP_AUTO_CREATE:
        xaccSchedXactionSetAutoCreate(sx, g_value_get_boolean(value), sx->autoCreateNotify);
        break;
    case PROP_AUTO_CREATE_NOTIFY:
        xaccSchedXactionSetAutoCreate(sx, sx->autoCreateOption, g_value_get_boolean(value));
        break;
    case PROP_ADVANCE_CREATION_DAYS:
        xaccSchedXactionSetAdvanceCreation(sx, g_value_get_int(value));
        break;
    case PROP_ADVANCE_REMINDER_DAYS:
        xaccSchedXactionSetAdvanceReminder(sx, g_value_get_int(value));
        break;
    case PROP_START_DATE:
        /* Note: when passed through a boxed gvalue, the julian value of the date is copied.
           The date may appear invalid until a function requiring for dmy calculation is
           called. */
        xaccSchedXactionSetStartDate(sx, g_value_get_boxed(value));
        break;
    case PROP_END_DATE:
        /* Note: when passed through a boxed gvalue, the julian value of the date is copied.
           The date may appear invalid until a function requiring for dmy calculation is
           called. */
        xaccSchedXactionSetEndDate(sx, g_value_get_boxed(value));
        break;
    case PROP_LAST_OCCURANCE_DATE:
        /* Note: when passed through a boxed gvalue, the julian value of the date is copied.
           The date may appear invalid until a function requiring for dmy calculation is
           called. */
        xaccSchedXactionSetLastOccurDate(sx, g_value_get_boxed(value));
        break;
    case PROP_INSTANCE_COUNT:
        gnc_sx_set_instance_count(sx, g_value_get_int(value));
        break;
    case PROP_TEMPLATE_ACCOUNT:
        sx_set_template_account(sx, g_value_get_object(value));
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
        break;
    }
}