diff --git a/ChangeLog b/ChangeLog index 7b63ff91ec..887aec3902 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,51 @@ +2001-10-22 Joshua Sled + + * src/gnome/Makefile.am: Removed obsolete dialog-nextrun.{c,h} + + * src/gnome/window-main.c (gnc_main_window_create_menus): Added + both Scheduled Transaction-related items to "Scheduled + Transactions" sub-menu of "Tools". + (gnc_main_window_about_cb): Added self to GUI About dlg. + + * src/gnome/dialog-scheduledxaction.c: Renamed '_'-led functions. + + * src/gnome/dialog-sxsincelast.c: Changed from a loose + confederation of multiple dialogs to the strong central authority + of a GnomeDruid-based since-last-run UI. Renamed '_'-led + functions. + + * src/gnome/glade/sched-xact.glade: Fixed a non-unique-name + problem between the GnomeNumberEntry "end_nentry" and it's + GtkEntry "end_nentry". Added Druid-based Since-Last-Run dialog. + + * src/gnome/dialog-scheduledxaction.c (schedXact_editor_populate), + (editor_ok_button_clicked): Added support for now-uniquely-named + "end_gnome_nentry". + + * src/engine/SchedXaction.c + (xaccSchedXactionCreateSequenceState): Added. + (xaccSchedXactionIncrSequenceState): Added. + (xaccSchedXactionDestroySequenceState): Added. + Added support for opaque state data when generating a sequence of + SX instances to support number-of-occurance-terminated SXes. + + * src/backend/file/gnc-freqspec-xml-v2.c (dom_tree_to_freqSpec): + Added missing instance of GNCSession propogation. + + * src/backend/file/io-gncxml-v2.c + (write_template_transaction_data): Added correct determination for + writing out the template-transaction section [before: only if + transactions existed in accounts; now: if any accounts exist] to + prevent read errors from SXes with valid-and-referenced Accounts, + but no Transactions in them. + + * src/gnome-utils/gnc-frequency.c (gnc_frequency_setup): Better + error text when UIFreqType isn't recognized or appropriate. + + * src/gnome/dialog-scheduledxaction.c (editor_ok_button_clicked): + Correctly sets SXes to have no occurance data if that's the case. + Better option variable naming, usage. + 2001-10-16 Dave Peticolas * src/engine/test-core/test-engine-stuff.c: work on test @@ -1304,6 +1352,7 @@ directory. * src/engine/io-gncbin-r.c: remove #if 0'ed code. + 2001-07-30 Joshua Sled * src/gnome/glade/sched-xact.glade: Added seperate reminders diff --git a/src/backend/file/gnc-freqspec-xml-v2.c b/src/backend/file/gnc-freqspec-xml-v2.c index c8f7643631..9cd1b26d0d 100644 --- a/src/backend/file/gnc-freqspec-xml-v2.c +++ b/src/backend/file/gnc-freqspec-xml-v2.c @@ -136,8 +136,9 @@ typedef struct static void fspd_init( fsParseData *fspd ) { - fspd->fs = NULL; - fspd->list = NULL; + fspd->fs = NULL; + fspd->list = NULL; + fspd->session = NULL; fspd->interval = fspd->offset = fspd->day @@ -594,6 +595,7 @@ dom_tree_to_freqSpec(xmlNodePtr node, GNCSession *session) fsParseData fspd; fspd_init( &fspd ); + fspd.session = session; fspd.fs = xaccFreqSpecMalloc(session); successful = dom_tree_generic_parse( node, fs_dom_handlers, &fspd ); diff --git a/src/backend/file/io-gncxml-v2.c b/src/backend/file/io-gncxml-v2.c index 3fdb5b027d..fb193009bd 100644 --- a/src/backend/file/io-gncxml-v2.c +++ b/src/backend/file/io-gncxml-v2.c @@ -720,22 +720,12 @@ static void write_template_transaction_data( FILE *out, GNCBook *book ) { AccountGroup *ag; - GList *gl; - gboolean hasTemplateTransactionData = FALSE; ag = gnc_book_get_template_group(book); - gl = xaccGroupGetSubAccounts( ag ); - while ( !hasTemplateTransactionData && (gl != NULL) ) - { - hasTemplateTransactionData |= - (xaccAccountGetSplitList( (Account*)gl->data ) != NULL); - gl = gl->next; - } - - if ( hasTemplateTransactionData ) + if ( xaccGroupGetNumSubAccounts(ag) > 0 ) { fprintf( out, "<%s>\n", TEMPLATE_TRANSACTION_TAG ); - write_account_group( out, gnc_book_get_template_group(book) ); + write_account_group( out, ag ); xaccGroupForEachTransaction( ag, xml_add_trn_data, (gpointer)out ); fprintf( out, "\n", TEMPLATE_TRANSACTION_TAG ); } diff --git a/src/doc/TODO-schedxactions b/src/doc/TODO-schedxactions index 02fcdf3e49..fc64fafd05 100644 --- a/src/doc/TODO-schedxactions +++ b/src/doc/TODO-schedxactions @@ -19,7 +19,7 @@ X would like "don't even tell me you instantiated it, just fscking do ################################################## ### To-Do -### '.' = to-do, 'X' = done +### '.' = to-do, 'X' = done, '?' = jsled verify ################################################## @@ -33,7 +33,7 @@ X create a template register . this is going to be: a tabbed notebook in which the tabs contain the number of transactions the GL they hold contain. -. Hook into 'book data changed' save-on-exit decision +? Hook into 'book data changed' save-on-exit decision . add a big calendar [gnome-pim? evo?] to SXaction List/overview @@ -42,6 +42,7 @@ X create a template register scanning code. . need "since-last-run" UI for instanatiation. + X Change from dialogs to druid X/O create transactions X numeric X formula @@ -59,6 +60,9 @@ X create a template register pop up the 'new scheduled transactions' dialog [option, time-of-day] . Should deal with "nothing-to-do" better [not even show up in the worst [read: no auto-notify/to-create/reminders] case]. + . this is different between the auto-invoked since-last-run dialog [show + nothing] and the menu-invoked since-last-run [show a dialog to the user + stating there's nothing to do]. . Double-clicking on auto-create list should jump to transaction . register of first split? . double-clicking a reminder should [probably] move it up to the to-create @@ -78,13 +82,13 @@ X create a template register not-yet-created transactions. . The ability to turn a non-recurring transaction into a recurring one... . inactive cells - . date - . recn + X date + . recn? . deal better with formulas in template transactions [real FormulaCell] . recognize purely numeric template transactions and balance at template-creation time. - . balance transaction via symbolic math? + . balance transaction via variable cancellation? . GNCFrequency . initial-settings synchronization [start date, optionmenus] @@ -107,23 +111,23 @@ X create a template register . Configuration options... . Overall - . Size of template register window + X Size of template register window . color of future register entries . conrad's desires - . policy - . create for N days in advance - . show for N days in advance, create when come-due - . defaults - . create/show for 'N' days in advance - . remind me 'M' days in advance - . just create - . notify when created - . Per-SX - . just create/notify - . create/show - . lead-time - . reminder - . lead-time + X policy + X create for N days in advance + X show for N days in advance, create when come-due + X defaults + X create/show for 'N' days in advance + X remind me 'M' days in advance + X just create + X notify when created + X Per-SX + X just create/notify + X create/show + X lead-time + X reminder + X lead-time @@ -144,8 +148,8 @@ X create a template register ### Bugs ################################################## -. General - . Date l10n. +X General + X Date l10n. . GNCFreqency . transitioning to a new tab doesn't correctly setup the agreement between @@ -157,7 +161,7 @@ X create a template register . Scheduled Transaction Editor . Can't click-out of the register - . auto-shrink on window create [the register is too wide, leading to too + X auto-shrink on window create [the register is too wide, leading to too much whitespace on the two top panels -- sometimes]. . Size/space issues. . Un-selecting "End Date" leaves calendar widget sensitive @@ -167,10 +171,11 @@ X create a template register . Scheduled Transaction List . Since-last-run - . any [horizontal] window size change height-grows the top/auto-create GL. + . correct "Back" button behavior in new Druid paradigm + X any [horizontal] window size change height-grows the top/auto-create GL. X always goes one date past the instantiation date. . tab-order on variable-entry window isn't always correct. - X credit and debit seem reversed at instantiation time... + ? credit and debit seem reversed at instantiation time... . this is fixed, but is the fix correct? ################################################## @@ -306,24 +311,3 @@ conrad wants to use this to remind him to pay his bills. He runs GnuCash continuously, and thus wants an option to "pop-up on day change [at time HH:MM]". He's interested in seeing future transactions as well as what's being created ATM. - ------ - - There are 2 reasons to create scheduled transactions - as a reminder you have to pay this bill by this day or I'll remind you until you do something, either skip me or mark me as paid, if the first I do nothing other than remind you, if the second I enter a transaction in the register - and second - as an actual transaction that goes into the register on a future date, ie I know that this money leaves my account in 2 days, so I want it to go in automatically on that day. If I leave gnucash running all the time, it'll wait until that day then enter the transaction - as you can see the purpose of each is quite different - Wilddev: Indeed... - For the first, you're saying that reminders should start some number of days before the transaction is usually due/paid... and that there are two acknowledgements of that... 'remind me later' or 'here's the amount/create'. - For the second, you're looking at ad-hoc once-scheduled transactions... which should go away immediately afterwards. - yes, tho it would be nice to have when you actually get reminded configurable :) - Wilddev: On a per-scheduled-transaction basis, I think. - yup - Okay... so this brings up something that isn't presently in the scheme at all: reminders. - I think it's as simple as a "[ ] Remind me __ days in advance" element in the SXEditor, and the appropriate logic in the since-last-run code... - how often is the last run code 'run'? - Wilddev: On startup, or when the timer [a-la conrad's requirement] goes off. - yes that would work - So the "since-last-run" dialog has three panes: 1) auto-created, notification requested. 2) To-create. 3) To-create-soon + reminders. - that sounds good diff --git a/src/engine/SchedXaction.c b/src/engine/SchedXaction.c index e8326033bd..b71a637d28 100644 --- a/src/engine/SchedXaction.c +++ b/src/engine/SchedXaction.c @@ -430,7 +430,7 @@ xaccSchedXactionSetAdvanceReminder( SchedXaction *sx, gint reminderDays ) /* FIXME: there is a bug in this, I think */ GDate -xaccSchedXactionGetNextInstance( SchedXaction *sx ) +xaccSchedXactionGetNextInstance( SchedXaction *sx, void *stateData ) { GDate last_occur, next_occur, tmpDate; @@ -453,18 +453,6 @@ xaccSchedXactionGetNextInstance( SchedXaction *sx ) } } -#if 0 - if ( g_date_valid( &last_occur ) ) { - g_date_set_time( &tmpDate, time(NULL) ); - last_occur = - ( g_date_compare( &last_occur, - &tmpDate ) > 0 ? - last_occur : tmpDate ); - } else { - g_date_set_time( &last_occur, time(NULL) ); - } -#endif /* 0 */ - if ( g_date_valid( &sx->start_date ) && ! g_date_valid( &sx->last_date ) ) { /* Think about this for a second, and you realize @@ -478,13 +466,54 @@ xaccSchedXactionGetNextInstance( SchedXaction *sx ) } xaccFreqSpecGetNextInstance( sx->freq, &last_occur, &next_occur ); + + /* out-of-bounds check */ + if ( xaccSchedXactionHasEndDate( sx ) ) { + GDate *end_date = xaccSchedXactionGetEndDate( sx ); + if ( g_date_compare( &next_occur, end_date ) > 0 ) { + PINFO( "next_occur past end date" ); + g_date_clear( &next_occur, 1 ); + } + } else if ( xaccSchedXactionHasOccurDef( sx ) && stateData ) { + /* FIXME: does this work? */ + gint remaining; + remaining = xaccSchedXactionGetRemOccur( sx ); + if ( remaining == 0 ) { + PINFO( "no more occurances remain" ); + g_date_clear( &next_occur, 1 ); + } + } + return next_occur; } -GDate xaccSchedXactionGetInstanceAfter( SchedXaction *sx, GDate *date ) +GDate +xaccSchedXactionGetInstanceAfter( SchedXaction *sx, + GDate *date, + void *stateData ) { GDate next_occur; + xaccFreqSpecGetNextInstance( sx->freq, date, &next_occur ); + + if ( xaccSchedXactionHasEndDate( sx ) ) { + GDate *end_date; + + end_date = xaccSchedXactionGetEndDate( sx ); + if ( g_date_compare( &next_occur, end_date ) > 0 ) { + PINFO( "next_occur past end_date" ); + g_date_clear( &next_occur, 1 ); + } + } else if ( xaccSchedXactionHasOccurDef( sx ) && stateData ) { + /* gint remaining = xaccSchedXactionGetRemOccur( sx ); */ + gint *remaining = (gint*)stateData; + DEBUG( "stateData [remaining]: %d", *remaining ); + if ( (*remaining - 1) < 0 ) { + PINFO( "next_occur is outside " + "reminaing-instances window." ); + g_date_clear( &next_occur, 1 ); + } + } return next_occur; } @@ -610,3 +639,39 @@ xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list, xaccTransCommitEdit(new_trans); } } + +void* +xaccSchedXactionCreateSequenceState( SchedXaction *sx ) +{ + void *toRet = NULL; + + if ( xaccSchedXactionHasOccurDef( sx ) ) { + toRet = g_new0( gint, 1 ); + *(gint*)toRet = xaccSchedXactionGetRemOccur( sx ); + DEBUG( "Returning state data [remaining]: %d", *(gint*)toRet ); + } else { + DEBUG( "Returning null state data" ); + } + return toRet; +} + +void +xaccSchedXactionIncrSequenceState( SchedXaction *sx, + void *stateData ) +{ + if ( xaccSchedXactionHasOccurDef( sx ) ) { + gint *remaining; + remaining = (gint*)stateData; + *remaining = *remaining - 1; + } +} + +void +xaccSchedXactionDestroySequenceState( SchedXaction *sx, + void *stateData ) +{ + if ( xaccSchedXactionHasOccurDef( sx ) ) { + g_free( (gint*)stateData ); + } +} + diff --git a/src/engine/SchedXaction.h b/src/engine/SchedXaction.h index c898b34090..fc981c036c 100644 --- a/src/engine/SchedXaction.h +++ b/src/engine/SchedXaction.h @@ -97,6 +97,9 @@ int xaccSchedXactionHasEndDate( SchedXaction *sx ); * Returns invalid date when there is no end-date specified. **/ GDate* xaccSchedXactionGetEndDate( SchedXaction *sx ); +/** + * Set to an invalid GDate to turn off 'end-date' definition. + **/ void xaccSchedXactionSetEndDate( SchedXaction *sx, GDate* newEnd ); GDate* xaccSchedXactionGetLastOccurDate( SchedXaction *sx ); @@ -108,6 +111,9 @@ void xaccSchedXactionSetLastOccurDate( SchedXaction *sx, GDate* newLastOccur ); **/ gboolean xaccSchedXactionHasOccurDef( SchedXaction *sx ); gint xaccSchedXactionGetNumOccur( SchedXaction *sx ); +/** + * Set to '0' to turn off number-of-occurances definition. + **/ void xaccSchedXactionSetNumOccur( SchedXaction *sx, gint numNum ); gint xaccSchedXactionGetRemOccur( SchedXaction *sx ); void xaccSchedXactionSetRemOccur( SchedXaction *sx, gint numRemain ); @@ -166,13 +172,35 @@ void xaccSchedXactionSetSlot( SchedXaction *sx, const GUID *xaccSchedXactionGetGUID( SchedXaction *sx ); void xaccSchedXactionSetGUID( SchedXaction *sx, GUID g ); +/** + * Next-Instance state data. + * + * If you're looking at to-create [but not-yet-created] scheduled + * transactions, you'll want to use this to keep track of any + * SX-type-specific information that relates to the sequence and when it + * should end. This is an opaque structure to the caller; it should be + * created and freed with the following functions, and passed into the + * GetNextInstance and GetInstanceAfter functions. + * + * The necessity for this arose in dealing with SXes with some number of + * remaining occurances, and thinking about how to keep track of this when + * looking at reminders... and generally thinking about not wanting the + * caller to know every possible thing that needs to be kept track of in a + * forward-looking sequence of SXes. + **/ +void *xaccSchedXactionCreateSequenceState( SchedXaction *sx ); +void xaccSchedXactionIncrSequenceState( SchedXaction *sx, void *stateData ); +void xaccSchedXactionDestroySequenceState( SchedXaction *sx, void *stateData ); + /** * Returns the next occurance of a scheduled transaction. If the * transaction hasn't occured, then it's based off the start date. * Otherwise, it's based off the last-occurance date. **/ -GDate xaccSchedXactionGetNextInstance( SchedXaction *sx ); -GDate xaccSchedXactionGetInstanceAfter( SchedXaction *sx, GDate *date ); +GDate xaccSchedXactionGetNextInstance( SchedXaction *sx, void *stateData ); +GDate xaccSchedXactionGetInstanceAfter( SchedXaction *sx, + GDate *date, + void *stateData ); /* * Set the schedxaction's template transaction. t_t_list is a glist diff --git a/src/gnome-utils/gnc-frequency.c b/src/gnome-utils/gnc-frequency.c index 2672871338..8a25f83038 100644 --- a/src/gnome-utils/gnc-frequency.c +++ b/src/gnome-utils/gnc-frequency.c @@ -323,9 +323,11 @@ gnc_frequency_setup( GNCFrequency *gf, FreqSpec *fs, GDate *startDate ) { GDate theDate; tmpTm = g_new0( struct tm, 1 ); - /* set the date */ + /* set the date */ if ( xaccFreqSpecGetOnce( fs, &theDate ) < 0 ) { - PERR( "Inappropriate FreqSpec type\n" ); + PERR( "Inappropriate FreqSpec type " + "[gnc-frequency: %d vs. FreqSpec: %d]\n", + uift, xaccFreqSpecGetUIType( fs ) ); return; } g_date_to_struct_tm( &theDate, tmpTm ); @@ -337,7 +339,9 @@ gnc_frequency_setup( GNCFrequency *gf, FreqSpec *fs, GDate *startDate ) { int dailyMult = -1; if ( xaccFreqSpecGetDaily( fs, &dailyMult ) < 0 ) { - PERR( "Inappropriate FreqSpec type\n" ); + PERR( "Inappropriate FreqSpec type " + "[gnc-frequency: %d vs. FreqSpec: %d]\n", + uift, xaccFreqSpecGetUIType( fs ) ); return; } o = glade_xml_get_widget( gf->gxml, "daily_spin" ); @@ -358,7 +362,9 @@ gnc_frequency_setup( GNCFrequency *gf, FreqSpec *fs, GDate *startDate ) } subFS = (FreqSpec*)fsList->data; if ( xaccFreqSpecGetWeekly( subFS, &weekMult, &dayOfWeek ) < 0 ) { - PERR( "Invalid FreqSpec type" ); + PERR( "Inappropriate FreqSpec type " + "[gnc-frequency: %d vs. FreqSpec: %d]\n", + uift, xaccFreqSpecGetUIType( fs ) ); return; } o = glade_xml_get_widget( gf->gxml, "dailymf_spin" ); @@ -380,7 +386,9 @@ gnc_frequency_setup( GNCFrequency *gf, FreqSpec *fs, GDate *startDate ) return; } if ( xaccFreqSpecGetWeekly( subFS, &weeklyMult, &dayOfWeek ) < 0 ) { - PERR( "Inappropriate FreqSpec type\n" ); + PERR( "Inappropriate FreqSpec type " + "[gnc-frequency: %d, FreqSpec: %d]\n", + uift, xaccFreqSpecGetUIType( fs ) ); return; } } else { @@ -391,7 +399,9 @@ gnc_frequency_setup( GNCFrequency *gf, FreqSpec *fs, GDate *startDate ) return; } if ( xaccFreqSpecGetWeekly( subFS, &otherWeeklyMult, &dayOfWeek ) < 0 ) { - PERR( "Inappropriate FreqSpec type\n" ); + PERR( "Inappropriate FreqSpec type " + "[gnc-frequency: %d, FreqSpec: %d]\n", + uift, xaccFreqSpecGetUIType( fs ) ); return; } if ( weeklyMult != otherWeeklyMult ) { @@ -425,7 +435,9 @@ gnc_frequency_setup( GNCFrequency *gf, FreqSpec *fs, GDate *startDate ) subFS = (FreqSpec*)(g_list_nth( list, 0 )->data); if ( xaccFreqSpecGetMonthly( subFS, &monthlyMult, &firstDayOfMonth, &monthOffset ) < 0 ) { - PERR( "Inappropriate FreqSpec type\n" ); + PERR( "Inappropriate FreqSpec type " + "[gnc-frequency: %d, FreqSpec: %d]\n", + uift, xaccFreqSpecGetUIType( fs ) ); return; } gtk_spin_button_set_value( GTK_SPIN_BUTTON(o), monthlyMult ); @@ -448,7 +460,9 @@ gnc_frequency_setup( GNCFrequency *gf, FreqSpec *fs, GDate *startDate ) int monthlyMult, dayOfMonth, monthOffset; if ( xaccFreqSpecGetMonthly( fs, &monthlyMult, &dayOfMonth, &monthOffset ) < 0 ) { - PERR( "Inappropriate FreqSpec type" ); + PERR( "Inappropriate FreqSpec type " + "[gnc-frequency: %d, FreqSpec: %d]\n", + uift, xaccFreqSpecGetUIType( fs ) ); return; } o = glade_xml_get_widget( gf->gxml, "monthly_spin" ); @@ -464,7 +478,9 @@ gnc_frequency_setup( GNCFrequency *gf, FreqSpec *fs, GDate *startDate ) if ( xaccFreqSpecGetMonthly( fs, &monthlyMult, &dayOfMonth, &monthOffset ) < 0 ) { - PERR( "Inappropriate FreqSpec type" ); + PERR( "Inappropriate FreqSpec type " + "[gnc-frequency: %d, FreqSpec: %d]\n", + uift, xaccFreqSpecGetUIType( fs ) ); return; } if ( monthlyMult != 3 ) { @@ -482,7 +498,9 @@ gnc_frequency_setup( GNCFrequency *gf, FreqSpec *fs, GDate *startDate ) if ( xaccFreqSpecGetMonthly( fs, &monthlyMult, &dayOfMonth, &monthOffset ) < 0 ) { - PERR( "Inappropriate FreqSpec type" ); + PERR( "Inappropriate FreqSpec type " + "[gnc-frequency: %d, FreqSpec: %d]\n", + uift, xaccFreqSpecGetUIType( fs ) ); return; } if ( monthlyMult != 4 ) { @@ -500,7 +518,9 @@ gnc_frequency_setup( GNCFrequency *gf, FreqSpec *fs, GDate *startDate ) if ( xaccFreqSpecGetMonthly( fs, &monthlyMult, &dayOfMonth, &monthOffset ) < 0 ) { - PERR( "Inappropriate FreqSpec type" ); + PERR( "Inappropriate FreqSpec type " + "[gnc-frequency: %d, FreqSpec: %d]\n", + uift, xaccFreqSpecGetUIType( fs ) ); return; } if ( monthlyMult != 6 ) { @@ -518,7 +538,9 @@ gnc_frequency_setup( GNCFrequency *gf, FreqSpec *fs, GDate *startDate ) if ( xaccFreqSpecGetMonthly( fs, &monthlyMult, &dayOfMonth, &monthOffset ) < 0 ) { - PERR( "Inappropriate FreqSpec type" ); + PERR( "Inappropriate FreqSpec type " + "[gnc-frequency: %d, FreqSpec: %d]\n", + uift, xaccFreqSpecGetUIType( fs ) ); return; } if ( (monthlyMult % 12) != 0) { @@ -539,7 +561,8 @@ gnc_frequency_setup( GNCFrequency *gf, FreqSpec *fs, GDate *startDate ) } break; default: - PERR( "unknown ui freq type [%d, %s]\n", __LINE__, __FILE__ ); + PERR( "unknown ui freq type %d [%d, %s]\n", + uift, __LINE__, __FILE__ ); break; } update_appropriate_cal( gf ); @@ -1118,6 +1141,7 @@ start_date_changed( GnomeDateEdit *gde, gpointer d ) o = NULL; switch (uift) { + case UIFREQ_ONCE: /* FALLTHROUGH */ case UIFREQ_DAILY: /* FALLTHROUGH */ case UIFREQ_DAILY_MF: /* FALLTHROUGH */ case UIFREQ_WEEKLY: /* FALLTHROUGH */ diff --git a/src/gnome/Makefile.am b/src/gnome/Makefile.am index 471d669eb8..f7f2ef1c7d 100644 --- a/src/gnome/Makefile.am +++ b/src/gnome/Makefile.am @@ -38,7 +38,6 @@ libgncgnome_la_SOURCES = \ window-reconcile.c \ window-register.c \ window-report.c \ - dialog-nextrun.c \ dialog-sxsincelast.c gnomeappdir = ${datadir}/gnome/apps/Applications @@ -80,7 +79,6 @@ noinst_HEADERS = \ window-reconcile.h \ window-register.h \ window-report.h \ - dialog-nextrun.h \ dialog-sxsincelast.h EXTRA_DIST = \ diff --git a/src/gnome/dialog-nextrun.c b/src/gnome/dialog-nextrun.c deleted file mode 100644 index b6a59c826f..0000000000 --- a/src/gnome/dialog-nextrun.c +++ /dev/null @@ -1,572 +0,0 @@ -/********************************************************************\ - * dialog-nextrun.c - "since last run" dialog. * - * Copyright (c) 2001 Joshua Sled * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 2 of * - * the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License* - * along with this program; if not, contact: * - * * - * Free Software Foundation Voice: +1-617-542-5942 * - * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * - * Boston, MA 02111-1307, USA gnu@gnu.org * -\********************************************************************/ - -#include "config.h" - -#include - -#include "Group.h" -#include "SchedXaction.h" -#include "Transaction.h" -#include "dialog-nextrun.h" -#include "dialog-utils.h" -#include "gnc-book.h" -#include "gnc-component-manager.h" -#include "gnc-engine-util.h" -#include "gnc-exp-parser.h" -#include "gnc-numeric.h" -#include "gnc-ui-util.h" -#include "split-register.h" - -#define DIALOG_NEXTRUN_CM_CLASS "dialog-nextrun" - -static short module = MOD_SX; - -typedef struct _toCreateTransaction { - SchedXaction *sx; - GDate *date; - - gint clistRow; -} toCreateTransaction; - -typedef struct _sxSinceLastData { - GtkWidget *nextrunDlg; - GladeXML *gxml; - GList /* */ *transList; -} sxSinceLastData; - -static void nextrun_init( sxSinceLastData *sxsld ); -static void nextrun_close_handler( gpointer ud ); -static void nr_ok_clicked( GtkButton *b, gpointer ud ); -static void nr_next_clicked( GtkButton *b, gpointer ud ); -static void nr_prev_xaction_clicked( GtkButton *b, gpointer ud ); -static void nr_next_xaction_clicked( GtkButton *b, gpointer ud ); - -static void nextrun_destroy( GtkObject *o, gpointer ud ); - -static void slr_create_transactions( SchedXaction *sx, GDate *gd ); - -/* int parse_vars_from_formula( const char *formula, GHashTable *varHash ); */ - -void -gnc_ui_nextrun_guile_wrapper( char *foo ) -{ - gnc_ui_nextrun_dialog_create(); -} - -void -gnc_ui_nextrun_dialog_create(void) -{ - sxSinceLastData *sxsld = g_new0( sxSinceLastData, 1 ); - sxsld->gxml = gnc_glade_xml_new( "sched-xact.glade", "Since-Last-Run Instantiation" ); - sxsld->nextrunDlg = glade_xml_get_widget( sxsld->gxml, "Since-Last-Run Instantiation" ); - - nextrun_init( sxsld ); -} - -static void -nextrun_init( sxSinceLastData *sxsld ) -{ - GtkWidget *o; - int i; - struct widgetNameSignalHandlerTuple { - char *name; - char *signal; - void (*handlerFn)(); - } widgets[] = { - { "ok", "clicked", nr_ok_clicked }, - { "next", "clicked", nr_next_clicked }, - { "prev_xaction", "clicked", nr_prev_xaction_clicked }, - { "next_xaction", "clicked", nr_next_xaction_clicked }, - { NULL, NULL, NULL } - }; - - gnc_register_gui_component( DIALOG_NEXTRUN_CM_CLASS, - NULL, - nextrun_close_handler, - sxsld->nextrunDlg ); - - gtk_signal_connect( GTK_OBJECT(sxsld->nextrunDlg), "destroy", - GTK_SIGNAL_FUNC( nextrun_destroy ), sxsld ); - - for ( i=0; widgets[i].name != NULL ; i++ ) { - o = glade_xml_get_widget( sxsld->gxml, widgets[i].name ); - gtk_signal_connect( GTK_OBJECT(o), widgets[i].signal, - GTK_SIGNAL_FUNC(widgets[i].handlerFn), - sxsld ); - - } - - o = glade_xml_get_widget( sxsld->gxml, "next" ); - gtk_signal_connect( GTK_OBJECT(o), "clicked", - GTK_SIGNAL_FUNC(nr_next_clicked), - sxsld ); - - o = glade_xml_get_widget( sxsld->gxml, "prev_xaction" ); - gtk_signal_connect( GTK_OBJECT(o), "clicked", - GTK_SIGNAL_FUNC(nr_prev_xaction_clicked), - sxsld ); - o = glade_xml_get_widget( sxsld->gxml, "next_xaction" ); - gtk_signal_connect( GTK_OBJECT(o), "clicked", - GTK_SIGNAL_FUNC(nr_next_xaction_clicked), - sxsld ); - - gtk_widget_show_all( sxsld->nextrunDlg ); -} - -static void -nextrun_close_handler( gpointer ud ) -{ - gnome_dialog_close( GNOME_DIALOG( ((sxSinceLastData*)ud)->nextrunDlg ) ); -} - -static void -nr_ok_clicked( GtkButton *b, gpointer ud ) -{ - sxSinceLastData *sxsld; - GList *tctList; - toCreateTransaction *tct; - - sxsld = (sxSinceLastData*)ud; - - tctList = sxsld->transList; - if ( tctList == NULL ) { - PERR( "no transactions to create\n" ); - } - do { - tct = (toCreateTransaction*)tctList->data; - slr_create_transactions( tct->sx, tct->date ); - } while ( (tctList = tctList->next) ); - - nextrun_close_handler( ud ); -} - -static void -free_elts( gpointer data, gpointer user_data ) -{ - g_free( data ); -} - -static void -nr_next_clicked( GtkButton *b, gpointer ud ) -{ - sxSinceLastData *sxsld; - GtkWidget *dlg; - GtkWidget *o; - GtkCList *cl; - time_t gdeDate; - GList *sxList; - GNCBook *book; - SchedXaction *sx; - GDate gd, *endDate; - gchar buf[1024]; - gint row; - char *rowText[2]; - toCreateTransaction *tct; - - sxsld = (sxSinceLastData*)ud; - o = glade_xml_get_widget( sxsld->gxml, "next_date" ); - gdeDate = gnome_date_edit_get_date( GNOME_DATE_EDIT(o) ); - - DEBUG( "Okay... I should run with a date of: %s", ctime(&gdeDate) ); - - /* destroy the previous transactions - destroy all the toCreateTransactions */ - if ( sxsld->transList != NULL ) { - g_list_foreach( sxsld->transList, free_elts, NULL ); - g_list_free( sxsld->transList ); - sxsld->transList = NULL; - } - - book = gnc_get_current_book (); - sxList = gnc_book_get_schedxactions( book ); - if ( sxList == NULL ) { - PERR( "No scheduled transactions to play with\n" ); - return; - } - - /* FIXME: This is actually a non-changeable date. */ - endDate = g_date_new(); - g_date_set_time( endDate, gdeDate ); - - o = glade_xml_get_widget( sxsld->gxml, "replace_with_register" ); - cl = GTK_CLIST(o); - gtk_clist_clear( cl ); - - g_date_clear( &gd, 1 ); - row = 0; - do { - sx = (SchedXaction*)sxList->data; - /* this is really "last-run-date", right? */ - g_date_set_time( &gd, time(NULL) ); - - gd = xaccSchedXactionGetNextInstance( sx ); - while ( g_date_compare( &gd, endDate ) <= 0 - && g_date_valid( &gd ) ) { - - g_date_strftime( buf, 1023, "%a, %b %e, %Y", &gd ); - /* add to clist [ahem... register... ahem] */ - rowText[0] = xaccSchedXactionGetName( sx ); - rowText[1] = malloc( sizeof(char) * 256 ); /* FIXME */ - g_date_strftime( rowText[1], 255, "%a, %b %e, %Y", &gd ); - - tct = g_new0( toCreateTransaction, 1 ); - tct->sx = sx; - tct->date = g_date_new(); - *tct->date = gd; - tct->clistRow = row; - sxsld->transList = g_list_append( sxsld->transList, tct ); - - gtk_clist_insert( cl, row, rowText ); - row += 1; - gd = xaccSchedXactionGetInstanceAfter( sx, &gd ); - } - } while ( (sxList = sxList->next) ); - - g_date_free( endDate ); -} - -static void -nextrun_destroy( GtkObject *o, gpointer ud ) -{ - DEBUG( "nuttin' doin...\n" ); -} - -static void -nr_prev_xaction_clicked( GtkButton *b, gpointer ud ) -{ -} - -static void -nr_next_xaction_clicked( GtkButton *b, gpointer ud ) -{ -} - -static gboolean -create_each_transaction( Transaction *t, void *d ) -{ - Transaction *newT; - GDate *gd; - GList *sList; - GList *osList; - Split *split; - kvp_frame *split_kvpf; - kvp_value *kvp_val; - gboolean errFlag; - - errFlag = FALSE; - - DEBUG( "I'm seeing Transaction \"%s\"\n", - xaccTransGetDescription( t ) ); - - gd = (GDate*)d; - - newT = xaccMallocTransaction(gnc_get_current_session ()); - xaccTransBeginEdit( newT ); - /* the action and description/memo are in the template */ - gnc_copy_trans_onto_trans( t, newT, FALSE, FALSE ); - - /* the date is new [gd] */ - xaccTransSetDate( newT, - g_date_day( gd ), - g_date_month( gd ), - g_date_year( gd ) ); - - /* the accounts and amounts are in the kvp_frames of the splits. */ - osList = xaccTransGetSplitList( t ); - sList = xaccTransGetSplitList( newT ); - if ( (osList == NULL) || (sList == NULL) ) { - PERR( "\tseen transaction w/o splits. :(\n" ); - return FALSE; - } - do { - split = (Split*)sList->data; - /* FIXME: Ick. This assumes that the split lists will be - ordered identically. :( I think it's fair to say they - will, but I'd rather not have to count on it. --jsled */ - split_kvpf = xaccSplitGetSlots( (Split*)osList->data ); - - DEBUG( "\tProcessing Split \"%s\"\n", - xaccSplitGetMemo( split ) ); - - DEBUG( "\tkvp_frame: %s\n", - kvp_frame_to_string( split_kvpf ) ); - - - /* from-transaction of splits */ - { - GUID *acct_guid; - Account *acct; - /* contains the guid of the split's actual account. */ - kvp_val = kvp_frame_get_slot_path( split_kvpf, - GNC_SX_ID, - GNC_SX_ACCOUNT, - NULL); - if ( kvp_val == NULL ) { - PERR( "Null kvp_val for account\n" ); - } - acct_guid = kvp_value_get_guid( kvp_val ); - acct = xaccAccountLookup( acct_guid, - gnc_get_current_session () ); - DEBUG( "Got account with name \"%s\"\n", - xaccAccountGetName( acct ) ); - /* xaccSplitSetAccount( split, acct ); */ - xaccAccountInsertSplit( acct, split ); - } - /* credit/debit formulas */ - { - char *str; - gnc_numeric credit_num; - gnc_numeric debit_num; - gnc_numeric final; - int gncn_error; - - kvp_val = kvp_frame_get_slot_path(split_kvpf, - GNC_SX_ID, - GNC_SX_CREDIT_FORMULA, - NULL); - str = kvp_value_get_string( kvp_val ); - credit_num = gnc_numeric_create( 0, 1 ); - if ( str != NULL ) { - - printf( "---------------\n" ); - printf( "Parsing formula:\n" ); - /* parse_vars_from_formula( str, NULL ); */ - printf( "---------------\n" ); - - xaccParseAmount( str, TRUE, &credit_num, NULL ); - /* string_to_gnc_numeric( str, &credit_num ); */ - printf( "gnc_numeric::credit: \"%s\" -> \"%s\"\n", - str, gnc_numeric_to_string( credit_num ) ); - } - - kvp_val = kvp_frame_get_slot_path( split_kvpf, - GNC_SX_ID, - GNC_SX_DEBIT_FORMULA, - NULL); - str = kvp_value_get_string( kvp_val ); - - debit_num = gnc_numeric_create( 0, 1 ); - if ( str != NULL ) { - - printf( "---------------\n" ); - printf( "Parsing formula:\n" ); - /* parse_vars_from_formula( str, NULL ); */ - printf( "---------------\n" ); - - xaccParseAmount( str, TRUE, &debit_num, NULL ); - /* string_to_gnc_numeric( str, &debit_num ); */ - printf( "gnc_numeric::debit: \"%s\" -> \"%s\"\n", - str, gnc_numeric_to_string( debit_num ) ); - } - - final = gnc_numeric_sub_fixed( credit_num, debit_num ); - - gncn_error = gnc_numeric_check( final ); - if ( gncn_error != GNC_ERROR_OK ) { - printf( "Error %d in final gnc_numeric value\n", gncn_error ); - errFlag = TRUE; - break; - } - DEBUG( "gnc_numeric::final: \"%s\"\n", - gnc_numeric_to_string( final ) ); - xaccSplitSetValue( split, final ); - } -#if 0 - kvp_val = kvp_frame_get_slot_path( split_kvpf, - GNC_SX_ID, - GNC_SX_SHARES, - NULL); - kvp_val = kvp_frame_get_slot_path( split_kvpf, - GNC_SX_ID, - GNC_SX_AMNT, - NULL); -#endif /* 0 */ - } while ( (sList = sList->next) && (osList = osList->next) ); - - if ( errFlag ) { - PERR( "Some error in new transaction creation...\n" ); - xaccTransRollbackEdit( newT ); - } else { - xaccTransCommitEdit( newT ); - } - - return TRUE; - -} - -static void -slr_create_transactions( SchedXaction *sx, GDate *gd ) -{ - AccountGroup *ag; - Account *acct; - char *id; - - /* get template account group */ - ag = gnc_book_get_template_group( gnc_get_current_book () ); - id = guid_to_string( xaccSchedXactionGetGUID(sx) ); - acct = xaccGetAccountFromName( ag, id ); - DEBUG( "Got account \"%s\"\n", - xaccAccountGetName( acct ) ); - g_free( id ); - - xaccAccountForEachTransaction( acct, - create_each_transaction, - gd ); -} - -#if 0 - -/** - * Parses in-fix mathematical formulas using the standard operators - * [+-/%*], and '(', ')' grouping. - * - * Any strings are placed in the GHashTable as variables. The value of - * each key in the hash-table is a struct of the form: - * { const char *varStr; - * gint idx; - * gint len; }; - * - **/ -int -parse_vars_from_formula( const char *formula, GHashTable *varHash ) -{ - gnc_numeric num_foo; - char *foo; - GList *list; - - gnc_exp_parser_init(); - if ( ! gnc_exp_parser_parse( formula, &num_foo, &foo ) ) { - PERR( "Error parsing at \"%s\": %s\n", - foo, gnc_exp_parser_error_string() ); - } - PINFO( "Successful parse...\n" ); - list = gnc_exp_parser_get_variable_names(); - if ( list == NULL ) { - PINFO( "NULL variable list\n" ); - } else { - do { - PINFO( "Variable \"%s\"\n", - list->data ); - } while ( (list = list->next) ); - } - - gnc_exp_parser_shutdown(); -} -#endif /* 0 */ - -#if 0 - GScanner *varScanner; - GTokenType tok; - - varScanner = g_scanner_new( NULL ); - g_scanner_set_scope( varScanner, 0 ); - g_scanner_freeze_symbol_table( varScanner ); - g_scanner_scope_add_symbol( varScanner, 0, "(", (gpointer)"left-paren" ); - g_scanner_scope_add_symbol( varScanner, 0, ")", (gpointer)"right-paren" ); - g_scanner_scope_add_symbol( varScanner, 0, "+", (gpointer)"plus" ); - g_scanner_scope_add_symbol( varScanner, 0, "-", (gpointer)"minus" ); - g_scanner_scope_add_symbol( varScanner, 0, "/", (gpointer)"div" ); - g_scanner_scope_add_symbol( varScanner, 0, "*", (gpointer)"mult" ); - g_scanner_thaw_symbol_table( varScanner ); - - g_scanner_input_text( varScanner, formula, strlen( formula ) ); - - do { - tok = g_scanner_get_next_token( varScanner ); - printf( "tok: " ); - switch ( varScanner->token ) { - case G_TOKEN_EOF: - printf( "EOF" ); break; - case G_TOKEN_LEFT_PAREN: - printf( "(" ); break; - case G_TOKEN_RIGHT_PAREN: - printf( ")" ); break; - case G_TOKEN_LEFT_CURLY: - printf( "{" ); break; - case G_TOKEN_RIGHT_CURLY: - printf( "}" ); break; - case G_TOKEN_LEFT_BRACE: - printf( "[" ); break; - case G_TOKEN_RIGHT_BRACE: - printf( "]" ); break; - case G_TOKEN_EQUAL_SIGN: - printf( "=" ); break; - case G_TOKEN_COMMA: - printf( "," ); break; - case G_TOKEN_NONE: - printf( "NONE" ); break; - case G_TOKEN_ERROR: - printf( "ERROR(%d)", varScanner->value.v_error ); break; - case G_TOKEN_CHAR: - printf( "CHAR(%c)", varScanner->value.v_char ); break; - case G_TOKEN_BINARY: - printf( "BINARY" ); break; - case G_TOKEN_OCTAL: - printf( "OCTAL(%ul)", varScanner->value.v_octal ); break; - case G_TOKEN_INT: - printf( "INT(%ul)", varScanner->value.v_int ); break; - case G_TOKEN_HEX: - printf( "HEX(%ul)", varScanner->value.v_hex ); break; - case G_TOKEN_FLOAT: - printf( "FLOAT(%f)", varScanner->value.v_float ); break; - case G_TOKEN_STRING: - printf( "STRING(%s)", varScanner->value.v_string ); break; - case G_TOKEN_SYMBOL: - printf( "SYMBOL(%s)", (gchar*)varScanner->value.v_symbol ); break; - case G_TOKEN_IDENTIFIER: - printf( "IDENT(%s)", varScanner->value.v_identifier ); break; - case G_TOKEN_IDENTIFIER_NULL: - printf( "NULL_IDENT" ); break; - case G_TOKEN_COMMENT_SINGLE: - case G_TOKEN_COMMENT_MULTI: - printf( "COMMENT(%s)", varScanner->value.v_comment ); break; - case G_TOKEN_LAST: - printf( "END" ); break; - default: - printf( "UNK" ); break; - }; - printf( "\n" ); - } while ( (varScanner->token != G_TOKEN_LAST) && - (varScanner->token != G_TOKEN_EOF) && - (varScanner->token != G_TOKEN_NONE) ); - return 1; - /* -"0.33 * ( base + ld ) + (0.25 * internet)": - -tok: FLOAT(0.330000) -tok: UNK -tok: ) -tok: IDENT(base) -tok: UNK -tok: IDENT(ld) -tok: ( -tok: UNK -tok: ) -tok: FLOAT(0.250000) -tok: UNK -tok: IDENT(internet) -tok: ( -tok: EOF - */ - -#endif /* 0 */ diff --git a/src/gnome/dialog-scheduledxaction.c b/src/gnome/dialog-scheduledxaction.c index d35658383b..f2b5fc4845 100644 --- a/src/gnome/dialog-scheduledxaction.c +++ b/src/gnome/dialog-scheduledxaction.c @@ -58,6 +58,7 @@ static short module = MOD_SX; #define ADVANCE_DAYS_SPIN "advance_days" #define REMIND_OPT "remind_opt" #define REMIND_DAYS_SPIN "remind_days" +#define END_GNOME_NUMENTRY "end_gnome_nentry" #define END_OPTION 0 #define NUM_OCCUR_OPTION 1 @@ -142,8 +143,8 @@ static void sxed_reg_xferCB( GtkWidget *w, gpointer d ); static void gnc_sxed_reg_check_close(SchedXactionEditorDialog *sxed); -static gboolean _editor_component_sx_equality( gpointer find_data, - gpointer user_data ); +static gboolean editor_component_sx_equality( gpointer find_data, + gpointer user_data ); /** Implementations *****************************************************/ @@ -162,6 +163,8 @@ sxed_close_handler ( gpointer user_data ) { SchedXactionEditorDialog *sxed = user_data; + DEBUG( "sxed_close_handler" ); + gnc_sxed_reg_check_close( sxed ); gnc_ledger_display_close( sxed->ledger ); @@ -203,7 +206,7 @@ void editor_ok_button_clicked( GtkButton *b, SchedXactionEditorDialog *sxed ) { GNCBook *book; - GtkWidget *o, *o2, *o3; + GtkWidget *w, *optEndDate, *optNoEnd, *optNumOccur; GList *sxList; FreqSpec *fs; gint row; @@ -213,28 +216,29 @@ editor_ok_button_clicked( GtkButton *b, SchedXactionEditorDialog *sxed ) gdate = g_date_new(); /* read out data back into SchedXaction object. */ - o = glade_xml_get_widget( sxed->gxml, "sxe_name" ); - xaccSchedXactionSetName( sxed->sx, gtk_entry_get_text( GTK_ENTRY(o) ) ); + w = glade_xml_get_widget( sxed->gxml, "sxe_name" ); + xaccSchedXactionSetName( sxed->sx, gtk_entry_get_text( GTK_ENTRY(w) ) ); - o = glade_xml_get_widget( sxed->gxml, "rb_enddate" ); - o2 = glade_xml_get_widget( sxed->gxml, "rb_noend" ); - o3 = glade_xml_get_widget( sxed->gxml, "rb_num_occur" ); - if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(o)) ) { + optEndDate = glade_xml_get_widget( sxed->gxml, "rb_enddate" ); + optNoEnd = glade_xml_get_widget( sxed->gxml, "rb_noend" ); + optNumOccur = glade_xml_get_widget( sxed->gxml, "rb_num_occur" ); + if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(optEndDate)) ) { /* get the end date data */ - o = glade_xml_get_widget( sxed->gxml, "sxe_end_date" ); - g_date_set_time( gdate, gnome_date_edit_get_date( GNOME_DATE_EDIT(o) ) ); + w = glade_xml_get_widget( sxed->gxml, "sxe_end_date" ); + g_date_set_time( gdate, gnome_date_edit_get_date( GNOME_DATE_EDIT(w) ) ); xaccSchedXactionSetEndDate( sxed->sx, gdate ); /* set the num occurances data */ - xaccSchedXactionSetNumOccur( sxed->sx, -1 ); - } else if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(o3) ) ) { + xaccSchedXactionSetNumOccur( sxed->sx, 0 ); + } else if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(optNumOccur) ) ) { + gint num; /* get the occurances data */ - o = glade_xml_get_widget( sxed->gxml, "end_nentry" ); - xaccSchedXactionSetNumOccur( sxed->sx, - (gint)gnome_number_entry_get_number( GNOME_NUMBER_ENTRY(o) ) ); + w = glade_xml_get_widget( sxed->gxml, END_GNOME_NUMENTRY ); + num = (gint)gnome_number_entry_get_number( GNOME_NUMBER_ENTRY(w) ); + xaccSchedXactionSetNumOccur( sxed->sx, num ); g_date_clear( gdate, 1 ); xaccSchedXactionSetEndDate( sxed->sx, gdate ); - } else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(o2) ) ) { - xaccSchedXactionSetNumOccur( sxed->sx, -1 ); + } else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(optNoEnd) ) ) { + xaccSchedXactionSetNumOccur( sxed->sx, 0 ); g_date_clear( gdate, 1 ); xaccSchedXactionSetEndDate( sxed->sx, gdate ); } else { @@ -244,10 +248,10 @@ editor_ok_button_clicked( GtkButton *b, SchedXactionEditorDialog *sxed ) { gboolean autocreateState, notifyState; - o = glade_xml_get_widget( sxed->gxml, "autocreate_opt" ); - autocreateState = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(o) ); - o = glade_xml_get_widget( sxed->gxml, "notify_opt" ); - notifyState = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(o) ); + w = glade_xml_get_widget( sxed->gxml, "autocreate_opt" ); + autocreateState = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(w) ); + w = glade_xml_get_widget( sxed->gxml, "notify_opt" ); + notifyState = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(w) ); /* "Notify" only makes sense if AutoCreate is actived; enforce that here. */ @@ -260,20 +264,20 @@ editor_ok_button_clicked( GtkButton *b, SchedXactionEditorDialog *sxed ) int daysInAdvance; daysInAdvance = 0; - o = glade_xml_get_widget( sxed->gxml, "advance_opt" ); - if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(o) ) ) { - o = glade_xml_get_widget( sxed->gxml, "advance_days" ); + w = glade_xml_get_widget( sxed->gxml, "advance_opt" ); + if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(w) ) ) { + w = glade_xml_get_widget( sxed->gxml, "advance_days" ); daysInAdvance = - gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(o) ); + gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(w) ); } xaccSchedXactionSetAdvanceCreation( sxed->sx, daysInAdvance ); daysInAdvance = 0; - o = glade_xml_get_widget( sxed->gxml, "remind_opt" ); - if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(o) ) ) { - o = glade_xml_get_widget( sxed->gxml, "remind_days" ); + w = glade_xml_get_widget( sxed->gxml, "remind_opt" ); + if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(w) ) ) { + w = glade_xml_get_widget( sxed->gxml, "remind_days" ); daysInAdvance = - gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(o) ); + gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(w) ); } xaccSchedXactionSetAdvanceReminder( sxed->sx, daysInAdvance ); } @@ -326,6 +330,8 @@ advance_toggle( GtkButton *o, SchedXactionEditorDialog *sxed ) } gtk_widget_set_sensitive( spin, gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(o) ) ); + /* FIXME: this doesn't do what we want... :( */ + gtk_editable_set_editable( GTK_EDITABLE(spin), TRUE ); } /* Local destruction of dialog */ @@ -519,7 +525,7 @@ gnc_ui_scheduled_xaction_editor_dialog_create( SchedXactionDialog *sxd, }; alreadyExists = gnc_find_gui_components( DIALOG_SCHEDXACTION_EDITOR_CM_CLASS, - _editor_component_sx_equality, + editor_component_sx_equality, sx ); if ( alreadyExists ) { sxed = (SchedXactionEditorDialog*)alreadyExists->data; @@ -593,9 +599,9 @@ void schedXact_editor_init( SchedXactionEditorDialog *sxed ) { GtkWidget *w; - w = glade_xml_get_widget( sxed->gxml, - "end_nentry" ); + w = glade_xml_get_widget( sxed->gxml, END_GNOME_NUMENTRY ); gtk_widget_set_sensitive( w, FALSE ); + /* Allow grow, allow shrink, auto-shrink */ gtk_window_set_policy (GTK_WINDOW(sxed->dialog), TRUE, TRUE, FALSE); } @@ -892,16 +898,10 @@ schedXact_editor_create_ledger( SchedXactionEditorDialog *sxed ) gnucash_register_attach_popup( sxed->reg, popup, sxed ); toolbar = schedXaction_editor_create_reg_tool_bar( sxed ); - gtk_container_set_border_width( GTK_CONTAINER(toolbar), 2 ); + //gtk_container_set_border_width( GTK_CONTAINER(toolbar), 2 ); - gtk_container_add( GTK_CONTAINER(vbox), toolbar ); - gtk_container_add( GTK_CONTAINER(vbox), regWidget ); - - /* FIXME: This doesn't actually do what we want. */ - gtk_box_set_child_packing( GTK_BOX(vbox), regWidget, - TRUE, TRUE, 2, - GTK_PACK_END /* it already has a - * position... */ ); + gtk_box_pack_start( GTK_BOX(vbox), toolbar, FALSE, FALSE, 2 ); + gtk_box_pack_end( GTK_BOX(vbox), regWidget, TRUE, TRUE, 2 ); #if 0 gtk_signal_connect( GTK_OBJECT(sxed->dialog), "activate_cursor", @@ -963,7 +963,7 @@ schedXact_editor_populate( SchedXactionEditorDialog *sxed ) } else if ( xaccSchedXactionGetNumOccur( sxed->sx ) != -1 ) { w = glade_xml_get_widget( sxed->gxml, "rb_num_occur" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(w), TRUE ); - w = glade_xml_get_widget( sxed->gxml, "end_nentry" ); + w = glade_xml_get_widget( sxed->gxml, END_GNOME_NUMENTRY ); w = gnome_number_entry_gtk_entry( GNOME_NUMBER_ENTRY(w) ); tmpgStr = g_string_sized_new(5); g_string_sprintf( tmpgStr, "%d", xaccSchedXactionGetNumOccur( sxed->sx ) ); @@ -1059,7 +1059,7 @@ set_endgroup_toggle_states( SchedXactionEditorDialog *sxed, EndType type ) dateCtl = glade_xml_get_widget( sxed->gxml, "sxe_end_date" ); gtk_widget_set_sensitive( GTK_WIDGET(dateCtl), (type == END_DATE) ); - occurCtl = glade_xml_get_widget( sxed->gxml, "end_nentry" ); + occurCtl = glade_xml_get_widget( sxed->gxml, END_GNOME_NUMENTRY ); gtk_widget_set_sensitive( GTK_WIDGET(occurCtl), (type == END_OCCUR) ); } @@ -1080,29 +1080,24 @@ static void edit_button_clicked( GtkButton *b, gpointer d ) { - GList *sel; - GtkCList *cl; - int row; - SchedXactionDialog *sxd; - SchedXaction *sx; + GList *sel; + GtkCList *cl; + int row; + SchedXactionDialog *sxd; + SchedXaction *sx; SchedXactionEditorDialog *sxed; sxd = (SchedXactionDialog*)d; cl = GTK_CLIST(glade_xml_get_widget( sxd->gxml, "sched_xact_list" )); - sel = cl->selection; - if ( !sel ) { - return; - } - - do { + for( sel = cl->selection; sel; sel = g_list_next(sel) ) { row = (int)sel->data; /* get the clist row for this listitem */ /* get the object UD */ sx = (SchedXaction*)gtk_clist_get_row_data( cl, row ); sxed = gnc_ui_scheduled_xaction_editor_dialog_create( sxd, sx, 0 ); - } while ( (sel = g_list_next(sel)) ); + } } static @@ -1229,7 +1224,7 @@ putSchedXactionInClist( gpointer data, gpointer user_data ) xaccFreqSpecGetFreqStr( xaccSchedXactionGetFreqSpec(sx), freqStr ); - gd = xaccSchedXactionGetNextInstance( sx ); + gd = xaccSchedXactionGetNextInstance( sx, NULL ); if ( ! g_date_valid( &gd ) ) { g_string_sprintf( nextDate, "not scheduled" ); @@ -1622,8 +1617,8 @@ gnc_sxed_reg_check_close(SchedXactionEditorDialog *sxed) } static gboolean -_editor_component_sx_equality( gpointer find_data, - gpointer user_data ) +editor_component_sx_equality( gpointer find_data, + gpointer user_data ) { return ( (SchedXaction*)find_data == ((SchedXactionEditorDialog*)user_data)->sx ); diff --git a/src/gnome/dialog-sxsincelast.c b/src/gnome/dialog-sxsincelast.c index 4a185a6f62..e140205097 100644 --- a/src/gnome/dialog-sxsincelast.c +++ b/src/gnome/dialog-sxsincelast.c @@ -20,6 +20,21 @@ * Boston, MA 02111-1307, USA gnu@gnu.org * \********************************************************************/ +/** + * . Page 1: reminders list + * . backed by: sxsld->reminderList + * . Page 2: auto-create notify ledger + * . backed by: sxsld->autoCreateList [?] + * . Page 3: to-create variable bindings + * . backed by: sxsld->toCreateData [s/Data/List/] + * . Page 4: created ledger + * . backed by: sxsld->createdList [?] + * . Page 5: obsolete list + * . backed by: sxsld->toRemoveList + * . Page 6: finish + * . implement changes? + **/ + #include "config.h" #include @@ -52,9 +67,15 @@ #define DIALOG_SXSINCELAST_REMIND_CM_CLASS "dialog-sxsincelast-remind" #define DIALOG_SXSINCELAST_OBSOLETE_CM_CLASS "dialog-sxsincelast-obsolete" -#define DIALOG_SXSINCELAST_GLADE_NAME "Real Since-Last-Run Dialog" -#define DIALOG_SXSINCELAST_REMIND_GLADE_NAME "Since-Last Reminders" -#define DIALOG_SXSINCELAST_OBSOLETE_GLADE_NAME "Obsolete-SXs" +#define DIALOG_SXSINCELAST_GLADE_NAME "Since Last Run Druid" + +#define SINCELAST_DRUID "sincelast_druid" +#define REMINDERS_PG "reminders_page" +#define AUTO_CREATE_NOTIFY_PG "auto_create_notify_page" +#define TO_CREATE_PG "to_create_page" +#define CREATED_PG "created_page" +#define OBSOLETE_PG "obsolete_page" +#define FINISH_PG "finish_page" #define SX_OBSOLETE_CLIST "sx_obsolete_clist" #define TO_CREATE_CLIST "to_create_clist" @@ -65,7 +86,8 @@ #define UNSELECT_ALL_BUTTON "unselect_all_button" #define OK_BUTTON "ok_button" #define CANCEL_BUTTON "cancel_button" - +#define VARIABLE_TABLE "variables_table" +#define AUTO_CREATE_VBOX "ac_vbox" #define TO_CREATE_CLIST_WIDTH 3 #define REMINDER_CLIST_WIDTH 3 @@ -89,29 +111,15 @@ static short module = MOD_SX; * handled here. **/ typedef struct _sxSinceLastData { - GtkWidget *sxsincelastDlg; - GladeXML *gxml; + GtkWidget *druid_sincelast; + GladeXML *gxml; - GtkWidget *dlg_remind; - GladeXML *gxml_remind; - - - GtkWidget *dlg_obsolete; - GladeXML *gxml_obsolete; - guint n_obsolete; - - gboolean sincelast_displayed; - gboolean remind_displayed; - gboolean obsolete_displayed; - - GList /* */ *toCreateData; - GList /* */ *reminderData; - - GList *actual_to_remove; - - GNCLedgerDisplay *ac_ledger; - GnucashRegister *reg; + GList /* */ *toCreateData; + GList /* */ *reminderList; + GList /* */ *toRemoveList; + GNCLedgerDisplay *ac_ledger; + GnucashRegister *reg; } sxSinceLastData; typedef struct _toCreateTuple { @@ -128,18 +136,18 @@ typedef struct _reminderTuple { gboolean isSelected; } reminderTuple; -typedef struct { - SchedXaction *sx; - GDate *endDate; - gchar *freq_info; - gboolean isSelected; +typedef struct _toDeleteTuple { + SchedXaction *sx; + GDate *endDate; + gchar *freq_info; + gboolean isSelected; } toDeleteTuple; typedef struct _creation_helper_userdata { /* the to-create tuple */ toCreateTuple *tct; /* a [pointer to a] GList to append the GUIDs of newly-created - transactions to, or NULL */ + * transactions to, or NULL */ GList **createdGUIDs; } createData; @@ -148,35 +156,36 @@ static int rl_row = 0; /* Next to-create clist row index to create. */ static int tcl_row = 0; - static void sxsincelast_init( sxSinceLastData *sxsld ); static void create_autoCreate_gen_ledger( sxSinceLastData *sxsld ); -static gncUIWidget _sxsld_ledger_get_parent( GNCLedgerDisplay *ld ); +static gncUIWidget sxsld_ledger_get_parent( GNCLedgerDisplay *ld ); static gboolean sxsincelast_populate( sxSinceLastData *sxsld ); +static void sxsincelast_druid_cancelled( GnomeDruid *druid, gpointer ud ); static void sxsincelast_close_handler( gpointer ud ); -static void sxsld_remind_close_handler( gpointer ud ); + static void sxsincelast_ok_clicked( GtkButton *b, gpointer ud ); -static void sxsld_remind_ok_clicked( GtkButton *b, gpointer ud ); + static void sxsincelast_cancel_clicked( GtkButton *b, gpointer ud ); static void sxsincelast_entry_changed( GtkEditable *e, gpointer ud ); static void sxsincelast_destroy( GtkObject *o, gpointer ud ); -static void _create_transactions_on( SchedXaction *sx, - GDate *gd, - toCreateTuple *tct, - GList **createdGUIDs ); -static gboolean _create_each_transaction_helper( Transaction *t, void *d ); -static void _sxsl_get_sx_vars( SchedXaction *sx, GHashTable *varHash ); -static void _hash_to_sorted_list( GHashTable *hashTable, GList **gl ); -static void _andequal_numerics_set( gpointer key, - gpointer value, - gpointer data ); -static void _print_vars_helper( gpointer key, - gpointer value, - gpointer user_data ); -static void _clean_variable_table( sxSinceLastData *sxsld ); +static void create_transactions_on( SchedXaction *sx, + GDate *gd, + toCreateTuple *tct, + GList **createdGUIDs ); +static gboolean create_each_transaction_helper( Transaction *t, void *d ); +static void sxsl_get_sx_vars( SchedXaction *sx, GHashTable *varHash ); +static void hash_to_sorted_list( GHashTable *hashTable, GList **gl ); +static void andequal_numerics_set( gpointer key, + gpointer value, + gpointer data ); +static void print_vars_helper( gpointer key, + gpointer value, + gpointer user_data ); +static void clean_sincelast_data( sxSinceLastData *sxsld ); +static void clean_variable_table( sxSinceLastData *sxsld ); static void processAutoCreateList( GList *, sxSinceLastData *sxsld, @@ -185,8 +194,9 @@ static void processToCreateList( GList *, sxSinceLastData *sxsld, SchedXaction * ); static void processReminderList( GList *, - sxSinceLastData *sxsld, - SchedXaction * ); + sxSinceLastData *sxsld ); +static void processRemoveList( GList *, + sxSinceLastData *sxsld ); static void processSelectedReminderList( GList *, sxSinceLastData * ); @@ -205,10 +215,11 @@ static void sxsld_remind_row_toggle( GtkCList *clist, GdkEventButton *event, gpointer user_data); -static void _create_bad_reminders_msg( gpointer data, gpointer ud ); -static gboolean _inform_or_add( GList *reminders, - reminderTuple *rt, gboolean okFlag, - GList *badList, GList **goodList ); +static gboolean processed_valid_reminders_listP( sxSinceLastData *sxsld ); +static void create_bad_reminders_msg( gpointer data, gpointer ud ); +static gboolean inform_or_add( GList *reminders, + reminderTuple *rt, gboolean okFlag, + GList *badList, GList **goodList ); int parse_vars_from_formula( const char *formula, GHashTable *varHash ); static void sx_obsolete_ok_clicked(GtkButton *button, gpointer user_data); @@ -220,7 +231,7 @@ static void sx_obsolete_row_unsel(GtkCList *clist, GdkEventButton *event, gpointer user_data); -static void sx_obsolete_close_handler(gpointer user_data); +static void sx_obsolete_close_handler(gpointer user_data); static void sx_obsolete_select_all_clicked(GtkButton *butt, gpointer user_data); static void sx_obsolete_unselect_all_clicked(GtkButton *button, gpointer user_data); @@ -229,6 +240,7 @@ static void sx_obsolete_row_sel(GtkCList *clist, gint column, GdkEventButton *event, gpointer user_data); + void gnc_ui_sxsincelast_guile_wrapper( char *foo ) { @@ -240,167 +252,333 @@ gnc_ui_sxsincelast_dialog_create(void) { sxSinceLastData *sxsld = g_new0( sxSinceLastData, 1 ); - sxsld->toCreateData = sxsld->reminderData = NULL; - sxsld->remind_displayed = sxsld->sincelast_displayed = FALSE; + sxsld->toCreateData = sxsld->reminderList = sxsld->toRemoveList = NULL; sxsld->gxml = gnc_glade_xml_new( SX_GLADE_FILE, DIALOG_SXSINCELAST_GLADE_NAME ); - sxsld->sxsincelastDlg = + sxsld->druid_sincelast = glade_xml_get_widget( sxsld->gxml, DIALOG_SXSINCELAST_GLADE_NAME ); - - sxsld->gxml_remind - = gnc_glade_xml_new( SX_GLADE_FILE, - DIALOG_SXSINCELAST_REMIND_GLADE_NAME ); - sxsld->dlg_remind - = glade_xml_get_widget( sxsld->gxml_remind, - DIALOG_SXSINCELAST_REMIND_GLADE_NAME ); - - sxsld->gxml_obsolete - = gnc_glade_xml_new( SX_GLADE_FILE, - DIALOG_SXSINCELAST_OBSOLETE_GLADE_NAME ); - - sxsld->dlg_obsolete - = glade_xml_get_widget( sxsld->gxml_obsolete, - DIALOG_SXSINCELAST_OBSOLETE_GLADE_NAME ); - sxsincelast_init( sxsld ); } - - static void -clist_set_all_cols_autoresize(GtkCList *cl, guint n_cols) +clist_set_all_cols_autoresize( GtkCList *cl, guint n_cols ) { - guint col; - for(col = 0; col< n_cols; col++) - { - gtk_clist_set_column_auto_resize (cl, col, TRUE); - } - return; + guint col; + for( col = 0; col< n_cols; col++ ) { + gtk_clist_set_column_auto_resize (cl, col, TRUE); + } + return; } typedef struct { - char *name; - char *signal; - void (*handlerFn)(); + char *name; + char *signal; + void (*handlerFn)(); } widgetSignalHandlerTuple; + +typedef struct { + char *pageName; + char *signal; + gboolean (*handlerFn)(); +} druidSignalHandlerTuple; static void dialog_widgets_attach_handlers(GladeXML *dialog_xml, widgetSignalHandlerTuple *handler_info, sxSinceLastData *sxsld) { - int i; - GtkWidget *w; + int i; + GtkWidget *w; - for(i = 0; handler_info[i].name != NULL; i++) - { - w = glade_xml_get_widget(dialog_xml, handler_info[i].name); - gtk_signal_connect( GTK_OBJECT(w), handler_info[i].signal, - GTK_SIGNAL_FUNC(handler_info[i].handlerFn), - sxsld); - } + for(i = 0; handler_info[i].name != NULL; i++) + { + w = glade_xml_get_widget(dialog_xml, handler_info[i].name); + gtk_signal_connect( GTK_OBJECT(w), handler_info[i].signal, + GTK_SIGNAL_FUNC(handler_info[i].handlerFn), + sxsld); + } +} - return; +static void +druid_pages_attach_handlers( GladeXML *dialog_xml, + druidSignalHandlerTuple *handler_info, + sxSinceLastData *sxsld ) +{ + int i; + GtkWidget *w; + + for(i = 0; handler_info[i].pageName != NULL; i++) + { + w = glade_xml_get_widget(dialog_xml, handler_info[i].pageName); + gtk_signal_connect( GTK_OBJECT(w), + handler_info[i].signal, + GTK_SIGNAL_FUNC(handler_info[i].handlerFn), + sxsld); + } +} + +static void +sxsincelast_druid_cancelled( GnomeDruid *druid, gpointer ud ) +{ + /* FIXME: make sure the user understands the impact of what they're + * doing, perhaps dependent on what stage of the process they're in. + * Close, destroy, &c. */ + DEBUG( "druid cancelled" ); +} + +static gboolean +theres_no_turning_back_bang( GnomeDruidPage *druid_page, + gpointer arg1, gpointer ud ) +{ + DEBUG( "there's no turning back!!! MuHahahahhaha" ); + return TRUE; +} + +static gboolean +reminders_prep( GnomeDruidPage *druid_page, + gpointer arg1, gpointer ud ) +{ + DEBUG( "reminders_prep" ); + return FALSE; +} + +static gboolean +reminders_next( GnomeDruidPage *druid_page, + gpointer arg1, gpointer ud ) +{ + sxSinceLastData *sxsld = (sxSinceLastData*)ud; + DEBUG( "reminders_next" ); + if ( !processed_valid_reminders_listP( sxsld ) ) { + return TRUE; + } + /* next-state determination */ + return FALSE; +} + +static gboolean +reminders_back( GnomeDruidPage *druid_page, + gpointer arg1, gpointer ud ) +{ + DEBUG( "reminders_back" ); + return FALSE; +} + +static gboolean +reminders_finish( GnomeDruidPage *druid_page, + gpointer arg1, gpointer ud ) +{ + DEBUG( "reminders_finish" ); + return FALSE; +} + +static gboolean +reminders_cancel( GnomeDruidPage *druid_page, + gpointer arg1, gpointer ud ) +{ + DEBUG( "reminders_cancel" ); + return FALSE; +} + +static gboolean +obsolete_prep( GnomeDruidPage *druid_page, + gpointer arg1, gpointer ud ) +{ + sxSinceLastData *sxsld = (sxSinceLastData*)ud; + DEBUG( "obsolete_prep" ); + if ( g_list_length( sxsld->toRemoveList ) > 0 ) { + processRemoveList( sxsld->toRemoveList, sxsld ); + } + return FALSE; +} + +static gboolean +obsolete_next( GnomeDruidPage *druid_page, + gpointer arg1, gpointer ud ) +{ + GList *sxList, *toDelPtr; + GtkCList *cl; + gint row; + toDeleteTuple *tdt; + sxSinceLastData *sxsld = (sxSinceLastData*)ud; + + DEBUG( "obsolete_next" ); + sxList = gnc_book_get_schedxactions( gnc_get_current_book() ); + cl = GTK_CLIST( glade_xml_get_widget( sxsld->gxml, + SX_OBSOLETE_CLIST ) ); + + /* toDelPtr = sxsld->toRemoveList; */ + for ( toDelPtr = cl->selection; + toDelPtr; + toDelPtr = toDelPtr->next ) { + row = (gint)toDelPtr->data; + tdt = (toDeleteTuple*)gtk_clist_get_row_data( cl, row ); + sxList = g_list_remove( sxList, tdt->sx ); + sxsld->toRemoveList = + g_list_remove( sxsld->toRemoveList, tdt->sx ); + + xaccSchedXactionFree( tdt->sx ); + tdt->sx = NULL; + g_free( tdt ); + } + + gnc_book_set_schedxactions( gnc_get_current_book(), sxList ); + + gtk_clist_freeze( cl ); + gtk_clist_clear( cl ); + gtk_clist_thaw( cl ); + + return FALSE; +} + +static gboolean +to_create_next( GnomeDruidPage *druid_page, + gpointer arg1, gpointer ud ) +{ + sxSinceLastData *sxsld; + GtkCList *cl; + GList *tcList; + gboolean allVarsBound; + toCreateTuple *tct; + + sxsld = (sxSinceLastData*)ud; + + cl = GTK_CLIST(glade_xml_get_widget( sxsld->gxml, TO_CREATE_CLIST )); + + /* First: check to make sure all TCTs are 'ready' [and return if not]. + * Second: create the entries based on the variable bindings. */ + + tcList = sxsld->toCreateData; + if ( tcList == NULL ) { + DEBUG( "No transactions to create..." ); + /* FIXME: sxsincelast_close_handler( sxsld ); */ + return FALSE; + } + do { + tct = (toCreateTuple*)tcList->data; + allVarsBound = TRUE; + g_hash_table_foreach( tct->varBindings, + andequal_numerics_set, + &allVarsBound ); + if ( !allVarsBound ) { + char tmpBuf[GNC_D_BUF_WIDTH]; + g_date_strftime( tmpBuf, GNC_D_WIDTH, GNC_D_FMT, tct->date ); + /* FIXME: this should be better-presented to the user. */ + DEBUG( "SX %s on date %s still has unbound variables.", + xaccSchedXactionGetName(tct->sx), tmpBuf ); + gtk_clist_select_row( cl, tct->clistRow, 0 ); + return TRUE; + } + } while ( (tcList = tcList->next) ); + + tcList = sxsld->toCreateData; + /* At this point we can assume there are to-create transactions and + all variables are bound. */ + g_return_val_if_fail( tcList, TRUE ); + do { + tct = (toCreateTuple*)tcList->data; + create_transactions_on( tct->sx, tct->date, tct, NULL ); + } while ( (tcList = tcList->next) ); + + /* FXME: place in GL for review */ + + return FALSE; } - -/* - * FIXME: jsled, is it getting to the point where we should take this function - * apart? - */ static void sxsincelast_init( sxSinceLastData *sxsld ) { GtkWidget *w; int i; - widgetSignalHandlerTuple widgets[] = { - { OK_BUTTON, "clicked", sxsincelast_ok_clicked }, - { CANCEL_BUTTON, "clicked", sxsincelast_cancel_clicked }, + static widgetSignalHandlerTuple widgets[] = { + { SINCELAST_DRUID, "cancel", sxsincelast_druid_cancelled }, + + { REMINDER_CLIST, "select-row", sxsld_remind_row_toggle }, + { REMINDER_CLIST, "unselect-row", sxsld_remind_row_toggle }, + { TO_CREATE_CLIST, "select-row", sxsincelast_tc_row_sel }, { TO_CREATE_CLIST, "unselect-row", sxsincelast_tc_row_unsel }, - { NULL, NULL, NULL } + + { SELECT_ALL_BUTTON, "clicked", + sx_obsolete_select_all_clicked }, + { UNSELECT_ALL_BUTTON, "clicked", + sx_obsolete_unselect_all_clicked }, + { NULL, NULL, NULL } }; - widgetSignalHandlerTuple widgets_remind[] = { - { OK_BUTTON, "clicked", sxsld_remind_ok_clicked }, - { REMINDER_CLIST, "select-row", sxsld_remind_row_toggle }, - { REMINDER_CLIST, "unselect-row", sxsld_remind_row_toggle }, - { NULL, NULL, NULL } - }; - - widgetSignalHandlerTuple widgets_obsolete[] = { - { OK_BUTTON, "clicked", sx_obsolete_ok_clicked }, - { CANCEL_BUTTON, "clicked", sx_obsolete_cancel_clicked }, - { SELECT_ALL_BUTTON, "clicked", sx_obsolete_select_all_clicked }, - { UNSELECT_ALL_BUTTON, "clicked", sx_obsolete_unselect_all_clicked }, - { SX_OBSOLETE_CLIST, "select-row", sx_obsolete_row_sel}, - { SX_OBSOLETE_CLIST, "unselect-row", sx_obsolete_row_unsel}, - { NULL, NULL, NULL} - }; + + static druidSignalHandlerTuple pages[] = { + { REMINDERS_PG, "prepare", reminders_prep }, + { REMINDERS_PG, "next", reminders_next }, + { REMINDERS_PG, "finish", reminders_finish }, + { REMINDERS_PG, "cancel", reminders_cancel }, + + { TO_CREATE_PG, "next", to_create_next }, + + { REMINDERS_PG, "back", theres_no_turning_back_bang }, + { AUTO_CREATE_NOTIFY_PG, "back", theres_no_turning_back_bang }, + { TO_CREATE_PG, "back", theres_no_turning_back_bang }, + { CREATED_PG, "back", theres_no_turning_back_bang }, + { OBSOLETE_PG, "back", theres_no_turning_back_bang }, + + { OBSOLETE_PG, "prepare", obsolete_prep }, + { OBSOLETE_PG, "next", obsolete_next }, + + { NULL, NULL, NULL } + }; + gnc_register_gui_component( DIALOG_SXSINCELAST_CM_CLASS, NULL, sxsincelast_close_handler, - sxsld->sxsincelastDlg ); - - gnc_register_gui_component( DIALOG_SXSINCELAST_REMIND_CM_CLASS, - NULL, - sxsld_remind_close_handler, - sxsld->dlg_remind ); - - gnc_register_gui_component( DIALOG_SXSINCELAST_OBSOLETE_CM_CLASS, - NULL, - sx_obsolete_close_handler, - sxsld->dlg_obsolete ); + sxsld->druid_sincelast ); - gtk_signal_connect( GTK_OBJECT(sxsld->sxsincelastDlg), "destroy", + gtk_signal_connect( GTK_OBJECT(sxsld->druid_sincelast), "destroy", GTK_SIGNAL_FUNC( sxsincelast_destroy ), sxsld ); - /* Note: we don't add a 'destroy' signal handler because the - appropriate work [freeing since-last-run-related data structures] - is done in the sxsincelast_destroy function. */ dialog_widgets_attach_handlers(sxsld->gxml, widgets, sxsld); - dialog_widgets_attach_handlers(sxsld->gxml_remind, widgets_remind, sxsld); - dialog_widgets_attach_handlers(sxsld->gxml_obsolete, widgets_obsolete, sxsld); - - /* FIXME: Magic Numbers to be replaced */ - + druid_pages_attach_handlers( sxsld->gxml, pages, sxsld ); + /* set all to-create clist columns to auto-resize. */ w = glade_xml_get_widget( sxsld->gxml, TO_CREATE_CLIST ); clist_set_all_cols_autoresize(GTK_CLIST(w), TO_CREATE_CLIST_WIDTH); - w = glade_xml_get_widget( sxsld->gxml_remind, REMINDER_CLIST ); - clist_set_all_cols_autoresize(GTK_CLIST(w), REMINDER_CLIST_WIDTH); - w = glade_xml_get_widget( sxsld->gxml_obsolete, SX_OBSOLETE_CLIST); - clist_set_all_cols_autoresize(GTK_CLIST(w), SX_OBSOLETE_CLIST_WIDTH); + w = glade_xml_get_widget( sxsld->gxml, REMINDER_CLIST ); + clist_set_all_cols_autoresize(GTK_CLIST(w), REMINDER_CLIST_WIDTH); + w = glade_xml_get_widget( sxsld->gxml, SX_OBSOLETE_CLIST ); + clist_set_all_cols_autoresize(GTK_CLIST(w), SX_OBSOLETE_CLIST_WIDTH); rl_row = tcl_row = 0; - sxsld->n_obsolete = 0; - create_autoCreate_gen_ledger( sxsld ); - /* FIXME: deal with neither dialog being displayed [read: - nothing-to-do.] */ + /* FIXME: deal with nothing-to-do. */ if ( ! sxsincelast_populate( sxsld ) ) { sxsincelast_close_handler( sxsld ); return; } - gtk_widget_show_all( sxsld->sxsincelastDlg ); - sxsld->sincelast_displayed = TRUE; + gtk_widget_show_all( sxsld->druid_sincelast ); } static void -_generate_instances( SchedXaction *sx, - GDate *end, - GList **instanceList, - GList **deadList ) +generate_instances( SchedXaction *sx, + GDate *end, + GDate *reminderEnd, + GList **instanceList, + GList **reminderList, + GList **deadList ) { GDate gd, *gdToReturn; + reminderTuple *rt; + void *seqStateData; char tmpBuf[GNC_D_BUF_WIDTH]; - gd = xaccSchedXactionGetNextInstance( sx ); + DEBUG( "Generating instances for \"%s\"", + xaccSchedXactionGetName( sx ) ); + + /* Process valid next instances. */ + seqStateData = xaccSchedXactionCreateSequenceState( sx ); + gd = xaccSchedXactionGetNextInstance( sx, seqStateData ); while ( g_date_valid(&gd) && g_date_compare( &gd, end ) <= 0 ) { @@ -411,17 +589,46 @@ _generate_instances( SchedXaction *sx, *gdToReturn = gd; *instanceList = g_list_append( *instanceList, gdToReturn ); - gd = xaccSchedXactionGetInstanceAfter( sx, &gd ); + xaccSchedXactionIncrSequenceState( sx, seqStateData ); + gd = xaccSchedXactionGetInstanceAfter( sx, &gd, seqStateData ); } - if ( ! g_date_valid( &gd ) ) { + /* Add to dead list, or process reminder instances. */ + if ( !g_date_valid( &gd ) + && deadList ) { + toDeleteTuple *tdt; + PINFO( "Should be added to dead-list..." ); - *deadList = g_list_append( *deadList, sx ); + tdt = g_new0( toDeleteTuple, 1 ); + tdt->sx = sx; + tdt->endDate = g_date_new(); + *tdt->endDate = gd; + *deadList = g_list_append( *deadList, tdt ); + } else { + while ( g_date_valid(&gd) + && g_date_compare( &gd, reminderEnd ) <= 0 ) { + g_date_strftime( tmpBuf, GNC_D_WIDTH, GNC_D_FMT, &gd ); + DEBUG( "Adding reminder instance %s", tmpBuf ); + rt = g_new0( reminderTuple, 1 ); + rt->sx = sx; + rt->endDate = g_date_new(); + *rt->endDate = *end; + rt->occurDate = g_date_new(); + *rt->occurDate = gd; + rt->isSelected = FALSE; + + *reminderList = g_list_append( *reminderList, rt ); + + xaccSchedXactionIncrSequenceState( sx, seqStateData ); + gd = xaccSchedXactionGetInstanceAfter( sx, &gd, seqStateData ); + } } + xaccSchedXactionDestroySequenceState( sx, seqStateData ); + seqStateData = NULL; } static void -_free_gdate_list_elts( gpointer data, gpointer user_data ) +free_gdate_list_elts( gpointer data, gpointer user_data ) { g_date_free( (GDate*)data ); } @@ -458,14 +665,11 @@ processAutoCreateList( GList *autoCreateList, sxSinceLastData *sxsld, SchedXacti Query *autoCreateQuery; GList *createdGUIDs = NULL; GList *thisGUID; - GtkFrame *f; gboolean autoCreateState, notifyState; char *rowText[2]; /* get the "automagically created and notification requested" * register, and create the entries in it. */ - f = GTK_FRAME( glade_xml_get_widget( sxsld->gxml, "auto_create_frame" ) ); - autoCreateQuery = xaccMallocQuery(); xaccQuerySetGroup( autoCreateQuery, gnc_book_get_group( gnc_get_current_book() ) ); @@ -473,8 +677,8 @@ processAutoCreateList( GList *autoCreateList, sxSinceLastData *sxsld, SchedXacti xaccSchedXactionGetAutoCreate( sx, &autoCreateState, ¬ifyState ); - _create_transactions_on( sx, (GDate*)autoCreateList->data, - NULL, &createdGUIDs ); + create_transactions_on( sx, (GDate*)autoCreateList->data, + NULL, &createdGUIDs ); if ( notifyState ) { thisGUID = createdGUIDs; for ( ; thisGUID ; (thisGUID = thisGUID->next) ) { @@ -518,7 +722,7 @@ processToCreateList( GList *toCreateList, sxSinceLastData *sxsld, SchedXaction * rowText[0] = xaccSchedXactionGetName( sx ); rowText[1] = g_new0( char, GNC_D_WIDTH ); g_date_strftime( rowText[1], GNC_D_WIDTH, GNC_D_FMT, tct->date ); - _sxsl_get_sx_vars( sx, tct->varBindings ); + sxsl_get_sx_vars( sx, tct->varBindings ); if ( g_hash_table_size( tct->varBindings ) == 0 ) { rowText[2] = "y"; @@ -541,29 +745,29 @@ processToCreateList( GList *toCreateList, sxSinceLastData *sxsld, SchedXaction * } static void -processReminderList( GList *reminderList, sxSinceLastData *sxsld, SchedXaction *sx ) +processReminderList( GList *reminderList, sxSinceLastData *sxsld ) { GtkCList *clist; char *rowText[3]; reminderTuple *rt; - gboolean showIt; - - showIt = (g_list_length( reminderList ) > 0); if ( reminderList == NULL ) return; - clist = GTK_CLIST( glade_xml_get_widget( sxsld->gxml_remind, REMINDER_CLIST ) ); + clist = GTK_CLIST( glade_xml_get_widget( sxsld->gxml, + REMINDER_CLIST ) ); do { rt = (reminderTuple*)reminderList->data; - /* add to clist [ahem... register... ahem] */ - rowText[0] = xaccSchedXactionGetName( sx ); + + rowText[0] = xaccSchedXactionGetName( rt->sx ); rowText[1] = g_new0( gchar, GNC_D_WIDTH ); - g_date_strftime( rowText[1], GNC_D_WIDTH, GNC_D_FMT, rt->occurDate ); - rowText[2] = g_new0( gchar, 5 ); /* FIXME: appropriate size */ + g_date_strftime( rowText[1], + GNC_D_WIDTH, GNC_D_FMT, rt->occurDate ); + rowText[2] = g_new0( gchar, 5 ); /* FIXME: appropriate size? */ sprintf( rowText[2], "%d", - (g_date_julian(rt->occurDate) - g_date_julian(rt->endDate)) ); + (g_date_julian(rt->occurDate) + - g_date_julian(rt->endDate)) ); gtk_clist_insert( clist, rl_row, rowText ); gtk_clist_set_row_data( clist, rl_row, (gpointer)rt ); @@ -571,14 +775,7 @@ processReminderList( GList *reminderList, sxSinceLastData *sxsld, SchedXaction * g_free( rowText[1] ); g_free( rowText[2] ); - sxsld->reminderData = g_list_append( sxsld->reminderData, rt ); - } while ( (reminderList = reminderList->next) ); - - if ( showIt ) { - gtk_widget_show_all( sxsld->dlg_remind ); - sxsld->remind_displayed = TRUE; - } } static void @@ -587,67 +784,44 @@ processRemoveList(GList *removeList, sxSinceLastData *sxsld) GtkCList *cl; char *rowtext[3]; int row; - //GList *sx_listEntry; GString *tmp_str; - SchedXaction *sx; + toDeleteTuple *tdt; FreqSpec *fs; - rowtext[1] = g_new0(gchar, GNC_D_BUF_WIDTH ); + GDate *gd; + rowtext[2] = g_new0(gchar, GNC_D_BUF_WIDTH ); - cl = GTK_CLIST( glade_xml_get_widget( sxsld->gxml_obsolete, + cl = GTK_CLIST( glade_xml_get_widget( sxsld->gxml, SX_OBSOLETE_CLIST )); - tmp_str = g_string_new(NULL); - gtk_clist_freeze(cl); + gtk_clist_freeze( cl ); + gtk_clist_clear( cl ); for(row = 0; removeList != NULL; row++, removeList = removeList->next) { - /*sx_listEntry = (GList *) removeList->data; - *sx = (SchedXaction *) sx_listEntry->data;*/ - sx = (SchedXaction*)removeList->data; - + tdt = (toDeleteTuple*)removeList->data; - rowtext[0] = xaccSchedXactionGetName( sx ); - + rowtext[0] = xaccSchedXactionGetName( tdt->sx ); - g_date_strftime(rowtext[1], GNC_D_WIDTH, GNC_D_FMT, - xaccSchedXactionGetEndDate( sx )); + fs = xaccSchedXactionGetFreqSpec( tdt->sx ); - fs = xaccSchedXactionGetFreqSpec( sx ); + xaccFreqSpecGetFreqStr( fs, tmp_str ); + rowtext[1] = tmp_str->str; - - xaccFreqSpecGetFreqStr(fs, tmp_str ); - rowtext[2] = tmp_str->str; + /* FIXME: This date is the first invalid one, as opposed to the + * last valid one. :( Or, even better, the reason for + * obsolesence. */ + /*g_date_strftime( rowtext[2], GNC_D_WIDTH, GNC_D_FMT, tdt->endDate ); */ + strcpy( rowtext[2], "obsolete" ); gtk_clist_insert( cl, row, rowtext ); - /* gtk_clist_set_row_data(cl, row, sx_listEntry ); */ - gtk_clist_set_row_data( cl, row, sx ); - sxsld->n_obsolete++; + gtk_clist_set_row_data(cl, row, removeList->data ); } gtk_clist_thaw( cl ); - /* FIXME: This can't be right -- jsled g_string_free(tmp_str, TRUE); - g_free(rowtext[1]); - */ - - /* FIXME: THIS IS UGLY!!! */ - - /* The idea is if the reminder list has popped up, we should wait until it's - * been closed to open. If not, we should pop ourselves up at this point. - * - * I still reckon a druid is the way to go for this, but anyway. . . - */ - - if( !(sxsld->remind_displayed) ) - { - sxsld->obsolete_displayed = TRUE; - gtk_widget_show_all(sxsld->dlg_obsolete); - } - - return; + g_free(rowtext[2]); } - - + /** * Moves the selected reminders to the appropriate [auto-create or to-create] * sections of the since-last-run dialog. @@ -657,12 +831,13 @@ processSelectedReminderList( GList *goodList, sxSinceLastData *sxsld ) { reminderTuple *rt; gboolean autoCreateOpt, notifyOpt; - GList *list; + GList *list = NULL; - while ( goodList ) { + for ( ; goodList ; goodList = goodList->next ) { rt = (reminderTuple*)goodList->data; - list = NULL; + DEBUG( "Processing selected reminder \"%s\"", + xaccSchedXactionGetName( rt->sx ) ); xaccSchedXactionGetAutoCreate( rt->sx, &autoCreateOpt, ¬ifyOpt ); @@ -675,32 +850,12 @@ processSelectedReminderList( GList *goodList, sxSinceLastData *sxsld ) rt->occurDate ); processToCreateList( list, sxsld, rt->sx ); } - /* FIXME: Cleanup appropriately? */ + g_list_free( list ); list = NULL; - - goodList = goodList->next; } } - - -/* - * returns true if a scheduled transaction is not going to be instantiated again - * and can be deleted - * FIXME: Doesn't deal w/number of occurrences ATM - nor does anything else. - */ - -static gboolean -sx_obsolete(SchedXaction *sx) -{ - GDate next_inst = xaccSchedXactionGetNextInstance(sx); - - return !( g_date_valid( &next_inst )); -} - - - /** * Returns TRUE if there's some populated in the dialog to show to the user, * FALSE if not. @@ -710,8 +865,7 @@ sxsincelast_populate( sxSinceLastData *sxsld ) { GList *sxList, *instanceList; - GList *autoCreateList, *toCreateList, *reminderList; - GList *removeList = NULL; /* list of sxlist entries to remove */ + GList *autoCreateList, *toCreateList; SchedXaction *sx; GDate end, endPlusReminders; GDate *instDate; @@ -724,8 +878,9 @@ sxsincelast_populate( sxSinceLastData *sxsld ) showIt = FALSE; - autoCreateList = toCreateList = reminderList = NULL; + autoCreateList = toCreateList = NULL; autoCreateRow = toCreateRow = remindersRow = 0; + instanceList = NULL; sxList = gnc_book_get_schedxactions( gnc_get_current_book () ); @@ -744,22 +899,11 @@ sxsincelast_populate( sxSinceLastData *sxsld ) daysInAdvance = xaccSchedXactionGetAdvanceReminder( sx ); g_date_add_days( &endPlusReminders, daysInAdvance ); - -#if 0 -/* NOT USED */ - { - char tmpBuf[GNC_D_BUF_WIDTH]; - - g_date_strftime( tmpBuf, GNC_D_WIDTH, GNC_D_FMT, &end ); - DEBUG( "We'll generate the appropriate instances now for " - "SX \"%s\" with end time %s...", - xaccSchedXactionGetName(sx), - tmpBuf ); - } -#endif /* 0 */ - instanceList = NULL; - _generate_instances( sx, &endPlusReminders, - &instanceList, &removeList ); + generate_instances( sx, &end, + &endPlusReminders, + &instanceList, + &sxsld->reminderList, + &sxsld->toRemoveList ); if ( instanceList == NULL ) { break; @@ -769,81 +913,59 @@ sxsincelast_populate( sxSinceLastData *sxsld ) ¬ifyState ); do { instDate = (GDate*)instanceList->data; -#if 0 -/* NOT USED */ - { - char tmpBuf[GNC_D_BUF_WIDTH]; - g_date_strftime( tmpBuf, GNC_D_WIDTH, GNC_D_FMT, instDate ); - DEBUG( "SX \"%s\" instance on %s", - xaccSchedXactionGetName(sx), tmpBuf ); - } -#endif /* 0 */ - - if ( (g_date_compare( &end, &endPlusReminders ) != 0) - && (g_date_compare( &end, instDate ) <= 0) ) { - rt = g_new0( reminderTuple, 1 ); - rt->sx = sx; - rt->endDate = &end; - rt->occurDate = instDate; - rt->isSelected = FALSE; - reminderList = g_list_append( reminderList, rt ); + if ( autocreateState ) { + autoCreateList = + g_list_append( autoCreateList, + instDate ); } else { - if ( autocreateState ) { - autoCreateList = - g_list_append( autoCreateList, - instDate ); - } else { - toCreateList = - g_list_append( toCreateList, - instDate ); - } + toCreateList = + g_list_append( toCreateList, + instDate ); } } while ( (instanceList = instanceList->next) ); - + /* Report RE:showing the dialog iff there's stuff in it to * show. */ showIt |= (g_list_length( autoCreateList ) > 0); showIt |= (g_list_length( toCreateList ) > 0); - + processAutoCreateList( autoCreateList, sxsld, sx ); - processReminderList ( reminderList, sxsld, sx ); processToCreateList ( toCreateList, sxsld, sx ); - - g_list_foreach( autoCreateList, _free_gdate_list_elts, NULL ); + g_list_foreach( autoCreateList, free_gdate_list_elts, NULL ); g_list_free( autoCreateList ); autoCreateList = NULL; - + /* We have moved the GDates over to the toCreateData list in - sxsld, so we don't free them here. */ + * sxsld, so we don't free them here. */ g_list_free( toCreateList ); toCreateList = NULL; - - /* We have moved the reminderTuples over to the reminderData - list in sxsld, so we don't free them here. */ - g_list_free( reminderList ); - reminderList = NULL; + + g_list_free( instanceList ); + instanceList = NULL; + } while ( (sxList = sxList->next) ); - processRemoveList( removeList, sxsld ); + processReminderList( sxsld->reminderList, sxsld ); + showIt |= (g_list_length( sxsld->reminderList ) > 0); + + /* Defer showing the obsolete list until the end of the reminder + * processing [as selection of reminders to create may affect the + * list length. */ + showIt |= (g_list_length( sxsld->toRemoveList ) > 0); + return showIt; } static void -_clean_sincelast_dlg( sxSinceLastData *sxsld ) +clean_sincelast_dlg( sxSinceLastData *sxsld ) { GtkWidget *w; /* . clean out to-create clist * . free associated memories. */ - _clean_variable_table( sxsld ); - -/* FIXME: this probably wants to clean up a autoCreate Query object, now */ -#if 0 - w = glade_xml_get_widget( sxsld->gxml, "auto_create_clist" ); - gtk_clist_clear( GTK_CLIST(w) ); -#endif /* 0 */ + clean_variable_table( sxsld ); w = glade_xml_get_widget( sxsld->gxml, TO_CREATE_CLIST ); gtk_clist_clear( GTK_CLIST(w) ); @@ -851,7 +973,6 @@ _clean_sincelast_dlg( sxSinceLastData *sxsld ) g_list_free( sxsld->toCreateData ); sxsld->toCreateData = NULL; tcl_row = 0; - } /* @@ -868,68 +989,33 @@ _clean_sincelast_dlg( sxSinceLastData *sxsld ) * . If !reminders-dialog-open && !since-last-dialog-open * . close/destroy reminders dialog. * . close/destroy since-last dialog. + * + * Fragile code alert... :( **/ +/* major problem... we don't know, here, whether we've been + * called because we've been asked to close, or because the + * remind_dialog close has called us. This is important, + * because it determines what we do at this point: + * + * 1. We were called... + * ...thus, we clean out and raise the reminder dlg, or + * create the obsolete dialog. + * + * 2. The remind-dialog-close was called, and then called us... + * ...thus, we wait around for our interaction to complete. + */ static void sxsincelast_close_handler( gpointer ud ) { sxSinceLastData *sxsld = (sxSinceLastData*)ud; - g_list_foreach( sxsld->toCreateData, _free_toCreate_list_elts, NULL ); - g_list_free( sxsld->toCreateData ); - sxsld->toCreateData = NULL; - if ( sxsld->sincelast_displayed ) { - DEBUG( "since-last dialog displayed" ); - } + DEBUG( "sxsincelast_close_handler" ); + clean_sincelast_dlg( sxsld ); + gtk_widget_hide( sxsld->druid_sincelast ); + gtk_widget_destroy( sxsld->druid_sincelast ); + clean_sincelast_data( sxsld ); - if ( sxsld->remind_displayed ) { - DEBUG( "reminder dialog displayed, just hiding the since-last dialog." ); - /* FIXME: need to clean out old ui shit. */ - _clean_sincelast_dlg( sxsld ); - gtk_widget_hide( sxsld->sxsincelastDlg ); - sxsld->sincelast_displayed = FALSE; - - DEBUG( "reminder dialog !displayed, closing both." ); - if ( sxsld->dlg_remind != NULL ) { - - PERR( "How did the reminder dialog get !displayed, but !destroyed?" ); - sxsld_remind_close_handler( sxsld ); - } - } - else - { - gnc_ledger_display_close( sxsld->ac_ledger ); - sxsld->ac_ledger = NULL; - - gnome_dialog_close( GNOME_DIALOG( sxsld->sxsincelastDlg ) ); - sxsld->sxsincelastDlg = NULL; - sxsld->sincelast_displayed = FALSE; - sxsld->reg = NULL; - } - - /* FIXME -- cleanup: - * . reminder data? - * . memory allocated for UI elts [labels and such]? - * do this in the _destroy... - */ -} - -static void -sxsld_remind_close_handler( gpointer ud ) -{ - sxSinceLastData *sxsld; - - sxsld = (sxSinceLastData*)ud; - - gnome_dialog_close( GNOME_DIALOG( sxsld->dlg_remind ) ); - sxsld->dlg_remind = NULL; - sxsld->remind_displayed = FALSE; - - if(sxsld->n_obsolete > 0) - { - gtk_widget_show_all(sxsld->dlg_obsolete); - sxsld->obsolete_displayed = TRUE; - } - + /* gtk_widget_destroy( sxsld->druid_sincelast ); */ } static void @@ -974,7 +1060,7 @@ sxsincelast_ok_clicked( GtkButton *b, gpointer ud ) tct = (toCreateTuple*)tcList->data; allVarsBound = TRUE; g_hash_table_foreach( tct->varBindings, - _andequal_numerics_set, + andequal_numerics_set, &allVarsBound ); if ( !allVarsBound ) { char tmpBuf[GNC_D_BUF_WIDTH]; @@ -993,7 +1079,7 @@ sxsincelast_ok_clicked( GtkButton *b, gpointer ud ) g_return_if_fail( tcList ); do { tct = (toCreateTuple*)tcList->data; - _create_transactions_on( tct->sx, tct->date, tct, NULL ); + create_transactions_on( tct->sx, tct->date, tct, NULL ); } while ( (tcList = tcList->next) ); /* FIXME: cleanup appropriately. */ @@ -1008,7 +1094,7 @@ sxsincelast_cancel_clicked( GtkButton *o, gpointer ud ) } static void -_andequal_numerics_set( gpointer key, gpointer value, gpointer data ) +andequal_numerics_set( gpointer key, gpointer value, gpointer data ) { gboolean *allVarsBound = data; *allVarsBound &= (value != NULL); @@ -1033,20 +1119,24 @@ sxsincelast_entry_changed( GtkEditable *e, gpointer ud ) dummyVarHash = g_hash_table_new( NULL, NULL ); /* FIXME: these debugs probably want to go into a staus bar... */ /* FIXME: Should be using xaccParseAmount instead of parser_parse_separate_vars? */ - if ( !gnc_exp_parser_parse_separate_vars( entryText, num, NULL, dummyVarHash ) ) { + if ( !gnc_exp_parser_parse_separate_vars( entryText, num, + NULL, dummyVarHash ) ) { DEBUG( "error parsing entry \"%s\"", entryText ); g_free( num ); num = NULL; } else if ( g_hash_table_size( dummyVarHash ) != 0 ) { - DEBUG( "no new variables allowed in variable bindings for expression \"%s\"", entryText ); + DEBUG( "no new variables allowed in variable " + "bindings for expression \"%s\"", entryText ); g_free( num ); num = NULL; } else if ( gnc_numeric_check( *num ) != GNC_ERROR_OK ) { - DEBUG( "entry \"%s\" is not gnc_numeric-parseable", entryText ); + DEBUG( "entry \"%s\" is not " + "gnc_numeric-parseable", entryText ); g_free( num ); num = NULL; } else if ( gnc_numeric_zero_p( *num ) ) { - DEBUG( "entry \"%s\" parses as '0'", ( entryText ? entryText : "(null)" ) ); + DEBUG( "entry \"%s\" parses as '0'", + ( entryText ? entryText : "(null)" ) ); g_free( num ); num = NULL; } @@ -1071,7 +1161,7 @@ sxsincelast_entry_changed( GtkEditable *e, gpointer ud ) /* If there are no un-bound variables, then set the 'ready-to-go' flag to 'y'. */ - g_hash_table_foreach( tct->varBindings, _andequal_numerics_set, &allVarsBound ); + g_hash_table_foreach( tct->varBindings, andequal_numerics_set, &allVarsBound ); clist = GTK_CLIST(glade_xml_get_widget( sxsld->gxml, TO_CREATE_CLIST )); gtk_clist_set_text( clist, tct->clistRow, 2, ( allVarsBound ? "y" : "n" ) ); } @@ -1080,14 +1170,20 @@ sxsincelast_entry_changed( GtkEditable *e, gpointer ud ) static void sxsincelast_destroy( GtkObject *o, gpointer ud ) { + sxSinceLastData *sxsld = (sxSinceLastData*)ud; + + DEBUG( "sxsincelast_destroy called\n" ); /* appropriate place to destroy data structures */ - _clean_sincelast_dlg( (sxSinceLastData*)ud ); - /* FIXME: remains: reminder data. */ - DEBUG( "nuttin' doin...\n" ); + clean_sincelast_data( sxsld ); + gnc_ledger_display_close( sxsld->ac_ledger ); + /* FIXME: need more freeing for ac_ledger? */ + sxsld->ac_ledger = NULL; + + g_free( sxsld ); } static gboolean -_create_each_transaction_helper( Transaction *t, void *d ) +create_each_transaction_helper( Transaction *t, void *d ) { Transaction *newT; GList *sList; @@ -1244,9 +1340,7 @@ _create_each_transaction_helper( Transaction *t, void *d ) #endif /* 0 */ /* FIXME: - * . Want to save the scheduled transaction GUID in the - * newly-created transactions/splits. - * . Want to store the variable bindings, but this might be + * . We'd like to store the variable bindings, but this might be * problematic [if the formulas change in the SX]. */ @@ -1296,9 +1390,9 @@ _create_each_transaction_helper( Transaction *t, void *d ) * will set the last occur date incorrectly. **/ static void -_create_transactions_on( SchedXaction *sx, GDate *gd, - toCreateTuple *tct, - GList **createdGUIDs ) +create_transactions_on( SchedXaction *sx, GDate *gd, + toCreateTuple *tct, + GList **createdGUIDs ) { createData createUD; AccountGroup *ag; @@ -1342,7 +1436,7 @@ _create_transactions_on( SchedXaction *sx, GDate *gd, createUD.tct = tct; createUD.createdGUIDs = createdGUIDs; xaccAccountForEachTransaction( acct, - _create_each_transaction_helper, + create_each_transaction_helper, /*tct*/ &createUD ); } } @@ -1366,7 +1460,7 @@ _hashToList( gpointer key, gpointer value, gpointer user_data ) } static void -_hash_to_sorted_list( GHashTable *hashTable, GList **gl ) +hash_to_sorted_list( GHashTable *hashTable, GList **gl ) { g_hash_table_foreach( hashTable, _hashToList, gl ); *gl = g_list_sort( *gl, g_str_equal ); @@ -1380,7 +1474,7 @@ _clear_variable_numerics( gpointer key, gpointer value, gpointer data ) } static void -_sxsl_get_sx_vars( SchedXaction *sx, GHashTable *varHash ) +sxsl_get_sx_vars( SchedXaction *sx, GHashTable *varHash ) { GList *splitList, *tmpL; kvp_frame *kvpf; @@ -1465,14 +1559,15 @@ sxsincelast_tc_row_sel( GtkCList *clist, } varList = NULL; - _hash_to_sorted_list( tct->varBindings, &varList ); + hash_to_sorted_list( tct->varBindings, &varList ); if ( g_hash_table_size( tct->varBindings ) == 0 ) { PINFO( "No variables to deal with" ); return; } - varTable = GTK_TABLE( glade_xml_get_widget( sxsld->gxml, "variable_table" ) ); + varTable = GTK_TABLE( glade_xml_get_widget( sxsld->gxml, + VARIABLE_TABLE ) ); gtk_table_resize( varTable, 4, NUM_COLS ); tableIdx = 1; @@ -1491,10 +1586,12 @@ sxsincelast_tc_row_sel( GtkCList *clist, gtk_object_set_data( GTK_OBJECT(entry), "varName", varList->data ); gtk_object_set_data( GTK_OBJECT(entry), "tct", tct ); gtk_widget_set_usize( entry, 64, 0 ); - numValue = (gnc_numeric*)g_hash_table_lookup( tct->varBindings, varList->data ); + numValue = (gnc_numeric*)g_hash_table_lookup( tct->varBindings, + varList->data ); if ( numValue != NULL ) { - - numValueStr = xaccPrintAmount( *numValue, gnc_default_print_info( FALSE ) ); + numValueStr = + xaccPrintAmount( *numValue, + gnc_default_print_info( FALSE ) ); gtk_entry_set_text( GTK_ENTRY(entry), numValueStr ); } @@ -1515,17 +1612,19 @@ sxsincelast_tc_row_sel( GtkCList *clist, } static void -_clean_variable_table( sxSinceLastData *sxsld ) +clean_variable_table( sxSinceLastData *sxsld ) { GtkTable *table; GList *children, *toFree; GtkTableChild *child; - table = GTK_TABLE( glade_xml_get_widget( sxsld->gxml, "variable_table" ) ); + table = GTK_TABLE( glade_xml_get_widget( sxsld->gxml, + VARIABLE_TABLE ) ); children = table->children; toFree = NULL; if ( children == NULL ) { - PERR( "The variable-binding table should always have at least 2 children..." ); + PERR( "The variable-binding table should always have at " + "least 2 children... something's amiss." ); return; } @@ -1556,11 +1655,11 @@ sxsincelast_tc_row_unsel( GtkCList *clist, sxSinceLastData *sxsld; sxsld = (sxSinceLastData*)user_data; - _clean_variable_table( sxsld ); + clean_variable_table( sxsld ); } static void -_print_vars_helper( gpointer key, gpointer value, gpointer user_data ) +print_vars_helper( gpointer key, gpointer value, gpointer user_data ) { DEBUG( "\"%s\" -> %.8x [%s]", (gchar*)key, (unsigned int)value, @@ -1584,7 +1683,7 @@ parse_vars_from_formula( const char *formula, GHashTable *varHash ) if ( g_hash_table_size( varHash ) == 0 ) { DEBUG( "No variables in expression \"%s\"", formula ); } else { - g_hash_table_foreach( varHash, _print_vars_helper, NULL ); + g_hash_table_foreach( varHash, print_vars_helper, NULL ); } #endif /* 0 */ @@ -1605,15 +1704,16 @@ parse_vars_from_formula( const char *formula, GHashTable *varHash ) * . If non-consecutive Reminders chosen, disallow. * . Else, for each selected reminder, add to to-create list. * . Dismiss dialog. + * + * Returns TRUE if there are processed, valid reminders... FALSE otherwise. **/ -static void -sxsld_remind_ok_clicked( GtkButton *b, gpointer ud ) +static gboolean +processed_valid_reminders_listP( sxSinceLastData *sxsld ) { - sxSinceLastData *sxsld; - GList *reminderList; reminderTuple *rt, *prevRT; char *rtName; gboolean overallOkFlag, okFlag, prevState; + GList *reminderListPtr; GList *badList; GList *badRecentRun; GList *goodList; @@ -1622,26 +1722,23 @@ sxsld_remind_ok_clicked( GtkButton *b, gpointer ud ) goodList = NULL; overallOkFlag = TRUE; - /* The following assignments are only to placate the compiler ["might - be used uninitialized"]. */ okFlag = prevState = TRUE; badList = badRecentRun = NULL; rt = prevRT = NULL; - sxsld = (sxSinceLastData*)ud; - reminderList = sxsld->reminderData; + reminderListPtr = sxsld->reminderList; - while ( reminderList != NULL ) { + while ( reminderListPtr != NULL ) { prevRT = rt; - rt = (reminderTuple*)reminderList->data; + rt = (reminderTuple*)reminderListPtr->data; if ( xaccSchedXactionGetName( rt->sx ) != rtName ) { if ( rtName != NULL ) { /* Deal with previous sequence. */ overallOkFlag &= - _inform_or_add( sxsld->reminderData, - prevRT, okFlag, - badList, &goodList ); + inform_or_add( reminderListPtr, + prevRT, okFlag, + badList, &goodList ); } /* Reset loop state vars */ @@ -1684,14 +1781,14 @@ sxsld_remind_ok_clicked( GtkButton *b, gpointer ud ) } - reminderList = reminderList->next; + reminderListPtr = reminderListPtr->next; } /* Deal with final sequence. */ if ( rtName != NULL ) { - overallOkFlag &= _inform_or_add( sxsld->reminderData, - rt, okFlag, - badList, &goodList ); + overallOkFlag &= inform_or_add( sxsld->reminderList, + rt, okFlag, + badList, &goodList ); } /* cleanup */ @@ -1699,38 +1796,23 @@ sxsld_remind_ok_clicked( GtkButton *b, gpointer ud ) g_list_free( badRecentRun ); /* Handle implications of above logic. */ - if ( overallOkFlag ) { - /* Go through to-create list and do so... - * . if auto-create, add to auto-create list. - * . if to-create, add to to-create list. - * . if need to bring up since-last dialog, do so. - * . dismiss reminder dialog - * . if since-last dialog is empty, close. - */ - if ( g_list_length( goodList ) > 0 ) { - /* gtk_widget_hide( sxsld->sxsincelastDlg ); */ - processSelectedReminderList( goodList, sxsld ); - gtk_widget_show_all( sxsld->sxsincelastDlg ); - sxsld->sincelast_displayed = TRUE; - } + if ( !overallOkFlag ) { + g_list_free( goodList ); + return FALSE; + } + /* Go through to-create list and do so... + * . if auto-create, add to auto-create list. + * . if to-create, add to to-create list. + * . if need to bring up since-last dialog, do so. + * . dismiss reminder dialog + * . if since-last dialog is empty, close. + */ + if ( g_list_length( goodList ) > 0 ) { + processSelectedReminderList( goodList, sxsld ); g_list_free( goodList ); - - sxsld_remind_close_handler( sxsld ); - - - /* FIXME: sufficient? we probably want the close-handler... - gtk_widget_destroy( sxsld->dlg_remind ); - sxsld->dlg_remind = NULL; */ } - /* else - { Just leave the dialog alone [and let the user deal with the - error dialog they just saw]. } - */ - - - /* now that's finished, run the obsolete transactions dialog */ - gtk_widget_show_all(sxsld->dlg_obsolete); + return TRUE; } static void @@ -1745,7 +1827,7 @@ sxsld_remind_row_toggle( GtkCList *clist, } static void -_create_bad_reminders_msg( gpointer data, gpointer ud ) +create_bad_reminders_msg( gpointer data, gpointer ud ) { GString *msg; reminderTuple *rt; @@ -1759,9 +1841,9 @@ _create_bad_reminders_msg( gpointer data, gpointer ud ) } static gboolean -_inform_or_add( GList *reminders, - reminderTuple *rt, gboolean okFlag, - GList *badList, GList **goodList ) +inform_or_add( GList *reminders, + reminderTuple *rt, gboolean okFlag, + GList *badList, GList **goodList ) { reminderTuple *curRt; GList *rtPtr; @@ -1792,13 +1874,14 @@ _inform_or_add( GList *reminders, "The following instances of \"%s\"\n" "must be selected as well:\n\n", xaccSchedXactionGetName( rt->sx ) ); - g_list_foreach( badList, _create_bad_reminders_msg, userMsg ); + g_list_foreach( badList, create_bad_reminders_msg, userMsg ); gnc_error_dialog( userMsg->str ); } return okFlag; } +#if 0 static void sx_obsolete_row_sel(GtkCList *clist, gint row, @@ -1842,7 +1925,7 @@ sx_obsolete_row_unsel(GtkCList *clist, return; } - + static void sx_obsolete_ok_clicked(GtkButton *button, gpointer user_data) { @@ -1870,97 +1953,98 @@ sx_obsolete_ok_clicked(GtkButton *button, gpointer user_data) gnc_book_set_schedxactions(book, actual_sx_list); + printf( "c\n" ); gnome_dialog_close(GNOME_DIALOG(sxsld->dlg_obsolete)); - - /* FIXME: what about cleaning up everything else */ } static void sx_obsolete_close_handler(gpointer user_data) { - sxSinceLastData *sxsld = user_data; - - g_list_free(sxsld->actual_to_remove); - sxsld->actual_to_remove = NULL; - - gnome_dialog_close(GNOME_DIALOG(sxsld->dlg_obsolete)); + sxSinceLastData *sxsld = user_data; - /* FIXME: clean up everything else */ + if ( sxsld->toRemoveList ) { + /* FIXME: g_list_foreach( tdt_destroyer, ...->toRemoveList ) */ + g_list_free(sxsld->toRemoveList); + sxsld->toRemoveList = NULL; + } + + if ( sxsld->actual_to_remove ) { + g_list_free(sxsld->actual_to_remove); + sxsld->actual_to_remove = NULL; + } + sxsld->n_obsolete = 0; + + if ( sxsld->dlg_obsolete ) { + printf( "d\n" ); + gnome_dialog_close(GNOME_DIALOG(sxsld->dlg_obsolete)); + sxsld->dlg_obsolete = NULL; + sxsld->obsolete_displayed = FALSE; + } + sxsincelast_close_handler( sxsld ); } + static void sx_obsolete_cancel_clicked(GtkButton *button, gpointer user_data) { sx_obsolete_close_handler(user_data); } - - +#endif /* 0 */ static void sx_obsolete_select_all_clicked(GtkButton *button, gpointer user_data) { - sxSinceLastData* sxsld = user_data; + sxSinceLastData* sxsld = user_data; - GtkCList *ob_clist = GTK_CLIST(glade_xml_get_widget(sxsld->gxml_obsolete, - SX_OBSOLETE_CLIST)); - int i; - - for(i = 0; i < sxsld->n_obsolete; i++) - { - gtk_clist_select_row(ob_clist, i, 0); - } - - return; + GtkCList *ob_clist = GTK_CLIST(glade_xml_get_widget(sxsld->gxml, + SX_OBSOLETE_CLIST)); + gtk_clist_select_all( ob_clist ); } - + static void sx_obsolete_unselect_all_clicked(GtkButton *button, gpointer user_data) { + sxSinceLastData* sxsld = user_data; - sxSinceLastData* sxsld = user_data; - - GtkCList *ob_clist = GTK_CLIST(glade_xml_get_widget(sxsld->gxml_obsolete, - SX_OBSOLETE_CLIST)); - int i; - - for(i = 0; i < sxsld->n_obsolete; i++) - { - gtk_clist_unselect_row(ob_clist, i, 0); - } - - return; + GtkCList *ob_clist = GTK_CLIST(glade_xml_get_widget(sxsld->gxml, + SX_OBSOLETE_CLIST)); + gtk_clist_unselect_all( ob_clist ); } static void create_autoCreate_gen_ledger( sxSinceLastData *sxsld ) { - GtkFrame *autoCreate_frame; - SplitRegister *splitreg; - GtkWidget *regWidget; - GtkWidget *popup; - - autoCreate_frame = - GTK_FRAME( glade_xml_get_widget( sxsld->gxml, - "auto_create_frame" ) ); + SplitRegister *splitreg; + GtkWidget *vbox; + GtkWidget *toolbar; + GtkWidget *regWidget; + GtkWidget *popup; + sxsld->ac_ledger = gnc_ledger_display_gl(); gnc_ledger_display_set_handlers( sxsld->ac_ledger, NULL, - _sxsld_ledger_get_parent ); + sxsld_ledger_get_parent ); gnc_ledger_display_set_user_data( sxsld->ac_ledger, (gpointer)sxsld ); splitreg = gnc_ledger_display_get_split_register( sxsld->ac_ledger ); - /* FIXME: make configurable */ - gnucash_register_set_initial_rows( 6 ); + /* FIXME: make configurable? */ + gnucash_register_set_initial_rows( 4 ); regWidget = gnucash_register_new( splitreg->table ); gnc_table_init_gui( regWidget, splitreg ); - - gtk_container_add( GTK_CONTAINER(glade_xml_get_widget( sxsld->gxml, - "ac_vbox" )), - regWidget ); sxsld->reg = GNUCASH_REGISTER(regWidget); - GNUCASH_SHEET(sxsld->reg->sheet)->window = GTK_WIDGET(sxsld->sxsincelastDlg); + GNUCASH_SHEET(sxsld->reg->sheet)->window = + GTK_WIDGET( sxsld->druid_sincelast ); + + vbox = glade_xml_get_widget( sxsld->gxml, AUTO_CREATE_VBOX ); + toolbar = gtk_label_new( "foo ... toolbar...uh... fooo" ); + + gtk_box_pack_start( GTK_BOX(vbox), toolbar, FALSE, FALSE, 2 ); + gtk_widget_show_all( toolbar ); + /* FIXME: Too bad this just increases it's size w/o bound. */ + gtk_box_pack_end( GTK_BOX(vbox), regWidget, TRUE, TRUE, 2 ); + gtk_widget_show_all( regWidget ); #if 0 gtk_signal_connect( GTK_OBJECT(sxed->dialog), "activate_cursor", @@ -1970,9 +2054,9 @@ create_autoCreate_gen_ledger( sxSinceLastData *sxsld ) #endif /* 0 */ -#if 0 /* FIXME: we should do all the happy-fun register stuff... button bar - controls ... popups ... */ + * controls ... popups ... */ +#if 0 popup = schedXaction_editor_create_reg_popup( sxsld ); gnucash_register_attach_popup( sxsld->reg, popup, sxsld ); #endif /* 0 */ @@ -1988,15 +2072,264 @@ create_autoCreate_gen_ledger( sxSinceLastData *sxsld ) /* force a refresh */ gnc_ledger_display_refresh( sxsld->ac_ledger ); - } static gncUIWidget -_sxsld_ledger_get_parent( GNCLedgerDisplay *ld ) +sxsld_ledger_get_parent( GNCLedgerDisplay *ld ) { sxSinceLastData *sxsld; sxsld = (sxSinceLastData*)gnc_ledger_display_get_user_data( ld ); - return sxsld->sxsincelastDlg; + return (gncUIWidget)sxsld->reg->sheet->window; } + +static void +clean_sincelast_data( sxSinceLastData *sxsld ) +{ + /* FIXME: much more to go, here. */ + g_list_foreach( sxsld->toCreateData, _free_toCreate_list_elts, NULL ); + if ( sxsld->toCreateData ) { + g_list_free( sxsld->toCreateData ); + sxsld->toCreateData = NULL; + } +} + +#if 0 +allocation: x: 15, y: 107, w: 719, h: 195, sheet_width: 195, sheet_height: 719 +size_request: returning 719 x 195 +size_request: returning 719 x 195 + +Breakpoint 2, gnucash_sheet_size_allocate (widget=0x839b708, + allocation=0xbfffd6c4) at gnucash-sheet.c:1013 +(gdb) bt +#0 gnucash_sheet_size_allocate (widget=0x839b708, allocation=0xbfffd6c4) + at gnucash-sheet.c:1013 +#1 0x40a18ae9 in gtk_marshal_NONE__POINTER (object=0x839b708, + func=0x403b8b1c , func_data=0x0, + args=0xbfffd418) at gtkmarshal.c:193 +#2 0x40a4486b in gtk_signal_real_emit (object=0x839b708, signal_id=18, + params=0xbfffd418) at gtksignal.c:1440 +#3 0x40a42c40 in gtk_signal_emit (object=0x839b708, signal_id=18) + at gtksignal.c:552 +#4 0x40a7689b in gtk_widget_size_allocate (widget=0x839b708, + allocation=0xbfffd718) at gtkwidget.c:2496 +#5 0x40a55652 in gtk_table_size_allocate_pass2 (table=0x839b4d0) + at gtktable.c:1551 +#6 0x40a54342 in gtk_table_size_allocate (widget=0x839b4d0, + allocation=0xbfffda88) at gtktable.c:832 +#7 0x40a18ae9 in gtk_marshal_NONE__POINTER (object=0x839b4d0, + func=0x40a54288 , func_data=0x0, args=0xbfffd7dc) + at gtkmarshal.c:193 +#8 0x40a4486b in gtk_signal_real_emit (object=0x839b4d0, signal_id=18, + params=0xbfffd7dc) at gtksignal.c:1440 +#9 0x40a42c40 in gtk_signal_emit (object=0x839b4d0, signal_id=18) + at gtksignal.c:552 +#10 0x40a7689b in gtk_widget_size_allocate (widget=0x839b4d0, + allocation=0xbfffdafc) at gtkwidget.c:2496 +#11 0x40a6c668 in gtk_vbox_size_allocate (widget=0x82e8e30, + allocation=0xbfffde48) at gtkvbox.c:329 +#12 0x40a18ae9 in gtk_marshal_NONE__POINTER (object=0x82e8e30, + func=0x40a6c174 , func_data=0x0, args=0xbfffdb9c) + at gtkmarshal.c:193 +#13 0x40a4486b in gtk_signal_real_emit (object=0x82e8e30, signal_id=18, + params=0xbfffdb9c) at gtksignal.c:1440 +#14 0x40a42c40 in gtk_signal_emit (object=0x82e8e30, signal_id=18) + at gtksignal.c:552 +#15 0x40a7689b in gtk_widget_size_allocate (widget=0x82e8e30, + allocation=0xbfffdeb8) at gtkwidget.c:2496 +#16 0x40a03c3b in gtk_hbox_size_allocate (widget=0x82e8de8, + allocation=0xbfffe204) at gtkhbox.c:275 +#17 0x40a18ae9 in gtk_marshal_NONE__POINTER (object=0x82e8de8, + func=0x40a038e0 , func_data=0x0, args=0xbfffdf58) + at gtkmarshal.c:193 +#18 0x40a4486b in gtk_signal_real_emit (object=0x82e8de8, signal_id=18, + params=0xbfffdf58) at gtksignal.c:1440 +#19 0x40a42c40 in gtk_signal_emit (object=0x82e8de8, signal_id=18) + at gtksignal.c:552 +#20 0x40a7689b in gtk_widget_size_allocate (widget=0x82e8de8, + allocation=0xbfffe278) at gtkwidget.c:2496 +#21 0x40a6c4e1 in gtk_vbox_size_allocate (widget=0x82e8da0, + allocation=0xbfffe5c4) at gtkvbox.c:273 +#22 0x40a18ae9 in gtk_marshal_NONE__POINTER (object=0x82e8da0, + func=0x40a6c174 , func_data=0x0, args=0xbfffe318) + at gtkmarshal.c:193 +#23 0x40a4486b in gtk_signal_real_emit (object=0x82e8da0, signal_id=18, + params=0xbfffe318) at gtksignal.c:1440 +#24 0x40a42c40 in gtk_signal_emit (object=0x82e8da0, signal_id=18) + at gtksignal.c:552 +#25 0x40a7689b in gtk_widget_size_allocate (widget=0x82e8da0, + allocation=0xbfffe5f0) at gtkwidget.c:2496 +#26 0x408afe24 in gnome_druid_page_size_allocate (widget=0x82e8d08, + allocation=0xbfffe960) at gnome-druid-page.c:189 +#27 0x408b2148 in gnome_druid_page_standard_size_allocate (widget=0x82e8d08, + allocation=0xbfffe960) at gnome-druid-page-standard.c:237 +#28 0x40a18ae9 in gtk_marshal_NONE__POINTER (object=0x82e8d08, + func=0x408b2118 , func_data=0x0, + args=0xbfffe6b4) at gtkmarshal.c:193 +#29 0x40a4486b in gtk_signal_real_emit (object=0x82e8d08, signal_id=18, + params=0xbfffe6b4) at gtksignal.c:1440 +#30 0x40a42c40 in gtk_signal_emit (object=0x82e8d08, signal_id=18) + at gtksignal.c:552 +#31 0x40a7689b in gtk_widget_size_allocate (widget=0x82e8d08, + allocation=0xbfffe990) at gtkwidget.c:2496 +#32 0x408ae034 in gnome_druid_size_allocate (widget=0x82f2b48, + allocation=0xbfffecdc) at gnome-druid.c:334 +#33 0x40a18ae9 in gtk_marshal_NONE__POINTER (object=0x82f2b48, + func=0x408addc8 , func_data=0x0, + args=0xbfffea30) at gtkmarshal.c:193 +#34 0x40a4486b in gtk_signal_real_emit (object=0x82f2b48, signal_id=18, + params=0xbfffea30) at gtksignal.c:1440 +#35 0x40a42c40 in gtk_signal_emit (object=0x82f2b48, signal_id=18) + at gtksignal.c:552 +#36 0x40a7689b in gtk_widget_size_allocate (widget=0x82f2b48, + allocation=0xbfffed00) at gtkwidget.c:2496 +#37 0x40a7e72a in gtk_window_size_allocate (widget=0x82f1998, + allocation=0xbffff04c) at gtkwindow.c:1180 +#38 0x40a18ae9 in gtk_marshal_NONE__POINTER (object=0x82f1998, + func=0x40a7e604 , func_data=0x0, args=0xbfffeda0) + at gtkmarshal.c:193 +#39 0x40a4486b in gtk_signal_real_emit (object=0x82f1998, signal_id=18, + params=0xbfffeda0) at gtksignal.c:1440 +#40 0x40a42c40 in gtk_signal_emit (object=0x82f1998, signal_id=18) + at gtksignal.c:552 +#41 0x40a7689b in gtk_widget_size_allocate (widget=0x82f1998, + allocation=0xbffff094) at gtkwidget.c:2496 +#42 0x40a7f944 in gtk_window_move_resize (window=0x82f1998) at gtkwindow.c:1750 +#43 0x40a7f21e in gtk_window_check_resize (container=0x82f1998) + at gtkwindow.c:1523 +#44 0x40a18c3f in gtk_marshal_NONE__NONE (object=0x82f1998, + func=0x40a7f178 , func_data=0x0, args=0xbffff1c4) + at gtkmarshal.c:312 +#45 0x40a449e8 in gtk_signal_real_emit (object=0x82f1998, signal_id=63, + params=0xbffff1c4) at gtksignal.c:1492 +#46 0x40a42c40 in gtk_signal_emit (object=0x82f1998, signal_id=63) + at gtksignal.c:552 +#47 0x409d9398 in gtk_container_check_resize (container=0x82f1998) + at gtkcontainer.c:928 +#48 0x409d908f in gtk_container_idle_sizer (data=0x0) at gtkcontainer.c:847 +#49 0x40bdd948 in g_idle_dispatch (source_data=0x409d9030, + dispatch_time=0xbffff4f8, user_data=0x0) at gmain.c:1367 +#50 0x40bdc9f6 in g_main_dispatch (dispatch_time=0xbffff4f8) at gmain.c:656 +#51 0x40bdcfb1 in g_main_iterate (block=1, dispatch=1) at gmain.c:877 +#52 0x40bdd129 in g_main_run (loop=0x83903e8) at gmain.c:935 +#53 0x40a1748a in gtk_main () at gtkmain.c:524 +#54 0x403fedd8 in gnc_ui_start_event_loop () at top-level.c:676 +#55 0x4001b7c9 in gwrap_gnc_ui_start_event_loop () at gw-gnc.c:257 +#56 0x40b1bcb8 in scm_deval (x=1088180304, env=1088218144) at eval.c:2636 +#57 0x40b19df3 in scm_deval (x=1088180272, env=1088218144) at eval.c:1954 +#58 0x40b19df3 in scm_deval (x=1088180032, env=1088218144) at eval.c:1954 +#59 0x40b1d885 in scm_dapply (proc=1088179888, arg1=10612, args=1088218344) + at eval.c:3473 +#60 0x40b18585 in scm_apply (proc=1088179864, arg1=10612, args=10612) + at eval.c:3283 +#61 0x40b23cfe in gh_call0 (proc=1088179864) at gh_funcs.c:150 +#62 0x40424de1 in gnucash_main_helper (argc=1, argv=0xbffff9b4) + at gnucash.c:125 +#63 0x40b23dc3 in gh_launch_pad (closure=0x40424bb0, argc=1, argv=0xbffff9b4) + at gh_init.c:60 +#64 0x40b270a2 in invoke_main_func (body_data=0xbffff8f8) at init.c:625 +#65 0x40b4834b in scm_internal_lazy_catch (tag=9076, + body=0x40b2707c , body_data=0xbffff8f8, + handler=0x40b4866c , handler_data=0x0) + at throw.c:283 +#66 0x40b2705c in scm_boot_guile_1 (base=0xbffff8f4, closure=0xbffff8f8) + at init.c:600 +#67 0x40b26d8d in scm_boot_guile (argc=1, argv=0xbffff9b4, + main_func=0x40b23da8 , closure=0x40424bb0) at init.c:443 +#68 0x40b23df1 in gh_enter (argc=1, argv=0xbffff9b4, + c_main_prog=0x40424bb0 ) at gh_init.c:70 +#69 0x40424e94 in gnc_main (argc=1, argv=0xbffff9b4) at gnucash.c:176 +#70 0x8048c36 in main (argc=1, argv=0xbffff9b4) at gnc-main.c:30 +#71 0x40c4f9cb in __libc_start_main (main=0x8048c28
, argc=1, + argv=0xbffff9b4, init=0x8048aec <_init>, fini=0x8048c6c <_fini>, + rtld_fini=0x4000ae60 <_dl_fini>, stack_end=0xbffff9ac) + at ../sysdeps/generic/libc-start.c:92 +(gdb) c +Continuing. +allocation: x: 15, y: 107, w: 727, h: 199, sheet_width: 195, sheet_height: 719 + +Breakpoint 2, gnucash_sheet_size_allocate (widget=0x839b708, + allocation=0xbfffec64) at gnucash-sheet.c:1013 +(gdb) bt +#0 gnucash_sheet_size_allocate (widget=0x839b708, allocation=0xbfffec64) + at gnucash-sheet.c:1013 +#1 0x40a18ae9 in gtk_marshal_NONE__POINTER (object=0x839b708, + func=0x403b8b1c , func_data=0x0, + args=0xbfffe9b8) at gtkmarshal.c:193 +#2 0x40a4486b in gtk_signal_real_emit (object=0x839b708, signal_id=18, + params=0xbfffe9b8) at gtksignal.c:1440 +#3 0x40a42c40 in gtk_signal_emit (object=0x839b708, signal_id=18) + at gtksignal.c:552 +#4 0x40a7689b in gtk_widget_size_allocate (widget=0x839b708, + allocation=0xbfffecb8) at gtkwidget.c:2496 +#5 0x40a55652 in gtk_table_size_allocate_pass2 (table=0x839b4d0) + at gtktable.c:1551 +#6 0x40a54342 in gtk_table_size_allocate (widget=0x839b4d0, + allocation=0xbffff028) at gtktable.c:832 +#7 0x40a18ae9 in gtk_marshal_NONE__POINTER (object=0x839b4d0, + func=0x40a54288 , func_data=0x0, args=0xbfffed7c) + at gtkmarshal.c:193 +#8 0x40a4486b in gtk_signal_real_emit (object=0x839b4d0, signal_id=18, + params=0xbfffed7c) at gtksignal.c:1440 +#9 0x40a42c40 in gtk_signal_emit (object=0x839b4d0, signal_id=18) + at gtksignal.c:552 +#10 0x40a7689b in gtk_widget_size_allocate (widget=0x839b4d0, + allocation=0x839b4f0) at gtkwidget.c:2496 +#11 0x409d9640 in gtk_container_resize_children (container=0x82f1998) + at gtkcontainer.c:1087 +#12 0x40a7fa8c in gtk_window_move_resize (window=0x82f1998) at gtkwindow.c:1856 +#13 0x40a7f21e in gtk_window_check_resize (container=0x82f1998) + at gtkwindow.c:1523 +#14 0x40a18c3f in gtk_marshal_NONE__NONE (object=0x82f1998, + func=0x40a7f178 , func_data=0x0, args=0xbffff1c4) + at gtkmarshal.c:312 +#15 0x40a449e8 in gtk_signal_real_emit (object=0x82f1998, signal_id=63, + params=0xbffff1c4) at gtksignal.c:1492 +#16 0x40a42c40 in gtk_signal_emit (object=0x82f1998, signal_id=63) + at gtksignal.c:552 +#17 0x409d9398 in gtk_container_check_resize (container=0x82f1998) + at gtkcontainer.c:928 +#18 0x409d908f in gtk_container_idle_sizer (data=0x0) at gtkcontainer.c:847 +#19 0x40bdd948 in g_idle_dispatch (source_data=0x409d9030, + dispatch_time=0xbffff4f8, user_data=0x0) at gmain.c:1367 +#20 0x40bdc9f6 in g_main_dispatch (dispatch_time=0xbffff4f8) at gmain.c:656 +#21 0x40bdcfb1 in g_main_iterate (block=1, dispatch=1) at gmain.c:877 +#22 0x40bdd129 in g_main_run (loop=0x83903e8) at gmain.c:935 +#23 0x40a1748a in gtk_main () at gtkmain.c:524 +#24 0x403fedd8 in gnc_ui_start_event_loop () at top-level.c:676 +#25 0x4001b7c9 in gwrap_gnc_ui_start_event_loop () at gw-gnc.c:257 +#26 0x40b1bcb8 in scm_deval (x=1088180304, env=1088218144) at eval.c:2636 +#27 0x40b19df3 in scm_deval (x=1088180272, env=1088218144) at eval.c:1954 +#28 0x40b19df3 in scm_deval (x=1088180032, env=1088218144) at eval.c:1954 +#29 0x40b1d885 in scm_dapply (proc=1088179888, arg1=10612, args=1088218344) + at eval.c:3473 +#30 0x40b18585 in scm_apply (proc=1088179864, arg1=10612, args=10612) + at eval.c:3283 +#31 0x40b23cfe in gh_call0 (proc=1088179864) at gh_funcs.c:150 +#32 0x40424de1 in gnucash_main_helper (argc=1, argv=0xbffff9b4) + at gnucash.c:125 +#33 0x40b23dc3 in gh_launch_pad (closure=0x40424bb0, argc=1, argv=0xbffff9b4) + at gh_init.c:60 +#34 0x40b270a2 in invoke_main_func (body_data=0xbffff8f8) at init.c:625 +#35 0x40b4834b in scm_internal_lazy_catch (tag=9076, + body=0x40b2707c , body_data=0xbffff8f8, + handler=0x40b4866c , handler_data=0x0) + at throw.c:283 +#36 0x40b2705c in scm_boot_guile_1 (base=0xbffff8f4, closure=0xbffff8f8) + at init.c:600 +#37 0x40b26d8d in scm_boot_guile (argc=1, argv=0xbffff9b4, + main_func=0x40b23da8 , closure=0x40424bb0) at init.c:443 +#38 0x40b23df1 in gh_enter (argc=1, argv=0xbffff9b4, + c_main_prog=0x40424bb0 ) at gh_init.c:70 +#39 0x40424e94 in gnc_main (argc=1, argv=0xbffff9b4) at gnucash.c:176 +#40 0x8048c36 in main (argc=1, argv=0xbffff9b4) at gnc-main.c:30 +#41 0x40c4f9cb in __libc_start_main (main=0x8048c28
, argc=1, + argv=0xbffff9b4, init=0x8048aec <_init>, fini=0x8048c6c <_fini>, + rtld_fini=0x4000ae60 <_dl_fini>, stack_end=0xbffff9ac) + at ../sysdeps/generic/libc-start.c:92 +(gdb) quit +The program is running. Exit anyway? (y or n) y + +Debugger finished +#endif /* 0 */ diff --git a/src/gnome/glade/sched-xact.glade b/src/gnome/glade/sched-xact.glade index 90a5aeba42..5afb248a1c 100644 --- a/src/gnome/glade/sched-xact.glade +++ b/src/gnome/glade/sched-xact.glade @@ -92,8 +92,8 @@ 0 0 - False - False + True + True @@ -519,7 +519,7 @@ GnomeNumberEntry - numberentry1 + end_gnome_nentry 10 0 @@ -563,8 +563,8 @@ GTK_SHADOW_ETCHED_IN 0 - False - False + True + True @@ -4512,4 +4512,527 @@ Anually + + GtkWindow + Since Last Run Druid + Since Last Run + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + + + GnomeDruid + sincelast_druid + + + GnomeDruidPageStandard + reminders_page + Transaction Reminders + 255,255,255 + 25,25,112 + 255,255,255 + + + GtkVBox + GnomeDruidPageStandard:vbox + druid-vbox5 + False + 0 + + 0 + True + True + + + + GtkLabel + label847862 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 11 + + 0 + False + False + + + + + GtkScrolledWindow + scrolledwindow15 + 3 + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + GtkCList + reminder_clist + True + 3 + 147,198,80 + GTK_SELECTION_EXTENDED + True + GTK_SHADOW_IN + + + GtkLabel + CList:title + label847863 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label847864 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label847865 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + + + GnomeDruidPageStandard + auto_create_notify_page + Auto-Created Transactions Notification + 255,255,255 + 25,25,112 + 255,255,255 + + + GtkVBox + GnomeDruidPageStandard:vbox + ac_vbox + False + 0 + + 0 + True + True + + + + Placeholder + + + + Placeholder + + + + + + GnomeDruidPageStandard + to_create_page + To-Create Transaction Preparation + 255,255,255 + 25,25,112 + 255,255,255 + + + GtkVBox + GnomeDruidPageStandard:vbox + druid-vbox7 + False + 0 + + 0 + True + True + + + + GtkHPaned + to_create_hpaned + 10 + 10 + 400 + + 0 + True + True + + + + GtkScrolledWindow + scrolledwindow16 + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + True + False + + + + GtkCList + to_create_clist + True + 3 + 80,123,80 + GTK_SELECTION_SINGLE + True + GTK_SHADOW_IN + + + GtkLabel + CList:title + label847866 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label847867 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label847868 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + GtkFrame + frame81 + 1 + + 0.1 + GTK_SHADOW_ETCHED_IN + + True + True + + + + GtkScrolledWindow + scrolledwindow17 + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + GtkViewport + viewport2 + 2 + GTK_SHADOW_IN + + + GtkTable + variables_table + 2 + 2 + False + 2 + 2 + + + GtkLabel + label847869 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 1 + 2 + 0 + 1 + 0 + 0 + True + False + False + False + True + False + + + + + GtkLabel + label847870 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + 1 + 0 + 1 + 0 + 0 + True + False + False + False + True + False + + + + + + + + + + + + GnomeDruidPageStandard + created_page + Created Transaction Review + 255,255,255 + 25,25,112 + 255,255,255 + + + GtkVBox + GnomeDruidPageStandard:vbox + created_vbox + False + 0 + + 0 + True + True + + + + Placeholder + + + + Placeholder + + + + + + GnomeDruidPageStandard + obsolete_page + Obsolete Scheduled Transactions + 255,255,255 + 25,25,112 + 255,255,255 + + + GtkVBox + GnomeDruidPageStandard:vbox + druid-vbox9 + False + 0 + + 0 + True + True + + + + GtkLabel + label847871 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 11 + + 0 + False + False + + + + + GtkScrolledWindow + scrolledwindow18 + 3 + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + GtkCList + sx_obsolete_clist + True + 3 + 80,80,80 + GTK_SELECTION_EXTENDED + True + GTK_SHADOW_IN + + + GtkLabel + CList:title + label847872 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label847873 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label847874 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + GtkHButtonBox + hbuttonbox8 + GTK_BUTTONBOX_SPREAD + 8 + 85 + 27 + 7 + 0 + + 0 + False + False + + + + GtkButton + select_all_button + True + True + + GTK_RELIEF_NORMAL + + + + GtkButton + unselect_all_button + True + True + + GTK_RELIEF_NORMAL + + + + + + + GnomeDruidPageFinish + finish_page + All Done + Thanks for playing our game... + 25,25,112 + 255,255,255 + 255,255,255 + 0,0,0 + 255,255,255 + + + + diff --git a/src/gnome/window-main.c b/src/gnome/window-main.c index a111003a2a..b05d174269 100644 --- a/src/gnome/window-main.c +++ b/src/gnome/window-main.c @@ -507,7 +507,8 @@ gnc_main_window_about_cb (GtkWidget *widget, gpointer data) { GtkWidget *about; const gchar *message = _("The GnuCash personal finance manager.\n" - "The GNU way to manage your money!"); + "The GNU way to manage your money!\n" + "http://www.gnucash.org/"); const gchar *copyright = "(C) 1998-2001 Linas Vepstas"; const gchar *authors[] = { "Rob Browning ", @@ -517,6 +518,7 @@ gnc_main_window_about_cb (GtkWidget *widget, gpointer data) "Dave Peticolas ", "Christian Stimming ", "Linas Vepstas ", + "Joshua Sled ", NULL }; @@ -627,6 +629,25 @@ gnc_main_window_create_menus(GNCMDIInfo * maininfo) }, GNOMEUIINFO_END }; + + static GnomeUIInfo gnc_sched_xaction_tools_submenu_template[] = + { + { GNOME_APP_UI_ITEM, + N_("List and Editor"), + N_("The list of Scheduled Transactions"), + gnc_main_window_sched_xaction_cb, NULL, NULL, + GNOME_APP_PIXMAP_NONE, NULL, + 0, 0, NULL + }, + { GNOME_APP_UI_ITEM, + N_("Since Last Run..."), + N_("Create Scheduled Transactions since the last time run."), + gnc_main_window_sched_xaction_slr_cb, NULL, NULL, + GNOME_APP_PIXMAP_NONE, NULL, + 0, 0, NULL + }, + GNOMEUIINFO_END + }; static GnomeUIInfo gnc_tools_menu_template[] = { @@ -669,20 +690,8 @@ gnc_main_window_create_menus(GNCMDIInfo * maininfo) GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL }, - { GNOME_APP_UI_ITEM, - N_("Scheduled Transactions List"), - N_("A list of Scheduled Transactions"), - gnc_main_window_sched_xaction_cb, NULL, NULL, - GNOME_APP_PIXMAP_NONE, NULL, - 0, 0, NULL - }, - { GNOME_APP_UI_ITEM, - N_("Scheduled Transactions Since-Last-Run..."), - N_("Create Scheduled Transactions since the last-time-run."), - gnc_main_window_sched_xaction_slr_cb, NULL, NULL, - GNOME_APP_PIXMAP_NONE, NULL, - 0, 0, NULL - }, + GNOMEUIINFO_SUBTREE( N_("Scheduled Transactions"), + gnc_sched_xaction_tools_submenu_template ), GNOMEUIINFO_END }; diff --git a/src/register/register-gnome/gnucash-sheet.c b/src/register/register-gnome/gnucash-sheet.c index d8d8acc27a..25d87128d6 100644 --- a/src/register/register-gnome/gnucash-sheet.c +++ b/src/register/register-gnome/gnucash-sheet.c @@ -40,10 +40,15 @@ #include "gnucash-header.h" #include "gnucash-item-edit.h" +/* +DEBUG Just for the time being, until we get this + * gnome-druid/gnucash-sheet problem sorted out. --jsled */ +#include "gnc-engine-util.h" +static short module = MOD_SX; +/* -DEBUG */ + #define DEFAULT_REGISTER_HEIGHT 400 #define DEFAULT_REGISTER_WIDTH 630 - static guint gnucash_register_initial_rows = 15; static void gnucash_sheet_start_editing_at_cursor (GnucashSheet *sheet); @@ -683,6 +688,10 @@ gnucash_sheet_size_request (GtkWidget *widget, GtkRequisition *requisition) requisition->width = compute_optimal_width (sheet); requisition->height = compute_optimal_height (sheet); +/* temporary -- jsled + DEBUG( "size_request: returning %d x %d\n", + requisition->width, requisition->height ); +*/ } const char * @@ -1013,11 +1022,30 @@ gnucash_sheet_size_allocate (GtkWidget *widget, GtkAllocation *allocation) if (GTK_WIDGET_CLASS(sheet_parent_class)->size_allocate) (*GTK_WIDGET_CLASS (sheet_parent_class)->size_allocate) (widget, allocation); +/* temporary -- jsled + DEBUG( "allocation: x: %d, y: %d, w: %d, h: %d, " + "sheet_width: %d, sheet_height: %d\n", + allocation->x, allocation->y, + allocation->width, allocation->height, + sheet->window_height, sheet->window_width ); +*/ if (allocation->height == sheet->window_height && allocation->width == sheet->window_width) return; + /* Deal with a bug in gnome-druid.c which causes the ledger to resize + * in 8x4 increments ad infinitum... :( + * + * THIS IS BAD AND LAME. THE RIGHT THING TO DO IS FIGURE OUT WHO'S + * DOING THE BAD THING AND FIX THEM. + * -- jsled + */ + if ( (allocation->height - GNOME_PAD_SMALL - sheet->window_height) == 0 + && (allocation->width - 2 * GNOME_PAD_SMALL - sheet->window_width) == 0 ) + return; + /* END LAMENESS */ + if (allocation->width != sheet->window_width) gnucash_sheet_styles_set_dimensions (sheet, allocation->width);