mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
46d91acdff
commit
2cadc70e3d
1 changed files with 11 additions and 14 deletions
11
gtk-gui.c
11
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);
|
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
|
||||||
|
|
||||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
|
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
|
||||||
GSList *filenames, *fn_glist;
|
GSList *fn_glist;
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
/* first, close the existing file, if any, and forget its name */
|
/* first, close the existing file, if any, and forget its name */
|
||||||
|
@ -309,11 +309,11 @@ static void file_open(GtkWidget *w, gpointer data)
|
||||||
free((void *)existing_filename);
|
free((void *)existing_filename);
|
||||||
existing_filename = NULL;
|
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;
|
GError *error = NULL;
|
||||||
while(filenames != NULL) {
|
filename = fn_glist->data;
|
||||||
filename = filenames->data;
|
|
||||||
parse_file(filename, &error);
|
parse_file(filename, &error);
|
||||||
if (error != NULL)
|
if (error != NULL)
|
||||||
{
|
{
|
||||||
|
@ -321,10 +321,7 @@ static void file_open(GtkWidget *w, gpointer data)
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
error = NULL;
|
error = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(filename);
|
g_free(filename);
|
||||||
filenames = g_slist_next(filenames);
|
|
||||||
}
|
|
||||||
g_slist_free(fn_glist);
|
g_slist_free(fn_glist);
|
||||||
report_dives(FALSE);
|
report_dives(FALSE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue