Add argument to fileBox to allow setting the default filename.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3183 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-11-20 21:55:01 +00:00
parent e49fce1712
commit 2b99156495
6 changed files with 21 additions and 22 deletions

View File

@ -28,6 +28,8 @@
#include "config.h" #include "config.h"
/** PROTOTYPES ******************************************************/ /** PROTOTYPES ******************************************************/
const char *fileBox( const char * title, const char * filter ); const char *fileBox (const char * title,
const char * filter,
const char * default_name);
#endif #endif

View File

@ -361,7 +361,7 @@ gncFileOpen (void)
if (!gncFileQuerySave ()) if (!gncFileQuerySave ())
return; return;
newfile = fileBox(_("Open"), NULL); newfile = fileBox(_("Open"), NULL, NULL);
gncPostFileOpen (newfile); gncPostFileOpen (newfile);
/* This dialogue can show up early in the startup process. If the /* This dialogue can show up early in the startup process. If the
@ -464,7 +464,7 @@ gncFileSaveAs (void)
const char *oldfile; const char *oldfile;
gboolean uh_oh = FALSE; gboolean uh_oh = FALSE;
filename = fileBox(_("Save"), "*.gnc"); filename = fileBox(_("Save"), "*.gnc", NULL);
if (!filename) return; if (!filename) return;
/* Check to see if the user specified the same file as the current /* Check to see if the user specified the same file as the current

View File

@ -61,12 +61,13 @@ static gboolean gnc_file_box_delete_cb(GtkWidget *widget, GdkEvent *event,
* (This function does not return until the user selects a file * * (This function does not return until the user selects a file *
* or presses "Cancel" or the window manager destroy button) * * or presses "Cancel" or the window manager destroy button) *
* * * *
* Args: title - the title of the window * * Args: title - the title of the window *
* filter - the file filter to use * * filter - the file filter to use *
* default_name - the default name to use *
* Return: containing the name of the file the user selected * * Return: containing the name of the file the user selected *
\********************************************************************/ \********************************************************************/
const char * const char *
fileBox(const char * title, const char * filter) fileBox (const char * title, const char * filter, const char *default_name)
{ {
const char *last_file; const char *last_file;
@ -83,7 +84,10 @@ fileBox(const char * title, const char * filter)
fb_info.file_name = NULL; fb_info.file_name = NULL;
last_file = gnc_history_get_last(); last_file = gnc_history_get_last();
if (last_file && !filter)
if (default_name)
gtk_file_selection_set_filename(fb_info.file_box, default_name);
else if (last_file)
gtk_file_selection_set_filename(fb_info.file_box, last_file); gtk_file_selection_set_filename(fb_info.file_box, last_file);
/* hack alert - this was filtering directory names as well as file /* hack alert - this was filtering directory names as well as file

View File

@ -226,8 +226,8 @@ gnc_ui_qif_import_select_file_cb(GtkButton * button,
const char * new_file_name; const char * new_file_name;
new_file_name = fileBox(_("Select QIF File"), "*.qif"); new_file_name = fileBox(_("Select QIF File"), "*.qif", "");
/* set the filename entry for what was selected */ /* set the filename entry for what was selected */
if(wind->filename_entry) { if(wind->filename_entry) {
if(new_file_name) { if(new_file_name) {
@ -239,9 +239,6 @@ gnc_ui_qif_import_select_file_cb(GtkButton * button,
""); "");
} }
} }
/* free new_file_name -- g_free or free? */
/* FIXME */
} }

View File

@ -201,16 +201,15 @@ gnc_report_error_dialog(const char *message)
parent = GTK_WINDOW(gnc_html_window_get_window(reportwindow)); parent = GTK_WINDOW(gnc_html_window_get_window(reportwindow));
if (message == NULL) if (message == NULL)
text = err_msg; text = g_strdup (err_msg);
else else
text = g_strconcat(err_msg, "\n\n", message, NULL); text = g_strconcat (err_msg, "\n\n", message, NULL);
PERR("gnc_report_error_dialog: error running report.\n%s\n", message); PERR("gnc_report_error_dialog: error running report.\n%s\n", message);
gnc_error_dialog_parented(parent, text); gnc_error_dialog_parented(parent, text);
if (message != NULL) g_free(text);
g_free(text);
} }
static char * static char *
@ -316,7 +315,7 @@ gnc_report_export(ReportData *report_data)
text = report_data->text; text = report_data->text;
/* Get the filename */ /* Get the filename */
export_filename = fileBox(_("Export To"), NULL); export_filename = fileBox(_("Export To"), NULL, "");
if (export_filename == NULL) if (export_filename == NULL)
return; return;

View File

@ -99,16 +99,13 @@
(list "Extensions" "") (list "Extensions" "")
(lambda () (lambda ()
(let ((file-name (gnc:file-selection-dialog (let ((file-name (gnc:file-selection-dialog
"Select file to save strings in" ".txt"))) "Select file to save strings in" ".txt" "")))
(if file-name (gnc:save-translatable-strings file-name)))))) (if file-name (gnc:save-translatable-strings file-name))))))
(gnc:add-extension menu) (gnc:add-extension menu)
(gnc:add-extension export-item) (gnc:add-extension export-item)
(gnc:add-extension progress-item) (gnc:add-extension progress-item)
(gnc:add-extension strings-item))
(if (gnc:debugging?)
(gnc:add-extension strings-item)))
(if (gnc:debugging?) (if (gnc:debugging?)
(gnc:hook-add-dangler gnc:*main-window-opened-hook* (gnc:hook-add-dangler gnc:*main-window-opened-hook*