mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Provide reasonable default directories for the "Save As" and "Export"
operations. #94428 git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7822 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
16
ChangeLog
16
ChangeLog
@@ -52,6 +52,22 @@
|
||||
|
||||
2003-01-12 David Hampton <hampton@employees.org>
|
||||
|
||||
* src/app-utils/gnc-ui-util.c: Add routine for easily extracting a
|
||||
directory path from a filename.
|
||||
|
||||
* src/app-file/gnc-file.c: Default the save directory to the
|
||||
directory of the last file used. Default the exports directory to
|
||||
the direcory of the last file exported this session, or the user's
|
||||
home dir for the first export. #94428
|
||||
|
||||
* src/scm/price-quotes.scm: Correctly handle the case where no
|
||||
stocks have been defined and the user askes gnucash to get price
|
||||
quotes. #102560
|
||||
|
||||
* src/network-utils/gnc-http.c: Work around bug in ghttp library
|
||||
so that intl users whose whole units/fractions separator is a
|
||||
comma can request web pages.
|
||||
|
||||
* src/register/register-gnome/gnucash-sheet.c
|
||||
(gnucash_sheet_insert_cb): Return the number of characters
|
||||
entered, not the length of the encoded multi-byte string. Possible
|
||||
|
||||
@@ -556,6 +556,9 @@ gnc_file_export_file(const char * newfile)
|
||||
GNCSession *current_session, *new_session;
|
||||
gboolean ok;
|
||||
GNCBackendError io_err = ERR_BACKEND_NO_ERR;
|
||||
static char *default_dir = NULL; /* default directory for exports */
|
||||
|
||||
gnc_init_default_directory(&default_dir);
|
||||
|
||||
if (!newfile) {
|
||||
if (!file_dialog_func) {
|
||||
@@ -563,11 +566,14 @@ gnc_file_export_file(const char * newfile)
|
||||
return;
|
||||
}
|
||||
|
||||
newfile = file_dialog_func (_("Export"), NULL, NULL);
|
||||
newfile = file_dialog_func (_("Export"), NULL, default_dir);
|
||||
if (!newfile)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Remember the directory as the default. */
|
||||
gnc_extract_directory(&default_dir, newfile);
|
||||
|
||||
gnc_engine_suspend_events();
|
||||
|
||||
/* -- this session code is NOT identical in FileOpen and FileSaveAs -- */
|
||||
@@ -695,6 +701,8 @@ gnc_file_save_as (void)
|
||||
GNCSession *new_session;
|
||||
GNCSession *session;
|
||||
const char *filename;
|
||||
char *default_dir = NULL; /* Default to last open */
|
||||
const char *last;
|
||||
char *newfile;
|
||||
const char *oldfile;
|
||||
GNCBackendError io_err = ERR_BACKEND_NO_ERR;
|
||||
@@ -707,7 +715,14 @@ gnc_file_save_as (void)
|
||||
return;
|
||||
}
|
||||
|
||||
filename = file_dialog_func (_("Save"), "*.gnc", NULL);
|
||||
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
|
||||
|
||||
@@ -245,6 +245,33 @@ gnc_reverse_balance (Account *account)
|
||||
return reverse_type[type];
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gnc_init_default_directory (char **dirname)
|
||||
{
|
||||
if (*dirname == NULL)
|
||||
*dirname = g_strdup_printf("%s/", getenv("HOME"));
|
||||
}
|
||||
|
||||
void
|
||||
gnc_extract_directory (char **dirname, const char *filename)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
if (*dirname)
|
||||
free(*dirname);
|
||||
|
||||
/* Parse out the directory. */
|
||||
if ((filename == NULL) || (rindex(filename, '/') == NULL)) {
|
||||
*dirname = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
*dirname = g_strdup(filename);
|
||||
tmp = rindex(*dirname, '/');
|
||||
*(tmp+1) = '\0';
|
||||
}
|
||||
|
||||
GNCBook *
|
||||
gnc_get_current_book (void)
|
||||
{
|
||||
|
||||
@@ -46,6 +46,12 @@ gboolean gnc_reverse_balance(Account *account);
|
||||
gboolean gnc_reverse_balance_type(GNCAccountType type);
|
||||
|
||||
|
||||
/* Default directories **********************************************/
|
||||
|
||||
void gnc_init_default_directory (char **dirname);
|
||||
void gnc_extract_directory (char **dirname, const char *filename);
|
||||
|
||||
|
||||
/* Engine enhancements & i18n ***************************************/
|
||||
GNCBook * gnc_get_current_book (void);
|
||||
AccountGroup * gnc_get_current_group (void);
|
||||
|
||||
Reference in New Issue
Block a user