diff --git a/ChangeLog b/ChangeLog index 4cb2695a5f..de9260c2e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2002-11-24 Joshua Sled + + * src/gnome/druid-loan.c (ld_rev_prep): Initial support for a + payment schedule review page, addressing Bug#98966. + + * src/gnome/dialog-scheduledxaction.c (putSchedXactionInDialog): + Don't double-free dates; fixes Bug#99452. + + * src/gnome/gnc-split-reg.c (gnc_split_reg_jump_to_split) + (gnc_split_reg_jump_to_split_amount, gnc_split_reg_record) + (gsr_emit_include_date_signal): + * src/gnome/window-register.c (gnc_register_include_date_adapter): + Add back in support for including a date in the range + limited/viewed by the window-register. + + * src/gnome/gnc-split-reg.c (gnc_split_reg_get_read_only) + * src/gnome/window-register.c (regWindowLedger): Change manner of + setting window-title in read-only-register case so the + gnc-split-reg isn't changing the window-titles of windows it has + no authority over. Fixed Bug#99396. + 2002-11-25 Benoit Grégoire * src/import-export/*.c,h: Split gnc-generic-import.h in one header per file. diff --git a/src/engine/FreqSpec.c b/src/engine/FreqSpec.c index bab0b83a9d..8493ab31d6 100644 --- a/src/engine/FreqSpec.c +++ b/src/engine/FreqSpec.c @@ -707,7 +707,6 @@ xaccFreqSpecGetFreqStr( FreqSpec *fs, GString *str ) char *tmpStr; int i; - /* FIXME: fill in. */ switch( xaccFreqSpecGetUIType( fs ) ) { case UIFREQ_ONCE: tmpStr = g_new0( char, GDATE_STRING_BUF_SIZE ); diff --git a/src/engine/gnc-session.c b/src/engine/gnc-session.c index 93a958ce77..3083ab69d6 100644 --- a/src/engine/gnc-session.c +++ b/src/engine/gnc-session.c @@ -751,8 +751,8 @@ gnc_session_destroy (GNCSession *session) gnc_book_destroy (book); } - session->books = NULL; - current_session=NULL; + session->books = NULL; + current_session = NULL; xaccLogEnable(); diff --git a/src/gnome/dialog-scheduledxaction.c b/src/gnome/dialog-scheduledxaction.c index c6c276b188..5cd9841084 100644 --- a/src/gnome/dialog-scheduledxaction.c +++ b/src/gnome/dialog-scheduledxaction.c @@ -1816,7 +1816,6 @@ putSchedXactionInDialog( gpointer data, gpointer user_data ) GDate **instArray; GList *instList; guint gdcMarkTag, oldMarkTag; - gboolean createdNextInstDate = FALSE; sx = (SchedXaction*)data; sxd = (SchedXactionDialog*)user_data; @@ -1836,7 +1835,6 @@ putSchedXactionInDialog( gpointer data, gpointer user_data ) generate_instances( sx, calEndDate, &instList ); g_date_free( calEndDate ); - /* cleanup the date memory, here... */ if ( instList == NULL ) { /* This was a bug [#90326]; while we do want to generate * instances within the visible calendar range, we also want @@ -1844,7 +1842,6 @@ putSchedXactionInDialog( gpointer data, gpointer user_data ) * calendar range. Thus, if the generate_instances above * returns nothing, double-check with the SX. */ nextInstDate = g_date_new(); - createdNextInstDate = TRUE; *nextInstDate = xaccSchedXactionGetNextInstance( sx, NULL ); if ( g_date_valid( nextInstDate ) ) { instList = g_list_append( instList, @@ -1856,7 +1853,7 @@ putSchedXactionInDialog( gpointer data, gpointer user_data ) g_string_sprintf( nextDate, "not scheduled" ); } else { char tmpBuf[ MAX_DATE_LENGTH+1 ]; - char dowBuf[ 25 ]; /* <- fixme: appropriate length? */ + char dowBuf[ 25 ]; /* <- FIXME: appropriate length? */ nextInstDate = (GDate*)instList->data; printGDate( tmpBuf, nextInstDate ); g_date_strftime( dowBuf, 25, "%A", nextInstDate ); @@ -1886,9 +1883,7 @@ putSchedXactionInDialog( gpointer data, gpointer user_data ) g_free( instArray ); g_list_foreach( instList, _gnc_sxd_free_dates, NULL ); g_list_free( instList ); - if ( createdNextInstDate ) { - g_free( nextInstDate ); - } + nextInstDate = NULL; } text[0] = xaccSchedXactionGetName( sx ); diff --git a/src/gnome/druid-loan.c b/src/gnome/druid-loan.c index a5faa273d4..aa79f473e5 100644 --- a/src/gnome/druid-loan.c +++ b/src/gnome/druid-loan.c @@ -83,7 +83,10 @@ # define PAY_TXN_PART_RB "pay_txn_part_rb" # define PAY_UNIQ_FREQ_RB "pay_uniq_freq_rb" # define PAY_FREQ_CONTAINER "pay_freq_align" - +#define PG_REVIEW "review_pg" +# define REV_SCROLLWIN "rev_scrollwin" +# define REV_RANGE_OPT "rev_range_opt" +# define REV_RANGE_TABLE "rev_date_range_table" #define OPT_VBOX_SPACING 2 static short module = MOD_SX; @@ -209,46 +212,54 @@ typedef struct LoanDruidData_ { /* widgets */ /* prm = params */ - GtkTable *prmTable; + GtkTable *prmTable; GNCAccountSel *prmAccountGAS; GNCAmountEdit *prmOrigPrincGAE; GtkSpinButton *prmIrateSpin; GtkOptionMenu *prmType; - GtkFrame *prmVarFrame; - GNCFrequency *prmVarGncFreq; - GNCDateEdit *prmStartDateGDE; + GtkFrame *prmVarFrame; + GNCFrequency *prmVarGncFreq; + GNCDateEdit *prmStartDateGDE; GtkSpinButton *prmLengthSpin; GtkOptionMenu *prmLengthType; GtkSpinButton *prmRemainSpin; /* opt = options */ - GtkVBox *optVBox; + GtkVBox *optVBox; GtkCheckButton *optEscrowCb; - GtkHBox *optEscrowHBox; - GNCAccountSel *optEscrowGAS; + GtkHBox *optEscrowHBox; + GNCAccountSel *optEscrowGAS; /* rep = repayment */ - GtkEntry *repTxnName; - GtkTable *repTable; - GtkEntry *repAmtEntry; + GtkEntry *repTxnName; + GtkTable *repTable; + GtkEntry *repAmtEntry; GNCAccountSel *repAssetsFromGAS; GNCAccountSel *repPrincToGAS; GNCAccountSel *repIntToGAS; GtkOptionMenu *repRemainderOpt; - GtkFrame *repFreqFrame; - GNCFrequency *repGncFreq; + GtkFrame *repFreqFrame; + GNCFrequency *repGncFreq; /* pay = payment[s] */ - GtkEntry *payTxnName; + GtkEntry *payTxnName; GnomeNumberEntry *payAmtGNE; - GtkEntry *payAmtEntry; - GNCAccountSel *payAcctFromGAS; - GNCAccountSel *payAcctToGAS; - GtkTable *payTable; - GtkRadioButton *payTxnFreqPartRb; - GtkRadioButton *payTxnFreqUniqRb; - GtkAlignment *payFreqAlign; - GNCFrequency *payGncFreq; + GtkEntry *payAmtEntry; + GNCAccountSel *payAcctFromGAS; + GNCAccountSel *payAcctToGAS; + GtkTable *payTable; + GtkRadioButton *payTxnFreqPartRb; + GtkRadioButton *payTxnFreqUniqRb; + GtkAlignment *payFreqAlign; + GNCFrequency *payGncFreq; + + /* rev = review */ + GtkOptionMenu *revRangeOpt; + GtkTable *revTable; + GNCDateEdit *revStartDate; + GNCDateEdit *revEndDate; + GtkScrolledWindow *revScrollWin; + GtkCList *revCL; } LoanDruidData; static void gnc_loan_druid_data_init( LoanDruidData *ldd ); @@ -268,6 +279,9 @@ static void ld_escrow_toggled( GtkToggleButton *tb, gpointer ud ); static void ld_pay_freq_toggle( GtkToggleButton *tb, gpointer ud ); +static void ldd_rev_range_opt_changed( GtkButton *b, gpointer ud ); +static void ldd_rev_range_changed( GNCDateEdit *gde, gpointer ud ); + static gboolean ld_info_save( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); static void ld_info_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); static gboolean ld_opts_tran( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); @@ -275,11 +289,13 @@ static void ld_opts_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); static gboolean ld_rep_next ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); static void ld_rep_prep ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); static gboolean ld_rep_back ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); -static void ld_rep_fin ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); static gboolean ld_pay_next ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); static void ld_pay_prep ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); static gboolean ld_pay_back ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); -static void ld_pay_fin ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); +static gboolean ld_rev_next ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); +static void ld_rev_prep ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); +static gboolean ld_rev_back ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); +static void ld_rev_fin ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ); static void ld_create_sxes( LoanDruidData *ldd ); @@ -353,21 +369,39 @@ gnc_ui_sx_loan_druid_create(void) } } - /* The GNCDateEdit */ + /* The GNCDateEdit[s] */ { - ldd->prmStartDateGDE = - GNC_DATE_EDIT( - gnc_date_edit_new( time(NULL), - FALSE, FALSE ) ); - gtk_table_attach( ldd->prmTable, - GTK_WIDGET( ldd->prmStartDateGDE ), - 1, 2, 4, 5, - (GTK_EXPAND | GTK_FILL), - GTK_FILL, 0, 0 ); + /* "gde" == GNCDateEdit */ + struct gde_in_tables_data { + GNCDateEdit **loc; + GtkTable *table; + int left, right, top, bottom; + } gde_data[] = { + /* These ints are the GtkTable boundries */ + { &ldd->prmStartDateGDE, ldd->prmTable, 1, 2, 4, 5 }, + { &ldd->revStartDate, ldd->revTable, 1, 2, 0, 1 }, + { &ldd->revEndDate, ldd->revTable, 1, 2, 1, 2 }, + { NULL } + }; + + for ( i=0; gde_data[i].loc != NULL; i++ ) { + *gde_data[i].loc = + GNC_DATE_EDIT( + gnc_date_edit_new( time(NULL), + FALSE, FALSE ) ); + gtk_table_attach( gde_data[i].table, + GTK_WIDGET( *gde_data[i].loc ), + gde_data[i].left, + gde_data[i].right, + gde_data[i].top, + gde_data[i].bottom, + (GTK_EXPAND | GTK_FILL), + GTK_FILL, 0, 0 ); + } + } gtk_widget_set_sensitive( GTK_WIDGET(ldd->prmVarFrame), FALSE ); - { GtkAlignment *a; GNCOptionInfo typeOptInfo[] = { @@ -420,6 +454,7 @@ gnc_ui_sx_loan_druid_create(void) gnc_option_menu_init( GTK_WIDGET(ldd->prmType) ); gnc_option_menu_init( GTK_WIDGET(ldd->prmLengthType) ); gnc_option_menu_init( GTK_WIDGET(ldd->repRemainderOpt) ); + gnc_option_menu_init( GTK_WIDGET(ldd->revRangeOpt) ); gtk_signal_connect( GTK_OBJECT(ldd->optEscrowCb), "toggled", GTK_SIGNAL_FUNC(ld_escrow_toggle), ldd ); @@ -519,6 +554,24 @@ gnc_ui_sx_loan_druid_create(void) GTK_WIDGET(ldd->payGncFreq) ); } + /* Review page widget setup. */ + { + gtk_signal_connect( GTK_OBJECT( gtk_option_menu_get_menu( + ldd->revRangeOpt)), + "selection-done", + GTK_SIGNAL_FUNC( ldd_rev_range_opt_changed ), + ldd ); + gtk_signal_connect( GTK_OBJECT(ldd->revStartDate), + "date-changed", + GTK_SIGNAL_FUNC( ldd_rev_range_changed ), + ldd ); + gtk_signal_connect( GTK_OBJECT(ldd->revEndDate), + "date-changed", + GTK_SIGNAL_FUNC( ldd_rev_range_changed ), + ldd ); + + } + { static struct { char *pageName; @@ -530,8 +583,9 @@ gnc_ui_sx_loan_druid_create(void) } DRUID_HANDLERS[] = { { PG_INFO, ld_info_save, ld_info_prep, ld_info_save, NULL }, { PG_OPTS, ld_opts_tran, ld_opts_prep, ld_opts_tran, NULL }, - { PG_REPAYMENT, ld_rep_next, ld_rep_prep, ld_rep_back, ld_rep_fin }, - { PG_PAYMENT, ld_pay_next, ld_pay_prep, ld_pay_back, ld_pay_fin }, + { PG_REPAYMENT, ld_rep_next, ld_rep_prep, ld_rep_back, NULL }, + { PG_PAYMENT, ld_pay_next, ld_pay_prep, ld_pay_back, NULL }, + { PG_REVIEW, ld_rev_next, ld_rev_prep, ld_rev_back, ld_rev_fin }, { NULL } }; @@ -646,7 +700,6 @@ gnc_loan_druid_get_widgets( LoanDruidData *ldd ) g_assert( ldd->gxml != NULL ); /* Get all widgets */ - #define GET_CASTED_WIDGET( cast, name ) \ (cast( glade_xml_get_widget( ldd->gxml, name ) )) @@ -657,8 +710,7 @@ gnc_loan_druid_get_widgets( LoanDruidData *ldd ) GET_CASTED_WIDGET( GTK_SPIN_BUTTON, IRATE_SPIN ); ldd->prmVarFrame = GET_CASTED_WIDGET( GTK_FRAME, VAR_CONTAINER ); - /*ldd->prmStartDateGDE = - GET_CASTED_WIDGET( GNOME_DATE_EDIT, START_DATE );*/ + /* ldd->prmStartDateGDE */ ldd->prmLengthSpin = GET_CASTED_WIDGET( GTK_SPIN_BUTTON, LENGTH_SPIN ); ldd->prmLengthType = @@ -701,6 +753,17 @@ gnc_loan_druid_get_widgets( LoanDruidData *ldd ) GET_CASTED_WIDGET( GTK_RADIO_BUTTON, PAY_UNIQ_FREQ_RB ); ldd->payFreqAlign = GET_CASTED_WIDGET( GTK_ALIGNMENT, PAY_FREQ_CONTAINER ); + + /* rev = review */ + ldd->revRangeOpt = + GET_CASTED_WIDGET( GTK_OPTION_MENU, REV_RANGE_OPT ); + ldd->revTable = + GET_CASTED_WIDGET( GTK_TABLE, REV_RANGE_TABLE ); + /* GNCDateEdit *revStartDate */ + /* GNCDateEdit *revEndDate */ + ldd->revScrollWin = + GET_CASTED_WIDGET( GTK_SCROLLED_WINDOW, REV_SCROLLWIN ); + } static @@ -1051,11 +1114,28 @@ ld_rep_next( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) ldd = (LoanDruidData*)ud; if ( ld_rep_save( ldd ) != FALSE ) { + DEBUG( "Couldn't save, stopping here." ); return TRUE; } - ldd->currentIdx++; - return FALSE; + { + int i; + gboolean haveMoreRepayOpts = FALSE; + for ( i = ldd->currentIdx + 1; + (i < ldd->ld.repayOptCount) && !haveMoreRepayOpts; + i++ ) { + haveMoreRepayOpts |= ldd->ld.repayOpts[i]->enabled; + } + if ( haveMoreRepayOpts ) { + ldd->currentIdx++; + return FALSE; + } + } + gnome_druid_set_page( ldd->druid, + GNOME_DRUID_PAGE( + glade_xml_get_widget( ldd->gxml, + PG_REVIEW ) ) ); + return TRUE; } static @@ -1073,22 +1153,22 @@ void ld_rep_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) { LoanDruidData *ldd; + GString *str; ldd = (LoanDruidData*)ud; - if ( !ldd->ld.repAmount ) { - GString *str; - str = g_string_sized_new( 64 ); - - g_string_sprintfa( str, "pmt( %.5f / 12 : %d : %0.2f : 0 : 0 )", - (ldd->ld.interestRate / 100), - ldd->ld.numPer, - gnc_numeric_to_double(ldd->ld.principal) ); - - ldd->ld.repAmount = str->str; - g_string_free( str, FALSE ); + if ( ldd->ld.repAmount ) { + g_free( ldd->ld.repAmount ); } + str = g_string_sized_new( 64 ); + g_string_sprintfa( str, "pmt( %.5f / 12 : %d : %0.2f : 0 : 0 )", + (ldd->ld.interestRate / 100), + ldd->ld.numPer, + gnc_numeric_to_double(ldd->ld.principal) ); + ldd->ld.repAmount = str->str; + g_string_free( str, FALSE ); + if ( ldd->ld.repMemo ) gtk_entry_set_text( ldd->repTxnName, ldd->ld.repMemo ); @@ -1107,6 +1187,7 @@ ld_rep_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) ldd->ld.repFreq, ldd->ld.repStartDate ); +#if 0 /* no longer needed */ { int i; gboolean haveRepayOpts = FALSE; @@ -1116,15 +1197,7 @@ ld_rep_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) } gnome_druid_set_show_finish( ldd->druid, !haveRepayOpts ); } -} - -static -void -ld_rep_fin( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) -{ - LoanDruidData *ldd = (LoanDruidData*)ud; - ld_rep_save( ldd ); - ld_create_sxes( ldd ); +#endif /* 0 -- no longer needed */ } static @@ -1167,6 +1240,8 @@ ld_pay_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) rod->fs, rod->startDate ); } +#if 0 /* no longer needed to set this up; all transitions are to the review + * page. */ { gboolean haveMoreRepayOpts = FALSE; int i = 0; @@ -1177,6 +1252,8 @@ ld_pay_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) } gnome_druid_set_show_finish( ldd->druid, !haveMoreRepayOpts ); } +#endif /* 0 -- no longer needed to set this up; all transitions are to the + * review page. */ g_string_free( str, TRUE ); } @@ -1268,16 +1345,24 @@ ld_pay_next( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) } /* Go through opts list and select next enabled option. */ - for ( i=(++ldd->currentIdx); + for ( i = ldd->currentIdx + 1; (i < ldd->ld.repayOptCount) && !ldd->ld.repayOpts[i]->enabled; i++ ) ; - if ( i != ldd->ld.repayOptCount ) { + + if ( i < ldd->ld.repayOptCount ) { ldd->currentIdx = i; ld_pay_prep( gdp, arg1, ud ); return TRUE; } - return FALSE; + + /* If there's no repayment options enabled, then go immediately to + * the review page. */ + gnome_druid_set_page( ldd->druid, + GNOME_DRUID_PAGE( + glade_xml_get_widget( ldd->gxml, + PG_REVIEW ) ) ); + return TRUE; } static @@ -1294,11 +1379,13 @@ ld_pay_back( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) return TRUE; } + /* go back through opts list and select next enabled options. */ for ( i=(--ldd->currentIdx); (i > -1) && !ldd->ld.repayOpts[i]->enabled; - i-- ) { - } - if ( i != -1 ) { + i-- ) + ; + + if ( i >= 0 ) { ldd->currentIdx = i; ld_pay_prep( gdp, arg1, ud ); return TRUE; @@ -1306,18 +1393,6 @@ ld_pay_back( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) return FALSE; } -static -void -ld_pay_fin( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) -{ - LoanDruidData *ldd = (LoanDruidData*)ud; - if ( ld_pay_save_current( ldd ) ) { - /* FIXME?: Error? */ - return; - } - ld_create_sxes( ldd ); -} - static void ld_pay_freq_toggle( GtkToggleButton *tb, gpointer ud ) @@ -1352,6 +1427,110 @@ ld_pay_freq_toggle( GtkToggleButton *tb, gpointer ud ) } } +static +gboolean +ld_rev_next( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) +{ + g_assert( FALSE ); + return TRUE; +} + +static +void +ld_rev_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) +{ + LoanDruidData *ldd = (LoanDruidData*)ud; + int i; + const static int BASE_COLS = 3; + int numCols = BASE_COLS; + gchar **titles; + int repayOptToColMap[ ( sizeof( REPAY_DEFAULTS ) + / sizeof( RepayOptDataDefault ) ) + - 1 ]; + + gnome_druid_set_show_finish( ldd->druid, TRUE ); + + /* Cleanup old clist */ + if ( ldd->revCL != NULL ) { + gtk_container_remove( GTK_CONTAINER(ldd->revScrollWin), + GTK_WIDGET(ldd->revCL) ); + ldd->revCL = NULL; + } + + /* Get the correct number of columns. */ + for ( i=0; i < ldd->ld.repayOptCount; i++ ) { + repayOptToColMap[i] = -1; + if ( !ldd->ld.repayOpts[i]->enabled ) { + continue; + } + numCols += 1; + repayOptToColMap[i] = numCols - 1; + } + titles = g_new0( gchar*, numCols ); + titles[0] = _( "Date" ); + titles[1] = _( "Principal" ); + titles[2] = _( "Interest" ); + /* move the appropriate names over into the title array */ + { + for ( i=0; i < ldd->ld.repayOptCount; i++ ) { + if ( repayOptToColMap[i] == -1 ) { + continue; + } + titles[ repayOptToColMap[i] ] = + ldd->ld.repayOpts[i]->name; + } + } + + ldd->revCL = GTK_CLIST( + gtk_clist_new_with_titles( numCols, + titles ) ); + + for( i=0; i < numCols; i++ ) { + gtk_clist_set_column_auto_resize( ldd->revCL, i, TRUE ); + } + gtk_container_add( GTK_CONTAINER(ldd->revScrollWin), + GTK_WIDGET(ldd->revCL) ); + gtk_widget_show_all( GTK_WIDGET(ldd->revCL) ); +} + +static +gboolean +ld_rev_back( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) +{ + LoanDruidData *ldd = (LoanDruidData*)ud; + int i; + + gnome_druid_set_show_finish( ldd->druid, FALSE ); + + /* Get the correct page based on the repayment state. */ + /* go back through opts list and select next enabled options. */ + for ( i = ldd->currentIdx; + (i > -1) && !ldd->ld.repayOpts[i]->enabled; + i-- ) { + } + if ( i >= 0 ) { + ldd->currentIdx = i; + /* natural transition to the payments page */ + return FALSE; + } + + /* If there are no payment options, then go directly to the main + * repayment page. */ + gnome_druid_set_page( ldd->druid, + GNOME_DRUID_PAGE( + glade_xml_get_widget( ldd->gxml, + PG_REPAYMENT ) ) ); + return TRUE; +} + +static +void +ld_rev_fin( GnomeDruidPage *gdp, gpointer arg1, gpointer ud ) +{ + LoanDruidData *ldd = (LoanDruidData*)ud; + ld_create_sxes( ldd ); +} + static void ld_gnc_ttinfo_free( gpointer data, gpointer ud ) @@ -1649,3 +1828,17 @@ ld_calc_upd_rem_payments( GtkWidget *w, gpointer ud ) remain = total - i; gtk_spin_button_set_value( ldd->prmRemainSpin, remain ); } + +static +void +ldd_rev_range_opt_changed( GtkButton *b, gpointer ud ) +{ + DEBUG( "FIXME" ); +} + +static +void +ldd_rev_range_changed( GNCDateEdit *gde, gpointer ud ) +{ + DEBUG( "FIXME" ); +} diff --git a/src/gnome/glade/sched-xact.glade b/src/gnome/glade/sched-xact.glade index 01ef4cf8f9..e3135703d4 100644 --- a/src/gnome/glade/sched-xact.glade +++ b/src/gnome/glade/sched-xact.glade @@ -4095,7 +4095,7 @@ Postpone GtkFrame to_create_txn_reg_frame - + 0.05 GTK_SHADOW_ETCHED_IN @@ -5547,6 +5547,205 @@ Escrow + + + GnomeDruidPageStandard + review_pg + Review + 255,255,255 + 25,25,112 + 255,255,255 + + + GtkVBox + GnomeDruidPageStandard:vbox + druid-vbox14 + False + 0 + + 0 + True + True + + + + GtkVBox + vbox177 + False + 0 + + 0 + True + True + + + + GtkHBox + hbox176 + False + 0 + + 0 + False + False + + + + GtkHBox + hbox178 + False + 0 + + 0 + False + False + + + + GtkLabel + label847973 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 5 + 5 + + 0 + False + False + + + + + GtkVBox + vbox178 + False + 0 + + 0 + True + True + + + + GtkOptionMenu + rev_range_opt + True + Current Year +Now + 1 Year +Whole Loan +Custom + + 0 + + 0 + True + False + + + + + + + GtkFrame + frame93 + 2 + False + + 0.05 + GTK_SHADOW_ETCHED_IN + + 2 + True + True + + + + GtkTable + rev_date_range_table + 2 + 2 + False + 0 + 0 + + + GtkLabel + label847971 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 5 + 5 + + 0 + 1 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label847972 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 5 + 5 + + 0 + 1 + 1 + 2 + 0 + 0 + False + False + False + False + True + False + + + + + + + + GtkScrolledWindow + rev_scrollwin + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + Placeholder + + + + + diff --git a/src/gnome/gnc-split-reg.c b/src/gnome/gnc-split-reg.c index 8427744c96..61cc46533e 100644 --- a/src/gnome/gnc-split-reg.c +++ b/src/gnome/gnc-split-reg.c @@ -67,7 +67,7 @@ static short module = MOD_SX; * X fill out gnc-split-reg.h interface * X calendar/date-picker * . beta-necessary - * . date-inclusion on jumping + * X date-inclusion on jumping * . pass in, use number-of-lines * . title-renaming in read-only case. * X size-allocation @@ -143,9 +143,9 @@ void gsr_default_copy_txn_handler ( GNCSplitReg *w, gpointer ud ); void gsr_default_paste_handler ( GNCSplitReg *w, gpointer ud ); void gsr_default_paste_txn_handler( GNCSplitReg *w, gpointer ud ); -static void gsr_emit_signal( GNCSplitReg *gsr, const char *sigName ); +static void gsr_emit_simple_signal( GNCSplitReg *gsr, const char *sigName ); static void gsr_emit_help_changed( GnucashRegister *reg, gpointer user_data ); - +static void gsr_emit_include_date_signal( GNCSplitReg *gsr, time_t date ); void gnc_split_reg_cut_cb(GtkWidget *w, gpointer data); void gnc_split_reg_copy_cb(GtkWidget *w, gpointer data); @@ -239,6 +239,7 @@ enum gnc_split_reg_signal_enum { PASTE_SIGNAL, PASTE_TXN_SIGNAL, HELP_CHANGED_SIGNAL, + INCLUDE_DATE_SIGNAL, LAST_SIGNAL }; @@ -270,18 +271,30 @@ gnc_split_reg_class_init( GNCSplitRegClass *class ) { PASTE_SIGNAL, "paste", GTK_SIGNAL_OFFSET( GNCSplitRegClass, paste_cb ) }, { PASTE_TXN_SIGNAL, "paste_txn", GTK_SIGNAL_OFFSET( GNCSplitRegClass, paste_txn_cb ) }, { HELP_CHANGED_SIGNAL, "help-changed", GTK_SIGNAL_OFFSET( GNCSplitRegClass, help_changed_cb ) }, + { INCLUDE_DATE_SIGNAL, "include-date", GTK_SIGNAL_OFFSET( GNCSplitRegClass, include_date_cb ) }, { LAST_SIGNAL, NULL, 0 } }; object_class = (GtkObjectClass*) class; - for ( i=0; signals[i].signal_name != NULL; i++ ) { + for ( i=0; signals[i].s != INCLUDE_DATE_SIGNAL; i++ ) { gnc_split_reg_signals[ signals[i].s ] = gtk_signal_new( signals[i].signal_name, GTK_RUN_LAST, object_class->type, signals[i].defaultOffset, gtk_signal_default_marshaller, GTK_TYPE_NONE, 0 ); } + /* Setup the non-default-marshalled signals; 'i' is still valid, here. */ + /* "include-date" */ + gnc_split_reg_signals[ INCLUDE_DATE_SIGNAL ] = + gtk_signal_new( "include-date", + GTK_RUN_LAST, + object_class->type, + signals[i++].defaultOffset, + gtk_marshal_NONE__INT, /* time_t == int */ + GTK_TYPE_NONE, 1, GTK_TYPE_INT ); + + g_assert( i == LAST_SIGNAL ); gtk_object_class_add_signals (object_class, gnc_split_reg_signals, LAST_SIGNAL); @@ -303,6 +316,7 @@ gnc_split_reg_class_init( GNCSplitRegClass *class ) class->paste_txn_cb = gsr_default_paste_txn_handler; class->help_changed_cb = NULL; + class->include_date_cb = NULL; } GtkWidget* @@ -723,11 +737,6 @@ gsr_redraw_all_cb (GnucashRegister *g_reg, gpointer data) } } - /* FIXME */ -#if 0 /* FIXME */ - gnc_reg_set_window_name( gsr ); -#endif /* 0 -- FIXME */ - { gboolean expand; gboolean sensitive; @@ -838,7 +847,7 @@ void gnc_split_reg_cut_cb (GtkWidget *w, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "cut" ); + gsr_emit_simple_signal( gsr, "cut" ); } void @@ -854,7 +863,7 @@ void gnc_split_reg_copy_cb (GtkWidget *w, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "copy" ); + gsr_emit_simple_signal( gsr, "copy" ); } void @@ -870,7 +879,7 @@ void gnc_split_reg_paste_cb (GtkWidget *w, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "paste" ); + gsr_emit_simple_signal( gsr, "paste" ); } void @@ -887,7 +896,7 @@ void gnc_split_reg_cut_trans_cb (GtkWidget *w, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "cut_txn" ); + gsr_emit_simple_signal( gsr, "cut_txn" ); } void @@ -904,7 +913,7 @@ void gnc_split_reg_copy_trans_cb(GtkWidget *w, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "copy_txn" ); + gsr_emit_simple_signal( gsr, "copy_txn" ); } void @@ -921,7 +930,7 @@ void gnc_split_reg_paste_trans_cb (GtkWidget *w, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "paste_txn" ); + gsr_emit_simple_signal( gsr, "paste_txn" ); } /* Remove when porting to gtk2.0 */ @@ -985,7 +994,7 @@ void gnc_split_reg_reinitialize_trans_cb(GtkWidget *widget, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "reinit_ent" ); + gsr_emit_simple_signal( gsr, "reinit_ent" ); } void @@ -1117,7 +1126,7 @@ void gnc_split_reg_delete_trans_cb(GtkWidget *widget, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "delete_ent" ); + gsr_emit_simple_signal( gsr, "delete_ent" ); } void @@ -1134,7 +1143,7 @@ void gnc_split_reg_duplicate_trans_cb(GtkWidget *w, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "dup_ent" ); + gsr_emit_simple_signal( gsr, "dup_ent" ); } /** @@ -1189,7 +1198,7 @@ void gnc_split_reg_recur_cb(GtkWidget *w, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "schedule_ent" ); + gsr_emit_simple_signal( gsr, "schedule_ent" ); } /** @@ -1199,7 +1208,7 @@ void gnc_split_reg_record_trans_cb (GtkWidget *w, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "enter_ent" ); + gsr_emit_simple_signal( gsr, "enter_ent" ); } void @@ -1216,7 +1225,7 @@ void gnc_split_reg_cancel_trans_cb(GtkWidget *w, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "cancel_ent" ); + gsr_emit_simple_signal( gsr, "cancel_ent" ); } void @@ -1252,14 +1261,14 @@ void gnc_split_reg_expand_trans_menu_cb (GtkWidget *widget, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "expand_ent" ); + gsr_emit_simple_signal( gsr, "expand_ent" ); } void gnc_split_reg_expand_trans_toolbar_cb (GtkWidget *widget, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "expand_ent" ); + gsr_emit_simple_signal( gsr, "expand_ent" ); } /** @@ -1275,13 +1284,8 @@ gnc_split_reg_jump_to_split(GNCSplitReg *gsr, Split *split) if (!gsr) return; trans = xaccSplitGetParent(split); -#if 0 /* FIXME */ - if (trans != NULL) - if (gnc_register_include_date(gsr, xaccTransGetDate(trans))) - { - gnc_ledger_display_refresh( gsr->ledger ); - } -#endif /* 0 -- FIXME */ + + gsr_emit_include_date_signal( gsr, xaccTransGetDate(trans) ); reg = gnc_ledger_display_get_split_register( gsr->ledger ); @@ -1300,18 +1304,12 @@ gnc_split_reg_jump_to_split_amount(GNCSplitReg *gsr, Split *split) { VirtualLocation virt_loc; SplitRegister *reg; + Transaction *trans; if (!gsr) return; -#if 0 /* FIXME */ trans = xaccSplitGetParent(split); - if (trans != NULL) { - if (gnc_register_include_date(gsr, xaccTransGetDate(trans))) - { - gnc_ledger_display_refresh (gsr->ledger); - } - } -#endif /* 0 -- FIXME */ + gsr_emit_include_date_signal( gsr, xaccTransGetDate(trans) ); reg = gnc_ledger_display_get_split_register (gsr->ledger); @@ -1355,7 +1353,7 @@ void gnc_split_reg_new_trans_cb (GtkWidget *widget, gpointer data) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "blank" ); + gsr_emit_simple_signal( gsr, "blank" ); } void @@ -1410,7 +1408,7 @@ void gnc_split_reg_jump_cb( GtkWidget *widget, gpointer data ) { GNCSplitReg *gsr = data; - gsr_emit_signal( gsr, "jump" ); + gsr_emit_simple_signal( gsr, "jump" ); } static @@ -1607,12 +1605,7 @@ gnc_split_reg_record (GNCSplitReg *gsr) if (!gnc_split_register_save (reg, TRUE)) return; - /* FIXME */ -#if 0 /* FIXME */ - if (trans != NULL) - gnc_split_reg_include_date( gsr, xaccTransGetDate(trans) ); -#endif /* 0 - FIXME */ - + gsr_emit_include_date_signal( gsr, xaccTransGetDate(trans) ); gnc_split_register_redraw (reg); } @@ -1697,7 +1690,7 @@ gsr_default_enter_handler( GNCSplitReg *gsr, gpointer data ) void gnc_split_reg_record_cb (GnucashRegister *reg, gpointer data) { - gsr_emit_signal( (GNCSplitReg*)data, "enter_ent" ); + gsr_emit_simple_signal( (GNCSplitReg*)data, "enter_ent" ); } void @@ -1988,9 +1981,7 @@ void gnc_split_reg_determine_read_only( GNCSplitReg *gsr ) { dialog_args *args = g_malloc(sizeof(dialog_args)); - gchar *old_title, *new_title; SplitRegister *reg; - GtkArg objarg; gsr->read_only = FALSE; @@ -1998,7 +1989,6 @@ gnc_split_reg_determine_read_only( GNCSplitReg *gsr ) /* FIXME: this is not ideal, as whatever window-title solution we come up * with should be used in this case as well. */ - gsr->read_only = TRUE; } else { @@ -2034,18 +2024,6 @@ gnc_split_reg_determine_read_only( GNCSplitReg *gsr ) reg = gnc_ledger_display_get_split_register( gsr->ledger ); gnc_split_register_set_read_only( reg, TRUE ); - /* Rename the window title */ - /* FIXME: This isn't so good ... this thing shouldn't be directing - * window-title changes ... especially for the SX-related stuff. */ - objarg.name = "GtkWindow::title"; - gtk_object_arg_get(GTK_OBJECT(gsr->window), &objarg, NULL); - old_title = GTK_VALUE_STRING(objarg); - new_title = g_strdup_printf(_("%s [Read-Only]"), old_title); - /*gtk_object_set(GTK_OBJECT(gsr->window), - * "GtkWindow::title", new_title, NULL); */ - gtk_window_set_title( GTK_WINDOW(gsr->window), new_title ); - g_free(old_title); - g_free(new_title); } static @@ -2109,12 +2087,19 @@ static void gsr_emit_help_changed( GnucashRegister *reg, gpointer user_data ) { - gsr_emit_signal( (GNCSplitReg*)user_data, "help-changed" ); + gsr_emit_simple_signal( (GNCSplitReg*)user_data, "help-changed" ); } static void -gsr_emit_signal( GNCSplitReg *gsr, const char *sigName ) +gsr_emit_include_date_signal( GNCSplitReg *gsr, time_t date ) +{ + gtk_signal_emit_by_name( GTK_OBJECT(gsr), "include-date", date, NULL ); +} + +static +void +gsr_emit_simple_signal( GNCSplitReg *gsr, const char *sigName ) { gtk_signal_emit_by_name( GTK_OBJECT(gsr), sigName, NULL ); } @@ -2138,6 +2123,7 @@ gnc_split_reg_get_sort_type( GNCSplitReg *gsr ) void gnc_split_reg_set_sort_type( GNCSplitReg *gsr, SortType t ) { + /* FIXME */ PERR( "unimplemented" ); } @@ -2201,6 +2187,7 @@ void gnc_split_reg_set_split_state( GNCSplitReg *gsr, gboolean split ) { g_assert( gsr ); + /* FIXME */ PERR( "Unimplemented" ); } @@ -2208,6 +2195,7 @@ void gnc_split_reg_set_double_line( GNCSplitReg *gsr, gboolean doubleLine ) { g_assert( gsr ); + /* FIXME */ PERR( "unimplemented" ); } @@ -2234,3 +2222,10 @@ gnc_split_reg_use_extended_popup( GNCSplitReg *gsr ) gtk_widget_show_all( popup ); } + +gboolean +gnc_split_reg_get_read_only( GNCSplitReg *gsr ) +{ + g_assert( gsr ); + return gsr->read_only; +} diff --git a/src/gnome/gnc-split-reg.h b/src/gnome/gnc-split-reg.h index 11bd54ea66..632a72f840 100644 --- a/src/gnome/gnc-split-reg.h +++ b/src/gnome/gnc-split-reg.h @@ -149,6 +149,7 @@ struct _GNCSplitRegClass { void (*paste_cb) ( GNCSplitReg *w, gpointer user_data ); void (*paste_txn_cb) ( GNCSplitReg *w, gpointer user_data ); void (*help_changed_cb) ( GNCSplitReg *w, gpointer user_data ); + void (*include_date_cb) ( GNCSplitReg *w, time_t date, gpointer user_data ); }; typedef enum { @@ -271,6 +272,13 @@ gboolean gnc_split_reg_check_close( GNCSplitReg *gsr ); void gnc_split_reg_raise( GNCSplitReg *gsr ); +/** + * Callers can use this to determine if they need to reflect some "read-only" + * status in the window which contains the GNCSplitReg. + * @return TRUE if the register is read-only, FALSE if not. + **/ +gboolean gnc_split_reg_get_read_only( GNCSplitReg *gsr ); + /* * Function to jump to various places in the register */ diff --git a/src/gnome/window-register.c b/src/gnome/window-register.c index a29d9b5c99..3f3e0c50be 100644 --- a/src/gnome/window-register.c +++ b/src/gnome/window-register.c @@ -183,6 +183,12 @@ static void gnc_register_insert_cloned_toolbar_elt( GtkToolbar *dstToolbar, gint idx ); static gboolean gnc_register_include_date(RegWindow *regData, time_t date); +static void gnc_register_include_date_adapter( GNCSplitReg *gsr, + time_t date, + gpointer user_data ); + +static void gnc_register_set_read_only( RegWindow *regData ); + static void gnc_reg_save_size (RegWindow *regData); @@ -830,7 +836,9 @@ regWindowLedger( GNCLedgerDisplay *ledger ) numRows = (guint)gnc_lookup_number_option ( "_+Advanced", "Number of Rows", 20.0 ); - gsr = gnc_split_reg_new( ledger, GTK_WINDOW(register_window), numRows, + gsr = gnc_split_reg_new( ledger, + GTK_WINDOW(register_window), + numRows, ( CREATE_TOOLBAR | CREATE_MENUS | CREATE_POPUP @@ -842,6 +850,9 @@ regWindowLedger( GNCLedgerDisplay *ledger ) GNOME_APP(register_window)->menubar = glade_xml_get_widget( xml, "gnc_register_menubar" ); gnc_reg_set_window_name( regData ); + if ( gnc_split_reg_get_read_only( regData->gsr ) ) { + gnc_register_set_read_only( regData ); + } show_all = gnc_lookup_boolean_option( "_+Advanced", "Show All Transactions", @@ -876,6 +887,11 @@ regWindowLedger( GNCLedgerDisplay *ledger ) GTK_SIGNAL_FUNC( gnc_register_help_changed_cb ), regData ); + /* The "include-date" and "read-only" signals. */ + gtk_signal_connect( GTK_OBJECT(regData->gsr), "include-date", + GTK_SIGNAL_FUNC( gnc_register_include_date_adapter ), + regData ); + /* The menu bar. Menu extension setup needs to come *after* that. */ gnc_register_setup_menu_widgets( regData, xml ); gnc_extensions_menu_setup_with_data( GNOME_APP(register_window), @@ -1287,6 +1303,16 @@ gnc_register_start_recn_cb(GtkWidget * w, gpointer data) recnWindow(regData->window, account); } +static +void +gnc_register_include_date_adapter( GNCSplitReg *gsr, time_t date, gpointer user_data ) +{ + RegWindow *regData; + regData = (RegWindow*) user_data; + if ( gnc_register_include_date( regData, date ) ) { + gnc_ledger_display_refresh( gsr->ledger ); + } +} static gboolean gnc_register_include_date(RegWindow *regData, time_t date) @@ -1318,6 +1344,23 @@ gnc_register_include_date(RegWindow *regData, time_t date) return changed; } +static +void +gnc_register_set_read_only( RegWindow *regData ) +{ + gchar *old_title, *new_title; + GtkArg objarg; + + objarg.name = "GtkWindow::title"; + gtk_object_arg_get(GTK_OBJECT(regData->window), &objarg, NULL); + old_title = GTK_VALUE_STRING(objarg); + new_title = g_strdup_printf(_("%s [Read-Only]"), old_title); + gtk_window_set_title( GTK_WINDOW(regData->window), new_title ); + g_free(old_title); + g_free(new_title); + + regData->read_only = TRUE; +} /********************************************************************\ * gnc_register_close_cb *