aboutsummaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-15 15:22:36 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-17 21:03:29 -0400
commiteddea0e5e3f8cdf29cd71e1b90c22ec0f511697c (patch)
tree847ab4b94bd7e53edb01898c5159654c2ef0dc05 /gtk-gui.c
parentca696dd0cd7da7af7893639f5786e56972cbef09 (diff)
downloadsubsurface-eddea0e5e3f8cdf29cd71e1b90c22ec0f511697c.tar.gz
Put creation of the file selector box filter into helper function
This avoids duplication of code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r--gtk-gui.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index 355598983..3833b5892 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -126,6 +126,19 @@ void report_error(GError* error)
}
}
+static GtkFileFilter *setup_filter(void)
+{
+ GtkFileFilter *filter = gtk_file_filter_new();
+ gtk_file_filter_add_pattern(filter, "*.xml");
+ gtk_file_filter_add_pattern(filter, "*.XML");
+ gtk_file_filter_add_pattern(filter, "*.sda");
+ gtk_file_filter_add_pattern(filter, "*.SDA");
+ gtk_file_filter_add_mime_type(filter, "text/xml");
+ gtk_file_filter_set_name(filter, "XML file");
+
+ return filter;
+}
+
static void file_save_as(GtkWidget *w, gpointer data)
{
GtkWidget *dialog;
@@ -277,13 +290,7 @@ static void file_open(GtkWidget *w, gpointer data)
/* when opening the data file we should allow only one file to be chosen */
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
- filter = gtk_file_filter_new();
- gtk_file_filter_add_pattern(filter, "*.xml");
- gtk_file_filter_add_pattern(filter, "*.XML");
- gtk_file_filter_add_pattern(filter, "*.sda");
- gtk_file_filter_add_pattern(filter, "*.SDA");
- gtk_file_filter_add_mime_type(filter, "text/xml");
- gtk_file_filter_set_name(filter, "XML file");
+ filter = setup_filter();
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
@@ -495,13 +502,7 @@ static void pick_default_file(GtkWidget *w, GtkButton *button)
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fs_dialog), current_def_dir);
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fs_dialog), current_def_file);
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(fs_dialog), FALSE);
- filter = gtk_file_filter_new();
- gtk_file_filter_add_pattern(filter, "*.xml");
- gtk_file_filter_add_pattern(filter, "*.XML");
- gtk_file_filter_add_pattern(filter, "*.sda");
- gtk_file_filter_add_pattern(filter, "*.SDA");
- gtk_file_filter_add_mime_type(filter, "text/xml");
- gtk_file_filter_set_name(filter, "XML file");
+ filter = setup_filter();
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(fs_dialog), filter);
gtk_widget_show_all(fs_dialog);
if (gtk_dialog_run(GTK_DIALOG(fs_dialog)) == GTK_RESPONSE_ACCEPT) {
@@ -1310,13 +1311,7 @@ static void pick_import_files(GtkWidget *w, GSList **filelist)
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fs_dialog), current_def_dir);
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(fs_dialog), TRUE);
- filter = gtk_file_filter_new();
- gtk_file_filter_add_pattern(filter, "*.xml");
- gtk_file_filter_add_pattern(filter, "*.XML");
- gtk_file_filter_add_pattern(filter, "*.sda");
- gtk_file_filter_add_pattern(filter, "*.SDA");
- gtk_file_filter_add_mime_type(filter, "text/xml");
- gtk_file_filter_set_name(filter, "XML file");
+ filter = setup_filter();
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(fs_dialog), filter);
gtk_widget_show_all(fs_dialog);
if (gtk_dialog_run(GTK_DIALOG(fs_dialog)) == GTK_RESPONSE_ACCEPT)