26 #include <glib/gi18n.h> 28 #include "dialog-report-style-sheet.h" 32 #include "gnc-guile-utils.h" 34 #include "gnc-plugin-report-system.h" 36 #include "gnc-report.h" 38 #include "window-report.h" 40 static void gnc_plugin_report_system_finalize (GObject *
object);
44 static void gnc_plugin_report_system_cmd_edit_style_sheet (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
47 #define PLUGIN_ACTIONS_NAME "gnc-plugin-report-system-actions" 48 #define PLUGIN_UI_FILENAME "gnc-plugin-report-system.ui" 50 static GActionEntry gnc_plugin_actions [] =
52 {
"EditStyleSheetsAction", gnc_plugin_report_system_cmd_edit_style_sheet, NULL, NULL, NULL },
55 static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
58 static const gchar *gnc_plugin_load_ui_items [] =
69 G_DEFINE_TYPE(GncPluginReportSystem, gnc_plugin_report_system, GNC_TYPE_PLUGIN)
76 gnc_plugin_report_system_class_init (GncPluginReportSystemClass *klass)
78 GObjectClass *object_class = G_OBJECT_CLASS (klass);
79 GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
81 object_class->finalize = gnc_plugin_report_system_finalize;
84 plugin_class->plugin_name = GNC_PLUGIN_REPORT_SYSTEM_NAME;
88 plugin_class->actions = gnc_plugin_actions;
89 plugin_class->n_actions = gnc_plugin_n_actions;
91 plugin_class->ui_updates = gnc_plugin_load_ui_items;
95 gnc_plugin_report_system_init (GncPluginReportSystem *plugin)
100 gnc_plugin_report_system_finalize (GObject *
object)
102 g_return_if_fail (GNC_IS_PLUGIN_REPORT_SYSTEM (
object));
104 G_OBJECT_CLASS (gnc_plugin_report_system_parent_class)->finalize (
object);
112 gnc_plugin_report_system_cmd_edit_style_sheet (GSimpleAction *simple,
117 gnc_style_sheet_dialog_open (GTK_WINDOW(data->window));
125 gnc_report_system_file_stream_cb (
const char *location,
char ** data,
int *len)
132 gnc_report_system_report_stream_cb (
const char *location,
char ** data,
int *len)
134 gchar *captured_str = NULL;
136 gnc_run_report_id_string_with_error_handling (location, data,
141 *data = g_markup_printf_escaped (
"<html><body><h3>%s</h3>" 142 "<p>%s</p><pre>%s</pre></body></html>",
144 _(
"An error occurred while running the report."),
147 g_free(captured_str);
153 scm_c_eval_string(
"(gnc:report-finished)");
156 *len = strlen(*data);
162 gnc_report_system_options_url_cb (
const char *location,
const char *label,
168 g_return_val_if_fail (location != NULL, FALSE);
169 g_return_val_if_fail (result != NULL, FALSE);
171 result->load_to_stream = FALSE;
174 if (strncmp (
"report-id=", location, 10) == 0)
176 if (sscanf (location + 10,
"%d", &report_id) != 1)
178 result->error_message =
179 g_strdup_printf (_(
"Badly formed options URL: %s"), location);
184 report = gnc_report_find(report_id);
185 if (report == SCM_UNDEFINED ||
186 report == SCM_BOOL_F)
188 result->error_message =
189 g_strdup_printf (_(
"Badly-formed report id: %s"), location);
194 gnc_report_edit_options (report, GTK_WINDOW(result->parent));
200 result->error_message =
201 g_strdup_printf (_(
"Badly formed options URL: %s"), location);
208 gnc_report_system_report_url_cb (
const char *location,
const char *label,
211 g_return_val_if_fail (location != NULL, FALSE);
212 g_return_val_if_fail (result != NULL, FALSE);
219 url = gnc_build_url (URL_TYPE_REPORT, location, label);
220 gnc_main_window_open_report_url (url, GNC_MAIN_WINDOW(result->parent));
223 result->load_to_stream = FALSE;
227 result->load_to_stream = TRUE;
234 gnc_report_system_help_url_cb (
const char *location,
const char *label,
237 g_return_val_if_fail (location != NULL, FALSE);
239 if (label && (*label !=
'\0'))
252 gnc_plugin_report_system_new (
void)
258 GNC_TYPE_PLUGIN_PAGE_REPORT;
261 gnc_html_register_stream_handler (URL_TYPE_HELP, gnc_report_system_file_stream_cb);
262 gnc_html_register_stream_handler (URL_TYPE_FILE, gnc_report_system_file_stream_cb);
263 gnc_html_register_stream_handler (URL_TYPE_REPORT, gnc_report_system_report_stream_cb);
265 gnc_html_register_url_handler (URL_TYPE_OPTIONS, gnc_report_system_options_url_cb);
266 gnc_html_register_url_handler (URL_TYPE_REPORT, gnc_report_system_report_url_cb);
267 gnc_html_register_url_handler (URL_TYPE_HELP, gnc_report_system_help_url_cb);
269 scm_c_use_module(
"gnucash reports");
270 scm_c_use_module(
"gnucash report-menus");
271 scm_c_eval_string(
"(gnc:report-menu-setup)");
273 plugin = GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_REPORT_SYSTEM, NULL));
Plugin management functions for the GnuCash UI.
void gnc_plugin_manager_add_plugin(GncPluginManager *manager, GncPlugin *plugin)
Add a plugin to the list maintained by the plugin manager.
void gnc_gnome_help(GtkWindow *parent, const char *file_name, const char *anchor)
Launch the systems default help browser, gnome's yelp for linux, and open to a given link within a gi...
GncPluginManager * gnc_plugin_manager_get(void)
Retrieve a pointer to the plugin manager.
Gnome specific utility functions.
All type declarations for the whole Gnucash engine.
Utility functions for file access.
#define PLUGIN_ACTIONS_NAME
The label given to the main window for this plugin.
#define PLUGIN_UI_FILENAME
The name of the UI description file for this plugin.
int gncReadFile(const char *filename, char **data)
Reads the contents of a file into a buffer for further processing.