28 #include <glib/gi18n.h>
35 #include "dialog-options.h"
36 #include "dialog-sx-editor.h"
37 #include "dialog-transfer.h"
38 #include "dialog-totd.h"
39 #include "assistant-hierarchy.h"
41 #include "gnc-component-manager.h"
44 #include "gnc-hooks.h"
47 #include "gnc-menu-extensions.h"
52 #include "gnc-plugin-register.h"
53 #include "gnc-plugin-register2.h"
54 #include "gnc-plugin-budget.h"
56 #include "gnc-plugin-page-register2.h"
60 #include "gnc-report.h"
61 #include "gnc-split-reg.h"
65 #include "gnucash-color.h"
66 #include "gnucash-sheet.h"
67 #include "gnucash-style.h"
68 #include "guile-util.h"
69 #include "top-level.h"
70 #include "window-report.h"
83 validate_type(
const char *url_type,
const char *location,
88 QofBook * book = gnc_get_current_book();
91 result->error_message = g_strdup_printf (_(
"Bad URL: %s"), location);
98 result->error_message = g_strdup_printf (_(
"Entity Not Found: %s"),
108 gnc_html_register_url_cb (
const char *location,
const char *label,
113 Split * split = NULL;
120 g_return_val_if_fail (location != NULL, FALSE);
121 g_return_val_if_fail (result != NULL, FALSE);
123 result->load_to_stream = FALSE;
126 if (strncmp(
"account=", location, 8) == 0)
133 else if (strncmp (
"acct-guid=", location, strlen (
"acct-guid=")) == 0)
135 if (!validate_type(
"acct-guid=", location, GNC_ID_ACCOUNT, result, &guid, &entity))
138 account = GNC_ACCOUNT(entity);
141 else if (strncmp (
"trans-guid=", location, strlen (
"trans-guid=")) == 0)
143 if (!validate_type(
"trans-guid=", location, GNC_ID_TRANS, result, &guid, &entity))
157 result->error_message =
158 g_strdup_printf (_(
"Transaction with no Accounts: %s"), location);
163 else if (strncmp (
"split-guid=", location, strlen (
"split-guid=")) == 0)
165 if (!validate_type(
"split-guid=", location, GNC_ID_SPLIT, result, &guid, &entity))
168 split = (
Split *) entity;
173 result->error_message =
174 g_strdup_printf (_(
"Unsupported entity type: %s"), location);
183 gnc_split_reg_jump_to_split( gsr, split );
192 gnc_html_price_url_cb (
const char *location,
const char *label,
198 g_return_val_if_fail (location != NULL, FALSE);
199 g_return_val_if_fail (result != NULL, FALSE);
201 result->load_to_stream = FALSE;
204 if (strncmp (
"price-guid=", location, strlen (
"price-guid=")) == 0)
206 if (!validate_type(
"price-guid=", location, GNC_ID_PRICE, result, &guid, &entity))
209 if (!gnc_price_edit_by_guid (NULL, &guid))
211 result->error_message = g_strdup_printf (_(
"No such price: %s"),
218 result->error_message = g_strdup_printf (_(
"Badly formed URL %s"),
241 gnc_restore_all_state (gpointer session, gpointer unused)
243 GKeyFile *keyfile = NULL;
244 gchar *file_guid = NULL;
245 GError *error = NULL;
254 file_data = g_key_file_to_data(keyfile, &file_length, NULL);
255 DEBUG(
"=== File Data Read===\n%s\n=== File End ===\n", file_data);
262 if (!g_key_file_has_group (keyfile, STATE_FILE_TOP))
265 LEAVE(
"no state file");
271 file_guid = g_key_file_get_string(keyfile, STATE_FILE_TOP,
272 STATE_FILE_BOOK_GUID, &error);
276 g_warning(
"error reading group %s key %s: %s",
277 STATE_FILE_TOP, STATE_FILE_BOOK_GUID, error->message);
278 LEAVE(
"no guid in state file");
309 gnc_save_all_state (gpointer session, gpointer unused)
314 GError *error = NULL;
315 GKeyFile *keyfile = NULL;
323 gsize num_groups, curr;
324 gchar **groups = g_key_file_get_groups (keyfile, &num_groups);
326 for (curr=0; curr < num_groups; curr++)
328 if (g_str_has_prefix (groups[curr],
"Window ") ||
329 g_str_has_prefix (groups[curr],
"Page "))
331 DEBUG (
"Removing state group %s", groups[curr]);
332 g_key_file_remove_group (keyfile, groups[curr], NULL);
342 g_key_file_set_string(keyfile, STATE_FILE_TOP, STATE_FILE_BOOK_GUID,
352 file_data = g_key_file_to_data(keyfile, &file_length, NULL);
353 DEBUG(
"=== File Data Written===\n%s\n=== File End ===\n", file_data);
361 gnc_main_gui_init (
void)
365 if (!gnucash_style_init())
367 gnucash_color_init();
369 gnc_html_register_url_handler (URL_TYPE_REGISTER,
370 gnc_html_register_url_cb);
372 gnc_html_register_url_handler (URL_TYPE_PRICE,
373 gnc_html_price_url_cb);
375 gnc_ui_sx_initialize();
394 gnc_plugin_budget_new ());
395 gnc_ui_hierarchy_assistant_initialize();
398 gnc_hook_run(HOOK_UI_STARTUP, NULL);
400 gnc_hook_add_dangler(HOOK_BOOK_OPENED,
401 gnc_restore_all_state, NULL);
402 gnc_hook_add_dangler(HOOK_BOOK_CLOSED,
403 gnc_save_all_state, NULL);
404 gnc_hook_add_dangler(HOOK_BOOK_CLOSED,
405 (GFunc)gnc_reports_flush_global, NULL);
GncPluginPage * gnc_plugin_page_register_new(Account *account, gboolean subaccounts)
Functions to load, save and get gui state.
void gnc_main_window_restore_all_windows(const GKeyFile *keyfile)
Dialog for create/edit an account.
utility functions for the GnuCash UI
QofInstance * qof_collection_lookup_entity(const QofCollection *, const GncGUID *)
#define DEBUG(format, args...)
gboolean string_to_guid(const gchar *string, GncGUID *guid)
Functions that are supported by all types of windows.
GncPlugin * gnc_plugin_file_history_new(void)
GKeyFile helper routines.
Plugin management functions for the GnuCash UI.
void gnc_plugin_manager_add_plugin(GncPluginManager *manager, GncPlugin *plugin)
void gnc_shutdown(int exit_status)
gchar * guid_to_string_buff(const GncGUID *guid, gchar *buff)
#define ENTER(format, args...)
GKeyFile * gnc_state_get_current(void)
void gnc_main_window_save_all_windows(GKeyFile *keyfile)
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Functions for adding content to a window.
QofBook * qof_session_get_book(const QofSession *session)
Functions providing a register page for the GnuCash UI.
#define GUID_ENCODING_LENGTH
Functions providing the file history menu.
Account * gnc_account_lookup_by_full_name(const Account *any_acc, const gchar *name)
The ComboCell object implements a cell handler with a "combination-box" pull-down menu in it...
GncPluginManager * gnc_plugin_manager_get(void)
Gnome specific utility functions.
GncPlugin * gnc_plugin_basic_commands_new(void)
All type declarations for the whole Gnucash engine.
const GncGUID * qof_entity_get_guid(gconstpointer)
Utility functions for file access.
API for the transaction logger.
Account * xaccSplitGetAccount(const Split *s)
GncPlugin * gnc_plugin_account_tree_new(void)
Provide the menus to create a chart of account page.
#define LEAVE(format, args...)
QofCollection * qof_book_get_collection(const QofBook *, QofIdType)
void gnc_main_window_restore_default_state(GncMainWindow *window)
GKeyFile * gnc_state_load(const QofSession *session)
GNCSplitReg * gnc_plugin_page_register_get_gsr(GncPluginPage *plugin_page)
"select" and "new" commodity windows
Functions providing a basic set of menu items.
SplitList * xaccTransGetSplitList(const Transaction *trans)
const gchar * QofLogModule