- VikWindow *newvw = new_window();
- gboolean change_fn = (!files[1]); /* only change fn if one file */
- if ( newvw )
- while ( *files ) {
- vik_window_open_file ( newvw, *(files++), change_fn );
+ gboolean change_fn = (g_slist_length(files) == 1); /* only change fn if one file */
+ GSList *cur_file = files;
+ while ( cur_file ) {
+ // Only open a new window if a viking file
+ gchar *file_name = cur_file->data;
+ if (vw != NULL && check_file_magic_vik ( file_name ) ) {
+ VikWindow *newvw = new_window();
+ if (newvw)
+ vik_window_open_file ( newvw, file_name, change_fn );
+ }
+ else {
+ vik_window_open_file ( vw, file_name, change_fn );