|
|
|
|
@ -22,6 +22,7 @@
|
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
|
|
|
|
\********************************************************************/
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
@ -33,6 +34,7 @@
|
|
|
|
|
#include "dialog-utils.h"
|
|
|
|
|
#include "dialog-file-access.h"
|
|
|
|
|
#include "gnc-file.h"
|
|
|
|
|
#include "gnc-filepath-utils.h"
|
|
|
|
|
#include "gnc-plugin-file-history.h"
|
|
|
|
|
#include "gnc-session.h"
|
|
|
|
|
|
|
|
|
|
@ -243,6 +245,15 @@ get_default_database( void )
|
|
|
|
|
return default_db;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef bool (*CharToBool)(const char*);
|
|
|
|
|
|
|
|
|
|
static bool datafile_filter (const GtkFileFilterInfo* filter_info,
|
|
|
|
|
CharToBool filename_checker)
|
|
|
|
|
{
|
|
|
|
|
return filter_info && filter_info->filename &&
|
|
|
|
|
filename_checker (filter_info->filename);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void free_file_access_window (FileAccessWindow *faw)
|
|
|
|
|
{
|
|
|
|
|
g_free (faw->starting_dir);
|
|
|
|
|
@ -340,6 +351,31 @@ gnc_ui_file_access (GtkWindow *parent, int type)
|
|
|
|
|
faw->fileChooser = GTK_FILE_CHOOSER(fileChooser);
|
|
|
|
|
gtk_box_pack_start( GTK_BOX(file_chooser), GTK_WIDGET(fileChooser), TRUE, TRUE, 6 );
|
|
|
|
|
|
|
|
|
|
/* set up .gnucash filters for Datafile operations */
|
|
|
|
|
GtkFileFilter *filter = gtk_file_filter_new ();
|
|
|
|
|
gtk_file_filter_set_name (filter, _("All files"));
|
|
|
|
|
gtk_file_filter_add_pattern (filter, "*");
|
|
|
|
|
gtk_file_chooser_add_filter (faw->fileChooser, filter);
|
|
|
|
|
|
|
|
|
|
filter = gtk_file_filter_new ();
|
|
|
|
|
/* Translators: *.gnucash and *.xac are file patterns and must not
|
|
|
|
|
be translated*/
|
|
|
|
|
gtk_file_filter_set_name (filter, _("Datafiles only (*.gnucash, *.xac)"));
|
|
|
|
|
gtk_file_filter_add_custom (filter, GTK_FILE_FILTER_FILENAME,
|
|
|
|
|
(GtkFileFilterFunc)datafile_filter,
|
|
|
|
|
gnc_filename_is_datafile, NULL);
|
|
|
|
|
gtk_file_chooser_add_filter (faw->fileChooser, filter);
|
|
|
|
|
gtk_file_chooser_set_filter (faw->fileChooser, filter);
|
|
|
|
|
|
|
|
|
|
filter = gtk_file_filter_new ();
|
|
|
|
|
/* Translators: *.gnucash.*.gnucash, *.xac.*.xac are file
|
|
|
|
|
patterns and must not be translated*/
|
|
|
|
|
gtk_file_filter_set_name (filter, _("Backups only (*.gnucash.*.gnucash, *.xac.*.xac)"));
|
|
|
|
|
gtk_file_filter_add_custom (filter, GTK_FILE_FILTER_FILENAME,
|
|
|
|
|
(GtkFileFilterFunc)datafile_filter,
|
|
|
|
|
gnc_filename_is_backup, NULL);
|
|
|
|
|
gtk_file_chooser_add_filter (faw->fileChooser, filter);
|
|
|
|
|
|
|
|
|
|
/* Set the default directory */
|
|
|
|
|
if (type == FILE_ACCESS_OPEN || type == FILE_ACCESS_SAVE_AS)
|
|
|
|
|
{
|
|
|
|
|
|