mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/report/report-gnome/window-report.h: add new init api
* src/report/report-gnome/window-report.c: move some report initialization here from top-level.c * src/report/report-gnome/gncmod-report-gnome.c: call new report initialization function * src/report/report-gnome/Makefile.am: add app-utils dependency git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6409 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -9,6 +9,7 @@ AM_CFLAGS = \
|
||||
-I${top_srcdir}/src/app-utils \
|
||||
-I${top_srcdir}/src/gnome-utils \
|
||||
-I${top_srcdir}/src/app-file \
|
||||
-I${top_srcdir}/src/report/report-system \
|
||||
${GLADE_CFLAGS} \
|
||||
${GUILE_INCS} \
|
||||
${GTKHTML_CFLAGS} \
|
||||
@@ -35,6 +36,7 @@ libgncmod_report_gnome_la_LIBADD = \
|
||||
${top_srcdir}/src/gnc-module/libgncmodule.la \
|
||||
${top_srcdir}/src/gnome-utils/libgncmod-gnome-utils.la \
|
||||
${top_srcdir}/src/app-file/libgncmod-app-file.la \
|
||||
${top_srcdir}/src/report/report-system/libgncmod-report-system.la \
|
||||
${GLADE_LIBS} \
|
||||
${GUILE_LIBS} \
|
||||
${GNOME_PRINT_LIBS} \
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-module-api.h"
|
||||
|
||||
#include "window-report.h"
|
||||
|
||||
/* version of the gnc module system interface we require */
|
||||
int gnc_module_system_interface = 0;
|
||||
|
||||
@@ -59,6 +61,9 @@ gnc_module_init(int refcount) {
|
||||
lmod ("(g-wrapped gw-report-gnome)");
|
||||
lmod ("(gnucash report report-gnome)");
|
||||
|
||||
if (refcount == 0)
|
||||
gnc_report_init ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,14 +35,17 @@
|
||||
|
||||
#include "dialog-options.h"
|
||||
#include "dialog-utils.h"
|
||||
#include "file-utils.h"
|
||||
#include "gnc-component-manager.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-file-dialog.h"
|
||||
#include "gnc-gui-query.h"
|
||||
#include "gnc-html-history.h"
|
||||
#include "gnc-html.h"
|
||||
#include "gnc-report.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "option-util.h"
|
||||
#include "window-help.h"
|
||||
#include "window-report.h"
|
||||
|
||||
#define WINDOW_REPORT_CM_CLASS "window-report"
|
||||
@@ -1074,3 +1077,132 @@ gnc_report_raise_editor(SCM report) {
|
||||
SCM editor = gh_call1(get_editor, report);
|
||||
gdk_window_raise(GTK_WIDGET(gw_wcp_get_ptr(editor))->window);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_html_file_stream_cb (const char *location, char ** data)
|
||||
{
|
||||
return (gncReadFile (location, data) > 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_html_report_stream_cb (const char *location, char ** data)
|
||||
{
|
||||
gboolean ok;
|
||||
|
||||
ok = gnc_run_report_id_string (location, data);
|
||||
|
||||
if (!ok)
|
||||
*data = g_strdup (_("<html><body><h3>Report error</h3>"
|
||||
"<p>An error occurred while running the report.</p>"
|
||||
"</body></html>"));
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_html_options_url_cb (const char *location, const char *label,
|
||||
gboolean new_window, GNCURLResult *result)
|
||||
{
|
||||
SCM find_report = gh_eval_str ("gnc:find-report");
|
||||
SCM start_editor = gh_eval_str ("gnc:report-edit-options");
|
||||
SCM report;
|
||||
int report_id;
|
||||
|
||||
g_return_val_if_fail (location != NULL, FALSE);
|
||||
g_return_val_if_fail (result != NULL, FALSE);
|
||||
|
||||
result->load_to_stream = FALSE;
|
||||
|
||||
/* href="gnc-options:report-id=2676" */
|
||||
if (strncmp ("report-id=", location, 10) == 0)
|
||||
{
|
||||
if (sscanf (location + 10, "%d", &report_id) != 1)
|
||||
{
|
||||
result->error_message =
|
||||
g_strdup_printf (_("Badly formed options URL: %s"), location);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
report = gh_call1 (find_report, gh_int2scm (report_id));
|
||||
if (report == SCM_UNDEFINED ||
|
||||
report == SCM_BOOL_F)
|
||||
{
|
||||
result->error_message =
|
||||
g_strdup_printf (_("Badly report id: %s"), location);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gh_call1 (start_editor, report);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->error_message =
|
||||
g_strdup_printf (_("Badly formed options URL: %s"), location);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_html_report_url_cb (const char *location, const char *label,
|
||||
gboolean new_window, GNCURLResult *result)
|
||||
{
|
||||
g_return_val_if_fail (location != NULL, FALSE);
|
||||
g_return_val_if_fail (result != NULL, FALSE);
|
||||
|
||||
/* make a new window if necessary */
|
||||
if (new_window)
|
||||
{
|
||||
char *url;
|
||||
|
||||
url = gnc_build_url (URL_TYPE_REPORT, location, label);
|
||||
gnc_main_window_open_report_url (url, FALSE);
|
||||
g_free (url);
|
||||
|
||||
result->load_to_stream = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->load_to_stream = TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_html_help_url_cb (const char *location, const char *label,
|
||||
gboolean new_window, GNCURLResult *result)
|
||||
{
|
||||
g_return_val_if_fail (location != NULL, FALSE);
|
||||
g_return_val_if_fail (result != NULL, FALSE);
|
||||
|
||||
if (new_window)
|
||||
{
|
||||
gnc_help_window * help;
|
||||
|
||||
help = gnc_help_window_new ();
|
||||
gnc_help_window_show_help (help, location, label);
|
||||
|
||||
result->load_to_stream = FALSE;
|
||||
}
|
||||
else
|
||||
result->load_to_stream = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_report_init (void)
|
||||
{
|
||||
gnc_html_register_stream_handler (URL_TYPE_HELP, gnc_html_file_stream_cb);
|
||||
gnc_html_register_stream_handler (URL_TYPE_FILE, gnc_html_file_stream_cb);
|
||||
gnc_html_register_stream_handler (URL_TYPE_REPORT, gnc_html_report_stream_cb);
|
||||
|
||||
gnc_html_register_url_handler (URL_TYPE_OPTIONS, gnc_html_options_url_cb);
|
||||
gnc_html_register_url_handler (URL_TYPE_REPORT, gnc_html_report_url_cb);
|
||||
gnc_html_register_url_handler (URL_TYPE_HELP, gnc_html_help_url_cb);
|
||||
}
|
||||
|
||||
@@ -61,4 +61,6 @@ void gnc_report_window_remove_edited_report(gnc_report_window * win,
|
||||
SCM report);
|
||||
void gnc_report_raise_editor(SCM report);
|
||||
|
||||
void gnc_report_init (void);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user