2002-10-21 Joshua Sled <jsled@asynchronous.org>

* src/gnome/dialog-scheduledxaction.c (gnc_sxed_update_cal): Check
	validatity of date before subsequent processing; fixes Bug#96467.

	* src/gnome-utils/gnc-dense-cal.c
	(gnc_dense_cal_mark)
	(gnc_dense_cal_mark_remove): Queue a re-draw when marks are added
	or removed; fixes Bug#96468.

	* src/gnome-utils/gnc-frequency.c (year_range_sels_changed): Emit
	"changed" signal when the year-range selections change; fixes
	Bug#96470.

	* src/gnome/dialog-scheduledxaction.c (gnc_sxed_check_consistent):
	Free the name str after we've used it [conrad-found, unfiled bug].

	* src/gnome-utils/gnc-dense-cal.c (populate_hover_window): Now
	more tolerant of mark sets without names.

	* src/gnome/druid-loan.c:
	* src/gnome/dialog-scheduledxaction.c: Cleaned up compilation
	warnings so -Werror can go back on soon.

	* src/gnome/window-main.c (gnc_main_window_create_menus): Reworded
	MenuItem for loan-repayment druid as per Chris' suggestion.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7370 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Joshua Sled 2002-10-22 06:18:58 +00:00
parent bd1e487913
commit 04d39a88cb
8 changed files with 172 additions and 148 deletions

View File

@ -1,3 +1,30 @@
2002-10-21 Joshua Sled <jsled@asynchronous.org>
* src/gnome/dialog-scheduledxaction.c (gnc_sxed_update_cal): Check
validatity of date before subsequent processing; fixes Bug#96467.
* src/gnome-utils/gnc-dense-cal.c
(gnc_dense_cal_mark)
(gnc_dense_cal_mark_remove): Queue a re-draw when marks are added
or removed; fixes Bug#96468.
* src/gnome-utils/gnc-frequency.c (year_range_sels_changed): Emit
"changed" signal when the year-range selections change; fixes
Bug#96470.
* src/gnome/dialog-scheduledxaction.c (gnc_sxed_check_consistent):
Free the name str after we've used it [conrad-found, unfiled bug].
* src/gnome-utils/gnc-dense-cal.c (populate_hover_window): Now
more tolerant of mark sets without names.
* src/gnome/druid-loan.c:
* src/gnome/dialog-scheduledxaction.c: Cleaned up compilation
warnings so -Werror can go back on soon.
* src/gnome/window-main.c (gnc_main_window_create_menus): Reworded
MenuItem for loan-repayment druid as per Chris' suggestion.
2002-10-21 Derek Atkins <derek@ihtfp.com>
* app-utils/options.scm -- fix (find-first-account) to search subaccounts

View File

@ -27,6 +27,7 @@
#include <time.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gnome.h>
#include "gnc-dense-cal.h"
/* For PERR, only... */
@ -800,6 +801,7 @@ gnc_dense_cal_expose( GtkWidget *widget,
/* draw the day labels */
maxWidth = gdk_string_width( dcal->monthLabelFont, "88" );
if ( dcal->x_scale > maxWidth ) {
/* FIXME: i18n */
static const gchar *dayLabels[7] = {
"Su", "M", "Tu", "W", "Th", "F", "Sa"
};
@ -898,7 +900,7 @@ populate_hover_window( GncDenseCal *dcal, gint doc )
gtk_clist_clear( cl );
for ( l = dcal->marks[doc]; l; l = l->next ) {
gdcmd = (gdc_mark_data*)l->data;
rowText[0] = gdcmd->name;
rowText[0] = ( gdcmd->name ? gdcmd->name : _("(unnamed)") );
rowText[1] = gdcmd->info;
gtk_clist_insert( cl, row++, rowText );
}
@ -1389,19 +1391,16 @@ gnc_dense_cal_mark( GncDenseCal *dcal,
return -1;
}
if ( name == NULL
|| strlen(name) == 0 ) {
PERR( "name must be reasonable\n" );
return -1;
}
newMark = g_new0( gdc_mark_data, 1 );
newMark->name = g_strdup(name);
newMark->info = NULL;
newMark->name = NULL;
if ( name ) {
newMark->name = g_strdup(name);
}
newMark->info = NULL;
if ( info ) {
newMark->info = g_strdup(info);
}
newMark->tag = dcal->lastMarkTag++;
newMark->tag = dcal->lastMarkTag++;
newMark->ourMarks = NULL;
for ( i=0; i<size; i++ ) {
@ -1420,6 +1419,7 @@ gnc_dense_cal_mark( GncDenseCal *dcal,
GINT_TO_POINTER(doc) );
}
dcal->markData = g_list_append( dcal->markData, (gpointer)newMark );
gtk_widget_queue_draw( GTK_WIDGET( dcal ) );
return newMark->tag;
}
@ -1457,4 +1457,5 @@ gnc_dense_cal_mark_remove( GncDenseCal *dcal, guint markToRemove )
g_list_free( gdcmd->ourMarks );
dcal->markData = g_list_remove( dcal->markData, gdcmd );
g_free( gdcmd );
gtk_widget_queue_draw( GTK_WIDGET(dcal) );
}

View File

@ -894,6 +894,8 @@ year_range_sels_changed( GNCFrequency *gf,
tmpTm->tm_mon += occur - (tmpTm->tm_mon % monthsInRange);
tmpTT = mktime( tmpTm );
gnome_date_edit_set_time( gf->startDate, tmpTT );
gtk_signal_emit_by_name( GTK_OBJECT(gf), "changed", NULL );
}
static void
@ -925,6 +927,7 @@ yearly_sel_changed( GtkButton *b, gpointer d )
tmptt = mktime( tmptm );
gnome_date_edit_set_time( gf->startDate, tmptt );
gtk_signal_emit_by_name( GTK_OBJECT(gf), "changed", NULL );
}

View File

@ -206,12 +206,6 @@ static void gnc_sxed_freq_changed( GNCFrequency *gf, gpointer ud );
static void sxed_excal_update_adapt( GtkObject *o, gpointer ud );
static void gnc_sxed_update_cal( SchedXactionEditorDialog *sxed );
/* ledger standard-handlers */
static gncUIWidget sxe_ledger_get_parent( GNCLedgerDisplay *ld );
static void sxed_reg_recordCB( GtkWidget *w, gpointer d );
static void sxed_reg_cancelCB( GtkWidget *w, gpointer d );
static void gnc_sxed_reg_check_close(SchedXactionEditorDialog *sxed);
static gboolean editor_component_sx_equality( gpointer find_data,
@ -684,6 +678,7 @@ gnc_sxed_check_consistent( SchedXactionEditorDialog *sxed )
_( "Please name the Scheduled Transaction." );
gnc_error_dialog_parented( GTK_WINDOW(sxed->dialog),
sx_has_no_name_msg );
g_free( name );
return FALSE;
}
@ -702,7 +697,6 @@ gnc_sxed_check_consistent( SchedXactionEditorDialog *sxed )
data );
nameExists |= ( g_strcasecmp(name, existingName) == 0 );
}
g_free( name );
if ( nameHasChanged && nameExists ) {
const char *sx_has_existing_name_msg =
_( "A Scheduled Transaction with the "
@ -712,9 +706,11 @@ gnc_sxed_check_consistent( SchedXactionEditorDialog *sxed )
if ( ! gnc_verify_dialog_parented( sxed->dialog, FALSE,
sx_has_existing_name_msg,
name) ) {
g_free( name );
return FALSE;
}
}
g_free( name );
}
{
@ -1907,44 +1903,6 @@ sxe_ledger_get_parent( GNCLedgerDisplay *ld )
return sxed->dialog;
}
static
void
sxed_reg_recordCB( GtkWidget *w, gpointer d )
{
SchedXactionEditorDialog *sxed = (SchedXactionEditorDialog*)d;
SplitRegister *reg;
Transaction *trans;
reg = gnc_ledger_display_get_split_register( sxed->ledger );
trans = gnc_split_register_get_current_trans( reg );
if ( !gnc_split_register_save( reg, TRUE ) )
return;
gnc_split_register_redraw( reg );
}
static
void
sxed_reg_cancelCB( GtkWidget *w, gpointer d )
{
gnc_split_register_cancel_cursor_trans_changes(
gnc_ledger_display_get_split_register
( ((SchedXactionEditorDialog *)d)->ledger ) );
}
/* FIXME */
static void
refactor_transaction_delete_toggle_cb(GtkToggleButton *button, gpointer data)
{
GtkWidget *text = gtk_object_get_user_data(GTK_OBJECT(button));
gchar *s = data;
gint pos = 0;
gtk_editable_delete_text(GTK_EDITABLE(text), 0, -1);
gtk_editable_insert_text(GTK_EDITABLE(text), s, strlen(s), &pos);
}
/********************************************************************\
* gnc_register_check_close *
* *
@ -1956,20 +1914,26 @@ gnc_sxed_reg_check_close(SchedXactionEditorDialog *sxed)
{
gboolean pending_changes;
SplitRegister *reg;
const char *message =
_("The current template transaction "
"has been changed.\n"
"Would you like to record the changes?");
reg = gnc_ledger_display_get_split_register (sxed->ledger);
pending_changes = gnc_split_register_changed (reg);
if (pending_changes) {
const char *message =
_("The current template transaction "
"has been changed.\n"
"Would you like to record the changes?");
if (gnc_verify_dialog_parented(sxed->dialog, TRUE, message)) {
sxed_reg_recordCB(sxed->dialog, sxed);
} else {
gnc_split_register_cancel_cursor_trans_changes (reg);
}
if (!pending_changes) {
return;
}
if (gnc_verify_dialog_parented(sxed->dialog, TRUE, message)) {
Transaction *trans;
trans = gnc_split_register_get_current_trans( reg );
if ( !gnc_split_register_save( reg, TRUE ) )
return;
gnc_split_register_redraw( reg );
} else {
gnc_split_register_cancel_cursor_trans_changes (reg);
}
}
@ -2174,6 +2138,7 @@ gnc_sxed_update_cal( SchedXactionEditorDialog *sxed )
lastInst = xaccSchedXactionGetLastOccurDate( sxed->sx );
if ( g_date_valid( lastInst )
&& g_date_valid( &d )
&& g_date_compare( lastInst, &d ) <= 0 ) {
d = *lastInst;
}
@ -2212,6 +2177,10 @@ gnc_sxed_update_cal( SchedXactionEditorDialog *sxed )
GString *info;
name = gtk_editable_get_chars( sxed->nameEntry, 0, -1 );
if ( strlen( name ) == 0 ) {
g_free(name);
name = NULL;
}
info = g_string_sized_new( 16 );
xaccFreqSpecGetFreqStr( fs, info );
sxed->markId = gnc_dense_cal_mark( sxed->example_cal, i,

View File

@ -80,7 +80,6 @@
# 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_FINISH "finish_pg"
#define OPT_VBOX_SPACING 2
@ -273,15 +272,16 @@ 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_fin_prep ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud );
static gboolean ld_fin_back ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud );
static void ld_fin_fin ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud );
static void ld_pay_fin ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud );
static void ld_create_sxes( LoanDruidData *ldd );
struct LoanDruidData_*
gnc_ui_sx_loan_druid_create()
gnc_ui_sx_loan_druid_create(void)
{
int i;
LoanDruidData *ldd;
@ -506,9 +506,8 @@ gnc_ui_sx_loan_druid_create()
} 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 },
{ PG_PAYMENT, ld_pay_next, ld_pay_prep, ld_pay_back, NULL },
{ PG_FINISH, NULL, ld_fin_prep, ld_fin_back, ld_fin_fin },
{ 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 },
{ NULL }
};
@ -1027,24 +1026,7 @@ ld_rep_next( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
return TRUE;
}
if ( (ldd->currentIdx < 0)
|| (ldd->currentIdx >= ldd->ld.repayOptCount)
|| !ldd->ld.repayOpts[ldd->currentIdx]->enabled ) {
int i;
for ( i=0;
(i < ldd->ld.repayOptCount)
&& !ldd->ld.repayOpts[i]->enabled;
i++ )
;
if ( i == ldd->ld.repayOptCount ) {
/* transition to final page. */
GtkWidget *pg;
pg = glade_xml_get_widget( ldd->gxml, PG_FINISH );
gnome_druid_set_page( ldd->druid, GNOME_DRUID_PAGE(pg) );
return TRUE;
}
ldd->currentIdx = i;
}
ldd->currentIdx++;
return FALSE;
}
@ -1096,7 +1078,25 @@ ld_rep_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
gnc_frequency_setup( ldd->repGncFreq,
ldd->ld.repFreq,
ldd->ld.repStartDate );
{
int i;
gboolean haveRepayOpts = FALSE;
/* no repayment options selected */
for ( i=0; i<ldd->ld.repayOptCount && !haveRepayOpts; i++ ) {
haveRepayOpts |= ldd->ld.repayOpts[i]->enabled;
}
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 );
}
static
@ -1138,6 +1138,17 @@ ld_pay_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
rod->fs, rod->startDate );
}
{
gboolean haveMoreRepayOpts = FALSE;
int i = 0;
for ( i = ldd->currentIdx + 1;
(i < ldd->ld.repayOptCount) && !haveMoreRepayOpts;
i++ ) {
haveMoreRepayOpts |= ldd->ld.repayOpts[i]->enabled;
}
gnome_druid_set_show_finish( ldd->druid, !haveMoreRepayOpts );
}
g_string_free( str, TRUE );
}
@ -1267,31 +1278,15 @@ ld_pay_back( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
}
static
gboolean
ld_fin_back ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
void
ld_pay_fin( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
{
LoanDruidData *ldd;
ldd = (LoanDruidData*)ud;
if ( (ldd->currentIdx < 0)
|| (ldd->currentIdx >= ldd->ld.repayOptCount)
|| !ldd->ld.repayOpts[ldd->currentIdx]->enabled ) {
int i;
for ( i=ldd->ld.repayOptCount-1;
(i > -1)
&& !ldd->ld.repayOpts[i]->enabled;
i-- )
;
if ( i == -1 ) {
/* transition to Repayment page. */
GtkWidget *pg;
pg = glade_xml_get_widget( ldd->gxml, PG_REPAYMENT );
gnome_druid_set_page( ldd->druid, GNOME_DRUID_PAGE(pg) );
return TRUE;
}
ldd->currentIdx = i;
LoanDruidData *ldd = (LoanDruidData*)ud;
if ( ld_pay_save_current( ldd ) ) {
/* FIXME?: Error? */
return;
}
return FALSE;
ld_create_sxes( ldd );
}
static
@ -1328,20 +1323,6 @@ ld_pay_freq_toggle( GtkToggleButton *tb, gpointer ud )
}
}
static
void
ld_fin_prep ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
{
/* FIXME? */
}
static
void
ld_free_ttsi( gpointer data, gpointer ud )
{
gnc_ttsplitinfo_free( (TTSplitInfo*)data );
}
static
void
ld_gnc_ttinfo_free( gpointer data, gpointer ud )
@ -1349,11 +1330,13 @@ ld_gnc_ttinfo_free( gpointer data, gpointer ud )
gnc_ttinfo_free( (TTInfo*)data );
}
/**
* Actually does the work of creating the SXes from the LoanDruidData.
**/
static
void
ld_fin_fin ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
ld_create_sxes( LoanDruidData *ldd )
{
LoanDruidData *ldd;
int i;
TTInfo *tti;
TTSplitInfo *ttsi;
@ -1365,8 +1348,6 @@ ld_fin_fin ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
GString *repAssetsDebitFormula, *tmpGS;
GList *sxList;
ldd = (LoanDruidData*)ud;
/* Create a string for the Asset-account debit, which we will build
* up in the processing of the LoanData and Options. */
repAssetsDebitFormula = g_string_sized_new( 64 );
@ -1485,7 +1466,7 @@ ld_fin_fin ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
GList *ttList;
ttList = NULL;
/* Create new SX with given FreqSpec */
/* Create new SX with given FreqSpec */
ttList = g_list_append( ttList, tti );
tmpSX = xaccSchedXactionMalloc( gnc_get_current_book() );
@ -1494,7 +1475,6 @@ ld_fin_fin ( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
xaccSchedXactionSetFreqSpec( tmpSX, rod->fs );
xaccSchedXactionSetStartDate( tmpSX, rod->startDate );
xaccSchedXactionSetLastOccurDate( tmpSX, rod->startDate );
/* FIXME ... what are these values? */
xaccSchedXactionSetNumOccur( tmpSX, ldd->ld.numPer );
xaccSchedXactionSetRemOccur( tmpSX, ldd->ld.numPerRemain );
xaccSchedXactionSetTemplateTrans( tmpSX, ttList,

View File

@ -21,4 +21,4 @@
* Boston, MA 02111-1307, USA gnu@gnu.org *
\********************************************************************/
struct LoanDruidData_* gnc_ui_sx_loan_druid_create();
struct LoanDruidData_* gnc_ui_sx_loan_druid_create(void);

View File

@ -5550,17 +5550,61 @@ Escrow
</widget>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkMenu</class>
<name>Since Last Run popup</name>
<widget>
<class>GtkMenuItem</class>
<name>creation_state</name>
<label>Creation State</label>
<right_justify>False</right_justify>
<widget>
<class>GnomeDruidPageFinish</class>
<name>finish_pg</name>
<title>Review</title>
<text>We're about to do the following...</text>
<background_color>25,25,112</background_color>
<logo_background_color>255,255,255</logo_background_color>
<textbox_color>255,255,255</textbox_color>
<text_color>0,0,0</text_color>
<title_color>255,255,255</title_color>
<class>GtkMenu</class>
<name>creation_state_menu</name>
<widget>
<class>GtkPixmapMenuItem</class>
<name>ignore</name>
<signal>
<name>activate</name>
<handler>on_ignore_activate</handler>
<last_modification_time>Fri, 23 Aug 2002 22:16:45 GMT</last_modification_time>
</signal>
<label>Ignore</label>
<right_justify>False</right_justify>
<stock_icon>GNOME_STOCK_MENU_STOP</stock_icon>
</widget>
<widget>
<class>GtkPixmapMenuItem</class>
<name>postpone</name>
<signal>
<name>activate</name>
<handler>on_postpone_activate</handler>
<last_modification_time>Fri, 23 Aug 2002 22:16:45 GMT</last_modification_time>
</signal>
<label>Postpone</label>
<right_justify>False</right_justify>
<stock_icon>GNOME_STOCK_MENU_TIMER_STOP</stock_icon>
</widget>
<widget>
<class>GtkPixmapMenuItem</class>
<name>create</name>
<signal>
<name>activate</name>
<handler>on_create_activate</handler>
<last_modification_time>Fri, 23 Aug 2002 22:16:45 GMT</last_modification_time>
</signal>
<label>Create</label>
<right_justify>False</right_justify>
<stock_icon>GNOME_STOCK_MENU_TIMER</stock_icon>
</widget>
</widget>
</widget>
</widget>

View File

@ -868,7 +868,7 @@ gnc_main_window_create_menus(GNCMDIInfo * maininfo)
},
GNOMEUIINFO_SEPARATOR,
{ GNOME_APP_UI_ITEM,
N_( "_Mortgage/Loan Repayment Setup" ),
N_( "_Mortgage & Loan Repayment..." ),
N_( "Setup scheduled transactions for repayment of a loan" ),
gnc_main_window_sx_loan_druid_cb, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,