mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Extend gnc_file_dialog to take a GList of GtkFileFilters instead of a filter string. Allows patterns like *.[Qq][Ii][Ff] without messing up the dialog, fixes #336124.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@14142 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
816d9da11c
commit
77d9ef8604
@ -1,3 +1,12 @@
|
|||||||
|
2006-05-20 Andreas Köhler <andi5.py@gmx.net>
|
||||||
|
|
||||||
|
* src/gnome-utils/gnc-file.[ch]:
|
||||||
|
* src/import-export/log-replay/gnc-log-replay.c:
|
||||||
|
* src/import-export/qif-import/druid-qif-import.c: Extend
|
||||||
|
gnc_file_dialog to take a GList of GtkFileFilters instead of a
|
||||||
|
filter string. Allows patterns like *.[Qq][Ii][Ff] without
|
||||||
|
messing up the dialog, fixes #336124.
|
||||||
|
|
||||||
2006-05-19 David Hampton <hampton@employees.org>
|
2006-05-19 David Hampton <hampton@employees.org>
|
||||||
|
|
||||||
* src/register/register-gnome/gnucash-grid.c: Make the blue
|
* src/register/register-gnome/gnucash-grid.c: Make the blue
|
||||||
|
@ -65,7 +65,8 @@ static gint save_in_progress = 0;
|
|||||||
* 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 *
|
* filters - list of GtkFileFilters to use, will be *
|
||||||
|
freed automatically *
|
||||||
* default_dir - start the chooser in this directory *
|
* default_dir - start the chooser in this directory *
|
||||||
* type - what type of dialog (open, save, etc.) *
|
* type - what type of dialog (open, save, etc.) *
|
||||||
* Return: containing the name of the file the user selected *
|
* Return: containing the name of the file the user selected *
|
||||||
@ -73,7 +74,7 @@ static gint save_in_progress = 0;
|
|||||||
|
|
||||||
char *
|
char *
|
||||||
gnc_file_dialog (const char * title,
|
gnc_file_dialog (const char * title,
|
||||||
const char * filter,
|
GList * filters,
|
||||||
const char * starting_dir,
|
const char * starting_dir,
|
||||||
GNCFileDialogType type
|
GNCFileDialogType type
|
||||||
)
|
)
|
||||||
@ -144,14 +145,16 @@ gnc_file_dialog (const char * title,
|
|||||||
GTK_WINDOW(gnc_ui_get_toplevel()));
|
GTK_WINDOW(gnc_ui_get_toplevel()));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (filter != NULL)
|
if (filters != NULL)
|
||||||
{
|
{
|
||||||
GtkFileFilter* g_filter = gtk_file_filter_new();
|
GList* filter;
|
||||||
GtkFileFilter* all_filter = gtk_file_filter_new();
|
GtkFileFilter* all_filter = gtk_file_filter_new();
|
||||||
|
|
||||||
gtk_file_filter_set_name (g_filter, filter);
|
for (filter=filters; filter; filter=filter->next) {
|
||||||
gtk_file_filter_add_pattern (g_filter, filter);
|
g_return_val_if_fail(GTK_IS_FILE_FILTER(filter->data), NULL);
|
||||||
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_box), g_filter);
|
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_box),
|
||||||
|
GTK_FILE_FILTER (filter->data));
|
||||||
|
}
|
||||||
|
|
||||||
gtk_file_filter_set_name (all_filter, _("All files"));
|
gtk_file_filter_set_name (all_filter, _("All files"));
|
||||||
gtk_file_filter_add_pattern (all_filter, "*");
|
gtk_file_filter_add_pattern (all_filter, "*");
|
||||||
@ -161,7 +164,9 @@ gnc_file_dialog (const char * title,
|
|||||||
* The latter wins, and the filter ends up diabled. Since we are
|
* The latter wins, and the filter ends up diabled. Since we are
|
||||||
* only settin the starting directory for the chooser dialog,
|
* only settin the starting directory for the chooser dialog,
|
||||||
* everything works as expected. */
|
* everything works as expected. */
|
||||||
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (file_box), g_filter);
|
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (file_box),
|
||||||
|
GTK_FILE_FILTER (filters->data));
|
||||||
|
g_list_free (filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
response = gtk_dialog_run(GTK_DIALOG(file_box));
|
response = gtk_dialog_run(GTK_DIALOG(file_box));
|
||||||
|
@ -137,7 +137,7 @@ gboolean show_session_error (QofBackendError io_error,
|
|||||||
GNCFileDialogType type);
|
GNCFileDialogType type);
|
||||||
|
|
||||||
char * gnc_file_dialog (const char * title,
|
char * gnc_file_dialog (const char * title,
|
||||||
const char * filter,
|
GList * filters,
|
||||||
const char * starting_dir,
|
const char * starting_dir,
|
||||||
GNCFileDialogType type);
|
GNCFileDialogType type);
|
||||||
|
|
||||||
|
@ -499,6 +499,7 @@ void gnc_file_log_replay (void)
|
|||||||
char *default_dir;
|
char *default_dir;
|
||||||
char read_buf[256];
|
char read_buf[256];
|
||||||
char *read_retval;
|
char *read_retval;
|
||||||
|
GtkFileFilter *filter;
|
||||||
FILE *log_file;
|
FILE *log_file;
|
||||||
char * record_start_str = "===== START";
|
char * record_start_str = "===== START";
|
||||||
/* NOTE: This string must match src/engine/TransLog.c (sans newline) */
|
/* NOTE: This string must match src/engine/TransLog.c (sans newline) */
|
||||||
@ -517,8 +518,12 @@ void gnc_file_log_replay (void)
|
|||||||
default_dir = gnc_gconf_get_string(GCONF_SECTION, KEY_LAST_PATH, NULL);
|
default_dir = gnc_gconf_get_string(GCONF_SECTION, KEY_LAST_PATH, NULL);
|
||||||
if (default_dir == NULL)
|
if (default_dir == NULL)
|
||||||
gnc_init_default_directory(&default_dir);
|
gnc_init_default_directory(&default_dir);
|
||||||
|
|
||||||
|
filter = gtk_file_filter_new();
|
||||||
|
gtk_file_filter_set_name(filter, "*.log");
|
||||||
|
gtk_file_filter_add_pattern(filter, "*.[Ll][Oo][Gg]");
|
||||||
selected_filename = gnc_file_dialog(_("Select a .log file to replay"),
|
selected_filename = gnc_file_dialog(_("Select a .log file to replay"),
|
||||||
"*.log",
|
g_list_prepend(NULL, filter),
|
||||||
default_dir,
|
default_dir,
|
||||||
GNC_FILE_DIALOG_OPEN);
|
GNC_FILE_DIALOG_OPEN);
|
||||||
|
|
||||||
|
@ -348,6 +348,7 @@ gnc_ui_qif_import_select_file_cb(GtkButton * button,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
QIFImportWindow * wind = user_data;
|
QIFImportWindow * wind = user_data;
|
||||||
|
GtkFileFilter *filter;
|
||||||
char * new_file_name;
|
char * new_file_name;
|
||||||
char *file_name, *default_dir;
|
char *file_name, *default_dir;
|
||||||
|
|
||||||
@ -355,8 +356,14 @@ gnc_ui_qif_import_select_file_cb(GtkButton * button,
|
|||||||
default_dir = gnc_gconf_get_string(GCONF_SECTION, KEY_LAST_PATH, NULL);
|
default_dir = gnc_gconf_get_string(GCONF_SECTION, KEY_LAST_PATH, NULL);
|
||||||
if (default_dir == NULL)
|
if (default_dir == NULL)
|
||||||
gnc_init_default_directory(&default_dir);
|
gnc_init_default_directory(&default_dir);
|
||||||
new_file_name = gnc_file_dialog (_("Select QIF File"), "*.qif",
|
|
||||||
default_dir, GNC_FILE_DIALOG_IMPORT);
|
filter = gtk_file_filter_new ();
|
||||||
|
gtk_file_filter_set_name (filter, "*.qif");
|
||||||
|
gtk_file_filter_add_pattern (filter, "*.[Qq][Ii][Ff]");
|
||||||
|
new_file_name = gnc_file_dialog (_("Select QIF File"),
|
||||||
|
g_list_prepend (NULL, filter),
|
||||||
|
default_dir,
|
||||||
|
GNC_FILE_DIALOG_IMPORT);
|
||||||
|
|
||||||
/* Insure valid data, and something that can be freed. */
|
/* Insure valid data, and something that can be freed. */
|
||||||
if (new_file_name == NULL) {
|
if (new_file_name == NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user