25 #include <glib/gi18n.h>
29 #include "dialog-utils.h"
30 #include "assistant-xml-encoding.h"
32 #include "gnc-component-manager.h"
38 #include "gnc-gui-query.h"
39 #include "gnc-hooks.h"
41 #include "gnc-splash.h"
49 #include "gnc-session.h"
51 #include "gnc-autosave.h"
58 static GNCShutdownCB shutdown_cb = NULL;
59 static gint save_in_progress = 0;
78 gnc_file_dialog (
const char * title,
80 const char * starting_dir,
81 GNCFileDialogType type
85 const char *internal_name;
86 char *file_name = NULL;
87 gchar * okbutton = GTK_STOCK_OPEN;
88 const gchar *ok_icon = NULL;
89 GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
96 case GNC_FILE_DIALOG_OPEN:
97 action = GTK_FILE_CHOOSER_ACTION_OPEN;
98 okbutton = GTK_STOCK_OPEN;
102 case GNC_FILE_DIALOG_IMPORT:
103 action = GTK_FILE_CHOOSER_ACTION_OPEN;
104 okbutton = _(
"_Import");
108 case GNC_FILE_DIALOG_SAVE:
109 action = GTK_FILE_CHOOSER_ACTION_SAVE;
110 okbutton = GTK_STOCK_SAVE;
114 case GNC_FILE_DIALOG_EXPORT:
115 action = GTK_FILE_CHOOSER_ACTION_SAVE;
116 okbutton = _(
"_Export");
117 ok_icon = GTK_STOCK_CONVERT;
124 file_box = gtk_file_chooser_dialog_new(
128 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
131 gnc_gtk_dialog_add_button(file_box, okbutton, ok_icon, GTK_RESPONSE_ACCEPT);
133 gtk_dialog_add_button(GTK_DIALOG(file_box),
134 okbutton, GTK_RESPONSE_ACCEPT);
137 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (file_box),
140 gtk_window_set_modal(GTK_WINDOW(file_box), TRUE);
149 GtkFileFilter* all_filter = gtk_file_filter_new();
151 for (filter = filters; filter; filter = filter->next)
153 g_return_val_if_fail(GTK_IS_FILE_FILTER(filter->data), NULL);
154 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_box),
155 GTK_FILE_FILTER (filter->data));
158 gtk_file_filter_set_name (all_filter, _(
"All files"));
159 gtk_file_filter_add_pattern (all_filter,
"*");
160 gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_box), all_filter);
166 gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (file_box),
167 GTK_FILE_FILTER (filters->data));
168 g_list_free (filters);
171 response = gtk_dialog_run(GTK_DIALOG(file_box));
173 if (response == GTK_RESPONSE_ACCEPT)
176 internal_name = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER (file_box));
177 if (strstr (internal_name,
"file://") == internal_name)
180 internal_name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (file_box));
182 file_name = g_strdup(internal_name);
184 gtk_widget_destroy(GTK_WIDGET(file_box));
185 LEAVE(
"%s", file_name ? file_name :
"(null)");
193 GNCFileDialogType type)
197 gboolean uh_oh = TRUE;
198 const char *fmt, *label;
204 displayname = g_strdup(_(
"(null)"));
209 displayname = g_strdup (newfile);
213 case ERR_BACKEND_NO_ERR:
218 fmt = _(
"No suitable backend was found for %s.");
219 gnc_error_dialog(parent, fmt, displayname);
223 fmt = _(
"The URL %s is not supported by this version of GnuCash.");
224 gnc_error_dialog (parent, fmt, displayname);
228 fmt = _(
"Can't parse the URL %s.");
229 gnc_error_dialog (parent, fmt, displayname);
233 fmt = _(
"Can't connect to %s. "
234 "The host, username or password were incorrect.");
235 gnc_error_dialog (parent, fmt, displayname);
239 fmt = _(
"Can't connect to %s. "
240 "Connection was lost, unable to send data.");
241 gnc_error_dialog (parent, fmt, displayname);
245 fmt = _(
"This file/URL appears to be from a newer version "
246 "of GnuCash. You must upgrade your version of GnuCash "
247 "to work with this data.");
248 gnc_error_dialog (parent,
"%s", fmt);
252 fmt = _(
"The database %s doesn't seem to exist. "
253 "Do you want to create it?");
254 if (gnc_verify_dialog (parent, TRUE, fmt, displayname))
263 case GNC_FILE_DIALOG_OPEN:
265 label = GTK_STOCK_OPEN;
266 fmt = _(
"GnuCash could not obtain the lock for %s. "
267 "That database may be in use by another user, "
268 "in which case you should not open the database. "
269 "Do you want to proceed with opening the database?");
272 case GNC_FILE_DIALOG_IMPORT:
274 fmt = _(
"GnuCash could not obtain the lock for %s. "
275 "That database may be in use by another user, "
276 "in which case you should not import the database. "
277 "Do you want to proceed with importing the database?");
280 case GNC_FILE_DIALOG_SAVE:
281 label = GTK_STOCK_SAVE;
282 fmt = _(
"GnuCash could not obtain the lock for %s. "
283 "That database may be in use by another user, "
284 "in which case you should not save the database. "
285 "Do you want to proceed with saving the database?");
288 case GNC_FILE_DIALOG_EXPORT:
290 fmt = _(
"GnuCash could not obtain the lock for %s. "
291 "That database may be in use by another user, "
292 "in which case you should not export the database. "
293 "Do you want to proceed with exporting the database?");
297 dialog = gtk_message_dialog_new(GTK_WINDOW(parent),
298 GTK_DIALOG_DESTROY_WITH_PARENT,
299 GTK_MESSAGE_QUESTION,
303 gtk_dialog_add_buttons(GTK_DIALOG(dialog),
304 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
305 label, GTK_RESPONSE_YES,
308 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE);
309 response = gtk_dialog_run(GTK_DIALOG(dialog));
310 gtk_widget_destroy(dialog);
311 uh_oh = (response != GTK_RESPONSE_YES);
315 fmt = _(
"GnuCash could not write to %s. "
316 "That database may be on a read-only file system, "
317 "or you may not have write permission for the directory.");
318 gnc_error_dialog (parent, fmt, displayname);
322 fmt = _(
"The file/URL %s "
323 "does not contain GnuCash data or the data is corrupt.");
324 gnc_error_dialog (parent, fmt, displayname);
328 fmt = _(
"The server at URL %s "
329 "experienced an error or encountered bad or corrupt data.");
330 gnc_error_dialog (parent, fmt, displayname);
334 fmt = _(
"You do not have permission to access %s.");
335 gnc_error_dialog (parent, fmt, displayname);
339 fmt = _(
"An error occurred while processing %s.");
340 gnc_error_dialog (parent, fmt, displayname);
344 fmt = _(
"There was an error reading the file. "
345 "Do you want to continue?");
346 if (gnc_verify_dialog (parent, TRUE,
"%s", fmt))
353 fmt = _(
"There was an error parsing the file %s.");
354 gnc_error_dialog (parent, fmt, displayname);
358 fmt = _(
"The file %s is empty.");
359 gnc_error_dialog (parent, fmt, displayname);
363 if (type == GNC_FILE_DIALOG_SAVE)
369 fmt = _(
"The file %s could not be found.");
370 gnc_error_dialog (parent, fmt, displayname);
375 fmt = _(
"This file is from an older version of GnuCash. "
376 "Do you want to continue?");
377 if (gnc_verify_dialog (parent, TRUE,
"%s", fmt))
384 fmt = _(
"The file type of file %s is unknown.");
385 gnc_error_dialog(parent, fmt, displayname);
389 fmt = _(
"Could not make a backup of the file %s");
390 gnc_error_dialog(parent, fmt, displayname);
394 fmt = _(
"Could not write to file %s. Check that you have "
395 "permission to write to this file and that "
396 "there is sufficient space to create it.");
397 gnc_error_dialog(parent, fmt, displayname);
401 fmt = _(
"No read permission to read from file %s.");
402 gnc_error_dialog (parent, fmt, displayname);
409 fmt = _(
"You attempted to save in\n%s\nor a subdirectory thereof. "
410 "This is not allowed as %s reserves that directory for internal use.\n\n"
411 "Please try again in a different directory.");
416 fmt = _(
"This database is from an older version of GnuCash. "
417 "Select OK to upgrade it to the current version, Cancel "
418 "to mark it read-only.");
420 response = gnc_ok_cancel_dialog(parent, GTK_RESPONSE_CANCEL,
"%s", fmt);
421 uh_oh = (response == GTK_RESPONSE_CANCEL);
425 fmt = _(
"This database is from a newer version of GnuCash. "
426 "This version can read it, but cannot safely save to it. "
427 "It will be marked read-only until you do File>Save As, "
428 "but data may be lost in writing to the old version.");
429 gnc_warning_dialog (parent,
"%s", fmt);
434 fmt = _(
"The SQL database is in use by other users, "
435 "and the upgrade cannot be performed until they logoff. "
436 "If there are currently no other users, consult the "
437 "documentation to learn how to clear out dangling login "
439 gnc_error_dialog (parent,
"%s", fmt);
444 fmt = _(
"The library \"libdbi\" installed on your system doesn't correctly "
445 "store large numbers. This means GnuCash cannot use SQL databases "
446 "correctly. Gnucash will not open or save to SQL databases until this is "
447 "fixed by installing a different version of \"libdbi\". Please see "
448 "https://bugzilla.gnome.org/show_bug.cgi?id=611936 for more "
451 gnc_error_dialog (parent,
"%s", fmt);
456 fmt = _(
"GnuCash could not complete a critical test for the presence of "
457 "a bug in the \"libdbi\" library. This may be caused by a "
458 "permissions misconfiguration of your SQL database. Please see "
459 "https://bugzilla.gnome.org/show_bug.cgi?id=645216 for more "
462 gnc_error_dialog (parent,
"%s", fmt);
466 fmt = _(
"This file is from an older version of GnuCash and will be "
467 "upgraded when saved by this version. You will not be able "
468 "to read the saved file from the older version of Gnucash "
469 "(it will report an \"error parsing the file\"). If you wish "
470 "to preserve the old version, exit without saving.");
471 gnc_warning_dialog (parent,
"%s", fmt);
476 PERR(
"FIXME: Unhandled error %d", io_error);
477 fmt = _(
"An unknown I/O error (%d) occurred.");
478 gnc_error_dialog (parent, fmt, io_error);
482 g_free (displayname);
492 if (!session)
return;
494 url = qof_session_get_url ( session );
507 gnc_book_opened (
void)
509 gnc_hook_run(HOOK_BOOK_OPENED, gnc_get_current_session());
519 if (!gnc_file_query_save (TRUE))
522 if (gnc_current_session_exist())
524 session = gnc_get_current_session ();
531 gnc_hook_run(HOOK_BOOK_CLOSED, session);
533 gnc_close_gui_component_by_session (session);
535 gnc_clear_current_session();
540 gnc_get_current_session ();
542 gnc_hook_run(HOOK_NEW_BOOK, NULL);
544 gnc_gui_refresh_all ();
551 gnc_file_query_save (gboolean can_cancel)
556 if (!gnc_current_session_exist())
561 gnc_autosave_remove_timer(current_book);
573 const char *title = _(
"Save changes to the file?");
578 dialog = gtk_message_dialog_new(GTK_WINDOW(parent),
579 GTK_DIALOG_DESTROY_WITH_PARENT,
580 GTK_MESSAGE_QUESTION,
584 minutes = (
gnc_time (NULL) - oldest_change) / 60 + 1;
585 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
586 ngettext(
"If you don't save, changes from the past %d minute will be discarded.",
587 "If you don't save, changes from the past %d minutes will be discarded.",
589 gtk_dialog_add_button(GTK_DIALOG(dialog),
590 _(
"Continue _Without Saving"), GTK_RESPONSE_OK);
593 gtk_dialog_add_button(GTK_DIALOG(dialog),
594 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
595 gtk_dialog_add_button(GTK_DIALOG(dialog),
596 GTK_STOCK_SAVE, GTK_RESPONSE_YES);
598 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_YES);
600 response = gtk_dialog_run(GTK_DIALOG(dialog));
601 gtk_widget_destroy(dialog);
605 case GTK_RESPONSE_YES:
610 case GTK_RESPONSE_CANCEL:
617 case GTK_RESPONSE_OK:
628 #define RESPONSE_NEW 1
629 #define RESPONSE_OPEN 2
630 #define RESPONSE_QUIT 3
631 #define RESPONSE_READONLY 4
634 gnc_post_file_open (
const char * filename, gboolean is_readonly)
638 GList *invalid_account_names;
639 gboolean uh_oh = FALSE;
643 gchar *protocol = NULL;
644 gchar *hostname = NULL;
645 gchar *username = NULL;
646 gchar *password = NULL;
651 ENTER(
"filename %s", filename);
653 if (!filename || (*filename ==
'\0'))
return FALSE;
661 GNC_FILE_DIALOG_OPEN);
666 &port, &username, &password, &path);
676 gboolean have_valid_pw = FALSE;
678 path, &username, &password );
685 username, password, path);
691 gchar *default_dir = g_path_get_dirname(path);
692 gnc_set_default_directory (GNC_PREFS_GROUP_OPEN_SAVE, default_dir);
702 gnc_set_busy_cursor (NULL, TRUE);
706 if (gnc_current_session_exist())
708 current_session = gnc_get_current_session();
710 gnc_hook_run(HOOK_BOOK_CLOSED, current_session);
711 gnc_close_gui_component_by_session (current_session);
713 gnc_clear_current_session();
718 new_session = qof_session_new ();
727 show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN);
728 io_err = ERR_BACKEND_NO_ERR;
729 if (g_file_test (filename, G_FILE_TEST_IS_DIR))
730 directory = g_strdup (filename);
732 directory = gnc_get_default_directory (GNC_PREFS_GROUP_OPEN_SAVE);
734 filename = gnc_file_dialog (NULL, NULL, directory,
735 GNC_FILE_DIALOG_OPEN);
736 qof_session_destroy (new_session);
745 gchar *displayname = NULL;
747 char *fmt1 = _(
"GnuCash could not obtain the lock for %s.");
749 _(
"That database may be in use by another user, "
750 "in which case you should not open the database. "
751 "What would you like to do?") :
752 _(
"That database may be on a read-only file system, "
753 "or you may not have write permission for the directory. "
754 "If you proceed you may not be able to save any changes. "
755 "What would you like to do?")
762 displayname = g_strdup (newfile);
767 gnc_destroy_splash_screen();
769 dialog = gtk_message_dialog_new(NULL,
774 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
776 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE);
778 gnc_gtk_dialog_add_button(dialog, _(
"_Open Read-Only"),
779 GTK_STOCK_REVERT_TO_SAVED, RESPONSE_READONLY);
780 gnc_gtk_dialog_add_button(dialog, _(
"_Create New File"),
781 GTK_STOCK_NEW, RESPONSE_NEW);
782 gnc_gtk_dialog_add_button(dialog, _(
"Open _Anyway"),
783 GTK_STOCK_OPEN, RESPONSE_OPEN);
785 gtk_dialog_add_button(GTK_DIALOG(dialog),
786 GTK_STOCK_QUIT, RESPONSE_QUIT);
787 rc = gtk_dialog_run(GTK_DIALOG(dialog));
788 gtk_widget_destroy(dialog);
789 g_free (displayname);
791 if (rc == GTK_RESPONSE_DELETE_EVENT)
793 rc = shutdown_cb ? RESPONSE_QUIT : RESPONSE_NEW;
802 case RESPONSE_READONLY:
806 gnc_show_splash_screen();
813 gnc_show_splash_screen();
829 if (FALSE == show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN))
851 uh_oh = show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN);
863 path, username, password );
866 gnc_window_show_progress(_(
"Loading user data..."), 0.0);
867 qof_session_load (new_session, gnc_window_show_progress);
868 gnc_window_show_progress(NULL, -1.0);
883 if (gnc_xml_convert_single_file (newfile))
886 gnc_window_show_progress(_(
"Loading user data..."), 0.0);
887 qof_session_load (new_session, gnc_window_show_progress);
888 gnc_window_show_progress(NULL, -1.0);
898 uh_oh = show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN);
902 gnc_window_show_progress(_(
"Re-saving user data..."), 0.0);
905 uh_oh = show_session_error(io_err, newfile, GNC_FILE_DIALOG_SAVE);
918 if (uh_oh) new_root = NULL;
922 if (!uh_oh && !new_root)
925 GNC_FILE_DIALOG_OPEN);
950 gnc_unset_busy_cursor (NULL);
956 qof_session_destroy (new_session);
965 gnc_get_current_session ();
970 gnc_gui_refresh_all ();
977 gnc_set_current_session(new_session);
982 gnc_add_history (new_session);
987 gnc_gui_refresh_all ();
994 new_book = gnc_get_current_book();
997 if ( invalid_account_names )
1000 invalid_account_names );
1001 gnc_warning_dialog(NULL,
"%s", message);
1015 gnc_file_open (
void)
1017 const gchar * newfile;
1019 gchar *default_dir = NULL;
1022 if (!gnc_file_query_save (TRUE))
1028 default_dir = g_path_get_dirname( filepath );
1029 g_free ( filepath );
1032 default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_OPEN_SAVE);
1034 newfile = gnc_file_dialog (_(
"Open"), NULL, default_dir, GNC_FILE_DIALOG_OPEN);
1036 g_free ( default_dir );
1038 result = gnc_post_file_open ( newfile, FALSE );
1044 gnc_get_current_session ();
1050 gnc_file_open_file (
const char * newfile, gboolean open_readonly)
1052 if (!newfile)
return FALSE;
1054 if (!gnc_file_query_save (TRUE))
1057 return gnc_post_file_open (newfile, open_readonly);
1065 gnc_file_export (
void)
1067 const char *filename;
1068 char *default_dir = NULL;
1077 default_dir = g_path_get_dirname( filepath );
1078 g_free ( filepath );
1081 default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_EXPORT);
1083 filename = gnc_file_dialog (_(
"Save"), NULL, default_dir,
1084 GNC_FILE_DIALOG_SAVE);
1086 g_free ( default_dir );
1087 if (!filename)
return;
1089 gnc_file_do_export( filename );
1095 gnc_file_do_export(
const char * filename)
1102 const gchar *oldfile;
1104 gchar *protocol = NULL;
1105 gchar *hostname = NULL;
1106 gchar *username = NULL;
1107 gchar *password = NULL;
1119 GNC_FILE_DIALOG_EXPORT);
1126 &port, &username, &password, &path);
1131 if (g_strcmp0 (protocol,
"file") == 0)
1134 protocol = g_strdup (
"xml");
1136 username, password, path);
1138 newfile = norm_file;
1145 gchar *default_dir = g_path_get_dirname(path);
1146 gnc_set_default_directory (GNC_PREFS_GROUP_OPEN_SAVE, default_dir);
1147 g_free(default_dir);
1162 current_session = gnc_get_current_session ();
1163 oldfile = qof_session_get_url(current_session);
1164 if (oldfile && (strcmp(oldfile, newfile) == 0))
1168 GNC_FILE_DIALOG_EXPORT);
1176 new_session = qof_session_new ();
1183 const char *format = _(
"The file %s already exists. "
1184 "Are you sure you want to overwrite it?");
1192 if (!gnc_verify_dialog (NULL, FALSE, format, name))
1201 if (FALSE == show_session_error (io_err, newfile, GNC_FILE_DIALOG_EXPORT))
1211 gnc_set_busy_cursor (NULL, TRUE);
1212 gnc_window_show_progress(_(
"Exporting file..."), 0.0);
1213 ok = qof_session_export (new_session, current_session,
1214 gnc_window_show_progress);
1215 gnc_window_show_progress(NULL, -1.0);
1216 gnc_unset_busy_cursor (NULL);
1218 qof_session_destroy (new_session);
1225 const char *format = _(
"There was an error saving the file.\n\n%s");
1227 gnc_error_dialog (NULL, format, strerror(errno));
1232 static gboolean been_here_before = FALSE;
1235 gnc_file_save (
void)
1238 const char * newfile;
1245 session = gnc_get_current_session ();
1247 if (!qof_session_get_url(session))
1249 gnc_file_save_as ();
1256 GTK_RESPONSE_CANCEL,
1257 _(
"The database was opened read-only. "
1258 "Do you want to save it to a different place?"));
1259 if (response == GTK_RESPONSE_OK)
1261 gnc_file_save_as ();
1268 gnc_set_busy_cursor (NULL, TRUE);
1269 gnc_window_show_progress(_(
"Writing file..."), 0.0);
1271 gnc_window_show_progress(NULL, -1.0);
1272 gnc_unset_busy_cursor (NULL);
1278 if (ERR_BACKEND_NO_ERR != io_err)
1280 newfile = qof_session_get_url(session);
1281 show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE);
1283 if (been_here_before)
return;
1284 been_here_before = TRUE;
1285 gnc_file_save_as ();
1286 been_here_before = FALSE;
1291 gnc_add_history (session);
1292 gnc_hook_run(HOOK_BOOK_SAVED, session);
1301 gnc_file_save_as (
void)
1303 const gchar *filename;
1304 gchar *default_dir = NULL;
1313 default_dir = g_path_get_dirname( filepath );
1314 g_free ( filepath );
1317 default_dir = gnc_get_default_directory(GNC_PREFS_GROUP_OPEN_SAVE);
1319 filename = gnc_file_dialog (_(
"Save"), NULL, default_dir,
1320 GNC_FILE_DIALOG_SAVE);
1322 g_free ( default_dir );
1323 if (!filename)
return;
1325 gnc_file_do_save_as( filename );
1331 gnc_file_do_save_as (
const char* filename)
1337 const gchar *oldfile;
1339 gchar *protocol = NULL;
1340 gchar *hostname = NULL;
1341 gchar *username = NULL;
1342 gchar *password = NULL;
1357 GNC_FILE_DIALOG_SAVE);
1364 &port, &username, &password, &path);
1369 if (g_strcmp0 (protocol,
"file") == 0)
1372 protocol = g_strdup (
"xml");
1374 username, password, path);
1376 newfile = norm_file;
1383 gchar *default_dir = g_path_get_dirname(path);
1384 gnc_set_default_directory (GNC_PREFS_GROUP_OPEN_SAVE, default_dir);
1385 g_free(default_dir);
1400 session = gnc_get_current_session ();
1401 oldfile = qof_session_get_url(session);
1402 if (oldfile && (strcmp(oldfile, newfile) == 0))
1416 new_session = qof_session_new ();
1424 const char *format = _(
"The file %s already exists. "
1425 "Are you sure you want to overwrite it?");
1434 if (!gnc_verify_dialog (NULL, FALSE, format, name ))
1437 qof_session_destroy (new_session);
1448 if (FALSE == show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE))
1460 if (FALSE == show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE))
1472 if (ERR_BACKEND_NO_ERR != io_err)
1474 show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE);
1476 qof_session_destroy (new_session);
1488 path, username, password );
1508 gnc_set_busy_cursor (NULL, TRUE);
1509 gnc_window_show_progress(_(
"Writing file..."), 0.0);
1511 gnc_window_show_progress(NULL, -1.0);
1512 gnc_unset_busy_cursor (NULL);
1515 if ( ERR_BACKEND_NO_ERR != io_err )
1520 show_session_error (io_err, newfile, GNC_FILE_DIALOG_SAVE);
1523 qof_session_destroy( new_session );
1531 gnc_clear_current_session();
1532 gnc_set_current_session( new_session );
1537 gnc_add_history (new_session);
1538 gnc_hook_run(HOOK_BOOK_SAVED, new_session);
1549 gnc_file_quit (
void)
1553 gnc_set_busy_cursor (NULL, TRUE);
1554 session = gnc_get_current_session ();
1561 gnc_hook_run(HOOK_BOOK_CLOSED, session);
1562 gnc_close_gui_component_by_session (session);
1564 gnc_clear_current_session();
1567 gnc_unset_busy_cursor (NULL);
1571 gnc_file_set_shutdown_callback (GNCShutdownCB cb)
1577 gnc_file_save_in_progress (
void)
1579 QofSession *session = gnc_get_current_session();
Functions to load, save and get gui state.
void qof_session_save(QofSession *session, QofPercentageFunc percentage_func)
gboolean qof_session_save_in_progress(const QofSession *session)
Functions to save and retrieve passwords.
gboolean gnc_uri_is_file_protocol(const gchar *protocol)
gboolean gnc_uri_is_file_uri(const gchar *uri)
utility functions for the GnuCash UI
void gnc_state_save(const QofSession *session)
QofBackendError
The errors that can be reported to the GUI & other front-end users.
time64 qof_book_get_session_dirty_time(const QofBook *book)
void qof_session_safe_save(QofSession *session, QofPercentageFunc percentage_func)
void xaccLogDisable(void)
#define DEBUG(format, args...)
Functions that are supported by all types of windows.
gchar * gnc_uri_get_path(const gchar *uri)
GList * gnc_account_list_name_violations(QofBook *book, const gchar *separator)
void qof_book_mark_readonly(QofBook *book)
#define PERR(format, args...)
#define ENTER(format, args...)
QofBook * qof_session_get_book(const QofSession *session)
void gnc_history_add_file(const char *newfile)
Account handling public routines.
char * gnc_history_get_last(void)
gchar * gnc_uri_normalize_uri(const gchar *uri, gboolean allow_password)
gchar * gnc_account_name_violations_errmsg(const gchar *separator, GList *invalid_account_names)
void qof_session_call_close_hooks(QofSession *session)
Functions providing the file history menu.
QofBackendError qof_session_pop_error(QofSession *session)
void gnc_uri_get_components(const gchar *uri, gchar **protocol, gchar **hostname, gint32 *port, gchar **username, gchar **password, gchar **path)
void gnc_keyring_set_password(const gchar *access_method, const gchar *server, guint32 port, const gchar *service, const gchar *user, const gchar *password)
QofBackendError qof_session_get_error(QofSession *session)
gchar * gnc_features_test_unknown(QofBook *book)
void qof_session_swap_data(QofSession *session_1, QofSession *session_2)
gboolean qof_book_session_not_saved(const QofBook *book)
All type declarations for the whole Gnucash engine.
gchar * gnc_uri_add_extension(const gchar *uri, const gchar *extension)
gboolean gnc_keyring_get_password(GtkWidget *parent, const gchar *access_method, const gchar *server, guint32 port, const gchar *service, gchar **user, gchar **password)
API for the transaction logger.
void qof_session_begin(QofSession *session, const char *book_id, gboolean ignore_lock, gboolean create, gboolean force)
gboolean qof_book_is_readonly(const QofBook *book)
gchar * gnc_uri_create_uri(const gchar *protocol, const gchar *hostname, gint32 port, const gchar *username, const gchar *password, const gchar *path)
void qof_event_suspend(void)
Suspend all engine events.
void qof_event_resume(void)
void qof_session_ensure_all_data_loaded(QofSession *session)
#define LEAVE(format, args...)
time64 gnc_time(time64 *tbuf)
get the current local time
const gchar * gnc_dotgnucash_dir(void)
Ensure that the user's configuration directory exists and is minimally populated. ...
Utility functions for convert uri in separate components and back.
GtkWidget * gnc_ui_get_toplevel(void)
File path resolution utility functions.
Commodity handling public routines.
const gchar * QofLogModule
const gchar * gnc_get_account_separator_string(void)
Utility functions for file access.