2001-04-17 Bill Gribble <grib@billgribble.com>

* fixes to MDI bugs: only one param editor for accounts and
	reports, make sure reports reference and created children

	* new report: 'Frame URL'.  Give it an URL and it will display the
	contents in an <iframe>... handly for putting that stock ticker
	graph from yahoo or wherever in a sidebar of a multicolumn view.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3985 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-04-17 19:51:39 +00:00
parent 47dffe8cb9
commit a6f80c3f39
15 changed files with 213 additions and 118 deletions

View File

@ -1,3 +1,12 @@
2001-04-17 Bill Gribble <grib@billgribble.com>
* fixes to MDI bugs: only one param editor for accounts and
reports, make sure reports reference and created children
* new report: 'Frame URL'. Give it an URL and it will display the
contents in an <iframe>... handly for putting that stock ticker
graph from yahoo or wherever in a sidebar of a multicolumn view.
2001-04-17 Dave Peticolas <dave@krondo.com>
* lots of files: handle NULL pointer printf problems,

View File

@ -49,6 +49,15 @@ struct gncp_column_view_edit {
int contents_selected;
};
static void
gnc_column_view_edit_destroy(gnc_column_view_edit * view) {
gnc_options_dialog_destroy(view->optwin);
scm_unprotect_object(view->options);
scm_unprotect_object(view->view);
gnc_option_db_destroy(view->odb);
g_free(view);
}
static void
update_display_lists(gnc_column_view_edit * view) {
SCM get_names = gh_eval_str("gnc:all-report-template-names");
@ -134,12 +143,12 @@ gnc_column_view_edit_close_cb(GNCOptionWin * win, gpointer user_data) {
/********************************************************************
* gnc_column_view_edit_new
* gnc_column_view_edit_options
* create the editor.
********************************************************************/
gnc_column_view_edit *
gnc_column_view_edit_new(SCM options, SCM view) {
void
gnc_column_view_edit_options(SCM options, SCM view) {
gnc_column_view_edit * r = g_new0(gnc_column_view_edit, 1);
GtkObject * tlo;
GtkWidget * editor;
@ -188,19 +197,9 @@ gnc_column_view_edit_new(SCM options, SCM view) {
gnc_column_view_edit_close_cb, r);
gtk_widget_show_all(gnc_options_dialog_widget(r->optwin));
return r;
}
void
gnc_column_view_edit_destroy(gnc_column_view_edit * view) {
gnc_options_dialog_destroy(view->optwin);
scm_unprotect_object(view->options);
scm_unprotect_object(view->view);
gnc_option_db_destroy(view->odb);
g_free(view);
}
void
gnc_column_view_edit_add_cb(GtkButton * button, gpointer user_data) {
gnc_column_view_edit * r =

View File

@ -24,5 +24,4 @@
typedef struct gncp_column_view_edit gnc_column_view_edit;
gnc_column_view_edit * gnc_column_view_edit_new(SCM options, SCM view);
void gnc_column_view_edit_destroy(gnc_column_view_edit * e);
void gnc_column_view_edit_options(SCM options, SCM view);

View File

@ -79,6 +79,7 @@ struct GNCAcctTreeWin_p
GNCOptionDB * odb;
SCM options;
int options_id;
GNCOptionWin * editor_dialog;
GList * account_sensitives;
};
@ -944,6 +945,11 @@ gnc_acct_tree_window_destroy(GNCAcctTreeWin * win) {
gnc_unregister_option_change_callback_id
(win->euro_change_callback_id);
if(win->editor_dialog) {
gnc_options_dialog_destroy(win->editor_dialog);
win->editor_dialog = NULL;
}
g_list_free(win->account_sensitives);
win->account_sensitives = NULL;
@ -973,6 +979,7 @@ gnc_acct_tree_window_new(const gchar * url) {
treewin->account_tree = gnc_mainwin_account_tree_new();
treewin->options = SCM_BOOL_F;
scm_protect_object(treewin->options);
treewin->editor_dialog = NULL;
/* get the options and the window ID */
if(!url) {
@ -1043,13 +1050,6 @@ gnc_acct_tree_window_get_widget(GNCAcctTreeWin * win) {
* parameter editor handling
********************************************************************/
struct acct_tree_params_data {
GNCOptionWin * win;
GNCOptionDB * db;
SCM scm_options;
};
static void
gnc_options_dialog_apply_cb(GNCOptionWin * propertybox,
gpointer user_data) {
@ -1069,39 +1069,36 @@ gnc_options_dialog_help_cb(GNCOptionWin * propertybox,
static void
gnc_options_dialog_close_cb(GNCOptionWin * propertybox,
gpointer user_data) {
struct acct_tree_params_data * win = user_data;
scm_unprotect_object(win->scm_options);
gnc_options_dialog_destroy(win->win);
g_free(win);
GNCAcctTreeWin * win = user_data;
gnc_options_dialog_destroy(win->editor_dialog);
win->editor_dialog = NULL;
}
void
gnc_acct_tree_window_toolbar_options_cb(GtkWidget * widget, gpointer data) {
GNCAcctTreeWin * win = data;
struct acct_tree_params_data * prm =
g_new0(struct acct_tree_params_data, 1);
prm->scm_options = win->options;
prm->db = win->odb;
prm->win = gnc_options_dialog_new(TRUE);
scm_protect_object(prm->scm_options);
gnc_build_options_dialog_contents(prm->win, prm->db);
gnc_options_dialog_set_apply_cb(prm->win,
gnc_options_dialog_apply_cb,
(gpointer)win);
gnc_options_dialog_set_help_cb(prm->win,
gnc_options_dialog_help_cb,
(gpointer)prm);
gnc_options_dialog_set_close_cb(prm->win,
gnc_options_dialog_close_cb,
(gpointer)prm);
struct acct_tree_params_data * prm = NULL;
if(win->editor_dialog) {
gdk_window_raise(GTK_WIDGET
(gnc_options_dialog_widget(win->editor_dialog))->window);
}
else {
win->editor_dialog = gnc_options_dialog_new(TRUE);
gnc_build_options_dialog_contents(win->editor_dialog,
win->odb);
gnc_options_dialog_set_apply_cb(win->editor_dialog,
gnc_options_dialog_apply_cb,
(gpointer)win);
gnc_options_dialog_set_help_cb(win->editor_dialog,
gnc_options_dialog_help_cb,
(gpointer)win);
gnc_options_dialog_set_close_cb(win->editor_dialog,
gnc_options_dialog_close_cb,
(gpointer)win);
}
}

View File

@ -57,6 +57,7 @@
#include "option-util.h"
#include "global-options.h"
#include "query-user.h"
#include "file-history.h"
#define WINDOW_MAIN_CM_CLASS "window-main"
@ -141,6 +142,9 @@ gnc_main_window_app_created_cb(GnomeMDI * mdi, GnomeApp * app,
/* set up extensions menu and hints */
gnc_extensions_menu_setup(app);
/* make sure the file history is shown */
gnc_history_update_menu(app);
}
static void
@ -198,17 +202,18 @@ gnc_app_set_title (GnomeApp *app)
}
static void
gnc_refresh_main_window_titles (void)
gnc_refresh_main_window_info (void)
{
GList *containers = gtk_container_get_toplevels ();
while (containers)
{
while (containers) {
GtkWidget *w = containers->data;
if (GNOME_IS_APP (w))
if (GNOME_IS_APP (w)) {
gnc_app_set_title (GNOME_APP (w));
gnc_history_update_menu(GNOME_APP(w));
}
containers = containers->next;
}
}
@ -551,7 +556,7 @@ gnc_main_window_options_cb(GtkWidget *widget, gpointer data) {
static void
gnc_main_window_file_new_file_cb(GtkWidget * widget) {
gncFileNew();
gnc_refresh_main_window_titles();
gnc_refresh_main_window_info();
}
static void
@ -569,19 +574,19 @@ gnc_main_window_file_new_window_cb(GtkWidget * widget, GnomeMDI * mdi) {
static void
gnc_main_window_file_open_cb(GtkWidget * widget) {
gncFileOpen();
gnc_refresh_main_window_titles();
gnc_refresh_main_window_info();
}
static void
gnc_main_window_file_save_cb(GtkWidget * widget) {
gncFileSave();
gnc_refresh_main_window_titles();
gnc_refresh_main_window_info();
}
static void
gnc_main_window_file_save_as_cb(GtkWidget * widget) {
gncFileSaveAs();
gnc_refresh_main_window_titles();
gnc_refresh_main_window_info();
}
static void

View File

@ -56,6 +56,7 @@ struct _gnc_report_window {
SCM scm_options;
SCM scm_options_edit;
SCM name_change_callback_id;
GList * open_editors;
GNCOptionDB * odb; /* used to get callbacks from parameter edit */
@ -122,7 +123,6 @@ gnc_report_window_view_destroy(GtkObject * obj, gpointer user_data) {
GNCMainChildInfo * mc = user_data;
gnc_report_window * w = mc->user_data;
gnc_main_window_remove_child(gnc_ui_get_data(), mc);
g_free(mc->toolbar_info);
g_free(mc->menu_info);
g_free(mc->title);
@ -303,8 +303,7 @@ gnc_report_window_export_button_cb(GtkWidget * w, gpointer data) {
static int
gnc_report_window_params_cb(GtkWidget * w, gpointer data) {
gnc_report_window * report = data;
SCM scm_wintype = gh_eval_str("<gnc:report-window*>");
if((report->scm_report != SCM_BOOL_F) &&
(report->scm_options != SCM_BOOL_F)) {
@ -414,6 +413,8 @@ gnc_report_window_load_cb(gnc_html * html, URLType type,
scm_protect_object(win->scm_options);
if(win->odb) {
gnc_option_db_unregister_change_callback_id(win->odb,
win->name_change_callback_id);
gnc_option_db_destroy(win->odb);
}
win->odb = gnc_option_db_new(win->scm_options);
@ -664,6 +665,14 @@ gnc_report_window_destroy(gnc_report_window * win) {
SCM scm_wintype = gh_eval_str("<gnc:report-window*>");
SCM unshow_report = gh_eval_str("gnc:report-unregister-display");
if(win->odb) {
gnc_option_db_unregister_change_callback_id(win->odb,
win->name_change_callback_id);
gnc_option_db_destroy(win->odb);
win->odb = NULL;
}
if(win->scm_report != SCM_BOOL_F) {
gh_call2(unshow_report, win->scm_report,
gw_wcp_assimilate_ptr(win, scm_wintype));
@ -763,6 +772,9 @@ static void
gnc_options_dialog_close_cb(GNCOptionWin * propertybox,
gpointer user_data) {
struct report_default_params_data * win = user_data;
SCM set_editor = gh_eval_str("gnc:report-set-editor-widget!");
gh_call2(set_editor, win->scm_report, SCM_BOOL_F);
gnc_option_db_destroy(win->db);
scm_unprotect_object(win->scm_options);
gnc_options_dialog_destroy(win->win);
@ -772,27 +784,40 @@ gnc_options_dialog_close_cb(GNCOptionWin * propertybox,
void
gnc_report_window_default_params_editor(SCM options, SCM report) {
struct report_default_params_data * prm =
g_new0(struct report_default_params_data, 1);
prm->scm_options = options;
prm->scm_report = report;
prm->db = gnc_option_db_new(prm->scm_options);
prm->win = gnc_options_dialog_new(TRUE);
SCM get_editor = gh_eval_str("gnc:report-editor-widget");
SCM set_editor = gh_eval_str("gnc:report-set-editor-widget!");
SCM ptr_type = gh_eval_str("<gnc:UIWidget>");
SCM ptr;
scm_protect_object(prm->scm_options);
scm_protect_object(prm->scm_report);
gnc_build_options_dialog_contents(prm->win, prm->db);
gnc_options_dialog_set_apply_cb(prm->win,
gnc_options_dialog_apply_cb,
(gpointer)prm);
gnc_options_dialog_set_help_cb(prm->win,
gnc_options_dialog_help_cb,
(gpointer)prm);
gnc_options_dialog_set_close_cb(prm->win,
gnc_options_dialog_close_cb,
(gpointer)prm);
ptr = gh_call1(get_editor, report);
if(ptr != SCM_BOOL_F) {
GtkWidget * w = gw_wcp_get_ptr(ptr);
gdk_window_raise(GTK_WIDGET(w)->window);
}
else {
struct report_default_params_data * prm =
g_new0(struct report_default_params_data, 1);
prm->scm_options = options;
prm->scm_report = report;
prm->db = gnc_option_db_new(prm->scm_options);
prm->win = gnc_options_dialog_new(TRUE);
scm_protect_object(prm->scm_options);
scm_protect_object(prm->scm_report);
gnc_build_options_dialog_contents(prm->win, prm->db);
gnc_options_dialog_set_apply_cb(prm->win,
gnc_options_dialog_apply_cb,
(gpointer)prm);
gnc_options_dialog_set_help_cb(prm->win,
gnc_options_dialog_help_cb,
(gpointer)prm);
gnc_options_dialog_set_close_cb(prm->win,
gnc_options_dialog_close_cb,
(gpointer)prm);
gh_call2(set_editor, report,
gw_wcp_assimilate_ptr(gnc_options_dialog_widget(prm->win),
ptr_type));
}
}

View File

@ -72,7 +72,7 @@
(set! user-config-loaded? #t)
#t)
(begin
(gnc:warn "failure loading " user-file)
(gnc:warn "failure loading " file)
#f))
#f)))

View File

@ -224,7 +224,7 @@
(define <report>
(make-record-type "<report>"
'(type id options parents children
dirty? display-list ctext)))
dirty? display-list editor-widget ctext)))
(define gnc:report-type
(record-accessor <report> 'type))
@ -296,6 +296,12 @@
(define gnc:report-set-display-list!
(record-modifier <report> 'display-list))
(define gnc:report-editor-widget
(record-accessor <report> 'editor-widget))
(define gnc:report-set-editor-widget!
(record-modifier <report> 'editor-widget))
(define gnc:report-ctext
(record-accessor <report> 'ctext))
@ -303,32 +309,40 @@
(record-modifier <report> 'ctext))
(define (gnc:report-register-display report window)
(if (and window report)
(if (and window report
(not (member window (gnc:report-display-list report))))
(begin
(if (not (member window (gnc:report-display-list report)))
(gnc:report-set-display-list!
report
(cons window (gnc:report-display-list report))))
(gnc:report-set-display-list!
report
(cons window (gnc:report-display-list report)))
(for-each
(lambda (rep)
(gnc:report-register-display (gnc:find-report rep) window))
(gnc:report-children report)))))
(gnc:report-children report))
(for-each
(lambda (rep)
(gnc:report-register-display (gnc:find-report rep) window))
(gnc:report-parents report)))))
(define (gnc:report-unregister-display report window)
(if (and window report)
(begin
(if (member window (gnc:report-display-list report))
(gnc:report-set-display-list!
report
(delete window (gnc:report-display-list report))))
(if (and report window
(member window (gnc:report-display-list report)))
(begin
(gnc:report-set-display-list!
report
(delete window (gnc:report-display-list report)))
(for-each
(lambda (rep)
(gnc:report-unregister-display (gnc:find-report rep) window))
(gnc:report-children report)))))
(gnc:report-children report))
(for-each
(lambda (rep)
(gnc:report-unregister-display (gnc:find-report rep) window))
(gnc:report-parents report)))))
(define (gnc:make-report template-name . rest)
(let ((r ((record-constructor <report>)
template-name #f #f '() '() #t '() #f))
template-name #f #f '() '() #t '() #f #f))
(template (hash-ref *gnc:_report-templates_* template-name))
(id *gnc:_report-next-serial_*))
(gnc:report-set-id! r id)
@ -344,7 +358,7 @@
(define (gnc:restore-report id template-name parents children options)
(let ((r ((record-constructor <report>)
template-name id options parents children #t '() #f)))
template-name id options parents children #t '() #f #f)))
(if (>= id *gnc:_report-next-serial_*)
(set! *gnc:_report-next-serial_* (+ id 1)))
(hash-set! *gnc:_reports_* id r)))

View File

@ -8,6 +8,7 @@ gncscm_DATA = \
balance-sheet.scm \
category-barchart.scm \
hello-world.scm \
iframe-url.scm \
income-expense-graph.scm \
net-worth-timeseries.scm \
pnl.scm \

View File

@ -269,7 +269,8 @@ balance at a given time"))
(set! combined
(append start
(list (list sum (_ "Other")))))
(let ((options (gnc:make-report-options reportname)))
(let ((options (gnc:make-report-options reportname))
(id #f))
;; now copy all the options
(gnc:options-copy-values (gnc:report-options report-obj)
options)
@ -278,10 +279,12 @@ balance at a given time"))
(gnc:lookup-option options pagename-accounts
optname-accounts)
(map cadr finish))
(set! id (gnc:make-report reportname options))
(gnc:report-add-child-by-id! report-obj id)
(gnc:report-add-parent! (gnc:find-report id) report-obj)
;; set the URL.
(set! other-anchor
(gnc:report-anchor-text
(gnc:make-report reportname options))))))
(set! other-anchor (gnc:report-anchor-text id)))))
;; set the URLs; the slices are links to other reports
(gnc:html-piechart-set-button-1-slice-urls!

View File

@ -348,7 +348,8 @@ developing over time"))
(set! all-data
(append start
(list (list (_ "Other") other-sum))))
(let* ((options (gnc:make-report-options reportname)))
(let* ((options (gnc:make-report-options reportname))
(id #f))
;; now copy all the options
(gnc:options-copy-values
(gnc:report-options report-obj) options)
@ -358,16 +359,19 @@ developing over time"))
optname-accounts)
(map car finish))
;; Set the URL to point to this report.
(set! other-anchor
(gnc:report-anchor-text
(gnc:make-report reportname options))))))
(set! id (gnc:make-report reportname options))
(gnc:report-add-child-by-id! report-obj id)
(gnc:report-add-parent! (gnc:find-report id) report-obj)
(set! other-anchor (gnc:report-anchor-text id)))))
;; This adds the data. Note the apply-zip stuff: This
;; transposes the data, i.e. swaps rows and columns. Pretty
;; cool, eh? Courtesy of dave_p.
(gnc:html-barchart-set-data! chart
(apply zip (map cadr all-data)))
(if (not (null? all-data))
(gnc:html-barchart-set-data! chart
(apply zip (map cadr all-data))))
;; Labels and colors
(gnc:html-barchart-set-col-labels!
chart (map (lambda (pair)

View File

@ -0,0 +1,36 @@
(gnc:support "report/iframe-url.scm")
(gnc:depend "report-html.scm")
(let ()
(define (options-generator)
(let ((options (gnc:new-options)))
(gnc:register-option options
(gnc:make-string-option
(N_ "General")
(N_ "URL to frame")
"a" (N_ "URL to display in report")
"http://www.gnucash.org"))
options))
(define (renderer report-obj)
(let ((url (gnc:option-value
(gnc:lookup-option
(gnc:report-options report-obj)
(N_ "General") (N_ "URL to frame"))))
(doc (gnc:make-html-document))
(txt (gnc:make-html-text)))
(gnc:html-text-append!
txt
(gnc:html-markup/attr
"iframe" (format #f "src=\"~A\"" url)
"Your browser does not support inline frames, sorry."))
(gnc:html-document-add-object! doc txt)
doc))
(gnc:define-report
'version 1
'name (N_ "Frame URL")
'options-generator options-generator
'renderer renderer))

View File

@ -643,6 +643,7 @@
'renderer reg-renderer
'in-menu? #f))
(define (gnc:apply-register-report func invoice? query journal? double?
title debit-string credit-string)
(let* ((options (gnc:make-report-options "Register"))
@ -654,12 +655,12 @@
(debit-op (gnc:lookup-option options "__reg" "debit-string"))
(credit-op (gnc:lookup-option options "__reg" "credit-string"))
(account-op (gnc:lookup-option options "Display" "Account")))
(if invoice?
(begin
(set! journal? #f)
(gnc:option-set-value account-op #f)))
(gnc:option-set-value invoice-op invoice?)
(gnc:option-set-value query-op query)
(gnc:option-set-value journal-op journal?)
@ -667,9 +668,9 @@
(gnc:option-set-value title-op title)
(gnc:option-set-value debit-op debit-string)
(gnc:option-set-value credit-op credit-string)
(func (gnc:make-report "Register" options))))
(define (gnc:show-register-report . rest)
(apply gnc:apply-register-report
(cons gnc:report-window (cons #f rest))))

View File

@ -17,6 +17,8 @@
(gnc:depend "report/hello-world.scm")
(gnc:depend "report/portfolio.scm")
(gnc:depend "report/register.scm")
(gnc:depend "report/iframe-url.scm")
(let ((locale (setlocale LC_MESSAGES)))
(if (or (equal? locale "C")
(equal? locale "en")

View File

@ -49,7 +49,7 @@
options))
(define (edit-options option-obj report-obj)
(gnc:column-view-edit-new option-obj report-obj))
(gnc:column-view-edit-options option-obj report-obj))
(define (render-view report)
(let* ((view-doc (gnc:make-html-document))