diff --git a/src/FileBox.h b/src/FileBox.h index afb48d95d2..a7f6e4a3a8 100644 --- a/src/FileBox.h +++ b/src/FileBox.h @@ -28,6 +28,8 @@ #include "config.h" /** PROTOTYPES ******************************************************/ -const char *fileBox( const char * title, const char * filter ); +const char *fileBox (const char * title, + const char * filter, + const char * default_name); #endif diff --git a/src/FileDialog.c b/src/FileDialog.c index 90b0ecc300..62eb3a14f2 100644 --- a/src/FileDialog.c +++ b/src/FileDialog.c @@ -361,7 +361,7 @@ gncFileOpen (void) if (!gncFileQuerySave ()) return; - newfile = fileBox(_("Open"), NULL); + newfile = fileBox(_("Open"), NULL, NULL); gncPostFileOpen (newfile); /* This dialogue can show up early in the startup process. If the @@ -464,7 +464,7 @@ gncFileSaveAs (void) const char *oldfile; gboolean uh_oh = FALSE; - filename = fileBox(_("Save"), "*.gnc"); + filename = fileBox(_("Save"), "*.gnc", NULL); if (!filename) return; /* Check to see if the user specified the same file as the current diff --git a/src/gnome/dialog-filebox.c b/src/gnome/dialog-filebox.c index 261ee4c035..2b7754720d 100644 --- a/src/gnome/dialog-filebox.c +++ b/src/gnome/dialog-filebox.c @@ -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 * * or presses "Cancel" or the window manager destroy button) * * * - * Args: title - the title of the window * - * filter - the file filter to use * + * 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 * \********************************************************************/ const char * -fileBox(const char * title, const char * filter) +fileBox (const char * title, const char * filter, const char *default_name) { const char *last_file; @@ -83,7 +84,10 @@ fileBox(const char * title, const char * filter) fb_info.file_name = NULL; 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); /* hack alert - this was filtering directory names as well as file diff --git a/src/gnome/druid-qif-import.c b/src/gnome/druid-qif-import.c index 0d99468233..d36dc3a066 100644 --- a/src/gnome/druid-qif-import.c +++ b/src/gnome/druid-qif-import.c @@ -226,8 +226,8 @@ gnc_ui_qif_import_select_file_cb(GtkButton * button, 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 */ if(wind->filename_entry) { 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 */ } diff --git a/src/gnome/window-report.c b/src/gnome/window-report.c index aba7eba973..b78bf5fffd 100644 --- a/src/gnome/window-report.c +++ b/src/gnome/window-report.c @@ -201,16 +201,15 @@ gnc_report_error_dialog(const char *message) parent = GTK_WINDOW(gnc_html_window_get_window(reportwindow)); if (message == NULL) - text = err_msg; + text = g_strdup (err_msg); 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); gnc_error_dialog_parented(parent, text); - if (message != NULL) - g_free(text); + g_free(text); } static char * @@ -316,7 +315,7 @@ gnc_report_export(ReportData *report_data) text = report_data->text; /* Get the filename */ - export_filename = fileBox(_("Export To"), NULL); + export_filename = fileBox(_("Export To"), NULL, ""); if (export_filename == NULL) return; diff --git a/src/scm/extensions.scm b/src/scm/extensions.scm index 72e25db52e..070797deee 100644 --- a/src/scm/extensions.scm +++ b/src/scm/extensions.scm @@ -99,16 +99,13 @@ (list "Extensions" "") (lambda () (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)))))) (gnc:add-extension menu) (gnc:add-extension export-item) (gnc:add-extension progress-item) - - (if (gnc:debugging?) - (gnc:add-extension strings-item))) - + (gnc:add-extension strings-item)) (if (gnc:debugging?) (gnc:hook-add-dangler gnc:*main-window-opened-hook*