summaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-16 05:05:53 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-17 21:03:30 -0400
commit2cadc70e3dc521b0b208587b5a9121378ff855e5 (patch)
tree5015c7fcf90b86f068a5b5bc437e14e39b5a5055 /gtk-gui.c
parent46d91acdffd9a7d9d54fce5d72a07bfc62100b02 (diff)
downloadsubsurface-2cadc70e3dc521b0b208587b5a9121378ff855e5.tar.gz
Simplify code in file_open as we now only open one file
This doesn't change functionality - it's just pointless to loop over a list that is known to have only one element. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r--gtk-gui.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index 27bf30cc4..c440eb2e7 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -301,7 +301,7 @@ static void file_open(GtkWidget *w, gpointer data)
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
- GSList *filenames, *fn_glist;
+ GSList *fn_glist;
char *filename;
/* first, close the existing file, if any, and forget its name */
@@ -309,22 +309,19 @@ static void file_open(GtkWidget *w, gpointer data)
free((void *)existing_filename);
existing_filename = NULL;
- filenames = fn_glist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
+ /* we know there is only one filename */
+ fn_glist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
GError *error = NULL;
- while(filenames != NULL) {
- filename = filenames->data;
- parse_file(filename, &error);
- if (error != NULL)
- {
- report_error(error);
- g_error_free(error);
- error = NULL;
- }
-
- g_free(filename);
- filenames = g_slist_next(filenames);
+ filename = fn_glist->data;
+ parse_file(filename, &error);
+ if (error != NULL)
+ {
+ report_error(error);
+ g_error_free(error);
+ error = NULL;
}
+ g_free(filename);
g_slist_free(fn_glist);
report_dives(FALSE);
}