[Gnucash-changes] Move files from the app-file and gnome
directories to the gnome-utils
David Hampton
hampton at cvs.gnucash.org
Mon Jul 18 23:52:57 EDT 2005
Log Message:
-----------
Move files from the app-file and gnome directories to the gnome-utils
directory. This commit collapses ten files down to five.
Tags:
----
gnucash-gnome2-dev
Modified Files:
--------------
gnucash/src/gnome:
Makefile.am
gnucash/src/gnome-utils:
Makefile.am
gw-gnome-utils-spec.scm
Added Files:
-----------
gnucash/src/gnome-utils:
gnc-file.c
gnc-file.h
gnc-plugin-file-history.c
gnc-plugin-file-history.h
gnucash/src/gnome-utils/schemas:
Makefile.am
apps_gnucash_history.schemas
Removed Files:
-------------
gnucash/src/app-file:
Makefile.am
gnc-file-dialog.h
gnc-file-history.c
gnc-file-history.h
gnc-file-p.h
gnc-file.c
gnc-file.h
gw-app-file-spec.scm
gnucash/src/app-file/gnome:
Makefile.am
gnc-file-dialog.c
gnucash/src/app-file/schemas:
Makefile.am
apps_gnucash_history.schemas
gnucash/src/gnome:
gnc-plugin-file-history.c
gnc-plugin-file-history.h
Revision Data
-------------
--- src/app-file/gw-app-file-spec.scm
+++ /dev/null
@@ -1,62 +0,0 @@
-(define-module (g-wrapped gw-app-file-spec))
-(debug-set! maxdepth 100000)
-(debug-set! stack 2000000)
-
-(use-modules (g-wrap))
-
-(use-modules (g-wrap gw-standard-spec))
-(use-modules (g-wrap gw-glib-spec))
-
-(use-modules (g-wrapped gw-engine-spec))
-
-(let ((ws (gw:new-wrapset "gw-app-file")))
-
- (gw:wrapset-depends-on ws "gw-standard")
- (gw:wrapset-depends-on ws "gw-glib")
-
- (gw:wrapset-depends-on ws "gw-engine")
-
- (gw:wrapset-set-guile-module! ws '(g-wrapped gw-app-file))
-
- (gw:wrapset-add-cs-declarations!
- ws
- (lambda (wrapset client-wrapset)
- (list
- "#include <gnc-file.h>\n"
- "#include <gnc-file-history.h>\n"
- "#include <gnc-file-dialog.h>\n")))
-
- (gw:wrap-function
- ws
- 'gnc:file-query-save
- '<gw:bool>
- "gnc_file_query_save"
- '()
- "Query the user whether to save the current file, and save
-if they say 'Yes'. The return is false if the user says 'Cancel'.")
-
- (gw:wrap-function
- ws
- 'gnc:file-quit
- '<gw:void>
- "gnc_file_quit"
- '()
- "Stop working with the current file.")
-
- (gw:wrap-function
- ws
- 'gnc:file-open-file
- '<gw:bool>
- "gnc_file_open_file"
- '(((<gw:mchars> caller-owned const) filename))
- "Open filename.")
-
- (gw:wrap-function
- ws
- 'gnc:history-get-last
- '(<gw:mchars> callee-owned)
- "gnc_history_get_last"
- '()
- "Get the last file opened by the user.")
-
- )
--- src/app-file/gnc-file.c
+++ /dev/null
@@ -1,971 +0,0 @@
-/********************************************************************\
- * FileDialog.c -- file-handling utility dialogs for gnucash. *
- * *
- * Copyright (C) 1997 Robin D. Clark *
- * Copyright (C) 1998, 1999, 2000 Linas Vepstas *
- * *
- * 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, write to the Free Software *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
-\********************************************************************/
-
-#include "config.h"
-
-#include <errno.h>
-#include <glib.h>
-#include <libguile.h>
-#include <string.h>
-#include <g-wrap-wct.h>
-
-#include "global-options.h"
-#include "gnc-commodity.h"
-#include "gnc-component-manager.h"
-#include "gnc-engine-util.h"
-#include "gnc-engine.h"
-#include "gnc-event.h"
-#include "gnc-file-dialog.h"
-#include "gnc-file-history.h"
-#include "gnc-file-p.h"
-#include "gnc-filepath-utils.h"
-#include "gnc-gui-query.h"
-#include "gnc-hooks.h"
-#include "gnc-splash.h"
-#include "gnc-ui.h"
-#include "gnc-ui-util.h"
-#include "gnc-window.h"
-#include "gnc-gconf-utils.h"
-#include "qofbackend.h"
-#include "qofbook.h"
-#include "qofsession.h"
-#include "messages.h"
-#include "TransLog.h"
-
-#define GCONF_SECTION "dialogs/export_accounts"
-
-/** GLOBALS *********************************************************/
-/* This static indicates the debugging module that this .o belongs to. */
-static short module = MOD_GUI;
-
-static GNCCanCancelSaveCB can_cancel_cb = NULL;
-static GNCShutdownCB shutdown_cb = NULL;
-
-static GNCHistoryAddFileFunc history_add_file_func = NULL;
-static GNCHistoryGetLastFunc history_get_last_func = NULL;
-
-static GNCFileDialogFunc file_dialog_func = NULL;
-
-
-void
-gnc_file_set_handlers (GNCHistoryAddFileFunc history_add_file_func_in,
- GNCHistoryGetLastFunc history_get_last_func_in,
- GNCFileDialogFunc file_dialog_func_in)
-{
- history_add_file_func = history_add_file_func_in;
- history_get_last_func = history_get_last_func_in;
- file_dialog_func = file_dialog_func_in;
-}
-
-void
-gnc_file_init (void)
-{
- /* Make sure we have a current session. */
- qof_session_get_current_session ();
-}
-
-gboolean
-show_session_error (QofBackendError io_error, const char *newfile)
-{
- GtkWidget *parent = gnc_ui_get_toplevel();
- gboolean uh_oh = TRUE;
- const char *fmt;
-
- gnc_destroy_splash_screen(); /* Just in case */
- if (NULL == newfile) { newfile = _("(null)"); }
-
- switch (io_error)
- {
- case ERR_BACKEND_NO_ERR:
- uh_oh = FALSE;
- break;
-
- case ERR_BACKEND_NO_HANDLER: {
- fmt = _("No suitable backend was found for\n%s.");
- gnc_error_dialog(parent, fmt, newfile);
- break;
- }
- case ERR_BACKEND_NO_BACKEND:
- fmt = _("The URL \n %s\n"
- "is not supported by this version of GnuCash.");
- gnc_error_dialog (parent, fmt, newfile);
- break;
-
- case ERR_BACKEND_BAD_URL:
- fmt = _("Can't parse the URL\n %s\n");
- gnc_error_dialog (parent, fmt, newfile);
- break;
-
- case ERR_BACKEND_CANT_CONNECT:
- fmt = _("Can't connect to\n %s\n"
- "The host, username or password were incorrect.");
- gnc_error_dialog (parent, fmt, newfile);
- break;
-
- case ERR_BACKEND_CONN_LOST:
- fmt = _("Can't connect to\n %s\n"
- "Connection was lost, unable to send data.");
- gnc_error_dialog (parent, fmt, newfile);
- break;
-
- case ERR_BACKEND_TOO_NEW:
- fmt = _("This file/URL appears to be from a newer version\n"
- "of GnuCash. You must upgrade your version of GnuCash\n"
- "to work with this data.");
- gnc_error_dialog (parent, fmt);
- break;
-
- case ERR_BACKEND_NO_SUCH_DB:
- fmt = _("The database\n"
- " %s\n"
- "doesn't seem to exist. Do you want to create it?\n");
- if (gnc_verify_dialog (parent, TRUE, fmt, newfile)) { uh_oh = FALSE; }
- break;
-
- case ERR_BACKEND_LOCKED:
- fmt = _("GnuCash could not obtain the lock for\n"
- " %s.\n"
- "That database may be in use by another user,\n"
- "in which case you should not open the database.\n"
- "\nDo you want to proceed with opening the database?");
- if (gnc_verify_dialog (parent, TRUE, fmt, newfile)) { uh_oh = FALSE; }
- break;
-
- case ERR_BACKEND_READONLY:
- fmt = _("GnuCash could not write to\n"
- " %s.\n"
- "That database may be on a read-only file system,\n"
- "or you may not have write permission for the directory.\n");
- gnc_error_dialog (parent, fmt, newfile);
- break;
-
- case ERR_BACKEND_DATA_CORRUPT:
- fmt = _("The file/URL \n %s\n"
- "does not contain GnuCash data or the data is corrupt.");
- gnc_error_dialog (parent, fmt, newfile);
- break;
-
- case ERR_BACKEND_SERVER_ERR:
- fmt = _("The server at URL \n %s\n"
- "experienced an error or encountered bad or corrupt data.");
- gnc_error_dialog (parent, fmt, newfile);
- break;
-
- case ERR_BACKEND_PERM:
- fmt = _("You do not have permission to access\n %s\n");
- gnc_error_dialog (parent, fmt, newfile);
- break;
-
- case ERR_BACKEND_MISC:
- fmt = _("An error occurred while processing\n %s\n");
- gnc_error_dialog (parent, fmt, newfile);
- break;
-
- /* QSF additions */
- case ERR_QSF_INVALID_OBJ: {
- fmt = _("Invalid QSF Object file!\n"
- "The QSF object file\n%s\n failed to validate"
- " against the QSF object schema.\nThe XML structure of the file"
- " is either not well-formed or contains illegal data.");
- gnc_error_dialog(parent, fmt, newfile);
- break;
- }
- case ERR_QSF_INVALID_MAP: {
- fmt = _("Invalid QSF Map file!\n"
- "The QSF map file\n%s\n failed to validate "
- " against the QSF map schema.\nThe XML structure of the file"
- " is either not well-formed or contains illegal data.");
- gnc_error_dialog(parent, fmt, newfile);
- break;
- }
- case ERR_QSF_BAD_QOF_VERSION: {
- fmt = _("The QSF Map file\n%s\nwas written for a different version of QOF\n"
- "It may need to be modified to work with your current QOF installation.");
- gnc_error_dialog(parent, fmt, newfile);
- break;
- }
- case ERR_QSF_BAD_MAP: {
- fmt = _("The selected QSF map\n%s\ncontains unusable data."
- " This is usually because not all the required parameters for "
- " the defined objects have calculations described in the map.");
- gnc_error_dialog(parent, fmt, newfile);
- break;
- }
- case ERR_QSF_BAD_OBJ_GUID: {
- fmt = _("The selected QSF object file\n%s\n contains one or more invalid GUIDs."
- "The file cannot be processed - please check the source of the file"
- " and try again.");
- gnc_error_dialog(parent, fmt, newfile);
- break;
- }
- case ERR_QSF_NO_MAP: {
- fmt = _("The selected QSF Object file\n%s\nrequires a map but it was not provided.");
- gnc_error_dialog(parent, fmt, newfile);
- break;
- }
- case ERR_QSF_WRONG_MAP: {
- fmt = _("Wrong QSF map selected.\n"
- "The selected map,\n%s\n validates but was written"
- "for different QOF objects.\n The list of objects defined in "
- "this map does not include all the objects described in"
- "the current QSF object file.");
- gnc_error_dialog(parent, fmt, newfile);
- break;
- }
- case ERR_QSF_MAP_NOT_OBJ: {
- fmt = _("The selected file %s is a QSF map and cannot be "
- "opened as a QSF object.");
- gnc_error_dialog(parent, fmt, newfile);
- break;
- }
- case ERR_QSF_OVERFLOW : {
- fmt = _("When converting XML strings into numbers, an overflow "
- "has been detected. The QSF object file\n%s\n contains invalid "
- "data in a field that is meant to hold a number.");
- gnc_error_dialog(parent, fmt, newfile);
- break;
- }
- case ERR_QSF_OPEN_NOT_MERGE : {
- fmt = _("The QSF object file\n%s\nis valid and contains GnuCash "
- "objects. However, GnuCash cannot open the file directly because "
- "the data needs to be merged into an existing GnuCash data book. "
- "Please open a GnuCash file or create a new one, then import "
- "this QSF object file so that the data can be merged into the "
- "main data book.");
- gnc_error_dialog(parent, fmt, newfile);
- break;
- }
- case ERR_FILEIO_FILE_BAD_READ:
- fmt = _("There was an error reading the file.\n"
- "Do you want to continue?");
- if (gnc_verify_dialog (parent, TRUE, fmt)) { uh_oh = FALSE; }
- break;
-
- case ERR_FILEIO_PARSE_ERROR:
- fmt = _("There was an error parsing the file \n %s\n");
- gnc_error_dialog (parent, fmt, newfile);
- break;
-
- case ERR_FILEIO_FILE_EMPTY:
- fmt = _("The file \n %s\n is empty.");
- gnc_error_dialog (parent, fmt, newfile);
- break;
-
- case ERR_FILEIO_FILE_NOT_FOUND:
- fmt = _("The file \n %s\n could not be found.");
- gnc_error_dialog (parent, fmt, newfile);
- break;
-
- case ERR_FILEIO_FILE_TOO_OLD:
- fmt = _("This file is from an older version of GnuCash.\n"
- "Do you want to continue?");
- if (gnc_verify_dialog (parent, TRUE, fmt)) { uh_oh = FALSE; }
- break;
-
- case ERR_FILEIO_UNKNOWN_FILE_TYPE:
- fmt = _("Unknown file type");
- gnc_error_dialog(parent, fmt, newfile);
- break;
-
- case ERR_FILEIO_BACKUP_ERROR:
- fmt = _("Could not make a backup of %s\n");
- gnc_error_dialog(parent, fmt, newfile);
- break;
-
- case ERR_FILEIO_WRITE_ERROR:
- fmt = _("Could not write to %s\nCheck that you have"
- " permission to write to this file and that "
- " there is sufficient space to create it.");
- gnc_error_dialog(parent, fmt, newfile);
- break;
-
- case ERR_SQL_DB_TOO_OLD:
- fmt = _("This database is from an older version of GnuCash.\n"
- "Do you want to want to upgrade the database "
- "to the current version?");
- if (gnc_verify_dialog (parent, TRUE, fmt)) { uh_oh = FALSE; }
- break;
-
- case ERR_SQL_DB_BUSY:
- fmt = _("The SQL database is in use by other users, "
- "and the upgrade cannot be performed until they logoff.\n"
- "If there are currently no other users, consult the \n"
- "documentation to learn how to clear out dangling login\n"
- "sessions.");
- gnc_error_dialog (parent, fmt);
- break;
-
- default:
- PERR("FIXME: Unhandled error %d", io_error);
- fmt = _("An unknown I/O error occurred.");
- gnc_error_dialog (parent, fmt);
- break;
- }
-
- return uh_oh;
-}
-
-static void
-gnc_add_history (QofSession * session)
-{
- char *url;
- char *file;
-
- if (!session) return;
- if (!history_add_file_func) return;
-
- url = xaccResolveURL (qof_session_get_url (session));
- if (!url)
- return;
-
- if (strncmp (url, "file:", 5) == 0)
- file = url + 5;
- else
- file = url;
-
- history_add_file_func (file);
-
- g_free (url);
-}
-
-static void
-gnc_book_opened (void)
-{
- gnc_hook_run(HOOK_BOOK_OPENED, qof_session_get_current_session());
-}
-
-void
-gnc_file_new (void)
-{
- QofSession *session;
-
- /* If user attempts to start a new session before saving results of
- * the last one, prompt them to clean up their act. */
- if (!gnc_file_query_save ())
- return;
-
- session = qof_session_get_current_session ();
-
- /* close any ongoing file sessions, and free the accounts.
- * disable events so we don't get spammed by redraws. */
- gnc_engine_suspend_events ();
-
- qof_session_call_close_hooks(session);
- gnc_hook_run(HOOK_BOOK_CLOSED, session);
-
- gnc_close_gui_component_by_session (session);
- xaccLogDisable();
- qof_session_destroy (session);
- xaccLogEnable();
-
- /* start a new book */
- qof_session_get_current_session ();
-
- gnc_hook_run(HOOK_NEW_BOOK, NULL);
-
- gnc_book_opened ();
-
- gnc_engine_resume_events ();
- gnc_gui_refresh_all ();
-}
-
-gboolean
-gnc_file_query_save (void)
-{
- GtkWidget *parent = gnc_ui_get_toplevel();
-
- /* If user wants to mess around before finishing business with
- * the old file, give em a chance to figure out what's up.
- * Pose the question as a "while" loop, so that if user screws
- * up the file-selection dialog, we don't blow em out of the water;
- * instead, give them another chance to say "no" to the verify box.
- */
- while (qof_book_not_saved(qof_session_get_book (qof_session_get_current_session ())))
- {
- gint result;
- const char *message = _("Changes have been made since the last "
- "Save. Save the data to file?");
-
- if (can_cancel_cb && can_cancel_cb ())
- result = gnc_verify_cancel_dialog (parent, GTK_RESPONSE_YES, message);
- else
- {
- gboolean do_save = gnc_verify_dialog (parent, TRUE, message);
-
- result = do_save ? GTK_RESPONSE_YES : GTK_RESPONSE_NO;
- }
-
- if (result == GTK_RESPONSE_CANCEL)
- return FALSE;
-
- if (result == GTK_RESPONSE_NO)
- return TRUE;
-
- gnc_file_save ();
- }
-
- return TRUE;
-}
-
-/* private utilities for file open; done in two stages */
-
-static gboolean
-gnc_post_file_open (const char * filename)
-{
- QofSession *current_session, *new_session;
- gboolean uh_oh = FALSE;
- char * newfile;
- QofBackendError io_err = ERR_BACKEND_NO_ERR;
-
- if (!filename) return FALSE;
-
- newfile = xaccResolveURL (filename);
- if (!newfile)
- {
- show_session_error (ERR_FILEIO_FILE_NOT_FOUND, filename);
- return FALSE;
- }
-
- /* disable events while moving over to the new set of accounts;
- * the mass deletetion of accounts and transactions during
- * switchover would otherwise cause excessive redraws. */
- gnc_engine_suspend_events ();
-
- /* Change the mouse to a busy cursor */
- gnc_set_busy_cursor (NULL, TRUE);
-
- /* -------------- BEGIN CORE SESSION CODE ------------- */
- /* -- this code is almost identical in FileOpen and FileSaveAs -- */
- current_session = qof_session_get_current_session();
- qof_session_call_close_hooks(current_session);
- gnc_hook_run(HOOK_BOOK_CLOSED, current_session);
- xaccLogDisable();
- qof_session_destroy (current_session);
- xaccLogEnable();
-
- /* load the accounts from the users datafile */
- /* but first, check to make sure we've got a session going. */
- new_session = qof_session_new ();
-
- qof_session_begin (new_session, newfile, FALSE, FALSE);
- io_err = qof_session_get_error (new_session);
- /* if file appears to be locked, ask the user ... */
- if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err)
- {
- const char *buttons[] = { GTK_STOCK_QUIT, GTK_STOCK_OPEN,
- GTK_STOCK_NEW, NULL };
- char *fmt = ((ERR_BACKEND_LOCKED == io_err) ?
- _("GnuCash could not obtain the lock for\n"
- " %s.\n"
- "That database may be in use by another user,\n"
- "in which case you should not open the database.\n"
- "\nWhat would you like to do?") :
- _("WARNING!!! GnuCash could not obtain the lock for\n"
- " %s.\n"
- "That database may be on a read-only file system,\n"
- "or you may not have write permission for the directory.\n"
- "If you proceed you may not be able to save any changes.\n"
- "\nWhat would you like to do?")
- );
- int rc;
-
- gnc_destroy_splash_screen(); /* Just in case */
- if (shutdown_cb) {
- rc = gnc_generic_question_dialog (NULL, buttons, fmt, newfile);
- } else {
- rc = gnc_generic_question_dialog (NULL, buttons+1, fmt, newfile)+1;
- }
-
- if (rc == 0)
- {
- if (shutdown_cb)
- shutdown_cb(0);
- g_assert(1);
- }
- else if (rc == 1)
- {
- /* user told us to ignore locks. So ignore them. */
- qof_session_begin (new_session, newfile, TRUE, FALSE);
- }
- else
- {
- /* Can't use the given file, so just create a new
- * database so that the user will get a window that
- * they can click "Exit" on.
- */
- gnc_file_new ();
- }
- }
- if(ERR_QSF_OPEN_NOT_MERGE == io_err)
- {
- uh_oh = TRUE;
- }
- /* if the database doesn't exist, ask the user ... */
- else if ((ERR_BACKEND_NO_SUCH_DB == io_err) ||
- (ERR_SQL_DB_TOO_OLD == io_err))
- {
- if (FALSE == show_session_error (io_err, newfile))
- {
- /* user told us to create a new database. Do it. */
- qof_session_begin (new_session, newfile, FALSE, TRUE);
- }
- }
-
- /* Check for errors again, since above may have cleared the lock.
- * If its still locked, still, doesn't exist, still too old, then
- * don't bother with the message, just die. */
- io_err = qof_session_get_error (new_session);
- if ((ERR_BACKEND_LOCKED == io_err) ||
- (ERR_BACKEND_READONLY == io_err) ||
- (ERR_BACKEND_NO_SUCH_DB == io_err) ||
- (ERR_SQL_DB_TOO_OLD == io_err))
- {
- uh_oh = TRUE;
- }
- else
- {
- uh_oh = show_session_error (io_err, newfile);
- }
-
- if (!uh_oh)
- {
- AccountGroup *new_group;
-
- char * logpath = xaccResolveFilePath(newfile);
- PINFO ("logpath=%s", logpath ? logpath : "(null)");
- xaccLogSetBaseName (logpath);
- xaccLogDisable();
-
- gnc_window_show_progress(_("Reading file..."), 0.0);
- qof_session_load (new_session, gnc_window_show_progress);
- gnc_window_show_progress(NULL, -1.0);
- xaccLogEnable();
-
- /* check for i/o error, put up appropriate error dialog */
- io_err = qof_session_get_error (new_session);
- uh_oh = show_session_error (io_err, newfile);
-
- new_group = gnc_book_get_group (qof_session_get_book (new_session));
- if (uh_oh) new_group = NULL;
-
- /* Umm, came up empty-handed, but no error:
- * The backend forgot to set an error. So make one up. */
- if (!uh_oh && !new_group)
- {
- uh_oh = show_session_error (ERR_BACKEND_MISC, newfile);
- }
- }
-
- gnc_unset_busy_cursor (NULL);
-
- /* going down -- abandon ship */
- if (uh_oh)
- {
- xaccLogDisable();
- qof_session_destroy (new_session);
- xaccLogEnable();
-
- /* well, no matter what, I think it's a good idea to have a
- * topgroup around. For example, early in the gnucash startup
- * sequence, the user opens a file; if this open fails for any
- * reason, we don't want to leave them high & dry without a
- * topgroup, because if the user continues, then bad things will
- * happen. */
- qof_session_get_current_session ();
-
- g_free (newfile);
-
- gnc_engine_resume_events ();
- gnc_gui_refresh_all ();
-
- gnc_book_opened ();
-
- return FALSE;
- }
-
- /* if we got to here, then we've successfully gotten a new session */
- /* close up the old file session (if any) */
- qof_session_set_current_session(new_session);
-
- gnc_book_opened ();
-
- /* --------------- END CORE SESSION CODE -------------- */
-
- /* clean up old stuff, and then we're outta here. */
- gnc_add_history (new_session);
-
- g_free (newfile);
-
- gnc_engine_resume_events ();
- gnc_gui_refresh_all ();
-
- return TRUE;
-}
-
-gboolean
-gnc_file_open (void)
-{
- const char * newfile;
- const char * last;
- gboolean result;
-
- if (!gnc_file_query_save ())
- return FALSE;
-
- if (!file_dialog_func)
- {
- PWARN ("no file dialog function");
- return FALSE;
- }
-
- last = history_get_last_func ? history_get_last_func () : NULL;
- newfile = file_dialog_func (_("Open"), NULL, last);
- result = gnc_post_file_open (newfile);
-
- /* This dialogue can show up early in the startup process. If the
- * user fails to pick a file (by e.g. hitting the cancel button), we
- * might be left with a null topgroup, which leads to nastiness when
- * user goes to create their very first account. So create one. */
- qof_session_get_current_session ();
-
- return result;
-}
-
-gboolean
-gnc_file_open_file (const char * newfile)
-{
- if (!newfile) return FALSE;
-
- if (!gnc_file_query_save ())
- return FALSE;
-
- return gnc_post_file_open (newfile);
-}
-
-void
-gnc_file_export_file(const char * newfile)
-{
- QofSession *current_session, *new_session;
- gboolean ok;
- QofBackendError io_err = ERR_BACKEND_NO_ERR;
- gchar *default_dir;
-
- default_dir = gnc_gconf_get_string(GCONF_SECTION, KEY_LAST_PATH, NULL);
- if (default_dir == NULL)
- gnc_init_default_directory(&default_dir);
-
- if (!newfile) {
- if (!file_dialog_func) {
- PWARN ("no file dialog function");
- return;
- }
-
- newfile = file_dialog_func (_("Export"), NULL, default_dir);
- g_free(default_dir);
- default_dir = NULL;
- if (!newfile)
- return;
- }
-
- /* Remember the directory as the default. */
- gnc_extract_directory(&default_dir, newfile);
- gnc_gconf_set_string(GCONF_SECTION, KEY_LAST_PATH, default_dir, NULL);
- g_free(default_dir);
-
- gnc_engine_suspend_events();
-
- /* -- this session code is NOT identical in FileOpen and FileSaveAs -- */
-
- new_session = qof_session_new ();
- qof_session_begin (new_session, newfile, FALSE, FALSE);
-
- io_err = qof_session_get_error (new_session);
-
- /* if file appears to be locked, ask the user ... */
- if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err)
- {
- if (FALSE == show_session_error (io_err, newfile))
- {
- /* user told us to ignore locks. So ignore them. */
- qof_session_begin (new_session, newfile, TRUE, FALSE);
- }
- }
-
- /* --------------- END CORE SESSION CODE -------------- */
-
- /* oops ... file already exists ... ask user what to do... */
- if (qof_session_save_may_clobber_data (new_session))
- {
- const char *format = _("The file \n %s\n already exists.\n"
- "Are you sure you want to overwrite it?");
-
- /* if user says cancel, we should break out */
- if (!gnc_verify_dialog (NULL, FALSE, format, newfile))
- {
- return;
- }
-
- /* Whoa-ok. Blow away the previous file. */
- }
-
- /* use the current session to save to file */
- gnc_set_busy_cursor (NULL, TRUE);
- current_session = qof_session_get_current_session();
- gnc_window_show_progress(_("Exporting file..."), 0.0);
- ok = qof_session_export (new_session, current_session,
- gnc_window_show_progress);
- gnc_window_show_progress(NULL, -1.0);
- gnc_unset_busy_cursor (NULL);
- xaccLogDisable();
- qof_session_destroy (new_session);
- xaccLogEnable();
- gnc_engine_resume_events();
-
- if (!ok)
- {
- /* %s is the strerror(3) error string of the error that occurred. */
- const char *format = _("There was an error saving the file.\n\n%s");
-
- gnc_error_dialog (NULL, format, strerror(errno));
- return;
- }
-}
-
-static gboolean been_here_before = FALSE;
-
-void
-gnc_file_save (void)
-{
- QofBackendError io_err;
- const char * newfile;
- QofSession *session;
- ENTER (" ");
-
- /* hack alert -- Somehow make sure all in-progress edits get committed! */
-
- /* If we don't have a filename/path to save to get one. */
- session = qof_session_get_current_session ();
-
- if (!qof_session_get_file_path (session))
- {
- gnc_file_save_as ();
- return;
- }
-
- /* use the current session to save to file */
- gnc_set_busy_cursor (NULL, TRUE);
- gnc_window_show_progress(_("Writing file..."), 0.0);
- qof_session_save (session, gnc_window_show_progress);
- gnc_window_show_progress(NULL, -1.0);
- gnc_unset_busy_cursor (NULL);
-
- /* Make sure everything's OK - disk could be full, file could have
- become read-only etc. */
- newfile = qof_session_get_file_path (session);
- io_err = qof_session_get_error (session);
- if (ERR_BACKEND_NO_ERR != io_err)
- {
- show_session_error (io_err, newfile);
-
- if (been_here_before) return;
- been_here_before = TRUE;
- gnc_file_save_as (); /* been_here prevents infinite recursion */
- been_here_before = FALSE;
- return;
- }
-
- gnc_add_history (session);
-
- /* save the main window state */
- scm_call_1 (scm_c_eval_string("gnc:main-window-save-state"),
- (session ?
- gw_wcp_assimilate_ptr (session, scm_c_eval_string("<gnc:Session*>")) :
- SCM_BOOL_F));
-
- LEAVE (" ");
-}
-
-void
-gnc_file_save_as (void)
-{
- QofSession *new_session;
- QofSession *session;
- const char *filename;
- char *default_dir = NULL; /* Default to last open */
- const char *last;
- char *newfile;
- const char *oldfile;
- QofBackendError io_err = ERR_BACKEND_NO_ERR;
-
- ENTER(" ");
-
- if (!file_dialog_func)
- {
- PWARN ("no file dialog func");
- return;
- }
-
- last = history_get_last_func ? history_get_last_func() : NULL;
- if (last)
- gnc_extract_directory(&default_dir, last);
- else
- gnc_init_default_directory(&default_dir);
- filename = file_dialog_func (_("Save"), "*.gnc", default_dir);
- if (default_dir)
- free(default_dir);
- if (!filename) return;
-
- /* Check to see if the user specified the same file as the current
- * file. If so, then just do that, instead of the below, which
- * assumes a truly new name was given. */
- newfile = xaccResolveURL (filename);
- if (!newfile)
- {
- show_session_error (ERR_FILEIO_FILE_NOT_FOUND, filename);
- return;
- }
-
- session = qof_session_get_current_session ();
- oldfile = qof_session_get_file_path (session);
- if (oldfile && (strcmp(oldfile, newfile) == 0))
- {
- g_free (newfile);
- gnc_file_save ();
- return;
- }
-
- /* -- this session code is NOT identical in FileOpen and FileSaveAs -- */
-
- new_session = qof_session_new ();
- qof_session_begin (new_session, newfile, FALSE, FALSE);
-
- io_err = qof_session_get_error (new_session);
-
- /* if file appears to be locked, ask the user ... */
- if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err)
- {
- if (FALSE == show_session_error (io_err, newfile))
- {
- /* user told us to ignore locks. So ignore them. */
- qof_session_begin (new_session, newfile, TRUE, FALSE);
- }
- }
-
- /* if the database doesn't exist, ask the user ... */
- else if ((ERR_BACKEND_NO_SUCH_DB == io_err) ||
- (ERR_SQL_DB_TOO_OLD == io_err))
- {
- if (FALSE == show_session_error (io_err, newfile))
- {
- /* user told us to create a new database. Do it. */
- qof_session_begin (new_session, newfile, FALSE, TRUE);
- }
- }
-
- /* check again for session errors (since above dialog may have
- * cleared a file lock & moved things forward some more)
- * This time, errors will be fatal.
- */
- io_err = qof_session_get_error (new_session);
- if (ERR_BACKEND_NO_ERR != io_err)
- {
- show_session_error (io_err, newfile);
- xaccLogDisable();
- qof_session_destroy (new_session);
- xaccLogEnable();
- g_free (newfile);
- return;
- }
-
- /* if we got to here, then we've successfully gotten a new session */
- /* close up the old file session (if any) */
- qof_session_swap_data (session, new_session);
- xaccLogDisable();
- qof_session_destroy (session);
- xaccLogEnable();
- session = NULL;
-
- /* XXX At this point, we should really mark the data in the new session
- * as being 'dirty', since we haven't saved it at all under the new
- * session. But I'm lazy...
- */
- qof_session_set_current_session(new_session);
-
- /* --------------- END CORE SESSION CODE -------------- */
-
- /* oops ... file already exists ... ask user what to do... */
- if (qof_session_save_may_clobber_data (new_session))
- {
- const char *format = _("The file \n %s\n already exists.\n"
- "Are you sure you want to overwrite it?");
-
- /* if user says cancel, we should break out */
- if (!gnc_verify_dialog (NULL, FALSE, format, newfile))
- {
- g_free (newfile);
- return;
- }
-
- /* Whoa-ok. Blow away the previous file. */
- }
-
- gnc_file_save ();
-
- g_free (newfile);
- LEAVE (" ");
-}
-
-void
-gnc_file_quit (void)
-{
- QofSession *session;
-
- gnc_set_busy_cursor (NULL, TRUE);
- session = qof_session_get_current_session ();
-
- /* disable events; otherwise the mass deletetion of accounts and
- * transactions during shutdown would cause massive redraws */
- gnc_engine_suspend_events ();
-
- qof_session_call_close_hooks(session);
- gnc_hook_run(HOOK_BOOK_CLOSED, session);
-
- xaccLogDisable();
- qof_session_destroy (session);
- xaccLogEnable();
-
- qof_session_get_current_session ();
-
- gnc_engine_resume_events ();
- gnc_unset_busy_cursor (NULL);
-}
-
-void
-gnc_file_set_can_cancel_callback (GNCCanCancelSaveCB cb)
-{
- can_cancel_cb = cb;
-}
-
-void
-gnc_file_set_shutdown_callback (GNCShutdownCB cb)
-{
- shutdown_cb = cb;
-}
--- src/app-file/gnc-file-p.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/********************************************************************\
- * Copyright (C) 1997 Robin D. Clark *
- * Copyright (C) 1998, 1999, 2000 Linas Vepstas (linas at linas.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, write to the Free Software *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
-\********************************************************************/
-
-#ifndef GNC_FILE_P_H
-#define GNC_FILE_P_H
-
-#include "gnc-file.h"
-
-void gnc_file_init (void);
-
-typedef void (*GNCHistoryAddFileFunc) (const char *filename);
-typedef char * (*GNCHistoryGetLastFunc) (void);
-
-typedef char * (*GNCFileDialogFunc) (const char * title,
- const char * filter,
- const char * default_name);
-
-void gnc_file_set_handlers (GNCHistoryAddFileFunc history_add_file_func,
- GNCHistoryGetLastFunc history_get_last_func,
- GNCFileDialogFunc file_dialog_func);
-
-#endif
--- src/app-file/gnc-file-history.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/********************************************************************\
- * gnc-file-history.h -- functions to maintain file-history menu *
- * Copyright (C) 2000 Robby Stephenson *
- * Copyright (C) 2005 David Hampton *
- * *
- * 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 *
- * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
- * Boston, MA 02111-1307, USA gnu at gnu.org *
-\********************************************************************/
-
-#ifndef GNC_FILE_HISTORY_H
-#define GNC_FILE_HISTORY_H
-
-#define MAX_HISTORY_FILES 10 /* May be any number up to 10 */
-#define HISTORY_STRING_SECTION "history"
-#define HISTORY_STRING_MAXFILES "maxfiles"
-#define HISTORY_STRING_FILE_N "file%d"
-
-void gnc_history_add_file (const char *filename);
-char * gnc_history_get_last (void);
-gchar *gnc_history_gconf_index_to_key (guint index);
-gint gnc_history_gconf_key_to_index (const gchar *fullkey);
-
-#endif
--- src/app-file/gnc-file-dialog.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/********************************************************************\
- * gnc-file-dialog.c -- the file dialog dialog *
- * Copyright (C) 1997 Robin D. Clark *
- * Copyright (c) 2001 Linux Developers Group *
- * *
- * 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, write to the Free Software *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
-\********************************************************************/
-
-#ifndef GNC_FILE_DIALOG_H
-#define GNC_FILE_DIALOG_H
-
-#include "config.h"
-
-/** PROTOTYPES ******************************************************/
-char * gnc_file_dialog (const char * title,
- const char * filter,
- const char * default_name);
-
-#endif
--- src/app-file/gnc-file.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/********************************************************************\
- * Copyright (C) 1997 Robin D. Clark *
- * Copyright (C) 1998, 1999, 2000 Linas Vepstas (linas at linas.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, write to the Free Software *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
-\********************************************************************/
-
-/*
- * FILE: gnc-file.h
- *
- * FUNCTION:
- * A set of file-handling utilities for GnuCash applications.
- * These utilities will "do the right thing" when used in the "File..."
- * pulldown menu, for the "New", "Open", "Save", "SaveAs", etc. menu entries.
- * In particular, they will verify that old files don't get clobbered,
- * they'll put up dialogue boxes to ask the user to confirm their actions,
- * etc.
- *
- * These utilities are written in a GUI-independent fashion, and should
- * work just fine with the Motif, gnome/gtk and Qt interfaces.
- * These utilities are appropriate for direct invocation from guile.
- * (they should be wrapped by g-wrap).
- *
- * These GUI utilities implement and maintain a single global "session"
- * that defines the currently edited account group. In a sense, these
- * functions provide the GUI for the xaccSession object. The session
- * is essentially a file that is open for editing, with locks on it
- * to prevent other readers and writers from accessing it as long as its
- * open.
- *
- *
- * The gnc_file_save() routine will check for an existing edit session,
- * and if one exists, it will save the account info to a file.
- * If an error occurs, a popup dialogue will inform the user of
- * the error. If there is no existing filename open, then the
- * user will be prompted for a file to save to (using the
- * gnc_file_save_as() routine). The existing session will remain
- * open for further editing.
- *
- * The gnc_file_save_as() routine will prompt the user for a filename
- * to save the account data to (using the standard GUI file dialogue
- * box). If the user specifies a filename, the account data will be
- * saved. If an error occurs, a popup dialogue will inform the user
- * of the error. One possible error is that another user has
- * the indicated file already locked up in a different session
- * (in which case it is up to the user to try again, or to pick
- * a different filename). If it is possible to save without
- * an error, then a new session is started for the indicated
- * filename, locking out other users. This new session remains
- * open for further editing.
- *
- * The gnc_file_query_save() routine will display a popup dialog asking
- * the user if they wish to save their current work. If they answer
- * "yes", their work will be saved (using the gncFileSave function),
- * otherwise no action will be performed. If there is no currently
- * locked session, a popup will query the user for a filename
- * (using the gnc_file_save_as() routine). The routine will return
- * TRUE if the user hits "Yes" or "No" and FALSE if the user
- * hits "Cancel". If nothing needed to be saved, the routine
- * will return TRUE.
- *
- * The gnc_file_new() routine will check for an existing edit session.
- * If one exists, it will ask the user if they want to save it,
- * (using the gnc_file_query_save_as() dialogue). Then the current
- * session will be destroyed, file locks will be removed, and
- * account group structures will be set up for a new session.
- *
- * The gnc_file_open() routine check for an existing edit session.
- * If one exists, it will ask the user if they want to save it.
- * (using the gnc_file_query_save() dialogue). Next, the user will
- * be prompted with a GUI standard file-selection dialogue to
- * to pick a new file. If no file is picked, this routine returns.
- * If a new file was picked, then the current session will be
- * destroyed and file locks on it will be removed. The new
- * file will then be opened for editing, establishing locks, etc.
- * If an error occurs, the user will be informed with a pop-up
- * dialogue. If the file cannot be found, or if a read
- * error occurs, a popup describing the error will pop up.
- * One possible error is that another user has the indicated
- * file already locked up in a different session (in which
- * case it is up to the user to try again, or to pick
- * a different filename).
- *
- * The gnc_file_open_file() routine behaves much like the gnc_file_open()
- * routine, except that the new file to open is passed as a char *
- * argument.
- *
- * The gnc_file_export_file() routine will check for an existing edit
- * session, and if one exists, it will save just the commodities
- * and accounts to a file. If an error occurs, a popup dialogue
- * will inform the user of the error.
- *
- * The gnc_file_quit() routine will close out and destroy the current session.
- * The user WILL NOT BE PROMPTED to confirm this action, or do do
- * any kind of saving beforehand.
- *
- * HISTORY:
- * Derived from Rob Clark's original MainWindow.c code, Dec 1998
- */
-
-#ifndef GNC_FILE_H
-#define GNC_FILE_H
-
-#include <glib.h>
-#include "qofbackend.h"
-
-void gnc_file_new (void);
-gboolean gnc_file_open (void);
-void gnc_file_save (void);
-void gnc_file_save_as (void);
-
-/** Tell the user about errors in the backends
-
-*/
-gboolean show_session_error (QofBackendError io_error, const char *newfile);
-
-gboolean gnc_file_open_file (const char *filename);
-void gnc_file_export_file(const char * filename);
-
-gboolean gnc_file_query_save (void);
-
-void gnc_file_quit (void);
-
-typedef gboolean (*GNCCanCancelSaveCB) (void);
-void gnc_file_set_can_cancel_callback (GNCCanCancelSaveCB cb);
-
-typedef void (*GNCShutdownCB) (int);
-void gnc_file_set_shutdown_callback (GNCShutdownCB cb);
-
-#endif /* GNC_FILE_H */
--- src/app-file/gnc-file-history.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/********************************************************************\
- * gnc-file-history.c -- functions to maintain file history menu *
- * Copyright (C) 2000 Robby Stephenson *
- * Copyright (C) 2005 David Hampton *
- * *
- * 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 *
- * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
- * Boston, MA 02111-1307, USA gnu at gnu.org *
-\********************************************************************/
-
-#include "config.h"
-
-#include <glib/gprintf.h>
-#include <gnome.h>
-#include "gnc-file.h"
-#include "gnc-file-history.h"
-#include "gnc-gconf-utils.h"
-
-gchar *
-gnc_history_gconf_index_to_key (guint index)
-{
- return g_strdup_printf(HISTORY_STRING_FILE_N, index);
-}
-
-gint
-gnc_history_gconf_key_to_index (const gchar *fullkey)
-{
- char *key;
- gint index, result;
-
- key = rindex(fullkey, '/');
- result = sscanf(key+1, HISTORY_STRING_FILE_N, &index);
- return (result == 1) ? index : -1;
-}
-
-void
-gnc_history_add_file (const char *newfile)
-{
- gchar *filename, *from, *to;
- gint i, last;
-
- if (newfile == NULL)
- return;
- if (!g_utf8_validate(newfile, -1, NULL))
- return;
-
- /*
- * Look for the filename in gconf.
- */
- last = MAX_HISTORY_FILES - 1;
- for (i = 0; i < MAX_HISTORY_FILES; i++) {
- from = g_strdup_printf(HISTORY_STRING_FILE_N, i);
- filename = gnc_gconf_get_string(HISTORY_STRING_SECTION, from, NULL);
- g_free(from);
-
- if (!filename) {
- last = i;
- break;
- }
- if (g_utf8_collate(newfile, filename) == 0) {
- g_free(filename);
- last = i;
- break;
- }
- g_free(filename);
- }
-
- /*
- * Shuffle filenames upward through gconf.
- */
- to = g_strdup_printf(HISTORY_STRING_FILE_N, last);
- for (i = last - 1; i >= 0; i--) {
- from = g_strdup_printf(HISTORY_STRING_FILE_N, i);
- filename = gnc_gconf_get_string(HISTORY_STRING_SECTION, from, NULL);
- if (filename) {
- gnc_gconf_set_string(HISTORY_STRING_SECTION, to, filename, NULL);
- g_free(filename);
- } else {
- gnc_gconf_unset(HISTORY_STRING_SECTION, to, NULL);
- }
- g_free(to);
- to = from;
- }
-
- /*
- * Store the new zero entry.
- */
- gnc_gconf_set_string(HISTORY_STRING_SECTION, to, newfile, NULL);
-}
-
-
-char *
-gnc_history_get_last (void)
-{
- static char *filename = NULL;
- char *key;
-
- /* The static string supports the current signature of this
- * function. At some point this should be changed to pass the
- * allocated string up to the caller and make them responsible for
- * freeing irt, but that change percolates up into the scheme code
- * and requires changing that as well. */
- if (filename) {
- g_free(filename);
- filename = NULL;
- }
-
- key = g_strdup_printf(HISTORY_STRING_FILE_N, 0);
- filename = gnc_gconf_get_string(HISTORY_STRING_SECTION, key, NULL);
- g_free(key);
-
- return filename;
-}
--- src/app-file/Makefile.am
+++ /dev/null
@@ -1,83 +0,0 @@
-SUBDIRS = gnome schemas . test
-PWD := $(shell pwd)
-
-pkglib_LTLIBRARIES = libgncmod-app-file.la libgw-app-file.la
-
-AM_CFLAGS = \
- -I${top_srcdir}/src/core-utils \
- -I${top_srcdir}/src/gnc-module \
- -I${top_srcdir}/src \
- -I${top_srcdir}/src/engine \
- -I${top_srcdir}/src/app-utils \
- -I${top_srcdir}/src/gnome-utils \
- ${GNOME_CFLAGS} \
- ${GUILE_INCS} \
- ${GLIB_CFLAGS} \
- ${G_WRAP_COMPILE_ARGS}
-
-libgncmod_app_file_la_SOURCES = \
- gnc-file.c \
- gnc-file-history.c \
- gncmod-app-file.c
-
-gncincludedir = ${GNC_INCLUDE_DIR}
-gncinclude_HEADERS = \
- gnc-file.h \
- gnc-file-dialog.h \
- gnc-file-history.h
-
-noinst_HEADERS = \
- gnc-file-p.h \
- gw-app-file.h
-
-libgncmod_app_file_la_LDFLAGS = -module
-
-libgncmod_app_file_la_LIBADD = \
- ../core-utils/libcore-utils.la \
- ../gnc-module/libgncmodule.la \
- ../engine/libgncmod-engine.la \
- ../gnome-utils/libgncmod-gnome-utils.la \
- gnome/libgnc-app-file-gnome.la \
- ../app-utils/libgncmod-app-utils.la \
- ${GUILE_LIBS} \
- ${GLIB_LIBS}
-
-libgw_app_file_la_SOURCES = gw-app-file.c
-libgw_app_file_la_LDFLAGS = -module
-
-gwmoddir = ${GNC_GWRAP_LIBDIR}
-gwmod_DATA = gw-app-file-spec.scm gw-app-file.scm
-
-noinst_DATA = .scm-links
-
-EXTRA_DIST = \
- ${gwmod_DATA}
-
-if GNUCASH_SEPARATE_BUILDDIR
-#Only needed when srcdir and builddir are different
-SCM_FILE_LINKS = gw-app-file-spec.scm
-endif
-
-.scm-links:
- rm -f gnucash g-wrapped
- ln -sf . gnucash
- ln -sf . g-wrapped
-if GNUCASH_SEPARATE_BUILDDIR
- for X in ${SCM_FILE_LINKS} ; do \
- ln -sf ${srcdir}/$$X . ; \
- done
-endif
- touch .scm-links
-
-gw-app-file.scm gw-app-file.c gw-app-file.h: \
- .scm-links gw-app-file-spec.scm ${top_builddir}/config.status
- FLAVOR=gnome guile -c \
- "(set! %load-path (cons \"${G_WRAP_MODULE_DIR}\" %load-path)) \
- (set! %load-path (cons \"${PWD}\" %load-path)) \
- (set! %load-path (cons \"${top_builddir}/src/engine\" %load-path)) \
- (primitive-load \"./gw-app-file-spec.scm\") \
- (gw:generate-wrapset \"gw-app-file\")"
-
-BUILT_SOURCES = gw-app-file.scm gw-app-file.c gw-app-file.h
-DISTCLEANFILES = gnucash g-wrapped .scm-links ${SCM_FILE_LINKS} \
- gw-app-file.html
--- src/gnome/gnc-plugin-file-history.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * gnc-plugin-file-history.h --
- * Copyright (C) 2003,2005 David Hampton <hampton at 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
- * 59 Temple Place - Suite 330 Fax: +1-617-542-2652
- * Boston, MA 02111-1307, USA gnu at gnu.org
- */
-
-/** @addtogroup GUI
- @{ */
-/** @addtogroup GuiImport Import GUI Utility functions.
- @{ */
-/** @file gnc-plugin-file-history.h
- @brief Utility functions for writing import modules.
- @author Copyright (C) 2002 David Hampton <hampton at employees.org>
-*/
-
-#ifndef __GNC_PLUGIN_FILE_HISTORY_H
-#define __GNC_PLUGIN_FILE_HISTORY_H
-
-#include <gtk/gtk.h>
-#include "gnc-plugin.h"
-
-G_BEGIN_DECLS
-
-/* type macros */
-#define GNC_TYPE_PLUGIN_FILE_HISTORY (gnc_plugin_file_history_get_type ())
-#define GNC_PLUGIN_FILE_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_FILE_HISTORY, GncPluginFileHistory))
-#define GNC_PLUGIN_FILE_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_FILE_HISTORY, GncPluginFileHistoryClass))
-#define GNC_IS_PLUGIN_FILE_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_FILE_HISTORY))
-#define GNC_IS_PLUGIN_FILE_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_FILE_HISTORY))
-#define GNC_PLUGIN_FILE_HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_FILE_HISTORY, GncPluginFileHistoryClass))
-
-#define GNC_PLUGIN_FILE_HISTORY_NAME "gnc-plugin-file-history"
-
-/* typedefs & structures */
-typedef struct GncPluginFileHistoryPrivate GncPluginFileHistoryPrivate;
-
-typedef struct {
- GncPlugin parent;
- GncPluginFileHistoryPrivate *priv;
-} GncPluginFileHistory;
-
-typedef struct {
- GncPluginClass parent;
-} GncPluginFileHistoryClass;
-
-/* function prototypes */
-
-
-/** Get the type of a file history plugin.
- *
- * @return A GType.
- */
-GType gnc_plugin_file_history_get_type (void);
-
-/** Create a new file history plugin. This plugin attaches the file
- * history menu to any window that is opened.
- *
- * @return A pointer to the new object.
- */
-GncPlugin *gnc_plugin_file_history_new (void);
-
-G_END_DECLS
-
-#endif /* __GNC_PLUGIN_FILE_HISTORY_H */
-
-/** @} */
-/** @} */
--- src/gnome/gnc-plugin-file-history.c
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * gnc-plugin-file-history.c --
- * Copyright (C) 2003,2005 David Hampton hampton at 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
- * 59 Temple Place - Suite 330 Fax: +1-617-542-2652
- * Boston, MA 02111-1307, USA gnu at gnu.org
- */
-
-/** @addtogroup GUI
- @{ */
-/** @addtogroup GuiImport Import GUI Utility functions.
- @{ */
-/** @internal
- @file gnc-plugin-file-history.c
- @brief Utility functions for writing import modules.
- @author Copyright (C) 2002 David Hampton <hampton at employees.org>
-*/
-
-#include "config.h"
-
-#include <string.h>
-#include <glib/gprintf.h>
-#include <libgnome/libgnome.h>
-
-#include "gnc-file.h"
-#include "gnc-file-history.h"
-#include "gnc-main-window.h"
-#include "gnc-plugin-file-history.h"
-#include "gnc-window.h"
-#include "gnc-trace.h"
-#include "messages.h"
-#include "gnc-gconf-utils.h"
-
-static GObjectClass *parent_class = NULL;
-
-#define FILENAME_STRING "filename"
-
-static void gnc_plugin_file_history_class_init (GncPluginFileHistoryClass *klass);
-static void gnc_plugin_file_history_init (GncPluginFileHistory *plugin);
-static void gnc_plugin_file_history_finalize (GObject *object);
-
-static void gnc_plugin_file_history_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type);
-static void gnc_plugin_file_history_remove_from_window (GncPlugin *plugin, GncMainWindow *window, GQuark type);
-
-static short module = MOD_GUI;
-
-/* Command callbacks */
-static void gnc_plugin_file_history_cmd_open_file (GtkAction *action, GncMainWindowActionData *data);
-
-
-#define PLUGIN_ACTIONS_NAME "gnc-plugin-file-history-actions"
-#define PLUGIN_UI_FILENAME "gnc-plugin-file-history-ui.xml"
-
-static GtkActionEntry gnc_plugin_actions [] = {
- { "RecentFile0Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
- { "RecentFile1Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
- { "RecentFile2Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
- { "RecentFile3Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
- { "RecentFile4Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
- { "RecentFile5Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
- { "RecentFile6Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
- { "RecentFile7Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
- { "RecentFile8Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
- { "RecentFile9Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
-};
-static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
-
-
-struct GncPluginFileHistoryPrivate
-{
- gpointer dummy;
-};
-
-
-/************************************************************
- * Other Functions *
- ************************************************************/
-
-/** This routine takes a filename and modifies it so that it will
- * display correctly in a GtkLabel. It also adds a mnemonic to
- * the start of the menu item.
- *
- * @filename A pointer to the filename to mangle.
- *
- * @return A pointer to the mangled filename. The Caller is
- * responsible for freeing this memory.
- */
-static gchar *
-gnc_history_generate_label (int index, const gchar *filename)
-{
- const gchar *src;
- gchar *result, *dst;
- gunichar unichar;
-
- /* raw byte length, not num characters */
- result = g_malloc(strlen(filename) * 2);
-
- dst = result;
- if (index < 10)
- dst += g_sprintf(result, "_%d ", (index + 1) % 10);
-
- /* Find the filename portion of the path */
- src = g_utf8_strrchr(filename, -1, '/');
- src = g_utf8_next_char(src);
-
- /* Fix up any underline characters so they aren't mistaken as
- * command accelerator keys. */
- for ( ; *src; src = g_utf8_next_char(src)) {
- unichar = g_utf8_get_char(src);
- dst += g_unichar_to_utf8 (unichar, dst);
-
- if (unichar == '_')
- dst += g_unichar_to_utf8 ('_', dst);
- }
-
- *dst = '\0';
- return result;
-}
-
-
-/** Update one entry in the file history menu. This function is
- * called by either the gnc_plugin_history_list_changed function or
- * the gnc_history_update_menus function. It updates the specified
- * file history item in the specified window.
- *
- * This routine attaches the actual filename to the menu_item (via
- * g_object_set_data) for later retrieval. It also massages the
- * filename so that it will display correctly in the menu, and also
- * add a mnemonic for the menu item.
- *
- * @window A pointer to window whose file history should be updated.
- *
- * @index Update this item in the menu (base-0).
- *
- * @filename The new filename to associate with this menu item.
- */
-static void
-gnc_history_update_action (GncMainWindow *window,
- gint index,
- const gchar *filename)
-{
- GtkActionGroup *action_group;
- GtkAction *action;
- gchar *action_name, *label_name, *old_filename;
-
- ENTER("window %p, index %d, filename %s", window, index, filename);
- /* Get the action group */
- action_group =
- gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME);
-
- action_name = g_strdup_printf("RecentFile%dAction", index);
- action = gtk_action_group_get_action (action_group, action_name);
-
- if (filename && (strlen(filename) > 0)) {
- /* set the menu label (w/accelerator) */
- label_name = gnc_history_generate_label(index, filename);
- g_object_set(G_OBJECT(action), "label", label_name, "visible", TRUE, NULL);
- g_free(label_name);
-
- /* set the filename for the callback function */
- old_filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING);
- if (old_filename)
- g_free(old_filename);
- g_object_set_data(G_OBJECT(action), FILENAME_STRING, g_strdup(filename));
- } else {
- g_object_set(G_OBJECT(action), "visible", FALSE, NULL);
- }
- g_free(action_name);
- LEAVE("");
-}
-
-
-/** Update an entry in the file history menu because a gconf entry
- * changed. This function is called whenever an item in the gconf
- * history section is changed. It is responsible for updating the
- * menu item that corresponds to that key.
- *
- * @client A pointer to gconf client that noticed an entry change.
- *
- * @cnxn_id Unused.
- *
- * @entry A pointer to gconf entry that changed.
- *
- * @user_data A pointer to the window that this gconf client is
- * associated with.
- */
-static void
-gnc_plugin_history_list_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
-{
- GncMainWindow *window;
- GConfValue *value;
- const gchar *key, *filename;
- gint index;
-
- ENTER("");
- key = gconf_entry_get_key(entry);
- index = gnc_history_gconf_key_to_index(key);
- if (index < 0)
- return;
-
- window = GNC_MAIN_WINDOW(user_data);
- value = gconf_entry_get_value(entry);
- if (!value) {
- LEAVE("No gconf value");
- return;
- }
- filename = gconf_value_get_string(value);
- gnc_history_update_action (window, index, filename);
-
- gnc_main_window_actions_updated (window);
- LEAVE("");
-}
-
-/** Update the file history menu for a window. This function walks
- * the list of all possible gconf keys for the file history and
- * forces a read/menu update on each key. It should only be called
- * once when the window is created.
- *
- * @window A pointer to the window whose file history menu should be
- * updated.
- */
-static void
-gnc_history_update_menus (GncMainWindow *window)
-{
- gchar *filename, *key;
- guint i;
-
- ENTER("");
- for (i = 0; i < MAX_HISTORY_FILES; i++) {
- key = g_strdup_printf(HISTORY_STRING_FILE_N, i);
- filename = gnc_gconf_get_string(HISTORY_STRING_SECTION, key, NULL);
- gnc_history_update_action(window, i, filename);
- g_free(filename);
- g_free(key);
- }
- LEAVE("");
-}
-
-
-/************************************************************
- * Object Implementation *
- ************************************************************/
-
-GType
-gnc_plugin_file_history_get_type (void)
-{
- static GType gnc_plugin_file_history_type = 0;
-
- if (gnc_plugin_file_history_type == 0) {
- static const GTypeInfo our_info = {
- sizeof (GncPluginFileHistoryClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) gnc_plugin_file_history_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GncPluginFileHistory),
- 0,
- (GInstanceInitFunc) gnc_plugin_file_history_init
- };
-
- gnc_plugin_file_history_type = g_type_register_static (GNC_TYPE_PLUGIN,
- "GncPluginFileHistory",
- &our_info, 0);
- }
-
- return gnc_plugin_file_history_type;
-}
-
-static void
-gnc_plugin_file_history_class_init (GncPluginFileHistoryClass *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_file_history_finalize;
-
- /* plugin info */
- plugin_class->plugin_name = GNC_PLUGIN_FILE_HISTORY_NAME;
-
- /* function overrides */
- plugin_class->add_to_window = gnc_plugin_file_history_add_to_window;
- plugin_class->remove_from_window = gnc_plugin_file_history_remove_from_window;
-
- /* 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;
-
- plugin_class->gconf_section = HISTORY_STRING_SECTION;
- plugin_class->gconf_notifications = gnc_plugin_history_list_changed;
-}
-
-static void
-gnc_plugin_file_history_init (GncPluginFileHistory *plugin)
-{
- ENTER("plugin %p", plugin);
- plugin->priv = g_new0 (GncPluginFileHistoryPrivate, 1);
- LEAVE("");
-}
-
-static void
-gnc_plugin_file_history_finalize (GObject *object)
-{
- GncPluginFileHistory *plugin;
-
- g_return_if_fail (GNC_IS_PLUGIN_FILE_HISTORY (object));
-
- plugin = GNC_PLUGIN_FILE_HISTORY (object);
- ENTER("plugin %p", plugin);
-
- g_return_if_fail (plugin->priv != NULL);
- g_free (plugin->priv);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
- LEAVE("");
-}
-
-GncPlugin *
-gnc_plugin_file_history_new (void)
-{
- GncPlugin *plugin_page = NULL;
-
- ENTER("");
- plugin_page = GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_FILE_HISTORY, NULL));
- LEAVE("plugin %p", plugin_page);
- return plugin_page;
-}
-
-/************************************************************
- * Plugin Function Implementation *
- ************************************************************/
-
-/** Initialize the file history menu for a window. This function is
- * called as part of the initialization of a window, after all the
- * plugin menu items have been added to the menu structure. Its job
- * is to correctly initialize the file history menu. It does this by
- * first calling a function that initializes the menu to the current
- * as maintained in gconf. It then creates a gconf client that will
- * listens for any changes to the file history menu, and will update
- * the meny when they are signalled.
- *
- * @param plugin A pointer to the gnc-plugin object responsible for
- * adding/removing the file history menu.
- *
- * @param window A pointer the gnc-main-window that is being initialized.
- *
- * @param type Unused
- */
-static void
-gnc_plugin_file_history_add_to_window (GncPlugin *plugin,
- GncMainWindow *window,
- GQuark type)
-{
- gnc_history_update_menus(window);
-}
-
-
-/** Finalize the file history menu for this window. This function is
- * called as part of the destruction of a window.
- *
- * @param plugin A pointer to the gnc-plugin object responsible for
- * adding/removing the file history menu. It stops the gconf
- * notifications for this window, and destroys the gconf client
- * object.
- *
- * @param window A pointer the gnc-main-window that is being destroyed.
- *
- * @param type Unused
- */
-static void
-gnc_plugin_file_history_remove_from_window (GncPlugin *plugin,
- GncMainWindow *window,
- GQuark type)
-{
-}
-
-/************************************************************
- * Command Callbacks *
- ************************************************************/
-
-/** The user has selected one of the items in the File History menu.
- * Close down the current session and start up a new one with the
- * requested file.
- *
- * @param action A pointer to the action selected by the user. This
- * action represents one of the items in the file history menu.
- *
- * @param data A pointer to the gnc-main-window data to be used by
- * this function. This is mainly to find out which window it was
- * that had a menu selected. That's not really important for this
- * function and we're about to close all the windows anyway.
- */
-static void
-gnc_plugin_file_history_cmd_open_file (GtkAction *action,
- GncMainWindowActionData *data)
-{
- gchar *filename;
-
- g_return_if_fail(GTK_IS_ACTION(action));
- g_return_if_fail(data != NULL);
-
- /* DRH - Do we need to close all open windows but the first?
- * Which progressbar should we be using? One in a window, or
- * in a new "file loading" dialog???
- */
- filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING);
- gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
- gnc_file_open_file (filename); /* also opens new account page */
- gnc_window_set_progressbar_window (NULL);
-}
-
-/** @} */
-/** @} */
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/Makefile.am,v
retrieving revision 1.107.4.23
retrieving revision 1.107.4.24
diff -Lsrc/gnome/Makefile.am -Lsrc/gnome/Makefile.am -u -r1.107.4.23 -r1.107.4.24
--- src/gnome/Makefile.am
+++ src/gnome/Makefile.am
@@ -9,13 +9,11 @@
libgncgnome_la_LDFLAGS = -module
libgncgnome_la_LIBADD = \
${top_builddir}/src/engine/libgncmod-engine.la \
- ${top_builddir}/src/app-file/libgncmod-app-file.la \
${top_builddir}/src/backend/file/libgncmod-backend-file.la \
${top_builddir}/src/report/report-system/libgncmod-report-system.la \
${top_builddir}/src/report/report-gnome/libgncmod-report-gnome.la \
${top_builddir}/src/register/ledger-core/libgncmod-ledger-core.la \
${top_builddir}/src/gnome-search/libgncmod-gnome-search.la \
- ${top_builddir}/src/app-file/libgncmod-app-file.la \
${GUILE_LIBS} ${GNOME_LIBS} ${GLIB_LIBS}
libgw_gnc_la_SOURCES = gw-gnc.c
@@ -48,7 +46,6 @@
druid-merge.c \
druid-loan.c \
druid-stock-split.c \
- gnc-plugin-file-history.c \
gnc-plugin-basic-commands.c \
gnc-plugin-account-tree.c \
gnc-plugin-register.c \
@@ -93,7 +90,6 @@
druid-stock-split.h \
gnc-plugin-account-tree.h \
gnc-plugin-basic-commands.h \
- gnc-plugin-file-history.h \
gnc-plugin-register.h \
gnc-plugin-page-account-tree.h \
gnc-plugin-page-register.h \
@@ -123,8 +119,6 @@
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/network-utils \
-I${top_srcdir}/src/app-utils \
- -I${top_srcdir}/src/app-file \
- -I${top_srcdir}/src/app-file/gnome \
-I${top_srcdir}/src/backend/file \
-I${top_srcdir}/src/g-wrap \
-I${top_srcdir}/src/gnome-utils \
--- /dev/null
+++ src/gnome-utils/gnc-plugin-file-history.h
@@ -0,0 +1,109 @@
+/*
+ * gnc-plugin-file-history.h --
+ * Copyright (C) 2003,2005 David Hampton <hampton at 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
+ * 59 Temple Place - Suite 330 Fax: +1-617-542-2652
+ * Boston, MA 02111-1307, USA gnu at gnu.org
+ */
+
+/** @addtogroup GUI
+ @{ */
+/** @addtogroup GuiImport Import GUI Utility functions.
+ @{ */
+/** @file gnc-plugin-file-history.h
+ @brief Utility functions for writing import modules.
+ @author Copyright (C) 2002 David Hampton <hampton at employees.org>
+*/
+
+#ifndef __GNC_PLUGIN_FILE_HISTORY_H
+#define __GNC_PLUGIN_FILE_HISTORY_H
+
+#include <gtk/gtk.h>
+#include "gnc-plugin.h"
+
+G_BEGIN_DECLS
+
+/* type macros */
+#define GNC_TYPE_PLUGIN_FILE_HISTORY (gnc_plugin_file_history_get_type ())
+#define GNC_PLUGIN_FILE_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_PLUGIN_FILE_HISTORY, GncPluginFileHistory))
+#define GNC_PLUGIN_FILE_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_PLUGIN_FILE_HISTORY, GncPluginFileHistoryClass))
+#define GNC_IS_PLUGIN_FILE_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_PLUGIN_FILE_HISTORY))
+#define GNC_IS_PLUGIN_FILE_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN_FILE_HISTORY))
+#define GNC_PLUGIN_FILE_HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_PLUGIN_FILE_HISTORY, GncPluginFileHistoryClass))
+
+#define GNC_PLUGIN_FILE_HISTORY_NAME "gnc-plugin-file-history"
+#define MAX_HISTORY_FILES 10 /* May be any number up to 10 */
+#define HISTORY_STRING_SECTION "history"
+#define HISTORY_STRING_MAXFILES "maxfiles"
+#define HISTORY_STRING_FILE_N "file%d"
+
+/* typedefs & structures */
+typedef struct GncPluginFileHistoryPrivate GncPluginFileHistoryPrivate;
+
+typedef struct {
+ GncPlugin parent;
+ GncPluginFileHistoryPrivate *priv;
+} GncPluginFileHistory;
+
+typedef struct {
+ GncPluginClass parent;
+} GncPluginFileHistoryClass;
+
+/* function prototypes */
+
+
+/** Get the type of a file history plugin.
+ *
+ * @return A GType.
+ */
+GType gnc_plugin_file_history_get_type (void);
+
+
+/** Create a new file history plugin. This plugin attaches the file
+ * history menu to any window that is opened.
+ *
+ * @return A pointer to the new object.
+ */
+GncPlugin *gnc_plugin_file_history_new (void);
+
+
+/** Add a file name to the front of the file "history list". If the
+ * name already exist on the list, then it is moved from its current
+ * location to the front of the list. The "list" is actually a
+ * sequence of up to ten gconf keys.
+ *
+ * @param filename The name of the file to add to the list.
+ */
+void gnc_history_add_file (const char *filename);
+
+
+/** Retrieve the name of the file most recently accessed. This is the
+ * name at the front of the list. Since the "list" is actually a
+ * sequence of up to ten gconf keys, this is the value of key zero.
+ *
+ * @return This function returns an allocated string containing the
+ * name of the most recently accessed file. The caller is
+ * responsible for freeing this string.
+ */
+char * gnc_history_get_last (void);
+
+G_END_DECLS
+
+#endif /* __GNC_PLUGIN_FILE_HISTORY_H */
+
+/** @} */
+/** @} */
--- /dev/null
+++ src/gnome-utils/gnc-file.c
@@ -0,0 +1,989 @@
+/********************************************************************\
+ * FileDialog.c -- file-handling utility dialogs for gnucash. *
+ * *
+ * Copyright (C) 1997 Robin D. Clark *
+ * Copyright (C) 1998, 1999, 2000 Linas Vepstas *
+ * *
+ * 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, write to the Free Software *
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
+\********************************************************************/
+
+#include "config.h"
+
+#include <errno.h>
+#include <glib.h>
+#include <libguile.h>
+#include <string.h>
+#include <g-wrap-wct.h>
+
+#include "global-options.h"
+#include "gnc-commodity.h"
+#include "gnc-component-manager.h"
+#include "gnc-engine-util.h"
+#include "gnc-engine.h"
+#include "gnc-event.h"
+#include "gnc-file.h"
+#include "gnc-filepath-utils.h"
+#include "gnc-gui-query.h"
+#include "gnc-hooks.h"
+#include "gnc-splash.h"
+#include "gnc-ui.h"
+#include "gnc-ui-util.h"
+#include "gnc-window.h"
+#include "gnc-gconf-utils.h"
+#include "gnc-plugin-file-history.h"
+#include "qofbackend.h"
+#include "qofbook.h"
+#include "qofsession.h"
+#include "messages.h"
+#include "TransLog.h"
+
+#define GCONF_SECTION "dialogs/export_accounts"
+
+/** GLOBALS *********************************************************/
+/* This static indicates the debugging module that this .o belongs to. */
+static short module = MOD_GUI;
+
+static GNCCanCancelSaveCB can_cancel_cb = NULL;
+static GNCShutdownCB shutdown_cb = NULL;
+
+
+/********************************************************************\
+ * gnc_file_dialog *
+ * Pops up a file selection dialog (either a "Save As" or an *
+ * "Open"), and returns the name of the file the user selected. *
+ * (This function does not return until the user selects a file *
+ * or presses "Cancel" or the window manager destroy button) *
+ * *
+ * Args: title - the title of the window *
+ * filter - the file filter to use *
+ * default_name - the default name to use *
+ * Return: containing the name of the file the user selected *
+\********************************************************************/
+
+char *
+gnc_file_dialog (const char * title,
+ const char * filter,
+ const char *default_name)
+{
+ GtkFileSelection *file_box;
+ const char *internal_name;
+ char *file_name = NULL;
+ gint response;
+
+ ENTER("\n");
+
+ /* Set a default title if nothing was passed in */
+ if (title == NULL)
+ title = _("Open");
+
+ file_box = GTK_FILE_SELECTION(gtk_file_selection_new(title));
+
+ if (default_name)
+ gtk_file_selection_set_filename(file_box, default_name);
+
+ /* hack alert - this was filtering directory names as well as file
+ * names, so I think we should not do this by default (rgmerk) */
+#if 0
+ if (filter != NULL)
+ gtk_file_selection_complete(file_box, filter);
+#endif
+
+ gtk_window_set_modal(GTK_WINDOW(file_box), TRUE);
+ gtk_window_set_transient_for(GTK_WINDOW(file_box),
+ GTK_WINDOW(gnc_ui_get_toplevel()));
+ response = gtk_dialog_run(GTK_DIALOG(file_box));
+
+ if (response == GTK_RESPONSE_OK) {
+ /* look for constructs like postgres://foo */
+ internal_name = gtk_entry_get_text(GTK_ENTRY(file_box->selection_entry));
+ if (strstr (internal_name, "://") == 0) {
+ /* nope, a local file name */
+ internal_name = gtk_file_selection_get_filename(file_box);
+ }
+ file_name = g_strdup(internal_name);
+ }
+ gtk_widget_destroy(GTK_WIDGET(file_box));
+ LEAVE("%s", file_name);
+ return file_name;
+}
+
+
+gboolean
+show_session_error (QofBackendError io_error, const char *newfile)
+{
+ GtkWidget *parent = gnc_ui_get_toplevel();
+ gboolean uh_oh = TRUE;
+ const char *fmt;
+
+ gnc_destroy_splash_screen(); /* Just in case */
+ if (NULL == newfile) { newfile = _("(null)"); }
+
+ switch (io_error)
+ {
+ case ERR_BACKEND_NO_ERR:
+ uh_oh = FALSE;
+ break;
+
+ case ERR_BACKEND_NO_HANDLER: {
+ fmt = _("No suitable backend was found for\n%s.");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+ }
+ case ERR_BACKEND_NO_BACKEND:
+ fmt = _("The URL \n %s\n"
+ "is not supported by this version of GnuCash.");
+ gnc_error_dialog (parent, fmt, newfile);
+ break;
+
+ case ERR_BACKEND_BAD_URL:
+ fmt = _("Can't parse the URL\n %s\n");
+ gnc_error_dialog (parent, fmt, newfile);
+ break;
+
+ case ERR_BACKEND_CANT_CONNECT:
+ fmt = _("Can't connect to\n %s\n"
+ "The host, username or password were incorrect.");
+ gnc_error_dialog (parent, fmt, newfile);
+ break;
+
+ case ERR_BACKEND_CONN_LOST:
+ fmt = _("Can't connect to\n %s\n"
+ "Connection was lost, unable to send data.");
+ gnc_error_dialog (parent, fmt, newfile);
+ break;
+
+ case ERR_BACKEND_TOO_NEW:
+ fmt = _("This file/URL appears to be from a newer version\n"
+ "of GnuCash. You must upgrade your version of GnuCash\n"
+ "to work with this data.");
+ gnc_error_dialog (parent, fmt);
+ break;
+
+ case ERR_BACKEND_NO_SUCH_DB:
+ fmt = _("The database\n"
+ " %s\n"
+ "doesn't seem to exist. Do you want to create it?\n");
+ if (gnc_verify_dialog (parent, TRUE, fmt, newfile)) { uh_oh = FALSE; }
+ break;
+
+ case ERR_BACKEND_LOCKED:
+ fmt = _("GnuCash could not obtain the lock for\n"
+ " %s.\n"
+ "That database may be in use by another user,\n"
+ "in which case you should not open the database.\n"
+ "\nDo you want to proceed with opening the database?");
+ if (gnc_verify_dialog (parent, TRUE, fmt, newfile)) { uh_oh = FALSE; }
+ break;
+
+ case ERR_BACKEND_READONLY:
+ fmt = _("GnuCash could not write to\n"
+ " %s.\n"
+ "That database may be on a read-only file system,\n"
+ "or you may not have write permission for the directory.\n");
+ gnc_error_dialog (parent, fmt, newfile);
+ break;
+
+ case ERR_BACKEND_DATA_CORRUPT:
+ fmt = _("The file/URL \n %s\n"
+ "does not contain GnuCash data or the data is corrupt.");
+ gnc_error_dialog (parent, fmt, newfile);
+ break;
+
+ case ERR_BACKEND_SERVER_ERR:
+ fmt = _("The server at URL \n %s\n"
+ "experienced an error or encountered bad or corrupt data.");
+ gnc_error_dialog (parent, fmt, newfile);
+ break;
+
+ case ERR_BACKEND_PERM:
+ fmt = _("You do not have permission to access\n %s\n");
+ gnc_error_dialog (parent, fmt, newfile);
+ break;
+
+ case ERR_BACKEND_MISC:
+ fmt = _("An error occurred while processing\n %s\n");
+ gnc_error_dialog (parent, fmt, newfile);
+ break;
+
+ /* QSF additions */
+ case ERR_QSF_INVALID_OBJ: {
+ fmt = _("Invalid QSF Object file!\n"
+ "The QSF object file\n%s\n failed to validate"
+ " against the QSF object schema.\nThe XML structure of the file"
+ " is either not well-formed or contains illegal data.");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+ }
+ case ERR_QSF_INVALID_MAP: {
+ fmt = _("Invalid QSF Map file!\n"
+ "The QSF map file\n%s\n failed to validate "
+ " against the QSF map schema.\nThe XML structure of the file"
+ " is either not well-formed or contains illegal data.");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+ }
+ case ERR_QSF_BAD_QOF_VERSION: {
+ fmt = _("The QSF Map file\n%s\nwas written for a different version of QOF\n"
+ "It may need to be modified to work with your current QOF installation.");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+ }
+ case ERR_QSF_BAD_MAP: {
+ fmt = _("The selected QSF map\n%s\ncontains unusable data."
+ " This is usually because not all the required parameters for "
+ " the defined objects have calculations described in the map.");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+ }
+ case ERR_QSF_BAD_OBJ_GUID: {
+ fmt = _("The selected QSF object file\n%s\n contains one or more invalid GUIDs."
+ "The file cannot be processed - please check the source of the file"
+ " and try again.");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+ }
+ case ERR_QSF_NO_MAP: {
+ fmt = _("The selected QSF Object file\n%s\nrequires a map but it was not provided.");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+ }
+ case ERR_QSF_WRONG_MAP: {
+ fmt = _("Wrong QSF map selected.\n"
+ "The selected map,\n%s\n validates but was written"
+ "for different QOF objects.\n The list of objects defined in "
+ "this map does not include all the objects described in"
+ "the current QSF object file.");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+ }
+ case ERR_QSF_MAP_NOT_OBJ: {
+ fmt = _("The selected file %s is a QSF map and cannot be "
+ "opened as a QSF object.");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+ }
+ case ERR_QSF_OVERFLOW : {
+ fmt = _("When converting XML strings into numbers, an overflow "
+ "has been detected. The QSF object file\n%s\n contains invalid "
+ "data in a field that is meant to hold a number.");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+ }
+ case ERR_QSF_OPEN_NOT_MERGE : {
+ fmt = _("The QSF object file\n%s\nis valid and contains GnuCash "
+ "objects. However, GnuCash cannot open the file directly because "
+ "the data needs to be merged into an existing GnuCash data book. "
+ "Please open a GnuCash file or create a new one, then import "
+ "this QSF object file so that the data can be merged into the "
+ "main data book.");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+ }
+ case ERR_FILEIO_FILE_BAD_READ:
+ fmt = _("There was an error reading the file.\n"
+ "Do you want to continue?");
+ if (gnc_verify_dialog (parent, TRUE, fmt)) { uh_oh = FALSE; }
+ break;
+
+ case ERR_FILEIO_PARSE_ERROR:
+ fmt = _("There was an error parsing the file \n %s\n");
+ gnc_error_dialog (parent, fmt, newfile);
+ break;
+
+ case ERR_FILEIO_FILE_EMPTY:
+ fmt = _("The file \n %s\n is empty.");
+ gnc_error_dialog (parent, fmt, newfile);
+ break;
+
+ case ERR_FILEIO_FILE_NOT_FOUND:
+ fmt = _("The file \n %s\n could not be found.");
+ gnc_error_dialog (parent, fmt, newfile);
+ break;
+
+ case ERR_FILEIO_FILE_TOO_OLD:
+ fmt = _("This file is from an older version of GnuCash.\n"
+ "Do you want to continue?");
+ if (gnc_verify_dialog (parent, TRUE, fmt)) { uh_oh = FALSE; }
+ break;
+
+ case ERR_FILEIO_UNKNOWN_FILE_TYPE:
+ fmt = _("Unknown file type");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+
+ case ERR_FILEIO_BACKUP_ERROR:
+ fmt = _("Could not make a backup of %s\n");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+
+ case ERR_FILEIO_WRITE_ERROR:
+ fmt = _("Could not write to %s\nCheck that you have"
+ " permission to write to this file and that "
+ " there is sufficient space to create it.");
+ gnc_error_dialog(parent, fmt, newfile);
+ break;
+
+ case ERR_SQL_DB_TOO_OLD:
+ fmt = _("This database is from an older version of GnuCash.\n"
+ "Do you want to want to upgrade the database "
+ "to the current version?");
+ if (gnc_verify_dialog (parent, TRUE, fmt)) { uh_oh = FALSE; }
+ break;
+
+ case ERR_SQL_DB_BUSY:
+ fmt = _("The SQL database is in use by other users, "
+ "and the upgrade cannot be performed until they logoff.\n"
+ "If there are currently no other users, consult the \n"
+ "documentation to learn how to clear out dangling login\n"
+ "sessions.");
+ gnc_error_dialog (parent, fmt);
+ break;
+
+ default:
+ PERR("FIXME: Unhandled error %d", io_error);
+ fmt = _("An unknown I/O error occurred.");
+ gnc_error_dialog (parent, fmt);
+ break;
+ }
+
+ return uh_oh;
+}
+
+static void
+gnc_add_history (QofSession * session)
+{
+ char *url;
+ char *file;
+
+ if (!session) return;
+
+ url = xaccResolveURL (qof_session_get_url (session));
+ if (!url)
+ return;
+
+ if (strncmp (url, "file:", 5) == 0)
+ file = url + 5;
+ else
+ file = url;
+
+ gnc_history_add_file (file);
+
+ g_free (url);
+}
+
+static void
+gnc_book_opened (void)
+{
+ gnc_hook_run(HOOK_BOOK_OPENED, qof_session_get_current_session());
+}
+
+void
+gnc_file_new (void)
+{
+ QofSession *session;
+
+ /* If user attempts to start a new session before saving results of
+ * the last one, prompt them to clean up their act. */
+ if (!gnc_file_query_save ())
+ return;
+
+ session = qof_session_get_current_session ();
+
+ /* close any ongoing file sessions, and free the accounts.
+ * disable events so we don't get spammed by redraws. */
+ gnc_engine_suspend_events ();
+
+ qof_session_call_close_hooks(session);
+ gnc_hook_run(HOOK_BOOK_CLOSED, session);
+
+ gnc_close_gui_component_by_session (session);
+ xaccLogDisable();
+ qof_session_destroy (session);
+ xaccLogEnable();
+
+ /* start a new book */
+ qof_session_get_current_session ();
+
+ gnc_hook_run(HOOK_NEW_BOOK, NULL);
+
+ gnc_book_opened ();
+
+ gnc_engine_resume_events ();
+ gnc_gui_refresh_all ();
+}
+
+gboolean
+gnc_file_query_save (void)
+{
+ GtkWidget *parent = gnc_ui_get_toplevel();
+
+ /* If user wants to mess around before finishing business with
+ * the old file, give em a chance to figure out what's up.
+ * Pose the question as a "while" loop, so that if user screws
+ * up the file-selection dialog, we don't blow em out of the water;
+ * instead, give them another chance to say "no" to the verify box.
+ */
+ while (qof_book_not_saved(qof_session_get_book (qof_session_get_current_session ())))
+ {
+ gint result;
+ const char *message = _("Changes have been made since the last "
+ "Save. Save the data to file?");
+
+ if (can_cancel_cb && can_cancel_cb ())
+ result = gnc_verify_cancel_dialog (parent, GTK_RESPONSE_YES, message);
+ else
+ {
+ gboolean do_save = gnc_verify_dialog (parent, TRUE, message);
+
+ result = do_save ? GTK_RESPONSE_YES : GTK_RESPONSE_NO;
+ }
+
+ if (result == GTK_RESPONSE_CANCEL)
+ return FALSE;
+
+ if (result == GTK_RESPONSE_NO)
+ return TRUE;
+
+ gnc_file_save ();
+ }
+
+ return TRUE;
+}
+
+/* private utilities for file open; done in two stages */
+
+static gboolean
+gnc_post_file_open (const char * filename)
+{
+ QofSession *current_session, *new_session;
+ gboolean uh_oh = FALSE;
+ char * newfile;
+ QofBackendError io_err = ERR_BACKEND_NO_ERR;
+
+ if (!filename) return FALSE;
+
+ newfile = xaccResolveURL (filename);
+ if (!newfile)
+ {
+ show_session_error (ERR_FILEIO_FILE_NOT_FOUND, filename);
+ return FALSE;
+ }
+
+ /* disable events while moving over to the new set of accounts;
+ * the mass deletetion of accounts and transactions during
+ * switchover would otherwise cause excessive redraws. */
+ gnc_engine_suspend_events ();
+
+ /* Change the mouse to a busy cursor */
+ gnc_set_busy_cursor (NULL, TRUE);
+
+ /* -------------- BEGIN CORE SESSION CODE ------------- */
+ /* -- this code is almost identical in FileOpen and FileSaveAs -- */
+ current_session = qof_session_get_current_session();
+ qof_session_call_close_hooks(current_session);
+ gnc_hook_run(HOOK_BOOK_CLOSED, current_session);
+ xaccLogDisable();
+ qof_session_destroy (current_session);
+ xaccLogEnable();
+
+ /* load the accounts from the users datafile */
+ /* but first, check to make sure we've got a session going. */
+ new_session = qof_session_new ();
+
+ qof_session_begin (new_session, newfile, FALSE, FALSE);
+ io_err = qof_session_get_error (new_session);
+ /* if file appears to be locked, ask the user ... */
+ if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err)
+ {
+ const char *buttons[] = { GTK_STOCK_QUIT, GTK_STOCK_OPEN,
+ GTK_STOCK_NEW, NULL };
+ char *fmt = ((ERR_BACKEND_LOCKED == io_err) ?
+ _("GnuCash could not obtain the lock for\n"
+ " %s.\n"
+ "That database may be in use by another user,\n"
+ "in which case you should not open the database.\n"
+ "\nWhat would you like to do?") :
+ _("WARNING!!! GnuCash could not obtain the lock for\n"
+ " %s.\n"
+ "That database may be on a read-only file system,\n"
+ "or you may not have write permission for the directory.\n"
+ "If you proceed you may not be able to save any changes.\n"
+ "\nWhat would you like to do?")
+ );
+ int rc;
+
+ gnc_destroy_splash_screen(); /* Just in case */
+ if (shutdown_cb) {
+ rc = gnc_generic_question_dialog (NULL, buttons, fmt, newfile);
+ } else {
+ rc = gnc_generic_question_dialog (NULL, buttons+1, fmt, newfile)+1;
+ }
+
+ if (rc == 0)
+ {
+ if (shutdown_cb)
+ shutdown_cb(0);
+ g_assert(1);
+ }
+ else if (rc == 1)
+ {
+ /* user told us to ignore locks. So ignore them. */
+ qof_session_begin (new_session, newfile, TRUE, FALSE);
+ }
+ else
+ {
+ /* Can't use the given file, so just create a new
+ * database so that the user will get a window that
+ * they can click "Exit" on.
+ */
+ gnc_file_new ();
+ }
+ }
+ if(ERR_QSF_OPEN_NOT_MERGE == io_err)
+ {
+ uh_oh = TRUE;
+ }
+ /* if the database doesn't exist, ask the user ... */
+ else if ((ERR_BACKEND_NO_SUCH_DB == io_err) ||
+ (ERR_SQL_DB_TOO_OLD == io_err))
+ {
+ if (FALSE == show_session_error (io_err, newfile))
+ {
+ /* user told us to create a new database. Do it. */
+ qof_session_begin (new_session, newfile, FALSE, TRUE);
+ }
+ }
+
+ /* Check for errors again, since above may have cleared the lock.
+ * If its still locked, still, doesn't exist, still too old, then
+ * don't bother with the message, just die. */
+ io_err = qof_session_get_error (new_session);
+ if ((ERR_BACKEND_LOCKED == io_err) ||
+ (ERR_BACKEND_READONLY == io_err) ||
+ (ERR_BACKEND_NO_SUCH_DB == io_err) ||
+ (ERR_SQL_DB_TOO_OLD == io_err))
+ {
+ uh_oh = TRUE;
+ }
+ else
+ {
+ uh_oh = show_session_error (io_err, newfile);
+ }
+
+ if (!uh_oh)
+ {
+ AccountGroup *new_group;
+
+ char * logpath = xaccResolveFilePath(newfile);
+ PINFO ("logpath=%s", logpath ? logpath : "(null)");
+ xaccLogSetBaseName (logpath);
+ xaccLogDisable();
+
+ gnc_window_show_progress(_("Reading file..."), 0.0);
+ qof_session_load (new_session, gnc_window_show_progress);
+ gnc_window_show_progress(NULL, -1.0);
+ xaccLogEnable();
+
+ /* check for i/o error, put up appropriate error dialog */
+ io_err = qof_session_get_error (new_session);
+ uh_oh = show_session_error (io_err, newfile);
+
+ new_group = gnc_book_get_group (qof_session_get_book (new_session));
+ if (uh_oh) new_group = NULL;
+
+ /* Umm, came up empty-handed, but no error:
+ * The backend forgot to set an error. So make one up. */
+ if (!uh_oh && !new_group)
+ {
+ uh_oh = show_session_error (ERR_BACKEND_MISC, newfile);
+ }
+ }
+
+ gnc_unset_busy_cursor (NULL);
+
+ /* going down -- abandon ship */
+ if (uh_oh)
+ {
+ xaccLogDisable();
+ qof_session_destroy (new_session);
+ xaccLogEnable();
+
+ /* well, no matter what, I think it's a good idea to have a
+ * topgroup around. For example, early in the gnucash startup
+ * sequence, the user opens a file; if this open fails for any
+ * reason, we don't want to leave them high & dry without a
+ * topgroup, because if the user continues, then bad things will
+ * happen. */
+ qof_session_get_current_session ();
+
+ g_free (newfile);
+
+ gnc_engine_resume_events ();
+ gnc_gui_refresh_all ();
+
+ gnc_book_opened ();
+
+ return FALSE;
+ }
+
+ /* if we got to here, then we've successfully gotten a new session */
+ /* close up the old file session (if any) */
+ qof_session_set_current_session(new_session);
+
+ gnc_book_opened ();
+
+ /* --------------- END CORE SESSION CODE -------------- */
+
+ /* clean up old stuff, and then we're outta here. */
+ gnc_add_history (new_session);
+
+ g_free (newfile);
+
+ gnc_engine_resume_events ();
+ gnc_gui_refresh_all ();
+
+ return TRUE;
+}
+
+gboolean
+gnc_file_open (void)
+{
+ const char * newfile;
+ gboolean result;
+
+ if (!gnc_file_query_save ())
+ return FALSE;
+
+ newfile = gnc_file_dialog (_("Open"), NULL, gnc_history_get_last());
+ result = gnc_post_file_open (newfile);
+
+ /* This dialogue can show up early in the startup process. If the
+ * user fails to pick a file (by e.g. hitting the cancel button), we
+ * might be left with a null topgroup, which leads to nastiness when
+ * user goes to create their very first account. So create one. */
+ qof_session_get_current_session ();
+
+ return result;
+}
+
+gboolean
+gnc_file_open_file (const char * newfile)
+{
+ if (!newfile) return FALSE;
+
+ if (!gnc_file_query_save ())
+ return FALSE;
+
+ return gnc_post_file_open (newfile);
+}
+
+void
+gnc_file_export_file(const char * newfile)
+{
+ QofSession *current_session, *new_session;
+ gboolean ok;
+ QofBackendError io_err = ERR_BACKEND_NO_ERR;
+ gchar *default_dir;
+
+ default_dir = gnc_gconf_get_string(GCONF_SECTION, KEY_LAST_PATH, NULL);
+ if (default_dir == NULL)
+ gnc_init_default_directory(&default_dir);
+
+ if (!newfile) {
+ newfile = gnc_file_dialog (_("Export"), NULL, default_dir);
+ g_free(default_dir);
+ default_dir = NULL;
+ if (!newfile)
+ return;
+ }
+
+ /* Remember the directory as the default. */
+ gnc_extract_directory(&default_dir, newfile);
+ gnc_gconf_set_string(GCONF_SECTION, KEY_LAST_PATH, default_dir, NULL);
+ g_free(default_dir);
+
+ gnc_engine_suspend_events();
+
+ /* -- this session code is NOT identical in FileOpen and FileSaveAs -- */
+
+ new_session = qof_session_new ();
+ qof_session_begin (new_session, newfile, FALSE, FALSE);
+
+ io_err = qof_session_get_error (new_session);
+
+ /* if file appears to be locked, ask the user ... */
+ if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err)
+ {
+ if (FALSE == show_session_error (io_err, newfile))
+ {
+ /* user told us to ignore locks. So ignore them. */
+ qof_session_begin (new_session, newfile, TRUE, FALSE);
+ }
+ }
+
+ /* --------------- END CORE SESSION CODE -------------- */
+
+ /* oops ... file already exists ... ask user what to do... */
+ if (qof_session_save_may_clobber_data (new_session))
+ {
+ const char *format = _("The file \n %s\n already exists.\n"
+ "Are you sure you want to overwrite it?");
+
+ /* if user says cancel, we should break out */
+ if (!gnc_verify_dialog (NULL, FALSE, format, newfile))
+ {
+ return;
+ }
+
+ /* Whoa-ok. Blow away the previous file. */
+ }
+
+ /* use the current session to save to file */
+ gnc_set_busy_cursor (NULL, TRUE);
+ current_session = qof_session_get_current_session();
+ gnc_window_show_progress(_("Exporting file..."), 0.0);
+ ok = qof_session_export (new_session, current_session,
+ gnc_window_show_progress);
+ gnc_window_show_progress(NULL, -1.0);
+ gnc_unset_busy_cursor (NULL);
+ xaccLogDisable();
+ qof_session_destroy (new_session);
+ xaccLogEnable();
+ gnc_engine_resume_events();
+
+ if (!ok)
+ {
+ /* %s is the strerror(3) error string of the error that occurred. */
+ const char *format = _("There was an error saving the file.\n\n%s");
+
+ gnc_error_dialog (NULL, format, strerror(errno));
+ return;
+ }
+}
+
+static gboolean been_here_before = FALSE;
+
+void
+gnc_file_save (void)
+{
+ QofBackendError io_err;
+ const char * newfile;
+ QofSession *session;
+ ENTER (" ");
+
+ /* hack alert -- Somehow make sure all in-progress edits get committed! */
+
+ /* If we don't have a filename/path to save to get one. */
+ session = qof_session_get_current_session ();
+
+ if (!qof_session_get_file_path (session))
+ {
+ gnc_file_save_as ();
+ return;
+ }
+
+ /* use the current session to save to file */
+ gnc_set_busy_cursor (NULL, TRUE);
+ gnc_window_show_progress(_("Writing file..."), 0.0);
+ qof_session_save (session, gnc_window_show_progress);
+ gnc_window_show_progress(NULL, -1.0);
+ gnc_unset_busy_cursor (NULL);
+
+ /* Make sure everything's OK - disk could be full, file could have
+ become read-only etc. */
+ newfile = qof_session_get_file_path (session);
+ io_err = qof_session_get_error (session);
+ if (ERR_BACKEND_NO_ERR != io_err)
+ {
+ show_session_error (io_err, newfile);
+
+ if (been_here_before) return;
+ been_here_before = TRUE;
+ gnc_file_save_as (); /* been_here prevents infinite recursion */
+ been_here_before = FALSE;
+ return;
+ }
+
+ gnc_add_history (session);
+
+ /* save the main window state */
+ scm_call_1 (scm_c_eval_string("gnc:main-window-save-state"),
+ (session ?
+ gw_wcp_assimilate_ptr (session, scm_c_eval_string("<gnc:Session*>")) :
+ SCM_BOOL_F));
+
+ LEAVE (" ");
+}
+
+void
+gnc_file_save_as (void)
+{
+ QofSession *new_session;
+ QofSession *session;
+ const char *filename;
+ char *default_dir = NULL; /* Default to last open */
+ const char *last;
+ char *newfile;
+ const char *oldfile;
+ QofBackendError io_err = ERR_BACKEND_NO_ERR;
+
+ ENTER(" ");
+
+ last = gnc_history_get_last();
+ if (last)
+ gnc_extract_directory(&default_dir, last);
+ else
+ gnc_init_default_directory(&default_dir);
+ filename = gnc_file_dialog (_("Save"), "*.gnc", default_dir);
+ if (default_dir)
+ free(default_dir);
+ if (!filename) return;
+
+ /* Check to see if the user specified the same file as the current
+ * file. If so, then just do that, instead of the below, which
+ * assumes a truly new name was given. */
+ newfile = xaccResolveURL (filename);
+ if (!newfile)
+ {
+ show_session_error (ERR_FILEIO_FILE_NOT_FOUND, filename);
+ return;
+ }
+
+ session = qof_session_get_current_session ();
+ oldfile = qof_session_get_file_path (session);
+ if (oldfile && (strcmp(oldfile, newfile) == 0))
+ {
+ g_free (newfile);
+ gnc_file_save ();
+ return;
+ }
+
+ /* -- this session code is NOT identical in FileOpen and FileSaveAs -- */
+
+ new_session = qof_session_new ();
+ qof_session_begin (new_session, newfile, FALSE, FALSE);
+
+ io_err = qof_session_get_error (new_session);
+
+ /* if file appears to be locked, ask the user ... */
+ if (ERR_BACKEND_LOCKED == io_err || ERR_BACKEND_READONLY == io_err)
+ {
+ if (FALSE == show_session_error (io_err, newfile))
+ {
+ /* user told us to ignore locks. So ignore them. */
+ qof_session_begin (new_session, newfile, TRUE, FALSE);
+ }
+ }
+
+ /* if the database doesn't exist, ask the user ... */
+ else if ((ERR_BACKEND_NO_SUCH_DB == io_err) ||
+ (ERR_SQL_DB_TOO_OLD == io_err))
+ {
+ if (FALSE == show_session_error (io_err, newfile))
+ {
+ /* user told us to create a new database. Do it. */
+ qof_session_begin (new_session, newfile, FALSE, TRUE);
+ }
+ }
+
+ /* check again for session errors (since above dialog may have
+ * cleared a file lock & moved things forward some more)
+ * This time, errors will be fatal.
+ */
+ io_err = qof_session_get_error (new_session);
+ if (ERR_BACKEND_NO_ERR != io_err)
+ {
+ show_session_error (io_err, newfile);
+ xaccLogDisable();
+ qof_session_destroy (new_session);
+ xaccLogEnable();
+ g_free (newfile);
+ return;
+ }
+
+ /* if we got to here, then we've successfully gotten a new session */
+ /* close up the old file session (if any) */
+ qof_session_swap_data (session, new_session);
+ xaccLogDisable();
+ qof_session_destroy (session);
+ xaccLogEnable();
+ session = NULL;
+
+ /* XXX At this point, we should really mark the data in the new session
+ * as being 'dirty', since we haven't saved it at all under the new
+ * session. But I'm lazy...
+ */
+ qof_session_set_current_session(new_session);
+
+ /* --------------- END CORE SESSION CODE -------------- */
+
+ /* oops ... file already exists ... ask user what to do... */
+ if (qof_session_save_may_clobber_data (new_session))
+ {
+ const char *format = _("The file \n %s\n already exists.\n"
+ "Are you sure you want to overwrite it?");
+
+ /* if user says cancel, we should break out */
+ if (!gnc_verify_dialog (NULL, FALSE, format, newfile))
+ {
+ g_free (newfile);
+ return;
+ }
+
+ /* Whoa-ok. Blow away the previous file. */
+ }
+
+ gnc_file_save ();
+
+ g_free (newfile);
+ LEAVE (" ");
+}
+
+void
+gnc_file_quit (void)
+{
+ QofSession *session;
+
+ gnc_set_busy_cursor (NULL, TRUE);
+ session = qof_session_get_current_session ();
+
+ /* disable events; otherwise the mass deletetion of accounts and
+ * transactions during shutdown would cause massive redraws */
+ gnc_engine_suspend_events ();
+
+ qof_session_call_close_hooks(session);
+ gnc_hook_run(HOOK_BOOK_CLOSED, session);
+
+ xaccLogDisable();
+ qof_session_destroy (session);
+ xaccLogEnable();
+
+ qof_session_get_current_session ();
+
+ gnc_engine_resume_events ();
+ gnc_unset_busy_cursor (NULL);
+}
+
+void
+gnc_file_set_can_cancel_callback (GNCCanCancelSaveCB cb)
+{
+ can_cancel_cb = cb;
+}
+
+void
+gnc_file_set_shutdown_callback (GNCShutdownCB cb)
+{
+ shutdown_cb = cb;
+}
Index: gw-gnome-utils-spec.scm
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/gw-gnome-utils-spec.scm,v
retrieving revision 1.19.4.9
retrieving revision 1.19.4.10
diff -Lsrc/gnome-utils/gw-gnome-utils-spec.scm -Lsrc/gnome-utils/gw-gnome-utils-spec.scm -u -r1.19.4.9 -r1.19.4.10
--- src/gnome-utils/gw-gnome-utils-spec.scm
+++ src/gnome-utils/gw-gnome-utils-spec.scm
@@ -35,14 +35,16 @@
"#include <gtk/gtk.h>\n"
"#include <gnc-amount-edit.h>\n"
"#include <gnc-date-edit.h>\n"
+ "#include <gnc-file.h>\n"
+ "#include <gnc-gconf-utils.h>\n"
"#include <gnc-gnome-utils.h>\n"
"#include <gnc-gui-query.h>\n"
"#include <gnc-html.h>\n"
"#include <gnc-mdi-utils.h>\n"
"#include <gnc-menu-extensions.h>\n"
+ "#include <gnc-plugin-file-history.h>\n"
"#include <gnc-ui.h>\n"
"#include <print-session.h>\n"
- "#include <gnc-gconf-utils.h>\n"
)))
@@ -496,4 +498,37 @@
'(((<gw:mchars> caller-owned) section)
((<gw:mchars> caller-owned) name))
"Get a boolean value from gconf.")
+
+ (gw:wrap-function
+ ws
+ 'gnc:file-query-save
+ '<gw:bool>
+ "gnc_file_query_save"
+ '()
+ "Query the user whether to save the current file, and save
+if they say 'Yes'. The return is false if the user says 'Cancel'.")
+
+ (gw:wrap-function
+ ws
+ 'gnc:file-quit
+ '<gw:void>
+ "gnc_file_quit"
+ '()
+ "Stop working with the current file.")
+
+ (gw:wrap-function
+ ws
+ 'gnc:file-open-file
+ '<gw:bool>
+ "gnc_file_open_file"
+ '(((<gw:mchars> caller-owned const) filename))
+ "Open filename.")
+
+ (gw:wrap-function
+ ws
+ 'gnc:history-get-last
+ '(<gw:mchars> callee-owned)
+ "gnc_history_get_last"
+ '()
+ "Get the last file opened by the user.")
)
--- /dev/null
+++ src/gnome-utils/gnc-file.h
@@ -0,0 +1,146 @@
+/********************************************************************\
+ * Copyright (C) 1997 Robin D. Clark *
+ * Copyright (C) 1998, 1999, 2000 Linas Vepstas (linas at linas.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, write to the Free Software *
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
+\********************************************************************/
+
+/*
+ * FILE: gnc-file.h
+ *
+ * FUNCTION:
+ * A set of file-handling utilities for GnuCash applications.
+ * These utilities will "do the right thing" when used in the "File..."
+ * pulldown menu, for the "New", "Open", "Save", "SaveAs", etc. menu entries.
+ * In particular, they will verify that old files don't get clobbered,
+ * they'll put up dialogue boxes to ask the user to confirm their actions,
+ * etc.
+ *
+ * These utilities are written in a GUI-independent fashion, and should
+ * work just fine with the Motif, gnome/gtk and Qt interfaces.
+ * These utilities are appropriate for direct invocation from guile.
+ * (they should be wrapped by g-wrap).
+ *
+ * These GUI utilities implement and maintain a single global "session"
+ * that defines the currently edited account group. In a sense, these
+ * functions provide the GUI for the xaccSession object. The session
+ * is essentially a file that is open for editing, with locks on it
+ * to prevent other readers and writers from accessing it as long as its
+ * open.
+ *
+ *
+ * The gnc_file_save() routine will check for an existing edit session,
+ * and if one exists, it will save the account info to a file.
+ * If an error occurs, a popup dialogue will inform the user of
+ * the error. If there is no existing filename open, then the
+ * user will be prompted for a file to save to (using the
+ * gnc_file_save_as() routine). The existing session will remain
+ * open for further editing.
+ *
+ * The gnc_file_save_as() routine will prompt the user for a filename
+ * to save the account data to (using the standard GUI file dialogue
+ * box). If the user specifies a filename, the account data will be
+ * saved. If an error occurs, a popup dialogue will inform the user
+ * of the error. One possible error is that another user has
+ * the indicated file already locked up in a different session
+ * (in which case it is up to the user to try again, or to pick
+ * a different filename). If it is possible to save without
+ * an error, then a new session is started for the indicated
+ * filename, locking out other users. This new session remains
+ * open for further editing.
+ *
+ * The gnc_file_query_save() routine will display a popup dialog asking
+ * the user if they wish to save their current work. If they answer
+ * "yes", their work will be saved (using the gncFileSave function),
+ * otherwise no action will be performed. If there is no currently
+ * locked session, a popup will query the user for a filename
+ * (using the gnc_file_save_as() routine). The routine will return
+ * TRUE if the user hits "Yes" or "No" and FALSE if the user
+ * hits "Cancel". If nothing needed to be saved, the routine
+ * will return TRUE.
+ *
+ * The gnc_file_new() routine will check for an existing edit session.
+ * If one exists, it will ask the user if they want to save it,
+ * (using the gnc_file_query_save_as() dialogue). Then the current
+ * session will be destroyed, file locks will be removed, and
+ * account group structures will be set up for a new session.
+ *
+ * The gnc_file_open() routine check for an existing edit session.
+ * If one exists, it will ask the user if they want to save it.
+ * (using the gnc_file_query_save() dialogue). Next, the user will
+ * be prompted with a GUI standard file-selection dialogue to
+ * to pick a new file. If no file is picked, this routine returns.
+ * If a new file was picked, then the current session will be
+ * destroyed and file locks on it will be removed. The new
+ * file will then be opened for editing, establishing locks, etc.
+ * If an error occurs, the user will be informed with a pop-up
+ * dialogue. If the file cannot be found, or if a read
+ * error occurs, a popup describing the error will pop up.
+ * One possible error is that another user has the indicated
+ * file already locked up in a different session (in which
+ * case it is up to the user to try again, or to pick
+ * a different filename).
+ *
+ * The gnc_file_open_file() routine behaves much like the gnc_file_open()
+ * routine, except that the new file to open is passed as a char *
+ * argument.
+ *
+ * The gnc_file_export_file() routine will check for an existing edit
+ * session, and if one exists, it will save just the commodities
+ * and accounts to a file. If an error occurs, a popup dialogue
+ * will inform the user of the error.
+ *
+ * The gnc_file_quit() routine will close out and destroy the current session.
+ * The user WILL NOT BE PROMPTED to confirm this action, or do do
+ * any kind of saving beforehand.
+ *
+ * HISTORY:
+ * Derived from Rob Clark's original MainWindow.c code, Dec 1998
+ */
+
+#ifndef GNC_FILE_H
+#define GNC_FILE_H
+
+#include <glib.h>
+#include "qofbackend.h"
+
+void gnc_file_new (void);
+gboolean gnc_file_open (void);
+void gnc_file_save (void);
+void gnc_file_save_as (void);
+
+/** Tell the user about errors in the backends
+
+*/
+gboolean show_session_error (QofBackendError io_error, const char *newfile);
+
+char * gnc_file_dialog (const char * title,
+ const char * filter,
+ const char * default_name);
+
+gboolean gnc_file_open_file (const char *filename);
+void gnc_file_export_file(const char * filename);
+
+gboolean gnc_file_query_save (void);
+
+void gnc_file_quit (void);
+
+typedef gboolean (*GNCCanCancelSaveCB) (void);
+void gnc_file_set_can_cancel_callback (GNCCanCancelSaveCB cb);
+
+typedef void (*GNCShutdownCB) (int);
+void gnc_file_set_shutdown_callback (GNCShutdownCB cb);
+
+#endif /* GNC_FILE_H */
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Makefile.am,v
retrieving revision 1.48.2.33
retrieving revision 1.48.2.34
diff -Lsrc/gnome-utils/Makefile.am -Lsrc/gnome-utils/Makefile.am -u -r1.48.2.33 -r1.48.2.34
--- src/gnome-utils/Makefile.am
+++ src/gnome-utils/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = . test ui
+SUBDIRS = schemas . test ui
PWD := $(shell pwd)
pkglib_LTLIBRARIES = libgncmod-gnome-utils.la libgw-gnome-utils.la
@@ -58,6 +58,7 @@
gnc-druid-provider-file-gnome.c \
gnc-druid-provider-multifile-gnome.c \
gnc-embedded-window.c \
+ gnc-file.c \
gnc-frequency.c \
gnc-general-select.c \
gnc-gnome-utils.c \
@@ -70,6 +71,7 @@
gnc-main-window.c \
gnc-mdi-utils.c \
gnc-menu-extensions.c \
+ gnc-plugin-file-history.c \
gnc-plugin-manager.c \
gnc-plugin-menu-additions.c \
gnc-plugin-page.c \
@@ -118,6 +120,7 @@
gnc-dense-cal.h \
gnc-druid-gnome-ui.h \
gnc-embedded-window.h \
+ gnc-file.h \
gnc-frequency.h \
gnc-general-select.h \
gnc-gnome-utils.h \
@@ -130,6 +133,7 @@
gnc-main-window.h \
gnc-mdi-utils.h \
gnc-menu-extensions.h \
+ gnc-plugin-file-history.h \
gnc-plugin-manager.h \
gnc-plugin-menu-additions.h \
gnc-plugin-page.h \
--- /dev/null
+++ src/gnome-utils/gnc-plugin-file-history.c
@@ -0,0 +1,553 @@
+/*
+ * gnc-plugin-file-history.c --
+ * Copyright (C) 2003,2005 David Hampton hampton at 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
+ * 59 Temple Place - Suite 330 Fax: +1-617-542-2652
+ * Boston, MA 02111-1307, USA gnu at gnu.org
+ */
+
+/** @addtogroup GUI
+ @{ */
+/** @addtogroup GuiImport Import GUI Utility functions.
+ @{ */
+/** @internal
+ @file gnc-plugin-file-history.c
+ @brief Utility functions for writing import modules.
+ @author Copyright (C) 2002 David Hampton <hampton at employees.org>
+*/
+
+#include "config.h"
+
+#include <string.h>
+#include <glib/gprintf.h>
+#include <libgnome/libgnome.h>
+
+#include "gnc-file.h"
+#include "gnc-main-window.h"
+#include "gnc-plugin-file-history.h"
+#include "gnc-window.h"
+#include "gnc-trace.h"
+#include "messages.h"
+#include "gnc-gconf-utils.h"
+
+static GObjectClass *parent_class = NULL;
+
+#define FILENAME_STRING "filename"
+
+static void gnc_plugin_file_history_class_init (GncPluginFileHistoryClass *klass);
+static void gnc_plugin_file_history_init (GncPluginFileHistory *plugin);
+static void gnc_plugin_file_history_finalize (GObject *object);
+
+static void gnc_plugin_file_history_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type);
+static void gnc_plugin_file_history_remove_from_window (GncPlugin *plugin, GncMainWindow *window, GQuark type);
+
+static short module = MOD_GUI;
+
+/* Command callbacks */
+static void gnc_plugin_file_history_cmd_open_file (GtkAction *action, GncMainWindowActionData *data);
+
+
+#define PLUGIN_ACTIONS_NAME "gnc-plugin-file-history-actions"
+#define PLUGIN_UI_FILENAME "gnc-plugin-file-history-ui.xml"
+
+static GtkActionEntry gnc_plugin_actions [] = {
+ { "RecentFile0Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
+ { "RecentFile1Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
+ { "RecentFile2Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
+ { "RecentFile3Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
+ { "RecentFile4Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
+ { "RecentFile5Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
+ { "RecentFile6Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
+ { "RecentFile7Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
+ { "RecentFile8Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
+ { "RecentFile9Action", NULL, "", NULL, NULL, G_CALLBACK (gnc_plugin_file_history_cmd_open_file) },
+};
+static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
+
+
+struct GncPluginFileHistoryPrivate
+{
+ gpointer dummy;
+};
+
+
+/************************************************************
+ * Other Functions *
+ ************************************************************/
+
+/* Add a file name to the front of the file "history list". If the
+ * name already exist on the list, then it is moved from its current
+ * location to the front of the list. The "list" is actually a
+ * sequence of up to ten gconf keys.
+ */
+void
+gnc_history_add_file (const char *newfile)
+{
+ gchar *filename, *from, *to;
+ gint i, last;
+
+ if (newfile == NULL)
+ return;
+ if (!g_utf8_validate(newfile, -1, NULL))
+ return;
+
+ /*
+ * Look for the filename in gconf.
+ */
+ last = MAX_HISTORY_FILES - 1;
+ for (i = 0; i < MAX_HISTORY_FILES; i++) {
+ from = g_strdup_printf(HISTORY_STRING_FILE_N, i);
+ filename = gnc_gconf_get_string(HISTORY_STRING_SECTION, from, NULL);
+ g_free(from);
+
+ if (!filename) {
+ last = i;
+ break;
+ }
+ if (g_utf8_collate(newfile, filename) == 0) {
+ g_free(filename);
+ last = i;
+ break;
+ }
+ g_free(filename);
+ }
+
+ /*
+ * Shuffle filenames upward through gconf.
+ */
+ to = g_strdup_printf(HISTORY_STRING_FILE_N, last);
+ for (i = last - 1; i >= 0; i--) {
+ from = g_strdup_printf(HISTORY_STRING_FILE_N, i);
+ filename = gnc_gconf_get_string(HISTORY_STRING_SECTION, from, NULL);
+ if (filename) {
+ gnc_gconf_set_string(HISTORY_STRING_SECTION, to, filename, NULL);
+ g_free(filename);
+ } else {
+ gnc_gconf_unset(HISTORY_STRING_SECTION, to, NULL);
+ }
+ g_free(to);
+ to = from;
+ }
+
+ /*
+ * Store the new zero entry.
+ */
+ gnc_gconf_set_string(HISTORY_STRING_SECTION, to, newfile, NULL);
+}
+
+
+/* Retrieve the name of the file most recently accessed. This is the
+ * name at the front of the list. Since the "list" is actually a
+ * sequence of up to ten gconf keys, this is the value of key zero.
+ */
+char *
+gnc_history_get_last (void)
+{
+ static char *filename = NULL;
+ char *key;
+
+ /* The static string supports the current signature of this
+ * function. At some point this should be changed to pass the
+ * allocated string up to the caller and make them responsible for
+ * freeing irt, but that change percolates up into the scheme code
+ * and requires changing that as well. */
+ if (filename) {
+ g_free(filename);
+ filename = NULL;
+ }
+
+ key = g_strdup_printf(HISTORY_STRING_FILE_N, 0);
+ filename = gnc_gconf_get_string(HISTORY_STRING_SECTION, key, NULL);
+ g_free(key);
+
+ return filename;
+}
+
+
+/************************************************************
+ * Other Functions *
+ ************************************************************/
+
+#if 0
+static gchar *
+gnc_history_gconf_index_to_key (guint index)
+{
+ return g_strdup_printf(HISTORY_STRING_FILE_N, index);
+}
+#endif
+
+
+static gint
+gnc_history_gconf_key_to_index (const gchar *fullkey)
+{
+ char *key;
+ gint index, result;
+
+ key = rindex(fullkey, '/');
+ result = sscanf(key+1, HISTORY_STRING_FILE_N, &index);
+ return (result == 1) ? index : -1;
+}
+
+
+/** This routine takes a filename and modifies it so that it will
+ * display correctly in a GtkLabel. It also adds a mnemonic to
+ * the start of the menu item.
+ *
+ * @filename A pointer to the filename to mangle.
+ *
+ * @return A pointer to the mangled filename. The Caller is
+ * responsible for freeing this memory.
+ */
+static gchar *
+gnc_history_generate_label (int index, const gchar *filename)
+{
+ const gchar *src;
+ gchar *result, *dst;
+ gunichar unichar;
+
+ /* raw byte length, not num characters */
+ result = g_malloc(strlen(filename) * 2);
+
+ dst = result;
+ if (index < 10)
+ dst += g_sprintf(result, "_%d ", (index + 1) % 10);
+
+ /* Find the filename portion of the path */
+ src = g_utf8_strrchr(filename, -1, '/');
+ src = g_utf8_next_char(src);
+
+ /* Fix up any underline characters so they aren't mistaken as
+ * command accelerator keys. */
+ for ( ; *src; src = g_utf8_next_char(src)) {
+ unichar = g_utf8_get_char(src);
+ dst += g_unichar_to_utf8 (unichar, dst);
+
+ if (unichar == '_')
+ dst += g_unichar_to_utf8 ('_', dst);
+ }
+
+ *dst = '\0';
+ return result;
+}
+
+
+/** Update one entry in the file history menu. This function is
+ * called by either the gnc_plugin_history_list_changed function or
+ * the gnc_history_update_menus function. It updates the specified
+ * file history item in the specified window.
+ *
+ * This routine attaches the actual filename to the menu_item (via
+ * g_object_set_data) for later retrieval. It also massages the
+ * filename so that it will display correctly in the menu, and also
+ * add a mnemonic for the menu item.
+ *
+ * @window A pointer to window whose file history should be updated.
+ *
+ * @index Update this item in the menu (base-0).
+ *
+ * @filename The new filename to associate with this menu item.
+ */
+static void
+gnc_history_update_action (GncMainWindow *window,
+ gint index,
+ const gchar *filename)
+{
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ gchar *action_name, *label_name, *old_filename;
+
+ ENTER("window %p, index %d, filename %s", window, index, filename);
+ /* Get the action group */
+ action_group =
+ gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME);
+
+ action_name = g_strdup_printf("RecentFile%dAction", index);
+ action = gtk_action_group_get_action (action_group, action_name);
+
+ if (filename && (strlen(filename) > 0)) {
+ /* set the menu label (w/accelerator) */
+ label_name = gnc_history_generate_label(index, filename);
+ g_object_set(G_OBJECT(action), "label", label_name, "visible", TRUE, NULL);
+ g_free(label_name);
+
+ /* set the filename for the callback function */
+ old_filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING);
+ if (old_filename)
+ g_free(old_filename);
+ g_object_set_data(G_OBJECT(action), FILENAME_STRING, g_strdup(filename));
+ } else {
+ g_object_set(G_OBJECT(action), "visible", FALSE, NULL);
+ }
+ g_free(action_name);
+ LEAVE("");
+}
+
+
+/** Update an entry in the file history menu because a gconf entry
+ * changed. This function is called whenever an item in the gconf
+ * history section is changed. It is responsible for updating the
+ * menu item that corresponds to that key.
+ *
+ * @client A pointer to gconf client that noticed an entry change.
+ *
+ * @cnxn_id Unused.
+ *
+ * @entry A pointer to gconf entry that changed.
+ *
+ * @user_data A pointer to the window that this gconf client is
+ * associated with.
+ */
+static void
+gnc_plugin_history_list_changed (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer user_data)
+{
+ GncMainWindow *window;
+ GConfValue *value;
+ const gchar *key, *filename;
+ gint index;
+
+ ENTER("");
+ key = gconf_entry_get_key(entry);
+ index = gnc_history_gconf_key_to_index(key);
+ if (index < 0)
+ return;
+
+ window = GNC_MAIN_WINDOW(user_data);
+ value = gconf_entry_get_value(entry);
+ if (!value) {
+ LEAVE("No gconf value");
+ return;
+ }
+ filename = gconf_value_get_string(value);
+ gnc_history_update_action (window, index, filename);
+
+ gnc_main_window_actions_updated (window);
+ LEAVE("");
+}
+
+/** Update the file history menu for a window. This function walks
+ * the list of all possible gconf keys for the file history and
+ * forces a read/menu update on each key. It should only be called
+ * once when the window is created.
+ *
+ * @window A pointer to the window whose file history menu should be
+ * updated.
+ */
+static void
+gnc_history_update_menus (GncMainWindow *window)
+{
+ gchar *filename, *key;
+ guint i;
+
+ ENTER("");
+ for (i = 0; i < MAX_HISTORY_FILES; i++) {
+ key = g_strdup_printf(HISTORY_STRING_FILE_N, i);
+ filename = gnc_gconf_get_string(HISTORY_STRING_SECTION, key, NULL);
+ gnc_history_update_action(window, i, filename);
+ g_free(filename);
+ g_free(key);
+ }
+ LEAVE("");
+}
+
+
+/************************************************************
+ * Object Implementation *
+ ************************************************************/
+
+/* Get the type of a file history plugin.
+ */
+GType
+gnc_plugin_file_history_get_type (void)
+{
+ static GType gnc_plugin_file_history_type = 0;
+
+ if (gnc_plugin_file_history_type == 0) {
+ static const GTypeInfo our_info = {
+ sizeof (GncPluginFileHistoryClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gnc_plugin_file_history_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GncPluginFileHistory),
+ 0,
+ (GInstanceInitFunc) gnc_plugin_file_history_init
+ };
+
+ gnc_plugin_file_history_type = g_type_register_static (GNC_TYPE_PLUGIN,
+ "GncPluginFileHistory",
+ &our_info, 0);
+ }
+
+ return gnc_plugin_file_history_type;
+}
+
+static void
+gnc_plugin_file_history_class_init (GncPluginFileHistoryClass *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_file_history_finalize;
+
+ /* plugin info */
+ plugin_class->plugin_name = GNC_PLUGIN_FILE_HISTORY_NAME;
+
+ /* function overrides */
+ plugin_class->add_to_window = gnc_plugin_file_history_add_to_window;
+ plugin_class->remove_from_window = gnc_plugin_file_history_remove_from_window;
+
+ /* 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;
+
+ plugin_class->gconf_section = HISTORY_STRING_SECTION;
+ plugin_class->gconf_notifications = gnc_plugin_history_list_changed;
+}
+
+static void
+gnc_plugin_file_history_init (GncPluginFileHistory *plugin)
+{
+ ENTER("plugin %p", plugin);
+ plugin->priv = g_new0 (GncPluginFileHistoryPrivate, 1);
+ LEAVE("");
+}
+
+static void
+gnc_plugin_file_history_finalize (GObject *object)
+{
+ GncPluginFileHistory *plugin;
+
+ g_return_if_fail (GNC_IS_PLUGIN_FILE_HISTORY (object));
+
+ plugin = GNC_PLUGIN_FILE_HISTORY (object);
+ ENTER("plugin %p", plugin);
+
+ g_return_if_fail (plugin->priv != NULL);
+ g_free (plugin->priv);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+ LEAVE("");
+}
+
+
+/* Create a new file history plugin. This plugin attaches the file
+ * history menu to any window that is opened.
+ */
+GncPlugin *
+gnc_plugin_file_history_new (void)
+{
+ GncPlugin *plugin_page = NULL;
+
+ ENTER("");
+ plugin_page = GNC_PLUGIN (g_object_new (GNC_TYPE_PLUGIN_FILE_HISTORY, NULL));
+ LEAVE("plugin %p", plugin_page);
+ return plugin_page;
+}
+
+/************************************************************
+ * Plugin Function Implementation *
+ ************************************************************/
+
+/** Initialize the file history menu for a window. This function is
+ * called as part of the initialization of a window, after all the
+ * plugin menu items have been added to the menu structure. Its job
+ * is to correctly initialize the file history menu. It does this by
+ * first calling a function that initializes the menu to the current
+ * as maintained in gconf. It then creates a gconf client that will
+ * listens for any changes to the file history menu, and will update
+ * the meny when they are signalled.
+ *
+ * @param plugin A pointer to the gnc-plugin object responsible for
+ * adding/removing the file history menu.
+ *
+ * @param window A pointer the gnc-main-window that is being initialized.
+ *
+ * @param type Unused
+ */
+static void
+gnc_plugin_file_history_add_to_window (GncPlugin *plugin,
+ GncMainWindow *window,
+ GQuark type)
+{
+ gnc_history_update_menus(window);
+}
+
+
+/** Finalize the file history menu for this window. This function is
+ * called as part of the destruction of a window.
+ *
+ * @param plugin A pointer to the gnc-plugin object responsible for
+ * adding/removing the file history menu. It stops the gconf
+ * notifications for this window, and destroys the gconf client
+ * object.
+ *
+ * @param window A pointer the gnc-main-window that is being destroyed.
+ *
+ * @param type Unused
+ */
+static void
+gnc_plugin_file_history_remove_from_window (GncPlugin *plugin,
+ GncMainWindow *window,
+ GQuark type)
+{
+}
+
+/************************************************************
+ * Command Callbacks *
+ ************************************************************/
+
+/** The user has selected one of the items in the File History menu.
+ * Close down the current session and start up a new one with the
+ * requested file.
+ *
+ * @param action A pointer to the action selected by the user. This
+ * action represents one of the items in the file history menu.
+ *
+ * @param data A pointer to the gnc-main-window data to be used by
+ * this function. This is mainly to find out which window it was
+ * that had a menu selected. That's not really important for this
+ * function and we're about to close all the windows anyway.
+ */
+static void
+gnc_plugin_file_history_cmd_open_file (GtkAction *action,
+ GncMainWindowActionData *data)
+{
+ gchar *filename;
+
+ g_return_if_fail(GTK_IS_ACTION(action));
+ g_return_if_fail(data != NULL);
+
+ /* DRH - Do we need to close all open windows but the first?
+ * Which progressbar should we be using? One in a window, or
+ * in a new "file loading" dialog???
+ */
+ filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING);
+ gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
+ gnc_file_open_file (filename); /* also opens new account page */
+ gnc_window_set_progressbar_window (NULL);
+}
+
+/** @} */
+/** @} */
--- src/app-file/schemas/apps_gnucash_history.schemas
+++ /dev/null
@@ -1,58 +0,0 @@
-<gconfschemafile>
- <schemalist>
- <schema>
- <key>/schemas/apps/gnucash/history/maxfiles</key>
- <applyto>/apps/gnucash/history/maxfiles</applyto>
- <owner>gnucash</owner>
- <type>int</type>
- <default>4</default>
- <locale name="C">
- <short>Number of files in history</short>
- <long>
- This key contains the number of files to keep in the
- Recently Opened Files menu. This value may be set to zero to
- disable the file history. This number has a maximum value
- of 10.
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/gnucash/history/first_file</key>
- <applyto>/apps/gnucash/history/file0</applyto>
- <owner>gnucash</owner>
- <type>string</type>
- <default></default>
- <locale name="C">
- <short>Most recently opened file</short>
- <long>
- This key contains the full path of the most recently opened file.
- </long>
- </locale>
- </schema>
-
-
- <schema>
- <key>/schemas/apps/gnucash/history/other_files</key>
- <applyto>/apps/gnucash/history/file1</applyto>
- <applyto>/apps/gnucash/history/file2</applyto>
- <applyto>/apps/gnucash/history/file3</applyto>
- <applyto>/apps/gnucash/history/file4</applyto>
- <applyto>/apps/gnucash/history/file5</applyto>
- <applyto>/apps/gnucash/history/file6</applyto>
- <applyto>/apps/gnucash/history/file7</applyto>
- <applyto>/apps/gnucash/history/file8</applyto>
- <applyto>/apps/gnucash/history/file9</applyto>
- <owner>gnucash</owner>
- <type>string</type>
- <default></default>
- <locale name="C">
- <short>Next most recently opened file</short>
- <long>
- This key contains the full path of the next most recently opened file.
- </long>
- </locale>
- </schema>
-
- </schemalist>
-</gconfschemafile>
--- src/app-file/schemas/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-schemadir = @GCONF_SCHEMA_FILE_DIR@
-schema_DATA = \
- apps_gnucash_history.schemas
-
-install-data-local:
-if GCONF_SCHEMAS_INSTALL
- -mkdir -p $(GCONF_SCHEMA_CONFIG_SOURCE_DIRONLY)
- -GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) gconftool-2 --makefile-install-rule $(srcdir)/$(schema_DATA)
-endif
-
-uninstall-local:
-if GCONF_SCHEMAS_INSTALL
- -GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) gconftool-2 --makefile-uninstall-rule $(srcdir)/$(schema_DATA)
-endif
-
--- src/app-file/gnome/gnc-file-dialog.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/********************************************************************\
- * gnc-file-dialog.c -- the file dialog box *
- * Copyright (C) 1997 Robin D. Clark <rclark at cs.hmc.edu> *
- * Copyright (C) 1998-99 Rob Browning <rlb at cs.utexas.edu> *
- * Copyright (C) 2000 Linas Vepstas <linas at linas.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 *
- * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
- * Boston, MA 02111-1307, USA gnu at gnu.org *
-\********************************************************************/
-
-#include "config.h"
-
-#include <gnome.h>
-
-#include "gnc-engine-util.h"
-#include "gnc-file-dialog.h"
-#include "gnc-ui.h"
-#include "messages.h"
-
-/* This static indicates the debugging module that this .o belongs to. */
-static short module = MOD_GUI;
-
-
-/********************************************************************\
- * gnc_file_dialog *
- * Pops up a file selection dialog (either a "Save As" or an *
- * "Open"), and returns the name of the file the user selected. *
- * (This function does not return until the user selects a file *
- * or presses "Cancel" or the window manager destroy button) *
- * *
- * Args: title - the title of the window *
- * filter - the file filter to use *
- * default_name - the default name to use *
- * Return: containing the name of the file the user selected *
-\********************************************************************/
-
-char *
-gnc_file_dialog (const char * title,
- const char * filter,
- const char *default_name)
-{
- GtkFileSelection *file_box;
- const char *internal_name;
- char *file_name = NULL;
- gint response;
-
- ENTER("\n");
-
- /* Set a default title if nothing was passed in */
- if (title == NULL)
- title = _("Open");
-
- file_box = GTK_FILE_SELECTION(gtk_file_selection_new(title));
-
- if (default_name)
- gtk_file_selection_set_filename(file_box, default_name);
-
- /* hack alert - this was filtering directory names as well as file
- * names, so I think we should not do this by default (rgmerk) */
-#if 0
- if (filter != NULL)
- gtk_file_selection_complete(file_box, filter);
-#endif
-
- gtk_window_set_modal(GTK_WINDOW(file_box), TRUE);
- gtk_window_set_transient_for(GTK_WINDOW(file_box),
- GTK_WINDOW(gnc_ui_get_toplevel()));
- response = gtk_dialog_run(GTK_DIALOG(file_box));
-
- if (response == GTK_RESPONSE_OK) {
- /* look for constructs like postgres://foo */
- internal_name = gtk_entry_get_text(GTK_ENTRY(file_box->selection_entry));
- if (strstr (internal_name, "://") == 0) {
- /* nope, a local file name */
- internal_name = gtk_file_selection_get_filename(file_box);
- }
- file_name = g_strdup(internal_name);
- }
- gtk_widget_destroy(GTK_WIDGET(file_box));
- LEAVE("%s", file_name);
- return file_name;
-}
--- src/app-file/gnome/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-lib_LTLIBRARIES = libgnc-app-file-gnome.la
-
-AM_CFLAGS = \
- -I${top_srcdir}/src \
- -I${top_srcdir}/src/app-file \
- -I${top_srcdir}/src/app-utils \
- -I${top_srcdir}/src/engine \
- ${GUILE_INCS} \
- ${G_WRAP_COMPILE_ARGS} \
- ${GLIB_CFLAGS} \
- ${GNOME_CFLAGS}
-
-libgnc_app_file_gnome_la_SOURCES = \
- gnc-file-dialog.c
-
-libgnc_app_file_gnome_la_LIBADD = \
- ${GUILE_LIBS} \
- ${GNOME_LIBS} \
- ${GLIB_LIBS}
--- /dev/null
+++ src/gnome-utils/schemas/apps_gnucash_history.schemas
@@ -0,0 +1,58 @@
+<gconfschemafile>
+ <schemalist>
+ <schema>
+ <key>/schemas/apps/gnucash/history/maxfiles</key>
+ <applyto>/apps/gnucash/history/maxfiles</applyto>
+ <owner>gnucash</owner>
+ <type>int</type>
+ <default>4</default>
+ <locale name="C">
+ <short>Number of files in history</short>
+ <long>
+ This key contains the number of files to keep in the
+ Recently Opened Files menu. This value may be set to zero to
+ disable the file history. This number has a maximum value
+ of 10.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gnucash/history/first_file</key>
+ <applyto>/apps/gnucash/history/file0</applyto>
+ <owner>gnucash</owner>
+ <type>string</type>
+ <default></default>
+ <locale name="C">
+ <short>Most recently opened file</short>
+ <long>
+ This key contains the full path of the most recently opened file.
+ </long>
+ </locale>
+ </schema>
+
+
+ <schema>
+ <key>/schemas/apps/gnucash/history/other_files</key>
+ <applyto>/apps/gnucash/history/file1</applyto>
+ <applyto>/apps/gnucash/history/file2</applyto>
+ <applyto>/apps/gnucash/history/file3</applyto>
+ <applyto>/apps/gnucash/history/file4</applyto>
+ <applyto>/apps/gnucash/history/file5</applyto>
+ <applyto>/apps/gnucash/history/file6</applyto>
+ <applyto>/apps/gnucash/history/file7</applyto>
+ <applyto>/apps/gnucash/history/file8</applyto>
+ <applyto>/apps/gnucash/history/file9</applyto>
+ <owner>gnucash</owner>
+ <type>string</type>
+ <default></default>
+ <locale name="C">
+ <short>Next most recently opened file</short>
+ <long>
+ This key contains the full path of the next most recently opened file.
+ </long>
+ </locale>
+ </schema>
+
+ </schemalist>
+</gconfschemafile>
--- /dev/null
+++ src/gnome-utils/schemas/Makefile.am
@@ -0,0 +1,15 @@
+schemadir = @GCONF_SCHEMA_FILE_DIR@
+schema_DATA = \
+ apps_gnucash_history.schemas
+
+install-data-local:
+if GCONF_SCHEMAS_INSTALL
+ -mkdir -p $(GCONF_SCHEMA_CONFIG_SOURCE_DIRONLY)
+ -GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) gconftool-2 --makefile-install-rule $(srcdir)/$(schema_DATA)
+endif
+
+uninstall-local:
+if GCONF_SCHEMAS_INSTALL
+ -GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) gconftool-2 --makefile-uninstall-rule $(srcdir)/$(schema_DATA)
+endif
+
More information about the gnucash-changes
mailing list