From 0cda41732fb58aaf18e8743a3f832b137b32412a Mon Sep 17 00:00:00 2001
From: Přemysl Eric Janouch <p@janouch.name>
Date: Wed, 10 Nov 2021 03:13:33 +0100
Subject: Add C-n to open a new instance in the directory

Also, improve error messages when opening a file fails.
---
 fastiv.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/fastiv.c b/fastiv.c
index 7266212..a8af8dd 100644
--- a/fastiv.c
+++ b/fastiv.c
@@ -145,7 +145,10 @@ open(const gchar *path)
 
 	GError *error = NULL;
 	if (!fastiv_view_open(FASTIV_VIEW(g.view), path, &error)) {
+		char *base = g_filename_display_basename(path);
+		g_prefix_error(&error, "%s: ", base);
 		show_error_dialog(error);
+		g_free(base);
 		return;
 	}
 
@@ -253,6 +256,14 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEvent *event,
 		case GDK_KEY_o:
 			on_open();
 			return TRUE;
+		case GDK_KEY_n: {
+			char *argv[] = {PROJECT_NAME, g.directory, NULL};
+			GError *error = NULL;
+			g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
+				NULL, &error);
+			g_clear_error(&error);
+			return TRUE;
+		}
 		}
 		break;
 	case 0:
-- 
cgit v1.2.3-70-g09d2