summaryrefslogtreecommitdiff
path: root/gui/viewer.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-10-15 16:02:00 -0300
committerWerner Almesberger <werner@almesberger.net>2016-10-15 17:28:11 -0300
commit039812a978a2be64108a76df292dc0fb21db2ba4 (patch)
tree3493c038e111a70313ef7cddfe1b07673b1b7920 /gui/viewer.c
parent3cc35a674b1eed337bba15626b55e951199042f0 (diff)
downloadeeshow-039812a978a2be64108a76df292dc0fb21db2ba4.tar.gz
eeshow-039812a978a2be64108a76df292dc0fb21db2ba4.tar.bz2
eeshow-039812a978a2be64108a76df292dc0fb21db2ba4.zip
gui/viewer.c (viewer): launch external viewer; use it in comp.c
Diffstat (limited to 'gui/viewer.c')
-rw-r--r--gui/viewer.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gui/viewer.c b/gui/viewer.c
new file mode 100644
index 0000000..9db5515
--- /dev/null
+++ b/gui/viewer.c
@@ -0,0 +1,41 @@
+/*
+ * gui/viewer.c - Document viewer
+ *
+ * Written 2016 by Werner Almesberger
+ * Copyright 2016 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "misc/diag.h"
+#include "gui/viewer.h"
+
+
+#define VIEWER_VAR "EESHOW_VIEWER"
+#define DEFAULT_VIEWER "xdg-open"
+
+
+void viewer(const char *url)
+{
+ const char *v;
+ pid_t pid;
+
+ v = getenv(VIEWER_VAR);
+ if (!v)
+ v = DEFAULT_VIEWER;
+ pid = fork();
+ if (pid < 0)
+ diag_perror("fork");
+ if (pid)
+ return;
+ execlp(v, v, url, NULL);
+ perror(v);
+ _exit(1);
+}