mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
RptCleanup - Consolidate report system gui initialization
For this gnc-plugin-stylesheets has gotten a wider scope to become gnc-plugin-report-system. The new plugin does all the report system initialization bits wrt to the gui.
This commit is contained in:
@@ -41,7 +41,7 @@ set (gnc_gnome_noinst_HEADERS
|
||||
gnc-plugin-business.h
|
||||
gnc-plugin-register.h
|
||||
gnc-plugin-register2.h
|
||||
gnc-plugin-stylesheets.h
|
||||
gnc-plugin-report-system.h
|
||||
gnc-plugin-page-account-tree.h
|
||||
gnc-plugin-page-budget.h
|
||||
gnc-plugin-page-invoice.h
|
||||
@@ -113,7 +113,7 @@ set (gnc_gnome_SOURCES
|
||||
gnc-plugin-business.c
|
||||
gnc-plugin-register.c
|
||||
gnc-plugin-register2.c
|
||||
gnc-plugin-stylesheets.c
|
||||
gnc-plugin-report-system.c
|
||||
gnc-plugin-page-account-tree.c
|
||||
gnc-plugin-page-budget.c
|
||||
gnc-plugin-page-invoice.c
|
||||
|
||||
275
gnucash/gnome/gnc-plugin-report-system.c
Normal file
275
gnucash/gnome/gnc-plugin-report-system.c
Normal file
@@ -0,0 +1,275 @@
|
||||
/*
|
||||
* gnc-plugin-report-system.c --
|
||||
* Copyright (C) 2003 David Hampton <hampton@employees.org>
|
||||
*
|
||||
* 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
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "dialog-report-style-sheet.h"
|
||||
#include "file-utils.h"
|
||||
#include "gnc-gnome-utils.h"
|
||||
#include "gnc-html.h"
|
||||
#include "gnc-plugin-page-report.h"
|
||||
#include "gnc-plugin-report-system.h"
|
||||
#include "gnc-plugin-manager.h"
|
||||
#include "gnc-report.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "window-report.h"
|
||||
|
||||
static void gnc_plugin_report_system_class_init (GncPluginReportSystemClass *klass);
|
||||
static void gnc_plugin_report_system_init (GncPluginReportSystem *plugin);
|
||||
static void gnc_plugin_report_system_finalize (GObject *object);
|
||||
|
||||
|
||||
/* Command callbacks */
|
||||
static void gnc_plugin_report_system_cmd_edit_style_sheet (GtkAction *action,
|
||||
GncMainWindowActionData *data);
|
||||
|
||||
|
||||
#define PLUGIN_ACTIONS_NAME "gnc-plugin-report-system-actions"
|
||||
#define PLUGIN_UI_FILENAME "gnc-plugin-report-system-ui.xml"
|
||||
|
||||
static GtkActionEntry gnc_plugin_actions [] =
|
||||
{
|
||||
/* Menu Items */
|
||||
{
|
||||
"EditStyleSheetsAction", NULL, N_("St_yle Sheets"), NULL,
|
||||
N_("Edit report style sheets"),
|
||||
G_CALLBACK (gnc_plugin_report_system_cmd_edit_style_sheet)
|
||||
},
|
||||
};
|
||||
static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
|
||||
|
||||
|
||||
typedef struct GncPluginReportSystemPrivate
|
||||
{
|
||||
gpointer dummy;
|
||||
} GncPluginReportSystemPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(GncPluginReportSystem, gnc_plugin_report_system, GNC_TYPE_PLUGIN)
|
||||
|
||||
#define GNC_PLUGIN_REPORT_SYSTEM_GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_REPORT_SYSTEM, GncPluginReportSystemPrivate))
|
||||
|
||||
static GObjectClass *parent_class = NULL;
|
||||
|
||||
/************************************************************
|
||||
* Object Implementation *
|
||||
************************************************************/
|
||||
|
||||
static void
|
||||
gnc_plugin_report_system_class_init (GncPluginReportSystemClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_plugin_report_system_finalize;
|
||||
|
||||
/* plugin info */
|
||||
plugin_class->plugin_name = GNC_PLUGIN_REPORT_SYSTEM_NAME;
|
||||
|
||||
/* widget addition/removal */
|
||||
plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
|
||||
plugin_class->actions = gnc_plugin_actions;
|
||||
plugin_class->n_actions = gnc_plugin_n_actions;
|
||||
plugin_class->ui_filename = PLUGIN_UI_FILENAME;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_report_system_init (GncPluginReportSystem *plugin)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_report_system_finalize (GObject *object)
|
||||
{
|
||||
g_return_if_fail (GNC_IS_PLUGIN_REPORT_SYSTEM (object));
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Command Callbacks *
|
||||
************************************************************/
|
||||
|
||||
static void
|
||||
gnc_plugin_report_system_cmd_edit_style_sheet (GtkAction *action,
|
||||
GncMainWindowActionData *data)
|
||||
{
|
||||
gnc_style_sheet_dialog_open(GTK_WINDOW (data->window));
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Html url and stream handlers *
|
||||
************************************************************/
|
||||
|
||||
static gboolean
|
||||
gnc_report_system_file_stream_cb (const char *location, char ** data, int *len)
|
||||
{
|
||||
*len = gncReadFile (location, data);
|
||||
return (*len > 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_report_system_report_stream_cb (const char *location, char ** data, int *len)
|
||||
{
|
||||
gboolean ok;
|
||||
|
||||
ok = gnc_run_report_id_string (location, data);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
*data = g_strdup_printf ("<html><body><h3>%s</h3>"
|
||||
"<p>%s</p></body></html>",
|
||||
_("Report error"),
|
||||
_("An error occurred while running the report."));
|
||||
|
||||
/* Make sure the progress bar is finished, which will also
|
||||
* make the GUI sensitive again. Easier to do this via guile
|
||||
* because otherwise we would need to link against gnome-utils
|
||||
* and a lot more. */
|
||||
scm_c_eval_string("(gnc:report-finished)");
|
||||
}
|
||||
|
||||
*len = strlen(*data);
|
||||
return ok;
|
||||
}
|
||||
|
||||
/* TODO: unroll start_editor */
|
||||
static gboolean
|
||||
gnc_report_system_options_url_cb (const char *location, const char *label,
|
||||
gboolean new_window, GNCURLResult *result)
|
||||
{
|
||||
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 = gnc_report_find(report_id);
|
||||
if (report == SCM_UNDEFINED ||
|
||||
report == SCM_BOOL_F)
|
||||
{
|
||||
result->error_message =
|
||||
g_strdup_printf (_("Badly-formed report id: %s"), location);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gnc_report_edit_options (report, GTK_WINDOW(result->parent));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->error_message =
|
||||
g_strdup_printf (_("Badly formed options URL: %s"), location);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_report_system_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, GNC_MAIN_WINDOW(result->parent));
|
||||
g_free (url);
|
||||
|
||||
result->load_to_stream = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->load_to_stream = TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_report_system_help_url_cb (const char *location, const char *label,
|
||||
gboolean new_window, GNCURLResult *result)
|
||||
{
|
||||
g_return_val_if_fail (location != NULL, FALSE);
|
||||
|
||||
if (label && (*label != '\0'))
|
||||
gnc_gnome_help (location, label);
|
||||
else
|
||||
gnc_gnome_help (location, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************
|
||||
* Plugin Bootstrapping *
|
||||
************************************************************/
|
||||
|
||||
void
|
||||
gnc_plugin_report_system_new (void)
|
||||
{
|
||||
GncPlugin *plugin;
|
||||
|
||||
/* Reference the report page plugin to ensure it exists in the gtk
|
||||
* type system. */
|
||||
GNC_TYPE_PLUGIN_PAGE_REPORT;
|
||||
|
||||
/* Register html handlers */
|
||||
gnc_html_register_stream_handler (URL_TYPE_HELP, gnc_report_system_file_stream_cb);
|
||||
gnc_html_register_stream_handler (URL_TYPE_FILE, gnc_report_system_file_stream_cb);
|
||||
gnc_html_register_stream_handler (URL_TYPE_REPORT, gnc_report_system_report_stream_cb);
|
||||
|
||||
gnc_html_register_url_handler (URL_TYPE_OPTIONS, gnc_report_system_options_url_cb);
|
||||
gnc_html_register_url_handler (URL_TYPE_REPORT, gnc_report_system_report_url_cb);
|
||||
gnc_html_register_url_handler (URL_TYPE_HELP, gnc_report_system_help_url_cb);
|
||||
|
||||
scm_c_use_module("gnucash report reports");
|
||||
scm_c_use_module("gnucash report-menus");
|
||||
scm_c_eval_string("(gnc:report-menu-setup)");
|
||||
|
||||
plugin = GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_REPORT_SYSTEM, NULL));
|
||||
gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), plugin);
|
||||
}
|
||||
59
gnucash/gnome/gnc-plugin-report-system.h
Normal file
59
gnucash/gnome/gnc-plugin-report-system.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* gnc-plugin-report-system.h --
|
||||
* Copyright (C) 2003 David Hampton <hampton@employees.org>
|
||||
*
|
||||
* 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
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef __GNC_PLUGIN_REPORT_SYSTEM_H
|
||||
#define __GNC_PLUGIN_REPORT_SYSTEM_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gnc-plugin.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* type macros */
|
||||
#define GNC_TYPE_PLUGIN_REPORT_SYSTEM (gnc_plugin_report_system_get_type ())
|
||||
#define GNC_PLUGIN_REPORT_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_REPORT_SYSTEM, GncPluginReportSystem))
|
||||
#define GNC_PLUGIN_REPORT_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_REPORT_SYSTEM, GncPluginReportSystemClass))
|
||||
#define GNC_IS_PLUGIN_REPORT_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_REPORT_SYSTEM))
|
||||
#define GNC_IS_PLUGIN_REPORT_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_REPORT_SYSTEM))
|
||||
#define GNC_PLUGIN_REPORT_SYSTEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_REPORT_SYSTEM, GncPluginReportSystemClass))
|
||||
|
||||
#define GNC_PLUGIN_REPORT_SYSTEM_NAME "gnc-plugin-report-system"
|
||||
|
||||
/* typedefs & structures */
|
||||
typedef struct
|
||||
{
|
||||
GncPlugin gnc_plugin;
|
||||
} GncPluginReportSystem;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GncPluginClass gnc_plugin;
|
||||
} GncPluginReportSystemClass;
|
||||
|
||||
/* function prototypes */
|
||||
GType gnc_plugin_report_system_get_type (void);
|
||||
void gnc_plugin_report_system_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GNC_PLUGIN_REPORT_SYSTEM_H */
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
* gnc-plugin-stylesheets.c --
|
||||
* Copyright (C) 2003 David Hampton <hampton@employees.org>
|
||||
*
|
||||
* 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
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "dialog-report-style-sheet.h"
|
||||
#include "gnc-gnome-utils.h"
|
||||
#include "gnc-plugin-stylesheets.h"
|
||||
#include "gnc-plugin-manager.h"
|
||||
#include "gnc-engine.h"
|
||||
|
||||
static void gnc_plugin_stylesheets_class_init (GncPluginStylesheetsClass *klass);
|
||||
static void gnc_plugin_stylesheets_init (GncPluginStylesheets *plugin);
|
||||
static void gnc_plugin_stylesheets_finalize (GObject *object);
|
||||
|
||||
|
||||
/* Command callbacks */
|
||||
static void gnc_plugin_stylesheets_cmd_edit_style_sheet (GtkAction *action,
|
||||
GncMainWindowActionData *data);
|
||||
|
||||
|
||||
#define PLUGIN_ACTIONS_NAME "gnc-plugin-stylesheets-actions"
|
||||
#define PLUGIN_UI_FILENAME "gnc-plugin-stylesheets-ui.xml"
|
||||
|
||||
static GtkActionEntry gnc_plugin_actions [] =
|
||||
{
|
||||
/* Menu Items */
|
||||
{
|
||||
"EditStyleSheetsAction", NULL, N_("St_yle Sheets"), NULL,
|
||||
N_("Edit report style sheets"),
|
||||
G_CALLBACK (gnc_plugin_stylesheets_cmd_edit_style_sheet)
|
||||
},
|
||||
};
|
||||
static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
|
||||
|
||||
|
||||
typedef struct GncPluginStylesheetsPrivate
|
||||
{
|
||||
gpointer dummy;
|
||||
} GncPluginStylesheetsPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(GncPluginStylesheets, gnc_plugin_stylesheets, GNC_TYPE_PLUGIN)
|
||||
|
||||
#define GNC_PLUGIN_STYLESHEETS_GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_STYLESHEETS, GncPluginStylesheetsPrivate))
|
||||
|
||||
static GObjectClass *parent_class = NULL;
|
||||
|
||||
/************************************************************
|
||||
* Object Implementation *
|
||||
************************************************************/
|
||||
|
||||
GncPlugin *
|
||||
gnc_plugin_stylesheets_new (void)
|
||||
{
|
||||
return GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_STYLESHEETS, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_stylesheets_class_init (GncPluginStylesheetsClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_plugin_stylesheets_finalize;
|
||||
|
||||
/* plugin info */
|
||||
plugin_class->plugin_name = GNC_PLUGIN_STYLESHEETS_NAME;
|
||||
|
||||
/* widget addition/removal */
|
||||
plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
|
||||
plugin_class->actions = gnc_plugin_actions;
|
||||
plugin_class->n_actions = gnc_plugin_n_actions;
|
||||
plugin_class->ui_filename = PLUGIN_UI_FILENAME;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_stylesheets_init (GncPluginStylesheets *plugin)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_plugin_stylesheets_finalize (GObject *object)
|
||||
{
|
||||
g_return_if_fail (GNC_IS_PLUGIN_STYLESHEETS (object));
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Command Callbacks *
|
||||
************************************************************/
|
||||
|
||||
static void
|
||||
gnc_plugin_stylesheets_cmd_edit_style_sheet (GtkAction *action,
|
||||
GncMainWindowActionData *data)
|
||||
{
|
||||
gnc_style_sheet_dialog_open(GTK_WINDOW (data->window));
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
* Plugin Bootstrapping *
|
||||
************************************************************/
|
||||
|
||||
void
|
||||
gnc_plugin_stylesheets_create_plugin (void)
|
||||
{
|
||||
GncPlugin *plugin = gnc_plugin_stylesheets_new ();
|
||||
|
||||
gnc_plugin_manager_add_plugin (gnc_plugin_manager_get (), plugin);
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* gnc-plugin-stylesheets.h --
|
||||
* Copyright (C) 2003 David Hampton <hampton@employees.org>
|
||||
*
|
||||
* 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
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#ifndef __GNC_PLUGIN_STYLESHEETS_H
|
||||
#define __GNC_PLUGIN_STYLESHEETS_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gnc-plugin.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* type macros */
|
||||
#define GNC_TYPE_PLUGIN_STYLESHEETS (gnc_plugin_stylesheets_get_type ())
|
||||
#define GNC_PLUGIN_STYLESHEETS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_STYLESHEETS, GncPluginStylesheets))
|
||||
#define GNC_PLUGIN_STYLESHEETS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_STYLESHEETS, GncPluginStylesheetsClass))
|
||||
#define GNC_IS_PLUGIN_STYLESHEETS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_STYLESHEETS))
|
||||
#define GNC_IS_PLUGIN_STYLESHEETS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_STYLESHEETS))
|
||||
#define GNC_PLUGIN_STYLESHEETS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_STYLESHEETS, GncPluginStylesheetsClass))
|
||||
|
||||
#define GNC_PLUGIN_STYLESHEETS_NAME "gnc-plugin-stylesheets"
|
||||
|
||||
/* typedefs & structures */
|
||||
typedef struct
|
||||
{
|
||||
GncPlugin gnc_plugin;
|
||||
} GncPluginStylesheets;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GncPluginClass gnc_plugin;
|
||||
} GncPluginStylesheetsClass;
|
||||
|
||||
/* function prototypes */
|
||||
GType gnc_plugin_stylesheets_get_type (void);
|
||||
|
||||
GncPlugin *gnc_plugin_stylesheets_new (void);
|
||||
|
||||
void gnc_plugin_stylesheets_create_plugin (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GNC_PLUGIN_STYLESHEETS_H */
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <config.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gnc-plugin-page-report.h>
|
||||
#include <window-report.h>
|
||||
#include <dialog-custom-report.h>
|
||||
%}
|
||||
#if defined(SWIGGUILE)
|
||||
|
||||
@@ -35,18 +35,14 @@
|
||||
#include "swig-runtime.h"
|
||||
#include "dialog-options.h"
|
||||
#include "dialog-report-column-view.h"
|
||||
#include "file-utils.h"
|
||||
#include "gnc-gkeyfile-utils.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
#include "gnc-report.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "option-util.h"
|
||||
#include "gnc-html.h"
|
||||
#include "window-report.h"
|
||||
#include "guile-mappings.h"
|
||||
|
||||
#include "gnc-plugin-page-report.h"
|
||||
#include "gnc-report.h"
|
||||
|
||||
#define WINDOW_REPORT_CM_CLASS "window-report"
|
||||
#define MDI_CHILD_CONFIG "mdi_child_config"
|
||||
@@ -257,137 +253,3 @@ gnc_report_edit_options(SCM report, GtkWindow *parent)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_html_file_stream_cb (const char *location, char ** data, int *len)
|
||||
{
|
||||
*len = gncReadFile (location, data);
|
||||
return (*len > 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_html_report_stream_cb (const char *location, char ** data, int *len)
|
||||
{
|
||||
gboolean ok;
|
||||
|
||||
ok = gnc_run_report_id_string (location, data);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
*data = g_strdup_printf ("<html><body><h3>%s</h3>"
|
||||
"<p>%s</p></body></html>",
|
||||
_("Report error"),
|
||||
_("An error occurred while running the report."));
|
||||
|
||||
/* Make sure the progress bar is finished, which will also
|
||||
make the GUI sensitive again. Easier to do this via guile
|
||||
because otherwise we would need to link against gnome-utils
|
||||
and a lot more. */
|
||||
scm_c_eval_string("(gnc:report-finished)");
|
||||
}
|
||||
|
||||
*len = strlen(*data);
|
||||
return ok;
|
||||
}
|
||||
|
||||
/* TODO: unroll start_editor */
|
||||
static gboolean
|
||||
gnc_html_options_url_cb (const char *location, const char *label,
|
||||
gboolean new_window, GNCURLResult *result)
|
||||
{
|
||||
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 = gnc_report_find(report_id);
|
||||
if (report == SCM_UNDEFINED ||
|
||||
report == SCM_BOOL_F)
|
||||
{
|
||||
result->error_message =
|
||||
g_strdup_printf (_("Badly-formed report id: %s"), location);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gnc_report_edit_options (report, GTK_WINDOW(result->parent));
|
||||
|
||||
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, GNC_MAIN_WINDOW(result->parent));
|
||||
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);
|
||||
|
||||
if (label && (*label != '\0'))
|
||||
gnc_gnome_help (location, label);
|
||||
else
|
||||
gnc_gnome_help (location, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_report_init (void)
|
||||
{
|
||||
/* Reference the report page plugin to ensure it exists in the gtk
|
||||
* type system. */
|
||||
GNC_TYPE_PLUGIN_PAGE_REPORT;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,5 @@ GtkWidget * gnc_report_window_default_params_editor(SCM options, SCM report, Gtk
|
||||
// scm-exposed; 3-liner which calls gnc_main_window_open_report after handling busy-cursor.
|
||||
void reportWindow(int id, GtkWindow *parent);
|
||||
gboolean gnc_report_edit_options(SCM report, GtkWindow *parent);
|
||||
// module[/plugin]-init
|
||||
void gnc_report_init (void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include "gnc-splash.h"
|
||||
#include "gnc-gnome-utils.h"
|
||||
#include "gnc-plugin-file-history.h"
|
||||
#include "gnc-plugin-stylesheets.h"
|
||||
#include "gnc-plugin-report-system.h"
|
||||
#include "dialog-new-user.h"
|
||||
#include "gnc-session.h"
|
||||
#include "engine-helpers-guile.h"
|
||||
@@ -631,11 +631,7 @@ inner_main (void *closure, int argc, char **argv)
|
||||
|
||||
/* Setting-up the report menu must come after the module
|
||||
loading but before the gui initializat*ion. */
|
||||
gnc_report_init ();
|
||||
scm_c_use_module("gnucash report reports");
|
||||
scm_c_use_module("gnucash report-menus");
|
||||
scm_c_eval_string("(gnc:report-menu-setup)");
|
||||
gnc_plugin_stylesheets_create_plugin();
|
||||
gnc_plugin_report_system_new();
|
||||
|
||||
/* TODO: After some more guile-extraction, this should happen even
|
||||
before booting guile. */
|
||||
|
||||
@@ -25,7 +25,7 @@ set (ui_SOURCES
|
||||
gnc-plugin-register22-ui.xml
|
||||
gnc-plugin-register2-ui.xml
|
||||
gnc-plugin-register-ui.xml
|
||||
gnc-plugin-stylesheets-ui.xml
|
||||
gnc-plugin-report-system-ui.xml
|
||||
gnc-reconcile-window-ui.xml
|
||||
gnc-sxed-to-create-window-ui.xml
|
||||
gnc-sxed-window-ui-full.xml
|
||||
|
||||
@@ -217,7 +217,7 @@
|
||||
; (gtk_accel_path "<Actions>/MenuAdditions/SampleReportwithExamplesAction" "")
|
||||
; (gtk_accel_path "<Actions>/MenuAdditions/GeneralJournalAction" "")
|
||||
; (gtk_accel_path "<Actions>/MenuAdditions/AssetBarchartAction" "")
|
||||
; (gtk_accel_path "<Actions>/gnc-plugin-stylesheets-actions/EditStyleSheetsAction" "")
|
||||
; (gtk_accel_path "<Actions>/gnc-plugin-report-system-actions/EditStyleSheetsAction" "")
|
||||
; (gtk_accel_path "<Actions>/gnc-plugin-account-tree-actions/ViewAccountTreeAction" "")
|
||||
; (gtk_accel_path "<Actions>/MainWindowActions/FileExportAction" "")
|
||||
; (gtk_accel_path "<Actions>/gnc-plugin-file-history-actions/RecentFile6Action" "")
|
||||
|
||||
@@ -91,7 +91,7 @@ gnucash/gnome/gnc-plugin-page-report.c
|
||||
gnucash/gnome/gnc-plugin-page-sx-list.c
|
||||
gnucash/gnome/gnc-plugin-register2.c
|
||||
gnucash/gnome/gnc-plugin-register.c
|
||||
gnucash/gnome/gnc-plugin-stylesheets.c
|
||||
gnucash/gnome/gnc-plugin-report-system.c
|
||||
gnucash/gnome/gnc-split-reg2.c
|
||||
gnucash/gnome/gnc-split-reg.c
|
||||
gnucash/gnome/gnucash.appdata.xml.in
|
||||
|
||||
Reference in New Issue
Block a user