mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bill Gribble's gnome mdi patch.
* Lots and lots of changes to support Gnome MDI. And I thought it would be an easy way to get that toolbar problem fixed. Short story is lots of function prototypes changed to reflect the notion that there is no longer a single top-level gnucash window or account tree. 41 files changed, which is too many for me to itemize :) * src/gnome/window-acct-tree.{c,h}: new file; the "account tree window" is the contents of the former main window. Now you can have as many of them open as you want. account trees and reports are the 2 kinds of "main window children" which MDI manages. * src/gnome/window-main-summarybar.{c,h}: new file. I moved the summary bar stuff out of the account tree because there's one summary bar per top-level window but possible many account trees per top-level window. * src/gnome/window-main.c: this is not what it used to be at all. the main gnucash ui element is now a 'GnomeMDI'. The only menus and toolbar items here are ones that are always visible in any top-level window. * src/scm/prefs/scm: acct tree prefs are treated differently (one options obj per acct tree) and are auto-saved and restored. * src/scm/report.scm: report options are auto saved and restored. * src/scm/html-style-sheet.scm: so are style sheets. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3953 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
6636f93862
commit
1ff77ccd23
31
ChangeLog
31
ChangeLog
@ -1,3 +1,34 @@
|
||||
2001-04-12 Bill Gribble <grib@billgribble.com>
|
||||
|
||||
* Lots and lots of changes to support Gnome MDI. And I thought it
|
||||
would be an easy way to get that toolbar problem fixed. Short
|
||||
story is lots of function prototypes changed to reflect the notion
|
||||
that there is no longer a single top-level gnucash window or
|
||||
account tree. 41 files changed, which is too many for me to
|
||||
itemize :)
|
||||
|
||||
* src/gnome/window-acct-tree.{c,h}: new file; the "account tree
|
||||
window" is the contents of the former main window. Now you can
|
||||
have as many of them open as you want. account trees and reports
|
||||
are the 2 kinds of "main window children" which MDI manages.
|
||||
|
||||
* src/gnome/window-main-summarybar.{c,h}: new file. I moved the
|
||||
summary bar stuff out of the account tree because there's one
|
||||
summary bar per top-level window but possible many account trees
|
||||
per top-level window.
|
||||
|
||||
* src/gnome/window-main.c: this is not what it used to be at all.
|
||||
the main gnucash ui element is now a 'GnomeMDI'. The only menus
|
||||
and toolbar items here are ones that are always visible in any
|
||||
top-level window.
|
||||
|
||||
* src/scm/prefs/scm: acct tree prefs are treated differently (one
|
||||
options obj per acct tree) and are auto-saved and restored.
|
||||
|
||||
* src/scm/report.scm: report options are auto saved and restored.
|
||||
|
||||
* src/scm/html-style-sheet.scm: so are style sheets.
|
||||
|
||||
2001-04-12 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/register/gnome/gnucash-item-list.c: same as below
|
||||
|
46
po/ChangeLog
46
po/ChangeLog
@ -1,3 +1,49 @@
|
||||
2001-04-11 gettextize <bug-gnu-utils@gnu.org>
|
||||
|
||||
* Makefile.in.in: Upgrade to gettext-0.10.36.
|
||||
|
||||
2001-04-11 gettextize <bug-gnu-utils@gnu.org>
|
||||
|
||||
* Makefile.in.in: Upgrade to gettext-0.10.36.
|
||||
|
||||
2001-04-11 gettextize <bug-gnu-utils@gnu.org>
|
||||
|
||||
* Makefile.in.in: Upgrade to gettext-0.10.36.
|
||||
|
||||
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
|
||||
|
||||
* Makefile.in.in: Upgrade to gettext-0.10.36.
|
||||
|
||||
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
|
||||
|
||||
* Makefile.in.in: Upgrade to gettext-0.10.36.
|
||||
|
||||
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
|
||||
|
||||
* Makefile.in.in: Upgrade to gettext-0.10.36.
|
||||
|
||||
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
|
||||
|
||||
* Makefile.in.in: Upgrade to gettext-0.10.36.
|
||||
|
||||
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
|
||||
|
||||
* Makefile.in.in: Upgrade to gettext-0.10.36.
|
||||
|
||||
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
|
||||
|
||||
* Makefile.in.in: Upgrade to gettext-0.10.36.
|
||||
|
||||
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
|
||||
|
||||
* Makefile.in.in: Upgrade to gettext-0.10.36.
|
||||
|
||||
2001-04-09 gettextize <bug-gnu-utils@gnu.org>
|
||||
|
||||
* Makefile.in.in: Upgrade to gettext-0.10.36.
|
||||
* cat-id-tbl.c: Remove file.
|
||||
* stamp-cat-id: Remove file.
|
||||
|
||||
2001-03-14 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* da.po: add Danish translation
|
||||
|
@ -36,6 +36,8 @@
|
||||
typedef struct _AccountWindow AccountWindow;
|
||||
|
||||
AccountWindow * gnc_ui_new_account_window (AccountGroup *group);
|
||||
AccountWindow * gnc_ui_new_account_window_with_default(AccountGroup *group,
|
||||
Account * parent);
|
||||
AccountWindow * gnc_ui_edit_account_window (Account *account);
|
||||
|
||||
Account * gnc_ui_new_accounts_from_name_window (const char *name);
|
||||
|
@ -244,8 +244,7 @@ gncFileNew (void)
|
||||
gboolean
|
||||
gncFileQuerySave (void)
|
||||
{
|
||||
GNCBook *book = gncGetCurrentBook();
|
||||
gncUIWidget app = gnc_get_ui_data();
|
||||
GNCBook * book = gncGetCurrentBook();
|
||||
|
||||
/* If user wants to mess around before finishing business with
|
||||
* the old file, give em a chance to figure out what's up.
|
||||
@ -258,8 +257,8 @@ gncFileQuerySave (void)
|
||||
const char *message = _("Changes have been made since the last "
|
||||
"Save. Save the data to file?");
|
||||
|
||||
result = gnc_verify_cancel_dialog_parented (app, message, GNC_VERIFY_YES);
|
||||
|
||||
result = gnc_verify_cancel_dialog (message, GNC_VERIFY_YES);
|
||||
|
||||
if (result == GNC_VERIFY_CANCEL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -57,7 +57,6 @@ noinst_HEADERS = \
|
||||
EuroUtils.h \
|
||||
FileBox.h \
|
||||
FileDialog.h \
|
||||
MainWindow.h \
|
||||
MultiLedger.h \
|
||||
RecnWindow.h \
|
||||
RegWindow.h \
|
||||
|
@ -23,10 +23,11 @@
|
||||
#ifndef __HISTORY_H__
|
||||
#define __HISTORY_H__
|
||||
|
||||
#include <gnome.h>
|
||||
#define MAX_HISTORY 4
|
||||
|
||||
void gnc_history_add_file (const char *filename);
|
||||
void gnc_history_update_menu (void);
|
||||
void gnc_history_update_menu (GnomeApp * app);
|
||||
const char * gnc_history_get_last (void);
|
||||
|
||||
#endif
|
||||
|
@ -36,8 +36,10 @@
|
||||
#include "FileDialog.h"
|
||||
#include "Group.h"
|
||||
#include "global-options.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include "gnc-common.h"
|
||||
#include "gnc-component-manager.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "messages.h"
|
||||
@ -1729,3 +1731,4 @@ gnc_set_auto_decimal_places( int places )
|
||||
{
|
||||
auto_decimal_places = places;
|
||||
}
|
||||
|
||||
|
32
src/gnc-ui.h
32
src/gnc-ui.h
@ -46,10 +46,6 @@
|
||||
#define HH_COMMODITY "xacc-commodity.html"
|
||||
|
||||
|
||||
/* Return the main GnuCash window ***********************************/
|
||||
gncUIWidget gnc_get_ui_data(void);
|
||||
|
||||
|
||||
/* Dialog windows ***************************************************/
|
||||
|
||||
typedef enum
|
||||
@ -61,18 +57,20 @@ typedef enum
|
||||
} GNCVerifyResult;
|
||||
|
||||
GNCVerifyResult
|
||||
gnc_verify_cancel_dialog_parented(gncUIWidget parent,
|
||||
const char *message,
|
||||
GNCVerifyResult default_result);
|
||||
gnc_verify_cancel_dialog_parented(gncUIWidget parent,
|
||||
const char *message,
|
||||
GNCVerifyResult default_result);
|
||||
|
||||
GNCVerifyResult gnc_verify_cancel_dialog(const char *message,
|
||||
GNCVerifyResult default_result);
|
||||
|
||||
gboolean gnc_verify_dialog_parented(gncUIWidget parent,
|
||||
const char *message,
|
||||
gboolean yes_is_default);
|
||||
|
||||
GNCVerifyResult
|
||||
gnc_ok_cancel_dialog_parented(gncUIWidget parent,
|
||||
const char *message,
|
||||
GNCVerifyResult default_result);
|
||||
GNCVerifyResult gnc_ok_cancel_dialog_parented(gncUIWidget parent,
|
||||
const char *message,
|
||||
GNCVerifyResult default_result);
|
||||
|
||||
void gnc_warning_dialog_parented(gncUIWidget parent, const char *message);
|
||||
|
||||
@ -108,21 +106,15 @@ gboolean gnc_get_username_password (gncUIWidget parent,
|
||||
|
||||
/* Managing the GUI Windows *****************************************/
|
||||
|
||||
void gnc_ui_destroy_all_subwindows (void);
|
||||
|
||||
void gnc_ui_shutdown (void);
|
||||
void gnc_ui_destroy_all_subwindows (void);
|
||||
gncUIWidget gnc_ui_get_toplevel(void);
|
||||
|
||||
/* Changing the GUI Cursor ******************************************/
|
||||
|
||||
void gnc_set_busy_cursor(gncUIWidget w, gboolean update_now);
|
||||
void gnc_unset_busy_cursor(gncUIWidget w);
|
||||
|
||||
|
||||
/* Getting main window information **********************************/
|
||||
|
||||
Account * gnc_get_current_account(void);
|
||||
GList * gnc_get_current_accounts(void);
|
||||
|
||||
|
||||
/* QIF Import Windows ***********************************************/
|
||||
|
||||
typedef struct _qifimportwindow QIFImportWindow;
|
||||
|
@ -53,8 +53,10 @@ libgncgnome_a_SOURCES = \
|
||||
query-user.c \
|
||||
reconcile-list.c \
|
||||
top-level.c \
|
||||
window-acct-tree.c \
|
||||
window-help.c \
|
||||
window-main.c \
|
||||
window-main-summarybar.c \
|
||||
window-reconcile.c \
|
||||
window-register.c \
|
||||
window-report.c
|
||||
@ -112,8 +114,11 @@ noinst_HEADERS = \
|
||||
print-session.h \
|
||||
query-user.h \
|
||||
reconcile-list.h \
|
||||
top-level.h \
|
||||
window-acct-tree.h \
|
||||
window-help.h \
|
||||
window-main.h \
|
||||
window-main-summarybar.h \
|
||||
window-reconcile.h \
|
||||
window-register.h \
|
||||
window-report.h
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#include "AccWindow.h"
|
||||
#include "FileDialog.h"
|
||||
#include "MainWindow.h"
|
||||
#include "MultiLedger.h"
|
||||
#include "account-tree.h"
|
||||
#include "dialog-account.h"
|
||||
@ -1820,7 +1819,14 @@ gnc_ui_new_account_window_internal (Account *base_account,
|
||||
AccountWindow *
|
||||
gnc_ui_new_account_window (AccountGroup *this_is_not_used)
|
||||
{
|
||||
return gnc_ui_new_account_window_internal (gnc_get_current_account (), NULL);
|
||||
/* FIXME get_current_account went away. */
|
||||
return gnc_ui_new_account_window_internal (NULL, NULL);
|
||||
}
|
||||
|
||||
AccountWindow *
|
||||
gnc_ui_new_account_window_with_default(AccountGroup *this_is_not_used,
|
||||
Account * parent) {
|
||||
return gnc_ui_new_account_window_internal (parent, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -206,7 +206,9 @@ gnc_column_view_edit_add_cb(GtkButton * button, gpointer user_data) {
|
||||
gnc_column_view_edit * r =
|
||||
gtk_object_get_data(GTK_OBJECT(user_data), "view_edit_struct");
|
||||
SCM make_report = gh_eval_str("gnc:make-report");
|
||||
SCM find_report = gh_eval_str("gnc:find-report");
|
||||
SCM add_child = gh_eval_str("gnc:report-add-child-by-id!");
|
||||
SCM add_parent = gh_eval_str("gnc:report-add-parent!");
|
||||
SCM template_name;
|
||||
SCM set_value = gh_eval_str("gnc:option-set-value");
|
||||
SCM new_report;
|
||||
@ -221,6 +223,7 @@ gnc_column_view_edit_add_cb(GtkButton * button, gpointer user_data) {
|
||||
gh_int2scm(r->available_selected));
|
||||
new_report = gh_call1(make_report, template_name);
|
||||
gh_call2(add_child, r->view, new_report);
|
||||
gh_call2(add_parent, gh_call1(find_report, new_report), r->view);
|
||||
|
||||
oldlength = gh_length(r->contents_list);
|
||||
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-ui.h"
|
||||
|
||||
|
||||
typedef struct _FileBoxInfo FileBoxInfo;
|
||||
struct _FileBoxInfo
|
||||
{
|
||||
@ -94,7 +93,7 @@ fileBox (const char * title, const char * filter, const char *default_name)
|
||||
|
||||
gtk_window_set_modal(GTK_WINDOW(fb_info.file_box), TRUE);
|
||||
gtk_window_set_transient_for(GTK_WINDOW(fb_info.file_box),
|
||||
GTK_WINDOW(gnc_get_ui_data()));
|
||||
GTK_WINDOW(gnc_ui_get_toplevel()));
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(fb_info.file_box->ok_button),
|
||||
"clicked", GTK_SIGNAL_FUNC(store_filename),
|
||||
|
@ -2103,12 +2103,6 @@ gnc_show_options_dialog(void)
|
||||
{
|
||||
options_dialog = gnc_options_dialog_new(TRUE);
|
||||
|
||||
/*
|
||||
gnome_dialog_close_hides(GNOME_DIALOG(options_dialog), TRUE);
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(options_dialog),
|
||||
GTK_WINDOW (gnc_get_ui_data()));
|
||||
*/
|
||||
|
||||
gnc_build_options_dialog_contents(options_dialog, global_options);
|
||||
gnc_option_db_clean(global_options);
|
||||
|
||||
|
@ -61,7 +61,7 @@ static void totd_close_cb(GtkWidget *widget, gpointer data);
|
||||
/** Implementations ***************************************************/
|
||||
|
||||
/************************************************************************\
|
||||
* gnc_ui_totd_dialog_crfeate_and_run *
|
||||
* gnc_ui_totd_dialog_create_and_run *
|
||||
* display and run the "Tip of the Day" dialog *
|
||||
* *
|
||||
* Returns: nothing *
|
||||
@ -92,8 +92,6 @@ gnc_ui_totd_dialog_create(void)
|
||||
GNOME_STOCK_BUTTON_CLOSE,
|
||||
NULL);
|
||||
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(win), GTK_WINDOW(gnc_get_ui_data()));
|
||||
|
||||
gnome_dialog_set_default(GNOME_DIALOG(win), 2);
|
||||
gnome_dialog_close_hides(GNOME_DIALOG(win), FALSE);
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-ui.h"
|
||||
|
||||
|
||||
typedef struct _ExtensionInfo ExtensionInfo;
|
||||
struct _ExtensionInfo
|
||||
{
|
||||
@ -269,8 +268,9 @@ gnc_create_extension_info(SCM extension)
|
||||
ext_info->info[1].type = GNOME_APP_UI_ENDOFINFO;
|
||||
|
||||
scm_protect_object(extension);
|
||||
|
||||
extension_list = g_slist_prepend(extension_list, ext_info);
|
||||
|
||||
/* need to append so we can run them in order */
|
||||
extension_list = g_slist_append(extension_list, ext_info);
|
||||
|
||||
return ext_info;
|
||||
}
|
||||
@ -295,24 +295,28 @@ gnc_add_extension(SCM extension)
|
||||
{
|
||||
GnomeApp *app;
|
||||
ExtensionInfo *ext_info;
|
||||
char *path;
|
||||
|
||||
ext_info = gnc_create_extension_info(extension);
|
||||
if (ext_info == NULL)
|
||||
{
|
||||
PERR("bad extension");
|
||||
return;
|
||||
}
|
||||
|
||||
path = gnc_extension_path(ext_info);
|
||||
|
||||
app = GNOME_APP(gnc_get_ui_data());
|
||||
gnome_app_insert_menus(app, path, ext_info->info);
|
||||
gnome_app_install_menu_hints(app, ext_info->info);
|
||||
|
||||
g_free(path);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_extensions_menu_setup(GnomeApp * app) {
|
||||
GSList * l = NULL;
|
||||
ExtensionInfo * info;
|
||||
char * path;
|
||||
|
||||
for(l=extension_list; l; l=l->next) {
|
||||
info = l->data;
|
||||
path = gnc_extension_path(info);
|
||||
gnome_app_insert_menus(app, path, info->info);
|
||||
gnome_app_install_menu_hints(app, info->info);
|
||||
g_free(path);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gnc_extensions_shutdown(void)
|
||||
|
@ -24,8 +24,10 @@
|
||||
#define __EXTENSIONS_H__
|
||||
|
||||
#include <guile/gh.h>
|
||||
#include <gnome.h>
|
||||
|
||||
void gnc_add_extension(SCM extension);
|
||||
void gnc_extensions_menu_setup(GnomeApp * app);
|
||||
void gnc_extensions_shutdown(void);
|
||||
|
||||
#endif
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "gnc-ui.h"
|
||||
#include "messages.h"
|
||||
|
||||
|
||||
static GSList *history_list = NULL;
|
||||
static gint num_menu_entries = -1;
|
||||
|
||||
@ -155,10 +154,9 @@ gnc_history_get_last(void)
|
||||
}
|
||||
|
||||
void
|
||||
gnc_history_update_menu(void)
|
||||
gnc_history_update_menu(GnomeApp * app)
|
||||
{
|
||||
GtkWidget *app_w;
|
||||
GnomeApp *app;
|
||||
GnomeUIInfo *menu;
|
||||
GnomeDockItem *di;
|
||||
GtkWidget *menushell;
|
||||
@ -170,12 +168,6 @@ gnc_history_update_menu(void)
|
||||
int i, n;
|
||||
int pos;
|
||||
|
||||
app_w = gnc_get_ui_data ();
|
||||
if (!app_w)
|
||||
return;
|
||||
|
||||
app = GNOME_APP (app_w);
|
||||
|
||||
di = gnome_app_get_dock_item_by_name(app, GNOME_APP_MENUBAR_NAME);
|
||||
if (di == NULL)
|
||||
return;
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "gnc-network.h"
|
||||
#include "query-user.h"
|
||||
#include "window-help.h"
|
||||
#include "window-main.h"
|
||||
#include "window-report.h"
|
||||
#include "messages.h"
|
||||
|
||||
@ -196,6 +197,9 @@ gnc_html_parse_url(gnc_html * html, const gchar * url,
|
||||
}
|
||||
else if(!strcmp(protocol, "gnc-register")) {
|
||||
retval = URL_TYPE_REGISTER;
|
||||
}
|
||||
else if(!strcmp(protocol, "gnc-acct-tree")) {
|
||||
retval = URL_TYPE_ACCTTREE;
|
||||
}
|
||||
else if(!strcmp(protocol, "gnc-report")) {
|
||||
retval = URL_TYPE_REPORT;
|
||||
@ -218,14 +222,19 @@ gnc_html_parse_url(gnc_html * html, const gchar * url,
|
||||
retval = URL_TYPE_JUMP;
|
||||
}
|
||||
else {
|
||||
retval = html->base_type;
|
||||
if(html) {
|
||||
retval = html->base_type;
|
||||
}
|
||||
else {
|
||||
retval = URL_TYPE_FILE;
|
||||
}
|
||||
}
|
||||
|
||||
g_free(protocol);
|
||||
|
||||
switch(retval) {
|
||||
case URL_TYPE_FILE:
|
||||
if(!found_protocol && path && html->base_location) {
|
||||
if(!found_protocol && path && html && html->base_location) {
|
||||
if(path[0] == '/') {
|
||||
*url_location = g_strdup(path);
|
||||
}
|
||||
@ -247,7 +256,7 @@ gnc_html_parse_url(gnc_html * html, const gchar * url,
|
||||
|
||||
case URL_TYPE_OTHER:
|
||||
default:
|
||||
if(!found_protocol && path && html->base_location) {
|
||||
if(!found_protocol && path && html && html->base_location) {
|
||||
if(path[0] == '/') {
|
||||
*url_location =
|
||||
g_strconcat(extract_machine_name(html->base_location),
|
||||
@ -347,7 +356,7 @@ extract_base_name(URLType type, const gchar * path) {
|
||||
|
||||
static char * url_type_names[] = {
|
||||
"file:", "", "http:", "ftp:", "https:",
|
||||
"gnc-register:", "gnc-report:", "gnc-options:", "gnc-scm:",
|
||||
"gnc-register:", "gnc-acct-tree:", "gnc-report:", "gnc-options:", "gnc-scm:",
|
||||
"gnc-help:", "gnc-xml:", "gnc-action:", ""
|
||||
};
|
||||
|
||||
@ -590,6 +599,7 @@ gnc_html_load_to_stream(gnc_html * html, GtkHTMLStream * handle,
|
||||
break;
|
||||
|
||||
case URL_TYPE_REGISTER:
|
||||
case URL_TYPE_ACCTTREE:
|
||||
case URL_TYPE_OPTIONS:
|
||||
case URL_TYPE_SCHEME:
|
||||
case URL_TYPE_FTP:
|
||||
@ -1088,23 +1098,26 @@ gnc_html_open_report(gnc_html * html, const gchar * location,
|
||||
const gchar * label, int newwin) {
|
||||
gnc_report_window * rwin;
|
||||
GtkHTMLStream * handle;
|
||||
char * rebuilt_url;
|
||||
|
||||
/* make a new window if necessary */
|
||||
if(newwin) {
|
||||
rwin = gnc_report_window_new(NULL);
|
||||
html = gnc_report_window_get_html(rwin);
|
||||
rebuilt_url = rebuild_url(URL_TYPE_REPORT, location, label);
|
||||
gnc_main_window_open_report_url(rebuilt_url, FALSE);
|
||||
g_free(rebuilt_url);
|
||||
}
|
||||
else {
|
||||
gnc_html_history_append(html->history,
|
||||
gnc_html_history_node_new(URL_TYPE_REPORT,
|
||||
location, label));
|
||||
|
||||
g_free(html->base_location);
|
||||
html->base_type = URL_TYPE_FILE;
|
||||
html->base_location = NULL;
|
||||
|
||||
handle = gtk_html_begin(GTK_HTML(html->html));
|
||||
gnc_html_load_to_stream(html, handle, URL_TYPE_REPORT, location, label);
|
||||
}
|
||||
|
||||
gnc_html_history_append(html->history,
|
||||
gnc_html_history_node_new(URL_TYPE_REPORT,
|
||||
location, label));
|
||||
|
||||
g_free(html->base_location);
|
||||
html->base_type = URL_TYPE_FILE;
|
||||
html->base_location = NULL;
|
||||
|
||||
handle = gtk_html_begin(GTK_HTML(html->html));
|
||||
gnc_html_load_to_stream(html, handle, URL_TYPE_REPORT, location, label);
|
||||
}
|
||||
|
||||
|
||||
@ -1250,6 +1263,7 @@ gnc_html_show_url(gnc_html * html, URLType type,
|
||||
(gpointer)html);
|
||||
break;
|
||||
|
||||
URL_TYPE_ACCTTREE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ typedef enum { URL_TYPE_FILE, URL_TYPE_JUMP,
|
||||
URL_TYPE_HTTP, URL_TYPE_FTP,
|
||||
URL_TYPE_SECURE,
|
||||
URL_TYPE_REGISTER, /* for gnucash register popups */
|
||||
URL_TYPE_ACCTTREE, /* for account tree windows */
|
||||
URL_TYPE_REPORT, /* for gnucash report popups */
|
||||
URL_TYPE_OPTIONS, /* for editing report options */
|
||||
URL_TYPE_SCHEME, /* for scheme code evaluation */
|
||||
|
@ -100,6 +100,16 @@ gnc_ok_cancel_dialog_parented(gncUIWidget parent, const char *message,
|
||||
* default - the button that will be the default *
|
||||
* Return: the result the user selected *
|
||||
\********************************************************************/
|
||||
|
||||
GNCVerifyResult
|
||||
gnc_verify_cancel_dialog(const char * message, GNCVerifyResult default_res)
|
||||
{
|
||||
gnc_verify_cancel_dialog_parented(gnc_ui_get_toplevel(), message,
|
||||
default_res);
|
||||
}
|
||||
|
||||
|
||||
|
||||
GNCVerifyResult
|
||||
gnc_verify_cancel_dialog_parented(GtkWidget *parent, const char *message,
|
||||
GNCVerifyResult default_result)
|
||||
@ -164,7 +174,7 @@ gnc_verify_cancel_dialog_parented(GtkWidget *parent, const char *message,
|
||||
gboolean
|
||||
gnc_verify_dialog(const char *message, gboolean yes_is_default)
|
||||
{
|
||||
return gnc_verify_dialog_parented(gnc_get_ui_data(),
|
||||
return gnc_verify_dialog_parented(gnc_ui_get_toplevel(),
|
||||
message, yes_is_default);
|
||||
}
|
||||
|
||||
@ -196,8 +206,8 @@ gnc_verify_dialog_parented(gncUIWidget parent, const char *message,
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(verify_box), GTK_WINDOW(parent));
|
||||
else
|
||||
gnome_dialog_set_parent(GNOME_DIALOG(verify_box),
|
||||
GTK_WINDOW(gnc_get_ui_data()));
|
||||
|
||||
GTK_WINDOW(gnc_ui_get_toplevel()));
|
||||
|
||||
gnome_dialog_set_default(GNOME_DIALOG(verify_box), yes_is_default ? 0 : 1);
|
||||
|
||||
return (gnome_dialog_run_and_close(GNOME_DIALOG(verify_box)) == 0);
|
||||
@ -213,7 +223,7 @@ gnc_verify_dialog_parented(gncUIWidget parent, const char *message,
|
||||
void
|
||||
gnc_info_dialog(const char *message)
|
||||
{
|
||||
gnc_info_dialog_parented(GTK_WINDOW(gnc_get_ui_data()), message);
|
||||
gnc_info_dialog_parented(GTK_WINDOW(gnc_ui_get_toplevel()), message);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -244,7 +254,7 @@ gnc_info_dialog_parented(GtkWindow *parent, const char *message)
|
||||
void
|
||||
gnc_warning_dialog(const char *message)
|
||||
{
|
||||
gnc_warning_dialog_parented(gnc_get_ui_data(), message);
|
||||
gnc_warning_dialog_parented(gnc_ui_get_toplevel(), message);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -275,7 +285,7 @@ gnc_warning_dialog_parented(GtkWidget *parent, const char *message)
|
||||
void
|
||||
gnc_error_dialog(const char *message)
|
||||
{
|
||||
gnc_error_dialog_parented(GTK_WINDOW(gnc_get_ui_data()), message);
|
||||
gnc_error_dialog_parented(GTK_WINDOW(gnc_ui_get_toplevel()), message);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "AccWindow.h"
|
||||
#include "FileBox.h"
|
||||
#include "FileDialog.h"
|
||||
#include "MainWindow.h"
|
||||
#include "SplitLedger.h"
|
||||
#include "TransLog.h"
|
||||
#include "argv-list-converters.h"
|
||||
@ -66,6 +65,7 @@
|
||||
#include "splitreg.h"
|
||||
#include "window-help.h"
|
||||
#include "window-main.h"
|
||||
#include "window-acct-tree.h"
|
||||
#include "window-report.h"
|
||||
#include "new-user-interface.h"
|
||||
#include "new-user-funs.h"
|
||||
@ -101,7 +101,7 @@ static void gnc_configure_register_hint_font(void);
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_GUI;
|
||||
|
||||
static GtkWidget *app = NULL;
|
||||
static GNCMainInfo * app = NULL;
|
||||
|
||||
static int gnome_is_running = FALSE;
|
||||
static int gnome_is_initialized = FALSE;
|
||||
@ -138,12 +138,19 @@ gnucash_ui_is_terminating(void)
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
gncUIWidget
|
||||
gnc_get_ui_data(void)
|
||||
GNCMainInfo *
|
||||
gnc_ui_get_data(void)
|
||||
{
|
||||
return app;
|
||||
}
|
||||
|
||||
gncUIWidget
|
||||
gnc_ui_get_toplevel(void) {
|
||||
/* FIXME */
|
||||
return gnc_main_window_get_toplevel(app);
|
||||
}
|
||||
|
||||
|
||||
static const char* gnc_scheme_remaining_var = "gnc:*command-line-remaining*";
|
||||
|
||||
static char**
|
||||
@ -236,13 +243,11 @@ gnucash_ui_init(void)
|
||||
|
||||
/* put up splash screen */
|
||||
gnc_show_splash_screen ();
|
||||
|
||||
|
||||
/* make sure splash is up */
|
||||
while (gtk_events_pending ())
|
||||
gtk_main_iteration ();
|
||||
|
||||
app = gnome_app_new("GnuCash", "GnuCash");
|
||||
|
||||
gnc_configure_date_format();
|
||||
date_callback_id =
|
||||
gnc_register_option_change_callback(gnc_configure_date_format_cb, NULL,
|
||||
@ -308,9 +313,17 @@ gnucash_ui_init(void)
|
||||
xaccRecnCellSetStringGetter(gnc_get_reconcile_str);
|
||||
|
||||
/* gnc_default_ui_start */
|
||||
|
||||
gnucash_style_init();
|
||||
gnucash_color_init();
|
||||
|
||||
/* initialize gnome MDI and set up application window defaults */
|
||||
app = gnc_main_window_new();
|
||||
/* Run the ui startup hooks. */
|
||||
{
|
||||
SCM run_danglers = gh_eval_str("gnc:hook-run-danglers");
|
||||
SCM hook = gh_eval_str("gnc:*ui-startup-hook*");
|
||||
gh_call1(run_danglers, hook);
|
||||
}
|
||||
}
|
||||
|
||||
LEAVE ("\n");
|
||||
@ -320,13 +333,14 @@ gnucash_ui_init(void)
|
||||
|
||||
static gboolean hasstarted = FALSE;
|
||||
void
|
||||
gnc_default_ui_start(void)
|
||||
{
|
||||
if(!hasstarted)
|
||||
{
|
||||
mainWindow();
|
||||
hasstarted = TRUE;
|
||||
gnc_default_ui_start(void) {
|
||||
if(!hasstarted) {
|
||||
if(!gnome_mdi_restore_state(app->mdi, "/GnuCash/MDI Session",
|
||||
gnc_main_window_create_child)) {
|
||||
gnc_main_window_open_accounts(FALSE);
|
||||
}
|
||||
hasstarted = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
@ -337,9 +351,9 @@ gnc_ui_shutdown (void)
|
||||
if (gnome_is_running && !gnome_is_terminating)
|
||||
{
|
||||
gnome_is_terminating = TRUE;
|
||||
gnc_ui_destroy_all_subwindows();
|
||||
gnc_ui_mainWindow_save_size();
|
||||
gtk_widget_hide(app);
|
||||
gnc_main_window_save(app);
|
||||
gnc_main_window_destroy(app);
|
||||
app = NULL;
|
||||
gtk_main_quit();
|
||||
#ifdef USE_GUPPI
|
||||
gnc_html_guppi_shutdown();
|
||||
@ -367,7 +381,7 @@ gnc_ui_destroy (void)
|
||||
|
||||
if (app != NULL)
|
||||
{
|
||||
gtk_widget_destroy(app);
|
||||
gnc_main_window_destroy(app);
|
||||
app = NULL;
|
||||
}
|
||||
|
||||
@ -385,20 +399,10 @@ gnc_ui_show_main_window(void)
|
||||
gnucash_ui_init();
|
||||
gnc_default_ui_start();
|
||||
|
||||
gtk_widget_show(app);
|
||||
|
||||
/* Get the main window on screen. */
|
||||
while (gtk_events_pending())
|
||||
gtk_main_iteration();
|
||||
|
||||
/* Run the main window hooks. */
|
||||
{
|
||||
SCM run_danglers = gh_eval_str("gnc:hook-run-danglers");
|
||||
SCM hook = gh_eval_str("gnc:*main-window-opened-hook*");
|
||||
SCM window = gw_wcp_assimilate_ptr(app, gh_eval_str("<gnc:UIWidget>"));
|
||||
gh_call2(run_danglers, hook, window);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
42
src/gnome/top-level.h
Normal file
42
src/gnome/top-level.h
Normal file
@ -0,0 +1,42 @@
|
||||
/********************************************************************
|
||||
* top-level.h -- public gnucash UI functions *
|
||||
* Copyright (C) 2001 Bill Gribble <grib@gnumatic.com> *
|
||||
* *
|
||||
* 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 *
|
||||
********************************************************************/
|
||||
|
||||
#ifndef __TOP_LEVEL_H__
|
||||
#define __TOP_LEVEL_H__
|
||||
|
||||
#include "window-main.h"
|
||||
|
||||
int gnucash_ui_is_running(void);
|
||||
int gnucash_ui_is_terminating(void);
|
||||
int gnucash_ui_init(void);
|
||||
int gnucash_ui_open_file(const char * name);
|
||||
int gnucash_ui_select_file(void);
|
||||
|
||||
GNCMainInfo * gnc_ui_get_data(void);
|
||||
void gnc_default_ui_start(void);
|
||||
void gnc_ui_shutdown(void);
|
||||
void gnc_ui_destroy(void);
|
||||
int gnc_ui_show_main_window(void);
|
||||
int gnc_ui_start_event_loop(void);
|
||||
int gnc_ui_main(void);
|
||||
|
||||
#endif
|
1088
src/gnome/window-acct-tree.c
Normal file
1088
src/gnome/window-acct-tree.c
Normal file
File diff suppressed because it is too large
Load Diff
41
src/gnome/window-acct-tree.h
Normal file
41
src/gnome/window-acct-tree.h
Normal file
@ -0,0 +1,41 @@
|
||||
/********************************************************************
|
||||
* window-acct-tree.h -- public account-tree-window functions *
|
||||
* Copyright (C) 1998,1999 Linas Vepstas *
|
||||
* Copyright (C) 2001 Bill Gribble <grib@gnumatic.com> *
|
||||
* 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 *
|
||||
********************************************************************/
|
||||
|
||||
#ifndef __WINDOW_ACCT_TREE_H__
|
||||
#define __WINDOW_ACCT_TREE_H__
|
||||
|
||||
#include "mainwindow-account-tree.h"
|
||||
#include "window-main.h"
|
||||
|
||||
typedef struct GNCAcctTreeWin_p GNCAcctTreeWin;
|
||||
|
||||
GNCAcctTreeWin * gnc_acct_tree_window_new(const gchar * url);
|
||||
void gnc_acct_tree_window_destroy(GNCAcctTreeWin * win);
|
||||
GtkWidget * gnc_acct_tree_window_get_widget(GNCAcctTreeWin * win);
|
||||
void gnc_acct_tree_window_create_menu(GNCAcctTreeWin * win,
|
||||
GNCMainChildInfo * child);
|
||||
void gnc_acct_tree_window_create_toolbar(GNCAcctTreeWin * win,
|
||||
GNCMainChildInfo * child);
|
||||
Account * gnc_acct_tree_window_get_current_account(GNCAcctTreeWin * w);
|
||||
GnomeMDIChild * gnc_acct_tree_window_create_child(const gchar * url);
|
||||
void gnc_main_window_open_accounts(gint toplevel);
|
||||
#endif
|
495
src/gnome/window-main-summarybar.c
Normal file
495
src/gnome/window-main-summarybar.c
Normal file
@ -0,0 +1,495 @@
|
||||
/********************************************************************
|
||||
* window-main-summarybar.c -- summary of financial info *
|
||||
* Copyright (C) 1998,1999 Jeremy Collins *
|
||||
* Copyright (C) 1998,1999,2000 Linas Vepstas *
|
||||
* Copyright (C) 2001 Bill Gribble *
|
||||
* *
|
||||
* 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 <gnome.h>
|
||||
#include <guile/gh.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "window-main.h"
|
||||
#include "window-main-summarybar.h"
|
||||
#include "dialog-utils.h"
|
||||
#include "gnc-component-manager.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "top-level.h"
|
||||
#include "gtkselect.h"
|
||||
#include "global-options.h"
|
||||
#include "option-util.h"
|
||||
#include "EuroUtils.h"
|
||||
#include "FileDialog.h"
|
||||
#include "Account.h"
|
||||
#include "Group.h"
|
||||
|
||||
typedef struct {
|
||||
GtkWidget * hbox;
|
||||
GtkWidget * totals_combo;
|
||||
GList * totals_list;
|
||||
int component_id;
|
||||
} GNCMainSummary;
|
||||
|
||||
#define WINDOW_SUMMARYBAR_CM_CLASS "summary-bar"
|
||||
|
||||
/* An accumulator for a given currency.
|
||||
*
|
||||
* This is used during the update to the status bar to contain the
|
||||
* accumulation for a single currency. These are placed in a GList and
|
||||
* kept around for the duration of the calculation. There may, in fact
|
||||
* be better ways to do this, but none occurred. */
|
||||
|
||||
typedef struct {
|
||||
gnc_commodity * currency;
|
||||
gnc_numeric assets;
|
||||
gnc_numeric profits;
|
||||
} GNCCurrencyAcc;
|
||||
|
||||
|
||||
/* An item to appear in the selector box in the status bar.
|
||||
*
|
||||
* This is maintained for the duration, where there is one per
|
||||
* currency, plus (eventually) one for the default currency
|
||||
* accumulation (like the EURO). */
|
||||
|
||||
typedef struct {
|
||||
char *namespace;
|
||||
char *mnemonic;
|
||||
GtkWidget *listitem;
|
||||
GtkWidget *assets_label;
|
||||
GtkWidget *profits_label;
|
||||
gint touched : 1;
|
||||
} GNCCurrencyItem;
|
||||
|
||||
|
||||
/* Build a single currency item.
|
||||
*
|
||||
* This function handles the building of a single currency item for
|
||||
* the selector. It looks like the old code in the update function,
|
||||
* but now only handles a single currency. */
|
||||
|
||||
static GNCCurrencyItem *
|
||||
gnc_ui_build_currency_item(gnc_commodity * currency)
|
||||
{
|
||||
GtkWidget *label;
|
||||
GtkWidget *topbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *listitem;
|
||||
GNCCurrencyItem *item;
|
||||
const char *mnemonic;
|
||||
char *label_str;
|
||||
|
||||
item = g_new0 (GNCCurrencyItem, 1);
|
||||
|
||||
item->namespace = g_strdup (gnc_commodity_get_namespace (currency));
|
||||
item->mnemonic = g_strdup (gnc_commodity_get_mnemonic (currency));
|
||||
|
||||
listitem = gtk_list_item_new();
|
||||
item->listitem = listitem;
|
||||
|
||||
topbox = gtk_hbox_new(FALSE, 2);
|
||||
gtk_widget_show(topbox);
|
||||
gtk_container_add(GTK_CONTAINER(listitem), topbox);
|
||||
|
||||
mnemonic = gnc_commodity_get_mnemonic (currency);
|
||||
|
||||
hbox = gtk_hbox_new(FALSE, 2);
|
||||
gtk_widget_show(hbox);
|
||||
gtk_box_pack_start(GTK_BOX(topbox), hbox, FALSE, FALSE, 5);
|
||||
|
||||
label_str = g_strdup_printf ("%s (%s):", _("Net Assets"), mnemonic);
|
||||
label = gtk_label_new(label_str);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
|
||||
gtk_widget_show(label);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
||||
g_free (label_str);
|
||||
|
||||
label = gtk_label_new("");
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
|
||||
gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show(label);
|
||||
item->assets_label = label;
|
||||
|
||||
hbox = gtk_hbox_new(FALSE, 2);
|
||||
gtk_widget_show(hbox);
|
||||
gtk_box_pack_start(GTK_BOX(topbox), hbox, FALSE, FALSE, 5);
|
||||
|
||||
label_str = g_strdup_printf ("%s (%s):", _("Profits"), mnemonic);
|
||||
label = gtk_label_new(label_str);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
|
||||
gtk_widget_show(label);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
||||
g_free (label_str);
|
||||
|
||||
label = gtk_label_new("");
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
|
||||
gtk_widget_show(label);
|
||||
gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
||||
item->profits_label = label;
|
||||
|
||||
gtk_widget_show(item->listitem);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_ui_currency_item_destroy (GNCCurrencyItem *item)
|
||||
{
|
||||
if (!item) return;
|
||||
|
||||
g_free (item->namespace);
|
||||
g_free (item->mnemonic);
|
||||
|
||||
item->namespace = NULL;
|
||||
item->mnemonic = NULL;
|
||||
|
||||
g_free (item);
|
||||
}
|
||||
|
||||
/* Get a currency accumulator.
|
||||
*
|
||||
* This will search the given list, and if no accumulator is found,
|
||||
* will allocate a fresh one. */
|
||||
static GNCCurrencyAcc *
|
||||
gnc_ui_get_currency_accumulator(GList **list, gnc_commodity * currency)
|
||||
{
|
||||
GList *current;
|
||||
GNCCurrencyAcc *found;
|
||||
|
||||
for (current = g_list_first(*list); current;
|
||||
current = g_list_next(current)) {
|
||||
found = current->data;
|
||||
if (gnc_commodity_equiv(currency, found->currency)) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
found = g_new0 (GNCCurrencyAcc, 1);
|
||||
found->currency = currency;
|
||||
found->assets = gnc_numeric_zero ();
|
||||
found->profits = gnc_numeric_zero ();
|
||||
*list = g_list_append (*list, found);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_ui_currency_item_match (const GNCCurrencyItem *item,
|
||||
const gnc_commodity *commodity)
|
||||
{
|
||||
if (!item || !commodity) return FALSE;
|
||||
|
||||
return
|
||||
(safe_strcmp (item->namespace,
|
||||
gnc_commodity_get_namespace (commodity)) == 0) &&
|
||||
(safe_strcmp (item->mnemonic,
|
||||
gnc_commodity_get_mnemonic (commodity)) == 0);
|
||||
|
||||
}
|
||||
|
||||
/* Get a currency item.
|
||||
*
|
||||
* This will search the given list, and if no accumulator is found, will
|
||||
* create a fresh one.
|
||||
*
|
||||
* It looks just like the function above, with some extra stuff to get
|
||||
* the item into the list. */
|
||||
|
||||
static GNCCurrencyItem *
|
||||
gnc_ui_get_currency_item (GList **list,
|
||||
gnc_commodity * currency,
|
||||
GtkWidget *holder)
|
||||
{
|
||||
GList *current;
|
||||
GNCCurrencyItem *found;
|
||||
|
||||
for (current = g_list_first(*list); current;
|
||||
current = g_list_next(current))
|
||||
{
|
||||
found = current->data;
|
||||
|
||||
if (gnc_ui_currency_item_match (found, currency))
|
||||
return found;
|
||||
}
|
||||
|
||||
found = gnc_ui_build_currency_item(currency);
|
||||
*list = g_list_append(*list, found);
|
||||
|
||||
current = g_list_append(NULL, found->listitem);
|
||||
gtk_select_append_items(GTK_SELECT(holder), current);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_ui_accounts_recurse (AccountGroup *group, GList **currency_list,
|
||||
gboolean euro)
|
||||
{
|
||||
gnc_numeric amount;
|
||||
AccountGroup *children;
|
||||
GNCAccountType account_type;
|
||||
gnc_commodity * account_currency;
|
||||
gnc_commodity * default_currency;
|
||||
gnc_commodity * euro_commodity;
|
||||
GNCCurrencyAcc *currency_accum;
|
||||
GNCCurrencyAcc *euro_accum = NULL;
|
||||
GList *list;
|
||||
GList *node;
|
||||
|
||||
default_currency =
|
||||
gnc_lookup_currency_option("International",
|
||||
"Default Currency",
|
||||
gnc_locale_default_currency ());
|
||||
|
||||
if (euro)
|
||||
{
|
||||
euro_commodity = gnc_get_euro ();
|
||||
euro_accum = gnc_ui_get_currency_accumulator(currency_list,
|
||||
euro_commodity);
|
||||
}
|
||||
else
|
||||
euro_commodity = NULL;
|
||||
|
||||
list = xaccGroupGetAccountList (group);
|
||||
for (node = list; node; node = node->next)
|
||||
{
|
||||
Account *account = node->data;
|
||||
|
||||
account_type = xaccAccountGetType(account);
|
||||
account_currency = xaccAccountGetCurrency(account);
|
||||
children = xaccAccountGetChildren(account);
|
||||
currency_accum = gnc_ui_get_currency_accumulator(currency_list,
|
||||
account_currency);
|
||||
|
||||
switch (account_type)
|
||||
{
|
||||
case BANK:
|
||||
case CASH:
|
||||
case ASSET:
|
||||
case STOCK:
|
||||
case MUTUAL:
|
||||
case CREDIT:
|
||||
case LIABILITY:
|
||||
amount = xaccAccountGetBalance(account);
|
||||
currency_accum->assets =
|
||||
gnc_numeric_add (currency_accum->assets, amount,
|
||||
gnc_commodity_get_fraction (account_currency),
|
||||
GNC_RND_ROUND);
|
||||
|
||||
if (euro)
|
||||
euro_accum->assets =
|
||||
gnc_numeric_add (euro_accum->assets,
|
||||
gnc_convert_to_euro(account_currency, amount),
|
||||
gnc_commodity_get_fraction (euro_commodity),
|
||||
GNC_RND_ROUND);
|
||||
|
||||
if (children != NULL)
|
||||
gnc_ui_accounts_recurse(children, currency_list, euro);
|
||||
break;
|
||||
case INCOME:
|
||||
case EXPENSE:
|
||||
amount = xaccAccountGetBalance(account);
|
||||
currency_accum->profits =
|
||||
gnc_numeric_sub (currency_accum->profits, amount,
|
||||
gnc_commodity_get_fraction (account_currency),
|
||||
GNC_RND_ROUND);
|
||||
|
||||
if (euro)
|
||||
gnc_numeric_sub (euro_accum->profits,
|
||||
gnc_convert_to_euro(account_currency, amount),
|
||||
gnc_commodity_get_fraction (euro_commodity),
|
||||
GNC_RND_ROUND);
|
||||
|
||||
if (children != NULL)
|
||||
gnc_ui_accounts_recurse(children, currency_list, euro);
|
||||
break;
|
||||
case EQUITY:
|
||||
/* no-op, see comments at top about summing assets */
|
||||
break;
|
||||
case CURRENCY:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The gnc_main_window_summary_refresh() subroutine redraws summary
|
||||
* information. The statusbar includes two fields, titled 'profits'
|
||||
* and 'assets'. The total assets equal the sum of all of the
|
||||
* non-equity, non-income accounts. In theory, assets also equals the
|
||||
* grand total value of the equity accounts, but that assumes that
|
||||
* folks are using the equity account type correctly (which is not
|
||||
* likely). Thus we show the sum of assets, rather than the sum of
|
||||
* equities.
|
||||
*
|
||||
* The EURO gets special treatment. There can be one line with
|
||||
* EUR amounts and a EUR (total) line which summs up all EURO
|
||||
* member currencies.
|
||||
*
|
||||
* There should be a 'grand total', too, which sums up all accounts
|
||||
* converted to one common currency. */
|
||||
|
||||
static void
|
||||
gnc_main_window_summary_refresh (GNCMainSummary * summary)
|
||||
{
|
||||
AccountGroup *group;
|
||||
char asset_string[256];
|
||||
char profit_string[256];
|
||||
gnc_commodity * default_currency;
|
||||
GNCCurrencyAcc *currency_accum;
|
||||
GNCCurrencyItem *currency_item;
|
||||
GList *currency_list;
|
||||
GList *current;
|
||||
gboolean euro;
|
||||
|
||||
default_currency =
|
||||
gnc_lookup_currency_option("International",
|
||||
"Default Currency",
|
||||
gnc_locale_default_currency ());
|
||||
|
||||
euro = gnc_lookup_boolean_option("International",
|
||||
"Enable EURO support",
|
||||
FALSE);
|
||||
|
||||
currency_list = NULL;
|
||||
|
||||
/* Make sure there's at least one accumulator in the list. */
|
||||
gnc_ui_get_currency_accumulator (¤cy_list, default_currency);
|
||||
|
||||
group = gncGetCurrentGroup ();
|
||||
gnc_ui_accounts_recurse(group, ¤cy_list, euro);
|
||||
|
||||
for (current = g_list_first(summary->totals_list); current;
|
||||
current = g_list_next(current)) {
|
||||
currency_item = current->data;
|
||||
currency_item->touched = 0;
|
||||
}
|
||||
|
||||
for (current = g_list_first(currency_list); current;
|
||||
current = g_list_next(current)) {
|
||||
currency_accum = current->data;
|
||||
currency_item = gnc_ui_get_currency_item(&summary->totals_list,
|
||||
currency_accum->currency,
|
||||
summary->totals_combo);
|
||||
currency_item->touched = 1;
|
||||
|
||||
*asset_string= '\0';
|
||||
xaccSPrintAmount(asset_string, currency_accum->assets,
|
||||
gnc_commodity_print_info(currency_accum->currency, TRUE));
|
||||
gtk_label_set_text(GTK_LABEL(currency_item->assets_label), asset_string);
|
||||
gnc_set_label_color(currency_item->assets_label, currency_accum->assets);
|
||||
|
||||
*profit_string= '\0';
|
||||
xaccSPrintAmount(profit_string, currency_accum->profits,
|
||||
gnc_commodity_print_info(currency_accum->currency, TRUE));
|
||||
gtk_label_set_text(GTK_LABEL(currency_item->profits_label), profit_string);
|
||||
gnc_set_label_color(currency_item->profits_label, currency_accum->profits);
|
||||
|
||||
g_free(currency_accum);
|
||||
current->data = NULL;
|
||||
}
|
||||
|
||||
g_list_free(currency_list);
|
||||
currency_list = NULL;
|
||||
|
||||
current = g_list_first(summary->totals_list);
|
||||
while (current) {
|
||||
GList *next = current->next;
|
||||
|
||||
currency_item = current->data;
|
||||
if (currency_item->touched == 0 &&
|
||||
!gnc_ui_currency_item_match(currency_item, default_currency)) {
|
||||
currency_list = g_list_prepend(currency_list, currency_item->listitem);
|
||||
summary->totals_list = g_list_remove_link(summary->totals_list,
|
||||
current);
|
||||
gnc_ui_currency_item_destroy(currency_item);
|
||||
current->data = NULL;
|
||||
g_list_free_1(current);
|
||||
}
|
||||
|
||||
current = next;
|
||||
}
|
||||
|
||||
if (currency_list) {
|
||||
gtk_select_remove_items(GTK_SELECT(summary->totals_combo),
|
||||
currency_list);
|
||||
g_list_free(currency_list);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_main_window_summary_destroy_cb(GtkObject * obj, gpointer data) {
|
||||
GNCMainSummary * summary = data;
|
||||
gnc_unregister_gui_component(summary->component_id);
|
||||
g_list_free(summary->totals_list);
|
||||
g_free(summary);
|
||||
}
|
||||
|
||||
static void
|
||||
summarybar_refresh_handler(GHashTable * changes, gpointer user_data) {
|
||||
GNCMainSummary * summary = user_data;
|
||||
gnc_main_window_summary_refresh(summary);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gnc_main_window_summary_new () {
|
||||
GNCMainSummary * retval = g_new0(GNCMainSummary, 1);
|
||||
GtkWidget * summarybar;
|
||||
GNCCurrencyItem * def_item;
|
||||
gnc_commodity * default_currency =
|
||||
gnc_lookup_currency_option ("International",
|
||||
"Default Currency",
|
||||
gnc_locale_default_currency ());
|
||||
|
||||
retval->hbox = gtk_hbox_new (FALSE, 5);
|
||||
retval->totals_combo = gtk_select_new ();
|
||||
retval->totals_list = NULL;
|
||||
retval->component_id = gnc_register_gui_component(WINDOW_SUMMARYBAR_CM_CLASS,
|
||||
summarybar_refresh_handler,
|
||||
retval, retval);
|
||||
gnc_gui_component_watch_entity_type (retval->component_id,
|
||||
GNC_ID_ACCOUNT,
|
||||
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
|
||||
|
||||
def_item = gnc_ui_get_currency_item (&retval->totals_list,
|
||||
default_currency,
|
||||
retval->totals_combo);
|
||||
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (retval->hbox), 2);
|
||||
gtk_select_select_child (GTK_SELECT(retval->totals_combo),
|
||||
def_item->listitem);
|
||||
gtk_box_pack_start (GTK_BOX(retval->hbox), retval->totals_combo,
|
||||
FALSE, FALSE, 5);
|
||||
gtk_widget_show (retval->totals_combo);
|
||||
gtk_widget_show (retval->hbox);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(retval->hbox), "destroy",
|
||||
gnc_main_window_summary_destroy_cb, retval);
|
||||
|
||||
gnc_main_window_summary_refresh(retval);
|
||||
|
||||
return retval->hbox;
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
/********************************************************************\
|
||||
* MainWindow.h -- the main window, and associated helper functions *
|
||||
* and callback functions for GnuCash *
|
||||
* Copyright (C) 1997 Robin D. Clark *
|
||||
* Copyright (C) 2000 Dave Peticolas *
|
||||
/********************************************************************
|
||||
* window-main-summarybar.h -- summary of finances in main window *
|
||||
* Copyright (C) 1998,1999 Linas Vepstas *
|
||||
* Copyright (C) 2001 Bill Gribble <grib@gnumatic.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -15,20 +14,18 @@
|
||||
* 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, write to the Free Software *
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Author: Rob Clark *
|
||||
* Internet: rclark@cs.hmc.edu *
|
||||
* Address: 609 8th Street *
|
||||
* Huntington Beach, CA 92648-4632 *
|
||||
\********************************************************************/
|
||||
* 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 *
|
||||
********************************************************************/
|
||||
|
||||
#ifndef __MAIN_WINDOW_H__
|
||||
#define __MAIN_WINDOW_H__
|
||||
#ifndef WINDOW_MAIN_SUMMARYBAR_H
|
||||
#define WINDOW_MAIN_SUMMARYBAR_H
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
#include <gnome.h>
|
||||
|
||||
void mainWindow();
|
||||
GtkWidget * gnc_main_window_summary_new(void);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
/*******************************************************************\
|
||||
/********************************************************************
|
||||
* window-main.h -- public GNOME main window functions *
|
||||
* Copyright (C) 1998,1999 Linas Vepstas *
|
||||
* Copyright (C) 2001 Bill Gribble <grib@gnumatic.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -18,23 +19,46 @@
|
||||
* 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 *
|
||||
\********************************************************************/
|
||||
********************************************************************/
|
||||
|
||||
#ifndef __WINDOW_MAIN_H__
|
||||
#define __WINDOW_MAIN_H__
|
||||
|
||||
#include "mainwindow-account-tree.h"
|
||||
#include <gnome.h>
|
||||
#include <guile/gh.h>
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
typedef struct {
|
||||
GnomeMDI * mdi;
|
||||
int component_id;
|
||||
SCM toolbar_change_callback_id;
|
||||
GList * children;
|
||||
} GNCMainInfo;
|
||||
|
||||
void mainWindow(void);
|
||||
typedef struct {
|
||||
GnomeMDIChild * child;
|
||||
GtkWidget * contents;
|
||||
GnomeApp * app;
|
||||
|
||||
GNCMainWinAccountTree * gnc_get_current_account_tree(void);
|
||||
GtkWidget * toolbar;
|
||||
GnomeUIInfo * toolbar_info;
|
||||
int toolbar_size;
|
||||
GnomeUIInfo * menu_info;
|
||||
|
||||
void gnc_ui_mainWindow_save_size(void);
|
||||
void gnc_default_ui_start(void);
|
||||
int gnucash_ui_init(void);
|
||||
int component_id;
|
||||
void * user_data;
|
||||
} GNCMainChildInfo;
|
||||
|
||||
void gnc_report_in_main_window (int report_id);
|
||||
|
||||
GNCMainInfo * gnc_main_window_new(void);
|
||||
void gnc_main_window_destroy(GNCMainInfo * wind);
|
||||
void gnc_main_window_save(GNCMainInfo * wind);
|
||||
GtkWidget * gnc_main_window_get_toplevel(GNCMainInfo * wind);
|
||||
void gnc_main_window_create_child_toolbar(GNCMainInfo * mi,
|
||||
GNCMainChildInfo * child);
|
||||
void gnc_main_window_add_child(GNCMainInfo * main,
|
||||
GNCMainChildInfo * child);
|
||||
void gnc_main_window_remove_child(GNCMainInfo * main,
|
||||
GNCMainChildInfo * child);
|
||||
void gnc_main_window_child_refresh(GNCMainChildInfo * mc);
|
||||
GnomeMDIChild * gnc_main_window_create_child(const gchar * configstring);
|
||||
#endif
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "AccWindow.h"
|
||||
#include "MainWindow.h"
|
||||
#include "MultiLedger.h"
|
||||
#include "RegWindow.h"
|
||||
#include "Scrub.h"
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "AccWindow.h"
|
||||
#include "EuroUtils.h"
|
||||
#include "FileDialog.h"
|
||||
#include "MainWindow.h"
|
||||
#include "MultiLedger.h"
|
||||
#include "RegWindow.h"
|
||||
#include "Scrub.h"
|
||||
|
@ -40,22 +40,24 @@
|
||||
#include "gnc-html-history.h"
|
||||
#include "gnc-html.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "option-util.h"
|
||||
#include "query-user.h"
|
||||
#include "top-level.h"
|
||||
#include "window-main.h"
|
||||
#include "window-report.h"
|
||||
|
||||
#define WINDOW_REPORT_CM_CLASS "window-report"
|
||||
|
||||
struct _gnc_report_window {
|
||||
GNCMainChildInfo * mc;
|
||||
GtkWidget * container;
|
||||
gboolean top_level;
|
||||
|
||||
GtkWidget * popup;
|
||||
GtkWidget * back_widg;
|
||||
GtkWidget * fwd_widg;
|
||||
|
||||
SCM scm_report;
|
||||
SCM scm_options;
|
||||
SCM scm_options_edit;
|
||||
SCM name_change_callback_id;
|
||||
|
||||
GNCOptionDB * odb; /* used to get callbacks from parameter edit */
|
||||
|
||||
gnc_html * html;
|
||||
};
|
||||
@ -68,6 +70,158 @@ static gint last_width = 0;
|
||||
static gint last_height = 0;
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* REPORT WINDOW FUNCTIONS
|
||||
* creating/managing report-window mdi children
|
||||
********************************************************************/
|
||||
|
||||
/********************************************************************
|
||||
* gnc_report_window_view_labeler
|
||||
* label the window/tab/menu item with the report name
|
||||
********************************************************************/
|
||||
|
||||
static GtkWidget *
|
||||
gnc_report_window_view_labeler(GnomeMDIChild * child, GtkWidget * current,
|
||||
gpointer user_data) {
|
||||
GNCMainChildInfo * rwin = gtk_object_get_user_data(GTK_OBJECT(child));
|
||||
gnc_report_window * report;
|
||||
SCM get_name = gh_eval_str("gnc:report-name");
|
||||
char * name = NULL;
|
||||
|
||||
if(rwin) {
|
||||
report = rwin->user_data;
|
||||
if(report->scm_report != SCM_BOOL_F) {
|
||||
name = gh_scm2newstr(gh_call1(get_name,
|
||||
report->scm_report),
|
||||
NULL);
|
||||
}
|
||||
else {
|
||||
name = strdup(_("(Report not found)"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
name = strdup(_("Report"));
|
||||
}
|
||||
if(current == NULL) {
|
||||
GtkWidget * label = gtk_label_new(name);
|
||||
free(name);
|
||||
return label;
|
||||
}
|
||||
else {
|
||||
gtk_label_set_text(GTK_LABEL(current), name);
|
||||
free(name);
|
||||
return current;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
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);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
* report_view_new
|
||||
* create a new report view.
|
||||
********************************************************************/
|
||||
|
||||
static GtkWidget *
|
||||
gnc_report_window_view_new(GnomeMDIChild * child, gpointer user_data) {
|
||||
GNCMainInfo * maininfo = user_data;
|
||||
GNCMainChildInfo * mc = g_new0(GNCMainChildInfo, 1);
|
||||
gnc_report_window * win = gnc_report_window_new(mc);
|
||||
URLType type;
|
||||
char * url_location = NULL;
|
||||
char * url_label = NULL;
|
||||
|
||||
mc->contents = gnc_report_window_get_container(win);
|
||||
mc->app = NULL;
|
||||
mc->user_data = win;
|
||||
mc->child = child;
|
||||
|
||||
gnc_main_window_add_child(maininfo, mc);
|
||||
|
||||
type = gnc_html_parse_url(gnc_report_window_get_html(win),
|
||||
child->name, &url_location, &url_label);
|
||||
|
||||
gnc_html_show_url(gnc_report_window_get_html(win),
|
||||
type, url_location, url_label, 0);
|
||||
|
||||
gtk_object_set_user_data(GTK_OBJECT(child), mc);
|
||||
gtk_signal_connect(GTK_OBJECT(child), "destroy",
|
||||
gnc_report_window_view_destroy, mc);
|
||||
|
||||
gnc_report_window_create_menu(win, mc);
|
||||
gnc_report_window_create_toolbar(win, mc);
|
||||
gnc_main_window_create_child_toolbar(maininfo, mc);
|
||||
|
||||
if(mc->menu_info) {
|
||||
gnome_mdi_child_set_menu_template(child, mc->menu_info);
|
||||
}
|
||||
|
||||
g_free(url_location);
|
||||
g_free(url_label);
|
||||
return mc->contents;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_report_window_create_child()
|
||||
* return an MDI child that will create views of the specified report
|
||||
* (configstring is the report URL)
|
||||
********************************************************************/
|
||||
|
||||
GnomeMDIChild *
|
||||
gnc_report_window_create_child(const gchar * configstring) {
|
||||
GnomeMDIGenericChild * reportchild =
|
||||
gnome_mdi_generic_child_new(configstring);
|
||||
GNCMainInfo * maininfo = gnc_ui_get_data();
|
||||
|
||||
gnome_mdi_generic_child_set_label_func(reportchild,
|
||||
gnc_report_window_view_labeler,
|
||||
maininfo);
|
||||
gnome_mdi_generic_child_set_view_creator(reportchild,
|
||||
gnc_report_window_view_new,
|
||||
maininfo);
|
||||
return GNOME_MDI_CHILD(reportchild);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_main_window_open_report()
|
||||
* open an report in a top level window from an ID number
|
||||
********************************************************************/
|
||||
|
||||
void
|
||||
gnc_main_window_open_report(int report_id, gint toplevel) {
|
||||
char * child_name = g_strdup_printf("gnc-report:id=%d", report_id);
|
||||
gnc_main_window_open_report_url(child_name, toplevel);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gnc_main_window_open_report_url(const char * url, gint toplevel) {
|
||||
GnomeMDIChild * reportchild = gnc_report_window_create_child(url);
|
||||
GNCMainInfo * maininfo = gnc_ui_get_data();
|
||||
|
||||
gnome_mdi_add_child(GNOME_MDI(maininfo->mdi),
|
||||
GNOME_MDI_CHILD(reportchild));
|
||||
if(toplevel) {
|
||||
gnome_mdi_add_toplevel_view(GNOME_MDI(maininfo->mdi),
|
||||
GNOME_MDI_CHILD(reportchild));
|
||||
}
|
||||
else {
|
||||
gnome_mdi_add_view(GNOME_MDI(maininfo->mdi),
|
||||
GNOME_MDI_CHILD(reportchild));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_report_window_check_urltype
|
||||
* is it OK to show a certain URLType in this window?
|
||||
@ -141,51 +295,57 @@ gnc_report_window_params_cb(GtkWidget * w, gpointer data) {
|
||||
gnc_report_window * report = data;
|
||||
SCM scm_wintype = gh_eval_str("<gnc:report-window*>");
|
||||
|
||||
if(gh_procedure_p(report->scm_options_edit)) {
|
||||
gh_call2(report->scm_options_edit,
|
||||
report->scm_options,
|
||||
report->scm_report);
|
||||
if((report->scm_report != SCM_BOOL_F) &&
|
||||
(report->scm_options != SCM_BOOL_F)) {
|
||||
|
||||
if(gh_procedure_p(report->scm_options_edit)) {
|
||||
gh_call2(report->scm_options_edit,
|
||||
report->scm_options,
|
||||
report->scm_report);
|
||||
}
|
||||
else {
|
||||
gnc_report_window_default_params_editor(report->scm_options,
|
||||
report->scm_report);
|
||||
}
|
||||
}
|
||||
else {
|
||||
gnc_report_window_default_params_editor(report->scm_options,
|
||||
report->scm_report);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
gnc_report_window_newwin_cb(GtkWidget * w, gpointer data) {
|
||||
gnc_report_window * report = data;
|
||||
gnc_report_window * newwin = gnc_report_window_new(NULL);
|
||||
SCM get_id = gh_eval_str("gnc:report-id");
|
||||
SCM id = gh_call1(get_id, report->scm_report);
|
||||
|
||||
if(gh_number_p(id)) {
|
||||
gnc_report_window_show_report(newwin, gh_scm2int(id));
|
||||
gnc_warning_dialog("There are no options for this report.");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
gnc_report_window_reload_button_cb(GtkWidget * w, gpointer data) {
|
||||
gnc_report_window * report = data;
|
||||
SCM dirty_report = gh_eval_str("gnc:report-set-dirty?!");
|
||||
|
||||
gh_call2(dirty_report, report->scm_report, SCM_BOOL_T);
|
||||
gnc_html_reload(report->html);
|
||||
if(report->scm_report != SCM_BOOL_F) {
|
||||
gh_call2(dirty_report, report->scm_report, SCM_BOOL_T);
|
||||
gnc_html_reload(report->html);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_report_window_set_back_button(gnc_report_window * win, int enabled) {
|
||||
gtk_widget_set_sensitive(win->back_widg, enabled);
|
||||
GnomeApp * app = win->mc->app;
|
||||
GnomeUIInfo * info;
|
||||
|
||||
if(app) {
|
||||
info = gnome_mdi_get_child_menu_info(app);
|
||||
if(info) gtk_widget_set_sensitive(info[0].widget, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_report_window_set_fwd_button(gnc_report_window * win, int enabled) {
|
||||
gtk_widget_set_sensitive(win->fwd_widg, enabled);
|
||||
GnomeApp * app = win->mc->app;
|
||||
GnomeUIInfo * info;
|
||||
|
||||
if(app) {
|
||||
info = gnome_mdi_get_child_menu_info(app);
|
||||
if(info) gtk_widget_set_sensitive(info[1].widget, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -215,7 +375,8 @@ gnc_report_window_load_cb(gnc_html * html, URLType type,
|
||||
SCM inst_options;
|
||||
SCM inst_options_ed;
|
||||
|
||||
if(!strncmp("id=", location, 3)) {
|
||||
if(location && (strlen(location) > 3) &&
|
||||
!strncmp("id=", location, 3)) {
|
||||
sscanf(location+3, "%d", &report_id);
|
||||
}
|
||||
else {
|
||||
@ -242,6 +403,17 @@ gnc_report_window_load_cb(gnc_html * html, URLType type,
|
||||
win->scm_options = inst_options;
|
||||
scm_protect_object(win->scm_options);
|
||||
|
||||
if(win->odb) {
|
||||
gnc_option_db_destroy(win->odb);
|
||||
}
|
||||
win->odb = gnc_option_db_new(win->scm_options);
|
||||
|
||||
win->name_change_callback_id =
|
||||
gnc_option_db_register_change_callback(win->odb,
|
||||
gnc_main_window_child_refresh,
|
||||
win->mc,
|
||||
"General", "Report name");
|
||||
|
||||
scm_unprotect_object(win->scm_options_edit);
|
||||
win->scm_options_edit = inst_options_ed;
|
||||
scm_protect_object(win->scm_options_edit);
|
||||
@ -278,78 +450,18 @@ gnc_report_window_load_cb(gnc_html * html, URLType type,
|
||||
static void
|
||||
gnc_report_window_destroy_cb(GtkWidget * w, gpointer data) {
|
||||
gnc_report_window * win = data;
|
||||
SCM scm_wintype = gh_eval_str("<gnc:report-window*>");
|
||||
SCM unshow_report = gh_eval_str("gnc:report-unregister-display");
|
||||
|
||||
if(win->scm_report != SCM_BOOL_F) {
|
||||
gh_call2(unshow_report, win->scm_report,
|
||||
gw_wcp_assimilate_ptr(win, scm_wintype));
|
||||
}
|
||||
|
||||
/* make sure we don't get a double dose -o- destruction */
|
||||
gtk_signal_disconnect_by_data(GTK_OBJECT(win->container),
|
||||
data);
|
||||
|
||||
/* delete the window from the open list */
|
||||
if(win->top_level) {
|
||||
gnc_unregister_gui_component_by_data (WINDOW_REPORT_CM_CLASS, win);
|
||||
}
|
||||
gnc_html_destroy(win->html);
|
||||
|
||||
if(win->popup) {
|
||||
gtk_widget_destroy(win->popup);
|
||||
}
|
||||
win->popup = NULL;
|
||||
win->container = NULL;
|
||||
win->html = NULL;
|
||||
|
||||
scm_unprotect_object(win->scm_options);
|
||||
scm_unprotect_object(win->scm_options_edit);
|
||||
scm_unprotect_object(win->scm_report);
|
||||
|
||||
g_free(win);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_report_window_close_cb
|
||||
********************************************************************/
|
||||
|
||||
static void
|
||||
gnc_report_window_close_cb(GtkWidget * w, gpointer data) {
|
||||
gnc_report_window * rw = data;
|
||||
|
||||
if(rw->top_level) {
|
||||
gnc_close_gui_component_by_data (WINDOW_REPORT_CM_CLASS, rw);
|
||||
}
|
||||
else {
|
||||
gtk_widget_destroy(rw->container);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_report_window_button_cb
|
||||
* mouse button clicks
|
||||
********************************************************************/
|
||||
|
||||
static int
|
||||
gnc_report_window_button_cb(gnc_html * html, GdkEventButton * event,
|
||||
gpointer user_data) {
|
||||
gnc_report_window * win = (gnc_report_window *)user_data;
|
||||
|
||||
if(event->type == GDK_BUTTON_PRESS) {
|
||||
if(event->button == 3) {
|
||||
if(win->popup) {
|
||||
gnome_popup_menu_do_popup(win->popup, NULL, NULL,
|
||||
event, (gpointer)win);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
gnc_report_window_destroy(win);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_report_window_print_cb
|
||||
********************************************************************/
|
||||
|
||||
static void
|
||||
gnc_report_window_print_cb(GtkWidget * w, gpointer data) {
|
||||
gnc_report_window * win = data;
|
||||
@ -381,16 +493,8 @@ gnc_report_window_history_destroy_cb(gnc_html_history_node * node,
|
||||
static void
|
||||
close_handler (gpointer user_data)
|
||||
{
|
||||
gnc_report_window *win = user_data;
|
||||
|
||||
if (win->top_level)
|
||||
{
|
||||
gdk_window_get_geometry (GTK_WIDGET(win->container)->window, NULL, NULL,
|
||||
&last_width, &last_height, NULL);
|
||||
|
||||
gnc_save_window_size ("report_win", last_width, last_height);
|
||||
}
|
||||
|
||||
gnc_report_window *win = user_data;
|
||||
printf("in close handler\n");
|
||||
gnc_report_window_destroy (win);
|
||||
}
|
||||
|
||||
@ -400,19 +504,65 @@ close_handler (gpointer user_data)
|
||||
********************************************************************/
|
||||
|
||||
gnc_report_window *
|
||||
gnc_report_window_new(GtkWidget * container) {
|
||||
gnc_report_window_new(GNCMainChildInfo * mc) {
|
||||
|
||||
gnc_report_window * report = g_new0(gnc_report_window, 1);
|
||||
GtkObject * tlo;
|
||||
GtkWidget * cframe = NULL;
|
||||
GtkWidget * toolbar = NULL;
|
||||
|
||||
report->mc = mc;
|
||||
report->html = gnc_html_new();
|
||||
report->scm_options = SCM_BOOL_F;
|
||||
report->scm_options_edit = SCM_BOOL_F;
|
||||
report->scm_report = SCM_BOOL_F;
|
||||
report->name_change_callback_id = SCM_BOOL_F;
|
||||
|
||||
scm_protect_object(report->scm_options);
|
||||
scm_protect_object(report->scm_options_edit);
|
||||
scm_protect_object(report->scm_report);
|
||||
|
||||
gnc_html_history_set_node_destroy_cb(gnc_html_get_history(report->html),
|
||||
gnc_report_window_history_destroy_cb,
|
||||
(gpointer)report);
|
||||
|
||||
|
||||
report->container = gtk_frame_new(NULL);
|
||||
gtk_frame_set_shadow_type(GTK_FRAME(report->container), GTK_SHADOW_NONE);
|
||||
|
||||
tlo = GTK_OBJECT(report->container);
|
||||
gtk_container_add(GTK_CONTAINER(report->container),
|
||||
gnc_html_get_widget(report->html));
|
||||
|
||||
gnc_register_gui_component (WINDOW_REPORT_CM_CLASS, NULL,
|
||||
close_handler, report);
|
||||
|
||||
gnc_html_set_urltype_cb(report->html, gnc_report_window_check_urltype);
|
||||
gnc_html_set_load_cb(report->html, gnc_report_window_load_cb, report);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(report->container), "destroy",
|
||||
GTK_SIGNAL_FUNC(gnc_report_window_destroy_cb),
|
||||
report);
|
||||
|
||||
gtk_widget_show_all(report->container);
|
||||
|
||||
return report;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_report_window_create_toolbar
|
||||
* make a toolbar for the top-level MDI app
|
||||
********************************************************************/
|
||||
|
||||
void
|
||||
gnc_report_window_create_toolbar(gnc_report_window * win,
|
||||
GNCMainChildInfo * child) {
|
||||
GnomeUIInfo toolbar_data[] =
|
||||
{
|
||||
{ GNOME_APP_UI_ITEM,
|
||||
_("Back"),
|
||||
_("Move back one step in the history"),
|
||||
gnc_report_window_back_cb, report,
|
||||
gnc_report_window_back_cb, win,
|
||||
NULL,
|
||||
GNOME_APP_PIXMAP_STOCK,
|
||||
GNOME_STOCK_PIXMAP_BACK,
|
||||
@ -421,7 +571,7 @@ gnc_report_window_new(GtkWidget * container) {
|
||||
{ GNOME_APP_UI_ITEM,
|
||||
_("Forward"),
|
||||
_("Move forward one step in the history"),
|
||||
gnc_report_window_fwd_cb, report,
|
||||
gnc_report_window_fwd_cb, win,
|
||||
NULL,
|
||||
GNOME_APP_PIXMAP_STOCK,
|
||||
GNOME_STOCK_PIXMAP_FORWARD,
|
||||
@ -430,7 +580,7 @@ gnc_report_window_new(GtkWidget * container) {
|
||||
{ GNOME_APP_UI_ITEM,
|
||||
N_("Reload"),
|
||||
N_("Reload the current report"),
|
||||
gnc_report_window_reload_button_cb, report,
|
||||
gnc_report_window_reload_button_cb, win,
|
||||
NULL,
|
||||
GNOME_APP_PIXMAP_STOCK,
|
||||
GNOME_STOCK_PIXMAP_REFRESH,
|
||||
@ -439,7 +589,7 @@ gnc_report_window_new(GtkWidget * container) {
|
||||
{ GNOME_APP_UI_ITEM,
|
||||
N_("Stop"),
|
||||
N_("Cancel outstanding HTML requests"),
|
||||
gnc_report_window_stop_button_cb, report,
|
||||
gnc_report_window_stop_button_cb, win,
|
||||
NULL,
|
||||
GNOME_APP_PIXMAP_STOCK,
|
||||
GNOME_STOCK_PIXMAP_STOP,
|
||||
@ -449,16 +599,16 @@ gnc_report_window_new(GtkWidget * container) {
|
||||
{ GNOME_APP_UI_ITEM,
|
||||
_("Export"),
|
||||
_("Export HTML-formatted report to file"),
|
||||
gnc_report_window_export_button_cb, report,
|
||||
gnc_report_window_export_button_cb, win,
|
||||
NULL,
|
||||
GNOME_APP_PIXMAP_STOCK,
|
||||
GNOME_STOCK_PIXMAP_CONVERT,
|
||||
0, 0, NULL
|
||||
},
|
||||
{ GNOME_APP_UI_ITEM,
|
||||
_("Parameters"),
|
||||
_("Options"),
|
||||
_("Edit report options"),
|
||||
gnc_report_window_params_cb, report,
|
||||
gnc_report_window_params_cb, win,
|
||||
NULL,
|
||||
GNOME_APP_PIXMAP_STOCK,
|
||||
GNOME_STOCK_PIXMAP_PROPERTIES,
|
||||
@ -467,93 +617,29 @@ gnc_report_window_new(GtkWidget * container) {
|
||||
{ GNOME_APP_UI_ITEM,
|
||||
_("Print"),
|
||||
_("Print report window"),
|
||||
gnc_report_window_print_cb, report,
|
||||
gnc_report_window_print_cb, win,
|
||||
NULL,
|
||||
GNOME_APP_PIXMAP_STOCK,
|
||||
GNOME_STOCK_PIXMAP_PRINT,
|
||||
0, 0, NULL
|
||||
},
|
||||
GNOMEUIINFO_SEPARATOR,
|
||||
{ GNOME_APP_UI_ITEM,
|
||||
_("New window"),
|
||||
_("Open this report in a new window"),
|
||||
gnc_report_window_newwin_cb, report,
|
||||
NULL,
|
||||
GNOME_APP_PIXMAP_STOCK,
|
||||
GNOME_STOCK_PIXMAP_NEW,
|
||||
0, 0, NULL
|
||||
},
|
||||
{ GNOME_APP_UI_ITEM,
|
||||
_("Close"),
|
||||
_("Close this report window"),
|
||||
gnc_report_window_close_cb, report,
|
||||
NULL,
|
||||
GNOME_APP_PIXMAP_STOCK,
|
||||
GNOME_STOCK_PIXMAP_CLOSE,
|
||||
0, 0, NULL
|
||||
},
|
||||
GNOMEUIINFO_END
|
||||
};
|
||||
|
||||
report->html = gnc_html_new();
|
||||
report->scm_options = SCM_BOOL_F;
|
||||
report->scm_options_edit = SCM_BOOL_F;
|
||||
report->scm_report = SCM_BOOL_F;
|
||||
child->toolbar_info =
|
||||
g_memdup(toolbar_data, sizeof(toolbar_data));
|
||||
child->toolbar_size = sizeof(toolbar_data) / sizeof(GnomeUIInfo);
|
||||
}
|
||||
|
||||
gnc_html_history_set_node_destroy_cb(gnc_html_get_history(report->html),
|
||||
gnc_report_window_history_destroy_cb,
|
||||
(gpointer)report);
|
||||
|
||||
scm_protect_object(report->scm_options);
|
||||
scm_protect_object(report->scm_options_edit);
|
||||
scm_protect_object(report->scm_report);
|
||||
|
||||
if(container) {
|
||||
report->container = container;
|
||||
report->top_level = FALSE;
|
||||
report->popup = gnome_popup_menu_new(toolbar_data);
|
||||
gtk_container_add(GTK_CONTAINER(container),
|
||||
gnc_html_get_widget(report->html));
|
||||
}
|
||||
else {
|
||||
report->container = create_Report_Window();
|
||||
report->top_level = TRUE;
|
||||
report->popup = NULL;
|
||||
|
||||
tlo = GTK_OBJECT(report->container);
|
||||
toolbar = gtk_object_get_data(tlo, "report_toolbar");
|
||||
cframe = gtk_object_get_data(tlo, "report_frame");
|
||||
gnome_app_fill_toolbar(GTK_TOOLBAR(toolbar), toolbar_data, NULL);
|
||||
gtk_container_add(GTK_CONTAINER(cframe),
|
||||
gnc_html_get_widget(report->html));
|
||||
gnc_register_gui_component (WINDOW_REPORT_CM_CLASS, NULL,
|
||||
close_handler, report);
|
||||
}
|
||||
|
||||
report->back_widg = toolbar_data[0].widget;
|
||||
report->fwd_widg = toolbar_data[1].widget;
|
||||
|
||||
gnc_html_set_urltype_cb(report->html, gnc_report_window_check_urltype);
|
||||
gnc_html_set_load_cb(report->html, gnc_report_window_load_cb, report);
|
||||
gnc_html_set_button_cb(report->html, gnc_report_window_button_cb, report);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(report->container), "destroy",
|
||||
GTK_SIGNAL_FUNC(gnc_report_window_destroy_cb),
|
||||
report);
|
||||
|
||||
if (report->top_level) {
|
||||
if (last_width == 0)
|
||||
gnc_get_window_size("report_win", &last_width, &last_height);
|
||||
|
||||
gtk_window_set_default_size(GTK_WINDOW(report->container),
|
||||
last_width, last_height);
|
||||
|
||||
gnc_window_adjust_for_screen (GTK_WINDOW(report->container));
|
||||
}
|
||||
|
||||
gtk_widget_show_all(report->container);
|
||||
|
||||
return report;
|
||||
/********************************************************************
|
||||
* gnc_report_window_create_menu
|
||||
* child menu for reports (none currently)
|
||||
********************************************************************/
|
||||
void
|
||||
gnc_report_window_create_menu(gnc_report_window * report,
|
||||
GNCMainChildInfo * child) {
|
||||
child->menu_info = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -565,9 +651,24 @@ gnc_report_window_new(GtkWidget * container) {
|
||||
void
|
||||
gnc_report_window_destroy(gnc_report_window * win) {
|
||||
|
||||
if (!win) return;
|
||||
SCM scm_wintype = gh_eval_str("<gnc:report-window*>");
|
||||
SCM unshow_report = gh_eval_str("gnc:report-unregister-display");
|
||||
|
||||
gtk_widget_destroy(GTK_WIDGET(win->container));
|
||||
if(win->scm_report != SCM_BOOL_F) {
|
||||
gh_call2(unshow_report, win->scm_report,
|
||||
gw_wcp_assimilate_ptr(win, scm_wintype));
|
||||
}
|
||||
|
||||
gnc_html_destroy(win->html);
|
||||
|
||||
win->container = NULL;
|
||||
win->html = NULL;
|
||||
|
||||
scm_unprotect_object(win->scm_options);
|
||||
scm_unprotect_object(win->scm_options_edit);
|
||||
scm_unprotect_object(win->scm_report);
|
||||
|
||||
g_free(win);
|
||||
}
|
||||
|
||||
gnc_html *
|
||||
@ -575,6 +676,16 @@ gnc_report_window_get_html(gnc_report_window * report) {
|
||||
return report->html;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gnc_report_window_get_container(gnc_report_window * report) {
|
||||
return report->container;
|
||||
}
|
||||
|
||||
SCM
|
||||
gnc_report_window_get_report(gnc_report_window * report) {
|
||||
return report->scm_report;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_report_window_show_report(gnc_report_window * report, int report_id) {
|
||||
char * location = g_strdup_printf("id=%d", report_id);
|
||||
@ -584,11 +695,8 @@ gnc_report_window_show_report(gnc_report_window * report, int report_id) {
|
||||
|
||||
void
|
||||
reportWindow(int report_id) {
|
||||
gnc_report_window * win;
|
||||
|
||||
gnc_set_busy_cursor (NULL, TRUE);
|
||||
win = gnc_report_window_new(NULL);
|
||||
gnc_report_window_show_report(win, report_id);
|
||||
gnc_main_window_open_report(report_id, FALSE);
|
||||
gnc_unset_busy_cursor (NULL);
|
||||
}
|
||||
|
||||
@ -612,6 +720,10 @@ gnc_print_report (int report_id)
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* default parameters editor handling
|
||||
********************************************************************/
|
||||
|
||||
struct report_default_params_data {
|
||||
GNCOptionWin * win;
|
||||
GNCOptionDB * db;
|
||||
@ -673,3 +785,4 @@ gnc_report_window_default_params_editor(SCM options, SCM report) {
|
||||
(gpointer)prm);
|
||||
|
||||
}
|
||||
|
||||
|
@ -28,20 +28,32 @@
|
||||
|
||||
#include "gnc-html.h"
|
||||
#include "dialog-options.h"
|
||||
#include "window-main.h"
|
||||
|
||||
typedef struct _gnc_report_window gnc_report_window;
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
|
||||
gnc_report_window * gnc_report_window_new(GtkWidget * container);
|
||||
gnc_report_window * gnc_report_window_new(GNCMainChildInfo * mc);
|
||||
void gnc_report_window_destroy(gnc_report_window * rep);
|
||||
void gnc_report_window_show_report(gnc_report_window * rw, int id);
|
||||
void gnc_report_window_reload(gnc_report_window * rw);
|
||||
gnc_html * gnc_report_window_get_html(gnc_report_window * rw);
|
||||
GtkWidget * gnc_report_window_get_container(gnc_report_window * rw);
|
||||
SCM gnc_report_window_get_report(gnc_report_window * rw);
|
||||
|
||||
void gnc_report_window_create_menu(gnc_report_window * report,
|
||||
GNCMainChildInfo * child);
|
||||
void gnc_report_window_create_toolbar(gnc_report_window * report,
|
||||
GNCMainChildInfo * child);
|
||||
|
||||
void gnc_report_window_default_params_editor(SCM options, SCM report);
|
||||
|
||||
void reportWindow(int id);
|
||||
void gnc_print_report (int report_id);
|
||||
void gnc_main_window_open_report (int report_id, gint toplevel);
|
||||
void gnc_main_window_open_report_url (const char * url, gint toplevel);
|
||||
|
||||
GnomeMDIChild * gnc_report_window_create_child(const gchar * url);
|
||||
void reportWindow(int id);
|
||||
void gnc_print_report (int report_id);
|
||||
|
||||
#endif
|
||||
|
@ -60,6 +60,11 @@
|
||||
(if (not result)
|
||||
(set! gnc:*load-slib-backup* #t)))
|
||||
|
||||
;; Test for simple-format
|
||||
(if (not (defined? 'simple-format))
|
||||
(begin
|
||||
(require 'format)
|
||||
(define simple-format format)))
|
||||
|
||||
(define (build-path firstelement . restofpath)
|
||||
(define separator "/")
|
||||
|
@ -57,15 +57,15 @@
|
||||
(gnc:make-extension 'separator #f #f path #f))
|
||||
|
||||
|
||||
(define (gnc:extensions-menu-setup win)
|
||||
(define (gnc:extensions-menu-setup)
|
||||
(define menu (gnc:make-menu "Extensions" (list "_Settings")))
|
||||
|
||||
(define export-item
|
||||
(gnc:make-menu-item (N_ "Export data as text (Danger: Unfinished)")
|
||||
(N_ "Export data as text.")
|
||||
(list "Extensions" "")
|
||||
(lambda () (gnc:main-win-account-group-write win))))
|
||||
|
||||
|
||||
; (define export-item
|
||||
; (gnc:make-menu-item (N_ "Export data as text (Danger: Unfinished)")
|
||||
; (N_ "Export data as text.")
|
||||
; (list "Extensions" "")
|
||||
; (lambda () (gnc:main-win-account-group-write win))))
|
||||
|
||||
(define progress-item
|
||||
(gnc:make-menu-item (N_ "Test progress dialog")
|
||||
(N_ "Test progress dialog")
|
||||
@ -91,11 +91,11 @@
|
||||
(gnc:progress-dialog-destroy dialog)))))
|
||||
|
||||
(gnc:add-extension menu)
|
||||
(gnc:add-extension export-item)
|
||||
; (gnc:add-extension export-item)
|
||||
(gnc:add-extension progress-item))
|
||||
|
||||
(if (gnc:debugging?)
|
||||
(gnc:hook-add-dangler gnc:*main-window-opened-hook*
|
||||
(gnc:hook-add-dangler gnc:*ui-startup-hook*
|
||||
gnc:extensions-menu-setup))
|
||||
|
||||
|
||||
|
@ -85,16 +85,16 @@
|
||||
'shutdown-hook
|
||||
"Functions to run at guile shutdown. Hook args: ()"))
|
||||
|
||||
(define gnc:*ui-startup-hook*
|
||||
(gnc:hook-define
|
||||
'ui-startup-hook
|
||||
"Functions to run when the ui comes up. Hook args: ()"))
|
||||
|
||||
(define gnc:*ui-shutdown-hook*
|
||||
(gnc:hook-define
|
||||
'ui-shutdown-hook
|
||||
"Functions to run at ui shutdown. Hook args: ()"))
|
||||
|
||||
(define gnc:*main-window-opened-hook*
|
||||
(gnc:hook-define
|
||||
'main-window-opened-hook
|
||||
"Functions to run whenever the main window is opened. Hook args: (window)"))
|
||||
|
||||
(define gnc:*file-opened-hook*
|
||||
(gnc:hook-define
|
||||
'file-opened-hook
|
||||
|
@ -61,6 +61,7 @@
|
||||
(define (gnc:html-style-sheet-template-find tname)
|
||||
(hash-ref *gnc:_style-sheet-templates_* tname))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; define-html-style-sheet
|
||||
;; actually defines an <html-style-sheet-template>.
|
||||
@ -91,7 +92,7 @@
|
||||
|
||||
(define <html-style-sheet>
|
||||
(make-record-type "<html-style-sheet>"
|
||||
'(name options renderer style)))
|
||||
'(name type options renderer style)))
|
||||
|
||||
(define gnc:html-style-sheet?
|
||||
(record-predicate <html-style-sheet>))
|
||||
@ -102,6 +103,12 @@
|
||||
(define gnc:html-style-sheet-set-name!
|
||||
(record-modifier <html-style-sheet> 'name))
|
||||
|
||||
(define gnc:html-style-sheet-type
|
||||
(record-accessor <html-style-sheet> 'type))
|
||||
|
||||
(define gnc:html-style-sheet-set-type!
|
||||
(record-modifier <html-style-sheet> 'type))
|
||||
|
||||
(define gnc:html-style-sheet-options
|
||||
(record-accessor <html-style-sheet> 'options))
|
||||
|
||||
@ -120,6 +127,26 @@
|
||||
(define gnc:html-style-sheet-style
|
||||
(record-accessor <html-style-sheet> 'style))
|
||||
|
||||
(define (gnc:save-style-sheet-options)
|
||||
(let ((port (open (build-path (getenv "HOME") ".gnucash" "config.auto")
|
||||
(logior O_WRONLY O_CREAT O_APPEND))))
|
||||
(hash-fold
|
||||
(lambda (id ss-obj p)
|
||||
(let ((code
|
||||
(string-append
|
||||
(format #f "(let ((template (gnc:html-style-sheet-template-find ~S)))\n"
|
||||
(gnc:html-style-sheet-type ss-obj))
|
||||
" (if template \n"
|
||||
" (let ((options ((gnc:html-style-sheet-template-options-generator template)))) \n"
|
||||
(gnc:generate-restore-forms
|
||||
(gnc:html-style-sheet-options ss-obj) "options")
|
||||
(format #f " (gnc:restore-html-style-sheet ~S ~S options))))\n"
|
||||
(gnc:html-style-sheet-name ss-obj)
|
||||
(gnc:html-style-sheet-type ss-obj)))))
|
||||
(display code port))
|
||||
#f) #f *gnc:_style-sheets_*)
|
||||
(close port)))
|
||||
|
||||
(define (gnc:html-style-sheet-set-style! sheet tag . rest)
|
||||
(let ((newstyle #f))
|
||||
(if (and (= (length rest) 2)
|
||||
@ -135,7 +162,7 @@
|
||||
(let* ((template (gnc:html-style-sheet-template-find template-name)))
|
||||
(if template
|
||||
(let ((rv (gnc:make-html-style-sheet-internal
|
||||
style-sheet-name
|
||||
style-sheet-name template-name
|
||||
((gnc:html-style-sheet-template-options-generator template))
|
||||
(gnc:html-style-sheet-template-renderer template)
|
||||
(gnc:make-html-style-table))))
|
||||
@ -161,6 +188,36 @@
|
||||
rv)
|
||||
#f)))
|
||||
|
||||
(define (gnc:restore-html-style-sheet style-sheet-name template-name options)
|
||||
(let* ((template (gnc:html-style-sheet-template-find template-name)))
|
||||
(if template
|
||||
(let ((rv (gnc:make-html-style-sheet-internal
|
||||
style-sheet-name template-name
|
||||
options
|
||||
(gnc:html-style-sheet-template-renderer template)
|
||||
(gnc:make-html-style-table))))
|
||||
;; set up the fallback data styles for every rendered document
|
||||
(gnc:html-style-sheet-set-style!
|
||||
rv "<string>"
|
||||
gnc:default-html-string-renderer #f)
|
||||
|
||||
(gnc:html-style-sheet-set-style!
|
||||
rv "<gnc-numeric>"
|
||||
gnc:default-html-gnc-numeric-renderer #f)
|
||||
|
||||
(gnc:html-style-sheet-set-style!
|
||||
rv "<number>"
|
||||
gnc:default-html-number-renderer #f)
|
||||
|
||||
(gnc:html-style-sheet-set-style!
|
||||
rv "<gnc-monetary>"
|
||||
gnc:default-html-gnc-monetary-renderer #f)
|
||||
|
||||
;; store it in the style sheet hash
|
||||
(hash-set! *gnc:_style-sheets_* style-sheet-name rv)
|
||||
rv)
|
||||
#f)))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; html-style-sheet-apply-changes
|
||||
|
@ -85,7 +85,6 @@
|
||||
(cond ((gnc:ui-is-running?)
|
||||
(if (not (gnc:ui-is-terminating?))
|
||||
(begin
|
||||
(gnc:ui-destroy-all-subwindows)
|
||||
(if (gnc:file-query-save)
|
||||
(begin
|
||||
(gnc:hook-run-danglers gnc:*ui-shutdown-hook*)
|
||||
@ -135,8 +134,12 @@
|
||||
;; add a hook to shut down the expression parser
|
||||
(gnc:hook-add-dangler gnc:*shutdown-hook* gnc:exp-parser-shutdown)
|
||||
|
||||
;; add a hook to save the user configs on shutdown
|
||||
(gnc:hook-add-dangler gnc:*shutdown-hook* gnc:save-global-options)
|
||||
;; add a hook to save the user configs on shutdown. this saves
|
||||
;; global options plus (for the moment) saved report and account
|
||||
;; tree window parameters. reports and parameters should probably
|
||||
;; be in a separate file, with the main data file, or something
|
||||
;; else.
|
||||
(gnc:hook-add-dangler gnc:*shutdown-hook* gnc:save-all-options)
|
||||
|
||||
;; add a hook to shut down the C side options code
|
||||
(gnc:hook-add-dangler gnc:*shutdown-hook* gnc:c-options-shutdown)
|
||||
|
@ -945,9 +945,11 @@
|
||||
(gnc:option-db-register-option db_handle option))
|
||||
options))
|
||||
|
||||
(define (gnc:save-options options options-string file header)
|
||||
(define (gnc:save-options options options-string file header truncate?)
|
||||
(let ((code (gnc:generate-restore-forms options options-string))
|
||||
(port (open file (logior O_WRONLY O_CREAT O_TRUNC))))
|
||||
(port (if truncate?
|
||||
(open file (logior O_WRONLY O_CREAT O_TRUNC))
|
||||
(open file (logior O_WRONLY O_CREAT O_APPEND)))))
|
||||
(if port (begin
|
||||
(display header port)
|
||||
(display code port)
|
||||
|
@ -69,7 +69,7 @@
|
||||
(build-path (getenv "HOME") ".gnucash" "config.user"))
|
||||
(auto-file
|
||||
(build-path (getenv "HOME") ".gnucash" "config.auto")))
|
||||
|
||||
|
||||
(if (access? user-file F_OK)
|
||||
(if (false-if-exception (primitive-load user-file))
|
||||
(set! user-config-loaded? #t)
|
||||
|
@ -71,6 +71,35 @@
|
||||
(define (gnc:global-options-clear-changes)
|
||||
(gnc:options-clear-changes gnc:*options-entries*))
|
||||
|
||||
;; save-all-options: this is the actual hook that gets called at
|
||||
;; shutdown. right now, we put all the options in the same file so
|
||||
;; it's important to make sure it happens in this order. later the
|
||||
;; hook should probably revert back to just save-global-options.
|
||||
(define (gnc:save-all-options)
|
||||
(gnc:save-global-options)
|
||||
(gnc:save-report-options)
|
||||
(gnc:save-acct-tree-options)
|
||||
(gnc:save-style-sheet-options))
|
||||
|
||||
(define (gnc:save-acct-tree-options)
|
||||
(let ((port (open (build-path (getenv "HOME") ".gnucash" "config.auto")
|
||||
(logior O_WRONLY O_CREAT O_APPEND)))
|
||||
(maxid 0))
|
||||
(hash-fold
|
||||
(lambda (id optobj p)
|
||||
(let ((code
|
||||
(string-append
|
||||
"(let ((options (gnc:make-acct-tree-window-options)))\n"
|
||||
(gnc:generate-restore-forms optobj "options")
|
||||
(simple-format
|
||||
#f " (hash-set! gnc:*acct-tree-options* ~A options))\n"
|
||||
id))))
|
||||
(display code port)
|
||||
(if (> id maxid) (set! maxid id)))
|
||||
#f) #f gnc:*acct-tree-options*)
|
||||
(format port " (set! gnc:*acct-tree-id* ~A)\n\n" (+ 1 maxid))
|
||||
(close port)))
|
||||
|
||||
(define (gnc:save-global-options)
|
||||
(gnc:make-home-dir)
|
||||
(gnc:save-options gnc:*options-entries*
|
||||
@ -80,7 +109,8 @@
|
||||
"(gnc:config-file-format-version 1)\n\n"
|
||||
";"
|
||||
(_ "GnuCash Configuration Options")
|
||||
"\n")))
|
||||
"\n")
|
||||
#t))
|
||||
|
||||
(define (gnc:config-file-format-version version) #t)
|
||||
|
||||
@ -121,55 +151,7 @@
|
||||
(define (gnc:get-credit-string type)
|
||||
(_ (assoc-ref gnc:*credit-strings* type)))
|
||||
|
||||
|
||||
;; Main Window options
|
||||
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-simple-boolean-option
|
||||
(N_ "Main Window") (N_ "Double click expands parent accounts")
|
||||
"a" (N_ "Double clicking on an account with children expands \
|
||||
the account instead of opening a register.") #f))
|
||||
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-simple-boolean-option
|
||||
(N_ "Main Window") (N_ "Reports appear in Main Window")
|
||||
"a" (N_ "By default, reports go into the main window instead of a separate window.") #t))
|
||||
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-list-option
|
||||
(N_ "Main Window") (N_ "Account types to display")
|
||||
"b" ""
|
||||
(list 'bank 'cash 'credit 'asset 'liability 'stock
|
||||
'mutual 'currency 'income 'expense 'equity)
|
||||
(list (list->vector (list 'bank (N_ "Bank") ""))
|
||||
(list->vector (list 'cash (N_ "Cash") ""))
|
||||
(list->vector (list 'credit (N_ "Credit") ""))
|
||||
(list->vector (list 'asset (N_ "Asset") ""))
|
||||
(list->vector (list 'liability (N_ "Liability") ""))
|
||||
(list->vector (list 'stock (N_ "Stock") ""))
|
||||
(list->vector (list 'mutual (N_ "Mutual Fund") ""))
|
||||
(list->vector (list 'currency (N_ "Currency") ""))
|
||||
(list->vector (list 'income (N_ "Income") ""))
|
||||
(list->vector (list 'expense (N_ "Expense") ""))
|
||||
(list->vector (list 'equity (N_ "Equity") "")))))
|
||||
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-list-option
|
||||
(N_ "Main Window") (N_ "Account fields to display")
|
||||
"c" ""
|
||||
(list 'description 'total)
|
||||
(list (list->vector (list 'type (N_ "Type") ""))
|
||||
(list->vector (list 'code (N_ "Code") ""))
|
||||
(list->vector (list 'description (N_ "Description") ""))
|
||||
(list->vector (list 'notes (N_ "Notes") ""))
|
||||
(list->vector (list 'currency (N_ "Currency") ""))
|
||||
(list->vector (list 'security (N_ "Security") ""))
|
||||
(list->vector (list 'balance (N_ "Balance") ""))
|
||||
(list->vector (list 'total (N_ "Total") "")))))
|
||||
|
||||
|
||||
;; International options
|
||||
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-multichoice-option
|
||||
(N_ "International") (N_ "Date Format")
|
||||
@ -519,6 +501,81 @@ transaction.") #t))
|
||||
"d" (N_ "Host to connect to for user registration and support services")
|
||||
"www.gnumatic.com"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; account tree options
|
||||
;; these are here because they used to be global preferences;
|
||||
;; they should probably move elsewhere.
|
||||
;;
|
||||
;; like reports, we have an integer tree id that is the index into a
|
||||
;; global hash table, and URLs of the form gnc-acct-tree:id=%d will
|
||||
;; open to the right window.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define gnc:*acct-tree-options* (make-hash-table 11))
|
||||
(define gnc:*acct-tree-id* 0)
|
||||
|
||||
(define (gnc:find-acct-tree-window-options id)
|
||||
(hash-ref gnc:*acct-tree-options* id))
|
||||
|
||||
(define (gnc:make-acct-tree-window-options)
|
||||
(let* ((options (gnc:new-options))
|
||||
(add-option
|
||||
(lambda (opt)
|
||||
(gnc:register-option options opt))))
|
||||
(add-option
|
||||
(gnc:make-string-option
|
||||
(N_ "Account Tree") (N_ "Name of account view")
|
||||
"a" (N_ "If you keep multiple account views open, it may be helpful
|
||||
to give each one a descriptive name") (N_ "Accounts")))
|
||||
(add-option
|
||||
(gnc:make-simple-boolean-option
|
||||
(N_ "Account Tree") (N_ "Double click expands parent accounts")
|
||||
"a" (N_ "Double clicking on an account with children expands \
|
||||
the account instead of opening a register.") #f))
|
||||
(add-option
|
||||
(gnc:make-list-option
|
||||
(N_ "Account Tree") (N_ "Account types to display")
|
||||
"b" ""
|
||||
(list 'bank 'cash 'credit 'asset 'liability 'stock
|
||||
'mutual 'currency 'income 'expense 'equity)
|
||||
(list (list->vector (list 'bank (N_ "Bank") ""))
|
||||
(list->vector (list 'cash (N_ "Cash") ""))
|
||||
(list->vector (list 'credit (N_ "Credit") ""))
|
||||
(list->vector (list 'asset (N_ "Asset") ""))
|
||||
(list->vector (list 'liability (N_ "Liability") ""))
|
||||
(list->vector (list 'stock (N_ "Stock") ""))
|
||||
(list->vector (list 'mutual (N_ "Mutual Fund") ""))
|
||||
(list->vector (list 'currency (N_ "Currency") ""))
|
||||
(list->vector (list 'income (N_ "Income") ""))
|
||||
(list->vector (list 'expense (N_ "Expense") ""))
|
||||
(list->vector (list 'equity (N_ "Equity") "")))))
|
||||
|
||||
(add-option
|
||||
(gnc:make-list-option
|
||||
(N_ "Account Tree") (N_ "Account fields to display")
|
||||
"c" ""
|
||||
(list 'description 'total)
|
||||
(list (list->vector (list 'type (N_ "Type") ""))
|
||||
(list->vector (list 'code (N_ "Code") ""))
|
||||
(list->vector (list 'description (N_ "Description") ""))
|
||||
(list->vector (list 'notes (N_ "Notes") ""))
|
||||
(list->vector (list 'currency (N_ "Currency") ""))
|
||||
(list->vector (list 'security (N_ "Security") ""))
|
||||
(list->vector (list 'balance (N_ "Balance") ""))
|
||||
(list->vector (list 'total (N_ "Total") "")))))
|
||||
|
||||
options))
|
||||
|
||||
(define (gnc:make-new-acct-tree-window)
|
||||
(let ((options (gnc:make-acct-tree-window-options))
|
||||
(id gnc:*acct-tree-id*))
|
||||
(hash-set! gnc:*acct-tree-options* id options)
|
||||
(set! gnc:*acct-tree-id* (+ 1 id))
|
||||
(cons options id)))
|
||||
|
||||
(define (gnc:free-acct-tree-window id)
|
||||
(hash-remove! gnc:*acct-tree-options* id))
|
||||
|
||||
;;; Configuation variables
|
||||
|
||||
(define gnc:*arg-show-version*
|
||||
|
@ -38,14 +38,19 @@
|
||||
(define *gnc:_reports_* (make-hash-table 23))
|
||||
(define *gnc:_report-next-serial_* 0)
|
||||
|
||||
(define (gnc:report-menu-setup win)
|
||||
(define menu (gnc:make-menu "_Reports" (list "_Accounts")))
|
||||
(define tax-menu (gnc:make-menu (N_ "_Taxes") (list "_Reports" "")))
|
||||
(define income-expense-menu
|
||||
(gnc:make-menu (N_ "_Income & Expense") (list "_Reports" "")))
|
||||
(define asset-liability-menu
|
||||
(gnc:make-menu (N_ "_Assets & Liabilities") (list "_Reports" "")))
|
||||
(define (gnc:report-menu-setup)
|
||||
;; since this menu gets added to every child window, we say it
|
||||
;; comes after the "_File" menu.
|
||||
(define menu (gnc:make-menu "New _Report"
|
||||
(list "_File" "New _Account Tree")))
|
||||
(define menu-namer (gnc:new-menu-namer))
|
||||
(define tax-menu (gnc:make-menu (N_ "_Taxes")
|
||||
(list "_File" "New _Report" "")))
|
||||
(define income-expense-menu
|
||||
(gnc:make-menu (N_ "_Income & Expense") (list "_File" "New _Report" "")))
|
||||
(define asset-liability-menu
|
||||
(gnc:make-menu (N_ "_Assets & Liabilities")
|
||||
(list "_File" "New _Report" "")))
|
||||
(define menu-hash (make-hash-table 23))
|
||||
|
||||
(define (add-report-menu-item name report)
|
||||
@ -55,57 +60,60 @@
|
||||
(menu-name (gnc:report-menu-name report))
|
||||
(menu-tip (gnc:report-menu-tip report))
|
||||
(item #f))
|
||||
|
||||
|
||||
(if (not menu-path)
|
||||
(set! menu-path '(""))
|
||||
(set! menu-path
|
||||
(append menu-path '(""))))
|
||||
|
||||
(set! menu-path (cons "_Reports" menu-path))
|
||||
|
||||
|
||||
(set! menu-path (append (list "_File" "New _Report") menu-path))
|
||||
|
||||
(if menu-name (set! name menu-name))
|
||||
|
||||
|
||||
(if (not menu-tip)
|
||||
(set! menu-tip
|
||||
(sprintf #f (_ "Display the %s report") name)))
|
||||
|
||||
|
||||
(set! item
|
||||
(gnc:make-menu-item
|
||||
((menu-namer 'add-name) name)
|
||||
menu-tip
|
||||
menu-path
|
||||
(lambda ()
|
||||
(gnc:backtrace-if-exception
|
||||
(lambda ()
|
||||
(let ((rept (gnc:make-report
|
||||
(gnc:report-template-name report))))
|
||||
(if (gnc:option-value
|
||||
(gnc:lookup-global-option
|
||||
"Main Window" "Reports appear in Main Window"))
|
||||
(gnc:report-in-main-window rept)
|
||||
(gnc:report-window rept))))))))
|
||||
(let ((rept (gnc:make-report
|
||||
(gnc:report-template-name report))))
|
||||
(gnc:main-window-open-report rept #f)))))
|
||||
(gnc:add-extension item))))
|
||||
|
||||
(gnc:add-extension menu)
|
||||
|
||||
;; add the menu option to edit style sheets
|
||||
(gnc:add-extension menu)
|
||||
(gnc:add-extension
|
||||
(gnc:make-menu-item
|
||||
((menu-namer 'add-name) (_ "Style Sheets..."))
|
||||
(_ "Edit report style sheets.")
|
||||
(list "_Reports" "")
|
||||
(list "_Settings" "")
|
||||
(lambda ()
|
||||
(gnc:style-sheet-dialog-open))))
|
||||
|
||||
(gnc:add-extension
|
||||
(gnc:make-separator (list "_Reports" "")))
|
||||
|
||||
(gnc:add-extension tax-menu)
|
||||
(gnc:add-extension income-expense-menu)
|
||||
(gnc:add-extension asset-liability-menu)
|
||||
|
||||
|
||||
;; push reports (new items added on top of menu)
|
||||
(hash-for-each add-report-menu-item *gnc:_report-templates_*))
|
||||
|
||||
(define (gnc:save-report-options)
|
||||
(let ((port (open (build-path (getenv "HOME") ".gnucash" "config.auto")
|
||||
(logior O_WRONLY O_CREAT O_APPEND))))
|
||||
(hash-fold
|
||||
(lambda (id report-obj p)
|
||||
(if (not (null? (gnc:report-display-list report-obj)))
|
||||
(let ((code (gnc:report-generate-restore-forms report-obj)))
|
||||
(display code port)))
|
||||
#f) #f *gnc:_reports_*)
|
||||
(close port)))
|
||||
|
||||
(define <report-template>
|
||||
(make-record-type "<report-template>"
|
||||
;; The data items in a report record
|
||||
@ -164,6 +172,12 @@
|
||||
(define gnc:report-menu-tip
|
||||
(record-accessor <report-template> 'menu-tip))
|
||||
|
||||
(define (gnc:report-template-new-options/name template-name)
|
||||
(let ((templ (hash-ref *gnc:_report-templates_* template-name)))
|
||||
(if templ
|
||||
(gnc:report-template-new-options templ)
|
||||
#f)))
|
||||
|
||||
(define (gnc:report-template-new-options report-template)
|
||||
(let ((generator (gnc:report-template-options-generator report-template))
|
||||
(namer
|
||||
@ -231,21 +245,16 @@
|
||||
(record-modifier <report> 'children))
|
||||
|
||||
(define (gnc:report-add-child! report child)
|
||||
(gnc:report-add-parent! child report)
|
||||
(gnc:report-set-children!
|
||||
report (cons (gnc:report-id child) (gnc:report-children report))))
|
||||
|
||||
(define (gnc:report-add-child-by-id! report child)
|
||||
(gnc:report-set-children!
|
||||
report (cons child (gnc:report-children report))))
|
||||
|
||||
(define (gnc:report-add-child-by-id! report child)
|
||||
(let ((childrep (gnc:find-report child)))
|
||||
(if childrep
|
||||
(begin
|
||||
(gnc:report-add-parent! childrep report)
|
||||
(gnc:report-set-children!
|
||||
report (cons childrep (gnc:report-children report)))))))
|
||||
|
||||
(define (gnc:report-add-parent! report parent)
|
||||
(gnc:report-set-parents!
|
||||
report (cons parent (gnc:report-parents report))))
|
||||
report (cons (gnc:report-id parent) (gnc:report-parents report))))
|
||||
|
||||
(define gnc:report-dirty?
|
||||
(record-accessor <report> 'dirty?))
|
||||
@ -260,7 +269,7 @@
|
||||
;; mark the parents as dirty
|
||||
(for-each
|
||||
(lambda (parent)
|
||||
(gnc:report-set-dirty?! parent val))
|
||||
(gnc:report-set-dirty?! (gnc:find-report parent) val))
|
||||
(gnc:report-parents report))
|
||||
|
||||
;; reload the window
|
||||
@ -283,18 +292,27 @@
|
||||
|
||||
(define (gnc:report-register-display report window)
|
||||
(if (and window report)
|
||||
(if (not (member window (gnc:report-display-list report)))
|
||||
(gnc:report-set-display-list!
|
||||
report
|
||||
(cons 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))))
|
||||
(for-each
|
||||
(lambda (rep)
|
||||
(gnc:report-register-display (gnc:find-report rep) window))
|
||||
(gnc:report-children report)))))
|
||||
|
||||
(define (gnc:report-unregister-display report window)
|
||||
(if (and window report)
|
||||
(if (member window (gnc:report-display-list report))
|
||||
(gnc:report-set-display-list!
|
||||
report
|
||||
(delete window (gnc:report-display-list report))))))
|
||||
|
||||
(begin
|
||||
(if (member window (gnc:report-display-list report))
|
||||
(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)))))
|
||||
|
||||
(define (gnc:make-report template-name . rest)
|
||||
(let ((r ((record-constructor <report>)
|
||||
@ -312,6 +330,14 @@
|
||||
(hash-set! *gnc:_reports_* (gnc:report-id r) r)
|
||||
id))
|
||||
|
||||
(define (gnc:restore-report id template-name parents children options)
|
||||
(let ((r ((record-constructor <report>)
|
||||
template-name id options parents children #t '() #f)))
|
||||
(if (>= id *gnc:_report-next-serial_*)
|
||||
(set! *gnc:_report-next-serial_* (+ id 1)))
|
||||
(hash-set! *gnc:_reports_* id r)))
|
||||
|
||||
|
||||
(define (gnc:make-report-options template-name)
|
||||
(let ((template (hash-ref *gnc:_report-templates_* template-name)))
|
||||
(if template
|
||||
@ -382,13 +408,25 @@
|
||||
(let ((r (hash-ref *gnc:_reports_* id)))
|
||||
(for-each
|
||||
(lambda (child)
|
||||
(gnc:report-remove-by-id (gnc:report-id child)))
|
||||
(gnc:report-remove-by-id child))
|
||||
(gnc:report-children r))
|
||||
(hash-remove! *gnc:_reports_* id)))
|
||||
|
||||
(define (gnc:find-report id)
|
||||
(hash-ref *gnc:_reports_* id))
|
||||
|
||||
(define (gnc:report-generate-restore-forms report)
|
||||
(string-append
|
||||
(simple-format
|
||||
#f "(let ((options (gnc:report-template-new-options/name ~S)))\n"
|
||||
(gnc:report-type report))
|
||||
(gnc:generate-restore-forms (gnc:report-options report)
|
||||
"options")
|
||||
(simple-format #f " (gnc:restore-report ~S ~S '~S '~S options))\n"
|
||||
(gnc:report-id report) (gnc:report-type report)
|
||||
(gnc:report-parents report)
|
||||
(gnc:report-children report))))
|
||||
|
||||
(define (gnc:backtrace-if-exception proc . args)
|
||||
(define (dumper key . args)
|
||||
(let ((stack (make-stack #t dumper)))
|
||||
@ -453,7 +491,6 @@
|
||||
html)
|
||||
#f))))
|
||||
|
||||
|
||||
(define (gnc:report-run id)
|
||||
(gnc:backtrace-if-exception
|
||||
(lambda ()
|
||||
@ -469,4 +506,4 @@
|
||||
html)
|
||||
#f)))))
|
||||
|
||||
(gnc:hook-add-dangler gnc:*main-window-opened-hook* gnc:report-menu-setup)
|
||||
(gnc:hook-add-dangler gnc:*ui-startup-hook* gnc:report-menu-setup)
|
||||
|
@ -74,15 +74,16 @@
|
||||
optname-display-depth optname-show-subaccounts
|
||||
optname-accounts "a" 1
|
||||
(lambda ()
|
||||
(let ((current-accounts (gnc:get-current-accounts)))
|
||||
;; FIXME : gnc:get-current-accounts disappeared
|
||||
(let ((current-accounts '()))
|
||||
(cond ((not (null? current-accounts)) current-accounts)
|
||||
(else
|
||||
(gnc:group-get-account-list (gnc:get-current-group)))))))
|
||||
|
||||
|
||||
;; with or without grouping
|
||||
(gnc:options-add-group-accounts!
|
||||
options pagename-accounts optname-group-accounts "b" #t)
|
||||
|
||||
|
||||
;; new options here
|
||||
(gnc:register-option
|
||||
options
|
||||
|
@ -37,7 +37,8 @@
|
||||
pagename-general (N_ "Accounts")
|
||||
"d" (N_ "Do transaction report on this account")
|
||||
(lambda ()
|
||||
(let ((current-accounts (gnc:get-current-accounts)))
|
||||
;; FIXME : gnc:get-current-accounts disappeared
|
||||
(let ((current-accounts '()))
|
||||
;; If some accounts were selected, use those
|
||||
(cond ((not (null? current-accounts))
|
||||
current-accounts)
|
||||
|
@ -1315,5 +1315,5 @@
|
||||
; gnc:budget-entries
|
||||
; (lambda () (display "Applied the budget.\n"))))));
|
||||
|
||||
(gnc:hook-add-dangler gnc:*main-window-opened-hook*
|
||||
(lambda (win) (gnc:add-extension budget-item))))
|
||||
(gnc:hook-add-dangler gnc:*ui-startup-hook*
|
||||
(lambda () (gnc:add-extension budget-item))))
|
||||
|
@ -162,7 +162,9 @@
|
||||
(gnc:make-account-list-option
|
||||
(N_ "Hello Again") (N_ "An account list option")
|
||||
"g" (N_ "This is an account list option")
|
||||
(lambda () (gnc:get-current-accounts))
|
||||
;; FIXME : this used to be gnc:get-current-accounts, but
|
||||
;; that doesn't exist any more.
|
||||
(lambda () '())
|
||||
#f #t))
|
||||
|
||||
;; This is a list option. The user can select one or (possibly)
|
||||
|
@ -332,7 +332,8 @@
|
||||
(N_ "General") (N_ "Account")
|
||||
"c" (N_ "Do transaction report on these accounts")
|
||||
(lambda ()
|
||||
(let ((current-accounts (gnc:get-current-accounts))
|
||||
;; FIXME : gnc:get-current-accounts disappeared.
|
||||
(let ((current-accounts '())
|
||||
(num-accounts (gnc:group-get-num-accounts
|
||||
(gnc:get-current-group)))
|
||||
(first-account (gnc:group-get-account
|
||||
|
@ -95,11 +95,13 @@
|
||||
|
||||
(gnc:read-tips)
|
||||
|
||||
(let ((mainopen-hook (gnc:hook-lookup 'main-window-opened-hook)))
|
||||
(gnc:hook-add-dangler
|
||||
mainopen-hook
|
||||
(lambda (window)
|
||||
(let ((tip-opt (gnc:lookup-global-option "General"
|
||||
"Display \"Tip of the Day\"")))
|
||||
(if (gnc:option-value tip-opt)
|
||||
(gnc:ui-totd-dialog-create-and-run))))))
|
||||
(gnc:hook-add-dangler
|
||||
gnc:*ui-startup-hook*
|
||||
(lambda ()
|
||||
(let ((tip-opt (gnc:lookup-global-option "General"
|
||||
"Display \"Tip of the Day\"")))
|
||||
(if (gnc:option-value tip-opt)
|
||||
(gnc:ui-totd-dialog-create-and-run)))))
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user