28 #include <glib/gi18n.h> 32 #include "business-options-gnome.h" 33 #include "business-urls.h" 36 #include "dialog-doclink.h" 38 #include "dialog-invoice.h" 40 #include "dialog-sx-editor.h" 41 #include "dialog-transfer.h" 42 #include "dialog-totd.h" 43 #include "assistant-hierarchy.h" 45 #include "gnc-component-manager.h" 48 #include "gnc-hooks.h" 52 #include "gnc-menu-extensions.h" 57 #include "gnc-plugin-register.h" 58 #include "gnc-plugin-budget.h" 59 #include "gnc-plugin-business.h" 64 #include "gnc-report.h" 65 #include "gnc-split-reg.h" 72 #include "search-core-type.h" 73 #include "search-owner.h" 74 #include "top-level.h" 75 #include "window-report.h" 82 static QofLogModule log_module = GNC_MOD_GUI;
88 validate_type(
const char *url_type,
const char *location,
93 QofBook * book = gnc_get_current_book();
96 result->error_message = g_strdup_printf (_(
"Bad URL: %s"), location);
103 result->error_message = g_strdup_printf (_(
"Entity Not Found: %s"),
113 gnc_html_register_url_cb (
const char *location,
const char *label,
117 GNCSplitReg * gsr = NULL;
118 Split * split = NULL;
121 GncInvoice * invoice;
126 g_return_val_if_fail (location != NULL, FALSE);
127 g_return_val_if_fail (result != NULL, FALSE);
129 result->load_to_stream = FALSE;
132 if (strncmp(
"account=", location, 8) == 0)
139 else if (strncmp (
"acct-guid=", location, strlen (
"acct-guid=")) == 0)
141 if (!validate_type(
"acct-guid=", location, GNC_ID_ACCOUNT, result, &guid, &entity))
144 account = GNC_ACCOUNT(entity);
147 else if (strncmp (
"trans-guid=", location, strlen (
"trans-guid=")) == 0)
149 if (!validate_type(
"trans-guid=", location, GNC_ID_TRANS, result, &guid, &entity))
152 trans = (Transaction *) entity;
163 result->error_message =
164 g_strdup_printf (_(
"Transaction with no Accounts: %s"), location);
169 else if (strncmp (
"trans-doclink-guid=", location,
170 strlen (
"trans-doclink-guid=")) == 0)
172 if (!validate_type(
"trans-doclink-guid=", location, GNC_ID_TRANS,
173 result, &guid, &entity))
176 trans = (Transaction *) entity;
182 else if (strncmp (
"invoice-doclink-guid=", location,
183 strlen (
"invoice-doclink-guid=")) == 0)
185 if (!validate_type(
"invoice-doclink-guid=", location, GNC_ID_INVOICE,
186 result, &guid, &entity))
189 invoice = (GncInvoice *) entity;
191 gncInvoiceGetDocLink (invoice));
195 else if (strncmp (
"split-guid=", location, strlen (
"split-guid=")) == 0)
197 if (!validate_type(
"split-guid=", location, GNC_ID_SPLIT, result, &guid, &entity))
200 split = (Split *) entity;
206 result->error_message =
207 g_strdup_printf (_(
"Unsupported entity type: %s"), location);
218 if (gnc_split_reg_clear_filter_for_split (gsr, split))
221 gnc_split_reg_jump_to_split (gsr, split);
229 gnc_html_price_url_cb (
const char *location,
const char *label,
235 g_return_val_if_fail (location != NULL, FALSE);
236 g_return_val_if_fail (result != NULL, FALSE);
238 result->load_to_stream = FALSE;
241 if (strncmp (
"price-guid=", location, strlen (
"price-guid=")) == 0)
243 if (!validate_type(
"price-guid=", location, GNC_ID_PRICE, result, &guid, &entity))
246 if (!gnc_price_edit_by_guid (GTK_WIDGET (result->parent), &guid))
248 result->error_message = g_strdup_printf (_(
"No such price: %s"),
255 result->error_message = g_strdup_printf (_(
"Badly formed URL %s"),
278 gnc_restore_all_state (gpointer session, gpointer unused)
280 GKeyFile *keyfile = NULL;
281 gchar *file_guid = NULL;
282 GError *error = NULL;
291 file_data = g_key_file_to_data(keyfile, &file_length, NULL);
292 DEBUG(
"=== File Data Read===\n%s\n=== File End ===\n", file_data);
299 if (!g_key_file_has_group (keyfile, STATE_FILE_TOP))
302 LEAVE(
"no state file");
308 file_guid = g_key_file_get_string(keyfile, STATE_FILE_TOP,
309 STATE_FILE_BOOK_GUID, &error);
313 g_warning(
"error reading group %s key %s: %s",
314 STATE_FILE_TOP, STATE_FILE_BOOK_GUID, error->message);
315 LEAVE(
"no guid in state file");
329 gnc_totd_dialog_reparent ();
348 gnc_save_all_state (gpointer session, gpointer unused)
353 GKeyFile *keyfile = NULL;
361 gsize num_groups, curr;
362 gchar **groups = g_key_file_get_groups (keyfile, &num_groups);
363 for (curr=0; curr < num_groups; curr++)
365 if (g_str_has_prefix (groups[curr],
"Window ") ||
366 g_str_has_prefix (groups[curr],
"Page "))
368 DEBUG (
"Removing state group %s", groups[curr]);
369 g_key_file_remove_group (keyfile, groups[curr], NULL);
379 PERR(
"Session has no book!");
384 g_key_file_set_string(keyfile, STATE_FILE_TOP, STATE_FILE_BOOK_GUID,
394 file_data = g_key_file_to_data(keyfile, &file_length, NULL);
395 DEBUG(
"=== File Data Written===\n%s\n=== File End ===\n", file_data);
403 gnc_main_gui_init (
void)
407 if (!gnucash_style_init())
409 gnucash_color_init();
411 gnc_html_register_url_handler (URL_TYPE_REGISTER,
412 gnc_html_register_url_cb);
414 gnc_html_register_url_handler (URL_TYPE_PRICE,
415 gnc_html_price_url_cb);
418 gnc_search_core_register_type (GNC_OWNER_MODULE_NAME,
419 (GNCSearchCoreNew) gnc_search_owner_new);
420 gnc_business_urls_initialize ();
440 gnc_plugin_budget_new ());
441 gnc_ui_hierarchy_assistant_initialize();
444 gnc_hook_run(HOOK_UI_STARTUP, NULL);
446 gnc_hook_add_dangler(HOOK_BOOK_OPENED,
447 gnc_restore_all_state, NULL, NULL);
448 gnc_hook_add_dangler(HOOK_BOOK_CLOSED,
449 gnc_save_all_state, NULL, NULL);
450 gnc_hook_add_dangler(HOOK_BOOK_CLOSED,
451 (GFunc)gnc_reports_flush_global, NULL, NULL);
452 gnc_hook_add_dangler(HOOK_BOOK_OPENED,
453 (GFunc)gnc_invoice_remind_bills_due_cb, NULL, NULL);
454 gnc_hook_add_dangler(HOOK_BOOK_OPENED,
455 (GFunc)gnc_invoice_remind_invoices_due_cb, NULL, NULL);
457 gnc_ui_sx_initialize();
461 gnc_preferences_add_page(
"business-prefs.glade",
"liststore_printinvoice,days_in_adj,cust_days_in_adj,business_prefs",
GncPluginPage * gnc_plugin_page_register_new(Account *account, gboolean subaccounts)
Create a new "register" plugin page, given a pointer to an account.
Functions to load, save and get gui state.
void gnc_preferences_add_page(const gchar *filename, const gchar *widgetname, const gchar *tabname)
This function adds a full page of preferences to the preferences dialog.
void gnc_main_window_restore_all_windows(const GKeyFile *keyfile)
Restore the persistent state of all windows.
The instance data structure for a content plugin.
This file contains the functions to present a gui to the user for creating a new account or editing a...
utility functions for the GnuCash UI
QofInstance * qof_collection_lookup_entity(const QofCollection *col, const GncGUID *guid)
Find the entity going only from its guid.
#define DEBUG(format, args...)
Print a debugging message.
gboolean string_to_guid(const gchar *string, GncGUID *guid)
Given a string, replace the given guid with the parsed one unless the given value is null...
Functions that are supported by all types of windows.
GncPlugin * gnc_plugin_file_history_new(void)
Create a new file history plugin.
GKeyFile helper routines.
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_shutdown(int exit_status)
Shutdown gnucash.
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
Convenience wrapper around GdkRGBA for use in Register Gnome classes.
#define PERR(format, args...)
Log a serious error.
#define ENTER(format, args...)
Print a function entry debugging message.
GtkWindow * gnc_ui_get_gtk_window(GtkWidget *widget)
Get a pointer to the widget's immediate top level GtkWindow.
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
void gnc_main_window_save_all_windows(GKeyFile *keyfile)
Save the persistent state of all windows.
const char * xaccTransGetDocLink(const Transaction *trans)
Gets the transaction Document Link.
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
Functions for adding content to a window.
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
Functions providing a register page for the GnuCash UI.
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
Functions providing the file history menu.
Account * gnc_account_lookup_by_full_name(const Account *any_acc, const gchar *name)
The gnc_account_lookup_full_name() subroutine works like gnc_account_lookup_by_name, but uses fully-qualified names using the given separator.
GncPluginManager * gnc_plugin_manager_get(void)
Retrieve a pointer to the plugin manager.
Gnome specific utility functions.
Public declarations of GnucashRegister class.
Dialog for handling user preferences.
GncPlugin * gnc_plugin_basic_commands_new(void)
Create a new basic commands menu plugin.
All type declarations for the whole Gnucash engine.
const GncGUID * qof_entity_get_guid(gconstpointer ent)
Utility functions for file access.
API for the transaction logger.
Business Invoice Interface.
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
GncPlugin * gnc_plugin_account_tree_new(void)
Create a new account tree menu plugin.
Provide the menus to create a chart of account page.
#define LEAVE(format, args...)
Print a function exit debugging message.
Styling functions for RegisterGnome.
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
void gnc_main_window_restore_default_state(GncMainWindow *window)
Restore the persistent state of one window to a sane default.
void gnc_plugin_page_register_clear_current_filter(GncPluginPage *plugin_page)
This function clears the registers current filter.
GKeyFile * gnc_state_load(const QofSession *session)
Load the state from a state file on disk for the given session.
The type used to store guids in C.
GNCSplitReg * gnc_plugin_page_register_get_gsr(GncPluginPage *plugin_page)
Get the GNCSplitReg data structure associated with this register page.
"select" and "new" commodity windows
Functions providing a basic set of menu items.
SplitList * xaccTransGetSplitList(const Transaction *trans)
The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
void gnc_business_options_gnome_initialize(void)
Set up the business and counters pages in the File Preferences dialog.