static gboolean sx_name_handler( xmlNodePtr node, gpointer sx_pdata ) { struct sx_pdata *pdata = sx_pdata; SchedXaction *sx = pdata->sx; gchar *tmp = dom_tree_to_text( node ); g_debug("sx named [%s]", tmp); g_return_val_if_fail( tmp, FALSE ); xaccSchedXactionSetName( sx, tmp ); g_free( tmp ); 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; }
static gint sxftd_init( SXFromTransInfo *sxfti ) { GtkWidget *w; const char *transName; gint pos; GList *schedule = NULL; time64 start_tt; struct tm *tmpTm; GDate date, nextDate; if ( ! sxfti->sx ) { return -1; } if ( ! sxfti->trans ) { return -2; } if ( xaccTransIsOpen( sxfti->trans ) ) { return SXFTD_ERRNO_OPEN_XACTION; } /* Setup Widgets */ { sxfti->ne_but = GTK_TOGGLE_BUTTON(gtk_builder_get_object(sxfti->builder, "never_end_button")); sxfti->ed_but = GTK_TOGGLE_BUTTON(gtk_builder_get_object(sxfti->builder, "end_on_date_button")); sxfti->oc_but = GTK_TOGGLE_BUTTON(gtk_builder_get_object(sxfti->builder, "n_occurrences_button")); sxfti->n_occurences = GTK_ENTRY(gtk_builder_get_object(sxfti->builder, "n_occurrences_entry")); } /* Get the name from the transaction, try that as the initial SX name. */ transName = xaccTransGetDescription( sxfti->trans ); xaccSchedXactionSetName( sxfti->sx, transName ); sxfti->name = GTK_ENTRY(gtk_builder_get_object(sxfti->builder, "name_entry" )); pos = 0; gtk_editable_insert_text( GTK_EDITABLE(sxfti->name), transName, (strlen(transName) * sizeof(char)), &pos ); sxfti_attach_callbacks(sxfti); /* Setup the example calendar and related data structures. */ { int num_marks = SXFTD_EXCAL_NUM_MONTHS * 31; w = GTK_WIDGET(gtk_builder_get_object(sxfti->builder, "ex_cal_frame" )); sxfti->dense_cal_model = gnc_dense_cal_store_new(num_marks); sxfti->example_cal = GNC_DENSE_CAL(gnc_dense_cal_new_with_model(GNC_DENSE_CAL_MODEL(sxfti->dense_cal_model))); g_object_ref_sink(sxfti->example_cal); g_assert(sxfti->example_cal); gnc_dense_cal_set_num_months( sxfti->example_cal, SXFTD_EXCAL_NUM_MONTHS ); gnc_dense_cal_set_months_per_col( sxfti->example_cal, SXFTD_EXCAL_MONTHS_PER_COL ); gtk_container_add( GTK_CONTAINER(w), GTK_WIDGET(sxfti->example_cal) ); } /* Setup the start and end dates as GNCDateEdits */ { GtkWidget *paramTable = GTK_WIDGET(gtk_builder_get_object(sxfti->builder, "param_table" )); sxfti->startDateGDE = GNC_DATE_EDIT( gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE)); gtk_table_attach( GTK_TABLE(paramTable), GTK_WIDGET( sxfti->startDateGDE ), 1, 2, 2, 3, (GTK_EXPAND | GTK_FILL), GTK_FILL, 0, 0 ); g_signal_connect( sxfti->startDateGDE, "date-changed", G_CALLBACK( sxftd_update_excal_adapt ), sxfti ); } { GtkWidget *endDateBox = GTK_WIDGET(gtk_builder_get_object(sxfti->builder, "end_date_hbox" )); sxfti->endDateGDE = GNC_DATE_EDIT( gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE)); gtk_box_pack_start( GTK_BOX( endDateBox ), GTK_WIDGET( sxfti->endDateGDE ), TRUE, TRUE, 0 ); g_signal_connect( sxfti->endDateGDE, "date-changed", G_CALLBACK( sxftd_update_excal_adapt ), sxfti ); } /* Setup the initial start date for user display/confirmation */ /* compute good initial date. */ start_tt = xaccTransGetDate( sxfti->trans ); gnc_gdate_set_time64( &date, start_tt ); sxfti->freq_combo = GTK_COMBO_BOX(gtk_builder_get_object(sxfti->builder, "freq_combo_box")); gtk_combo_box_set_active(GTK_COMBO_BOX(sxfti->freq_combo), 0); g_signal_connect( sxfti->freq_combo, "changed", G_CALLBACK(sxftd_freq_combo_changed), sxfti ); sxftd_update_schedule( sxfti, &date, &schedule); recurrenceListNextInstance(schedule, &date, &nextDate); recurrenceListFree(&schedule); start_tt = gnc_time64_get_day_start_gdate (&nextDate); gnc_date_edit_set_time( sxfti->startDateGDE, start_tt ); g_signal_connect( G_OBJECT(sxfti->name), "destroy", G_CALLBACK(sxftd_destroy), sxfti ); sxftd_update_example_cal( sxfti ); return 0; }
static gint sxftd_init( SXFromTransInfo *sxfti ) { GtkWidget *w; const char *transName; gint pos; GList *schedule = NULL; time_t start_tt; struct tm *tmpTm; GDate date, nextDate; if ( ! sxfti->sx ) { return -1; } if ( ! sxfti->trans ) { return -2; } if ( xaccTransIsOpen( sxfti->trans ) ) { return SXFTD_ERRNO_OPEN_XACTION; } sxfti_attach_callbacks(sxfti); /* Setup the example calendar and related data structures. */ { int num_marks = SXFTD_EXCAL_NUM_MONTHS * 31; w = GTK_WIDGET(glade_xml_get_widget( sxfti->gxml, SXFTD_EX_CAL_FRAME )); sxfti->dense_cal_model = gnc_dense_cal_store_new(num_marks); sxfti->example_cal = GNC_DENSE_CAL(gnc_dense_cal_new_with_model(GNC_DENSE_CAL_MODEL(sxfti->dense_cal_model))); g_object_ref_sink(sxfti->example_cal); g_assert(sxfti->example_cal); gnc_dense_cal_set_num_months( sxfti->example_cal, SXFTD_EXCAL_NUM_MONTHS ); gnc_dense_cal_set_months_per_col( sxfti->example_cal, SXFTD_EXCAL_MONTHS_PER_COL ); gtk_container_add( GTK_CONTAINER(w), GTK_WIDGET(sxfti->example_cal) ); } /* Setup the start and end dates as GNCDateEdits */ { GtkWidget *paramTable = glade_xml_get_widget( sxfti->gxml, SXFTD_PARAM_TABLE ); sxfti->startDateGDE = GNC_DATE_EDIT( gnc_date_edit_new( time( NULL ), FALSE, FALSE ) ); gtk_table_attach( GTK_TABLE(paramTable), GTK_WIDGET( sxfti->startDateGDE ), 1, 2, 2, 3, (GTK_EXPAND | GTK_FILL), GTK_FILL, 0, 0 ); g_signal_connect( sxfti->startDateGDE, "date-changed", G_CALLBACK( sxftd_update_excal_adapt ), sxfti ); } { GtkWidget *endDateBox = glade_xml_get_widget( sxfti->gxml, SXFTD_END_DATE_BOX ); sxfti->endDateGDE = GNC_DATE_EDIT( gnc_date_edit_new( time( NULL ), FALSE, FALSE ) ); gtk_box_pack_start( GTK_BOX( endDateBox ), GTK_WIDGET( sxfti->endDateGDE ), FALSE, TRUE, 0 ); g_signal_connect( sxfti->endDateGDE, "date-changed", G_CALLBACK( sxftd_update_excal_adapt ), sxfti ); } /* Get the name from the transaction, try that as the initial SX name. */ transName = xaccTransGetDescription( sxfti->trans ); xaccSchedXactionSetName( sxfti->sx, transName ); /* Setup the initial start date for user display/confirmation */ /* compute good initial date. */ start_tt = xaccTransGetDate( sxfti->trans ); g_date_set_time_t( &date, start_tt ); w = glade_xml_get_widget(sxfti->gxml, SXFTD_FREQ_COMBO_BOX); gtk_combo_box_set_active(GTK_COMBO_BOX(w), 0); g_signal_connect( w, "changed", G_CALLBACK(sxftd_freq_combo_changed), sxfti ); sxftd_update_schedule( sxfti, &date, &schedule); recurrenceListNextInstance(schedule, &date, &nextDate); recurrenceListFree(&schedule); tmpTm = g_new0( struct tm, 1 ); g_date_to_struct_tm( &nextDate, tmpTm ); start_tt = mktime( tmpTm ); g_free( tmpTm ); gnc_date_edit_set_time( sxfti->startDateGDE, start_tt ); w = glade_xml_get_widget( sxfti->gxml, SXFTD_NAME_ENTRY ); pos = 0; gtk_editable_insert_text( GTK_EDITABLE(w), transName, (strlen(transName) * sizeof(char)), &pos ); g_signal_connect( GTK_OBJECT(w), "destroy", G_CALLBACK(sxftd_destroy), sxfti ); sxftd_update_example_cal( sxfti ); return 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; } }