[Gnucash-changes] Reports save/restore: mark reports need-save on
creation, and destroy on
Joshua Sled
jsled at cvs.gnucash.org
Sat Oct 8 11:57:46 EDT 2005
Log Message:
-----------
Reports save/restore: mark reports need-save on creation, and destroy on plugin-page close.
Tags:
----
gnucash-gnome2-dev
Modified Files:
--------------
gnucash:
ChangeLog
GNOME2_STATUS
gnucash/src/report/report-gnome:
gnc-plugin-page-report.c
gnucash/src/scm:
main-window.scm
Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1487.2.316
retrieving revision 1.1487.2.317
diff -LChangeLog -LChangeLog -u -r1.1487.2.316 -r1.1487.2.317
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,12 @@
+2005-10-08 Joshua Sled <jsled at asynchronous.org>
+
+ * src/report/report-gnome/gnc-plugin-page-report.c
+ (gnc_plugin_page_report_destroy_widget): remove the report when
+ the page is destroyed so the report will be removed, &c.
+ (gnc_plugin_page_report_setup): gnc:report-set-needs-save?! on
+ report setup to indicate that the report needs to be written out
+ at book-state-save time.
+
2005-10-08 Christian Stimming <stimming at tuhh.de>
* src/import-export/ofx/gnc-ofx-import.c: Fix errornerous
Index: GNOME2_STATUS
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/Attic/GNOME2_STATUS,v
retrieving revision 1.1.2.71
retrieving revision 1.1.2.72
diff -LGNOME2_STATUS -LGNOME2_STATUS -u -r1.1.2.71 -r1.1.2.72
--- GNOME2_STATUS
+++ GNOME2_STATUS
@@ -152,8 +152,6 @@
- warlord reports this was true in 1.8 as well.
- - Removing a report page should remove the report from the runtime.
-
- Importing
- HBCI - Transaction templates eventually need to be converted from a GTK_CLIST
Index: gnc-plugin-page-report.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/report/report-gnome/Attic/gnc-plugin-page-report.c,v
retrieving revision 1.1.2.19
retrieving revision 1.1.2.20
diff -Lsrc/report/report-gnome/gnc-plugin-page-report.c -Lsrc/report/report-gnome/gnc-plugin-page-report.c -u -r1.1.2.19 -r1.1.2.20
--- src/report/report-gnome/gnc-plugin-page-report.c
+++ src/report/report-gnome/gnc-plugin-page-report.c
@@ -52,12 +52,11 @@
#define WINDOW_REPORT_CM_CLASS "window-report"
-// MOD_GUI; // MOD_REPORT;?
/* NW: you can add GNC_MOD_REPORT to gnc-engine.h
or simply define it locally. Any unique string with
a gnucash- prefix will do. Then just set a log level
with gnc_set_log_level().*/
-static QofLogModule log_module = GNC_MOD_GUI;
+static QofLogModule log_module = GNC_MOD_GUI;
static GObjectClass *parent_class = NULL;
@@ -76,7 +75,6 @@
static void gnc_plugin_page_report_constr_init(GncPluginPageReport *plugin_page, gint reportId);
static GtkWidget* gnc_plugin_page_report_create_widget( GncPluginPage *plugin_page );
-static void gnc_plugin_page_report_destroy_widget( GncPluginPage *plugin_page );
static void gnc_plugin_page_report_merge_actions( GncPluginPage *plugin_page, GtkUIManager *merge );
static void gnc_plugin_page_report_unmerge_actions( GncPluginPage *plugin_page, GtkUIManager *merge );
static void gnc_plugin_page_report_destroy_widget( GncPluginPage *plugin_page );
@@ -357,6 +355,7 @@
GncPluginPageReport *page = GNC_PLUGIN_PAGE_REPORT(ppage);
GncPluginPageReportPrivate *report = (GncPluginPageReportPrivate*)page->priv;
SCM find_report = scm_c_eval_string("gnc:find-report");
+ SCM set_needs_save = scm_c_eval_string("gnc:report-set-needs-save?!");
SCM inst_report;
int report_id;
@@ -371,7 +370,7 @@
g_object_get( ppage, "report-id", &report_id, NULL );
- DEBUG("report-id: %d\n", report_id);
+ PINFO("report-id: %d\n", report_id);
/* get the inst-report from the Scheme-side hash, and get its
* options and editor thunk */
@@ -385,6 +384,10 @@
report->initial_report = inst_report;
scm_gc_protect_object(report->initial_report);
}
+
+ // all reports need [to be] saved immediately after they're created.
+ PINFO("set needs save");
+ scm_call_2(set_needs_save, inst_report, SCM_BOOL_T);
}
/********************************************************************
@@ -439,12 +442,13 @@
LEAVE( "error getting inst_report" );
return;
}
-
- if (win->initial_report == SCM_BOOL_F) {
+
+ if (win->initial_report == SCM_BOOL_F) {
scm_gc_unprotect_object(win->initial_report);
win->initial_report = inst_report;
scm_gc_protect_object(win->initial_report);
+ DEBUG("calling set_needs_save for report with id=%d", report_id);
scm_call_2(set_needs_save, inst_report, SCM_BOOL_T);
win->initial_odb = gnc_option_db_new(scm_call_1(get_options, inst_report));
@@ -517,13 +521,13 @@
static SCM remover = SCM_BOOL_F;
int report_id;
- if(remover == SCM_BOOL_F) {
+ if (remover == SCM_BOOL_F) {
remover = scm_c_eval_string("gnc:report-remove-by-id");
}
- if(node &&
- !safe_strcmp (node->type, URL_TYPE_REPORT) &&
- !strncmp("id=", node->location, 3)) {
+ if (node
+ && !safe_strcmp (node->type, URL_TYPE_REPORT)\
+ && !strncmp("id=", node->location, 3)) {
sscanf(node->location+3, "%d", &report_id);
/* printf("unreffing report %d and children\n", report_id);
scm_call_1(remover, scm_int2num(report_id)); */
@@ -543,7 +547,6 @@
g_return_if_fail(GNC_IS_PLUGIN_PAGE_REPORT(page));
win = page->priv;
- DEBUG( "drawin'" );
ENTER( "report_draw" );
if (!win->need_reload)
{
@@ -560,7 +563,7 @@
// @param data is actually GncPluginPageReportPrivate
static void
-gnc_plugin_page_report_refresh (gpointer data)
+gnc_plugin_page_report_refresh(gpointer data)
{
// FIXME?
DEBUG( "report-refresh called" );
@@ -568,11 +571,21 @@
return;
}
-static
-void
-gnc_plugin_page_report_destroy_widget( GncPluginPage *plugin_page )
+static void
+gnc_plugin_page_report_destroy_widget(GncPluginPage *plugin_page)
{
- // FIXME: cleanup resources.
+ // FIXME: cleanup other resources.
+ static SCM remover = SCM_BOOL_F;
+ int report_id;
+
+ PINFO("destroy widget");
+ if (remover == SCM_BOOL_F) {
+ remover = scm_c_eval_string("gnc:report-remove-by-id");
+ }
+
+ report_id = GNC_PLUGIN_PAGE_REPORT(plugin_page)->priv->reportId;
+ PINFO("unreffing report %d and children\n", report_id);
+ scm_call_1(remover, scm_int2num(report_id));
}
/********************************************************************
@@ -589,16 +602,16 @@
gnc_unregister_gui_component_by_data (WINDOW_REPORT_CM_CLASS, win);
/* close any open editors */
- for(edited = scm_list_copy(win->edited_reports); !SCM_NULLP(edited);
- edited = SCM_CDR(edited)) {
+ for (edited = scm_list_copy(win->edited_reports); !SCM_NULLP(edited);
+ edited = SCM_CDR(edited)) {
editor = scm_call_1(get_editor, SCM_CAR(edited));
scm_call_2(set_editor, SCM_CAR(edited), SCM_BOOL_F);
- if(editor != SCM_BOOL_F) {
+ if (editor != SCM_BOOL_F) {
gtk_widget_destroy(GTK_WIDGET(gw_wcp_get_ptr(editor)));
}
}
- if(win->initial_odb) {
+ if (win->initial_odb) {
gnc_option_db_unregister_change_callback_id(win->initial_odb,
win->name_change_cb_id);
@@ -617,8 +630,7 @@
g_free(win);
}
-static
-void
+static void
gnc_plugin_page_report_merge_actions( GncPluginPage *plugin_page,
GtkUIManager *ui_merge )
{
@@ -637,8 +649,7 @@
DEBUG( "done merging" );
}
-static
-void
+static void
gnc_plugin_page_report_unmerge_actions( GncPluginPage *plugin_page,
GtkUIManager *ui_merge )
{
Index: main-window.scm
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/scm/main-window.scm,v
retrieving revision 1.23.2.11
retrieving revision 1.23.2.12
diff -Lsrc/scm/main-window.scm -Lsrc/scm/main-window.scm -u -r1.23.2.11 -r1.23.2.12
--- src/scm/main-window.scm
+++ src/scm/main-window.scm
@@ -112,8 +112,6 @@
(save-file? #f)
(book-path #f))
- ;;(gnc:msg (simple-format #f "saving ~S reports" (vector-length *gnc:_reports_*)))
-
;; make sure ~/.gnucash/books is there
(set! save-file? (and (gnc:make-dir dotgnucash-dir)
(gnc:make-dir file-dir)))
@@ -128,8 +126,7 @@
(hash-fold
(lambda (k v p)
(if (gnc:report-needs-save? v)
- (display
- (gnc:report-generate-restore-forms v))))
+ (display (gnc:report-generate-restore-forms v))))
#t *gnc:_reports_*)
(hash-fold
@@ -153,7 +150,7 @@
;; window's reference will keep the report alive until the
;; window is destroyed, but find-report will fail)
(for-each
- (lambda (dr)
+ (lambda (dr)
(hash-remove! *gnc:_reports_* dr))
dead-reports)))
@@ -177,7 +174,7 @@
;; the reports have only been created at this point; create their ui component.
(hash-fold (lambda (key val prior-result)
(gnc:main-window-open-report (gnc:report-id val)
- #f ;; window = nil: open in first window.
+ #f ;; =window: #f/null => open in first window
))
#t *gnc:_reports_*)
))
More information about the gnucash-changes
mailing list