[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Sun, 20 Mar 2022 04:55:18 -0400 (EDT) |
branch: master
commit 73916a23a03b6c7575b65dc127c8a0311b2631b2
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Wed Oct 16 16:44:29 2019 +0100
do not hardcode path to .libs
---
js/infog/main.c | 38 ++++++++++++++++++++++++++++++++------
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/js/infog/main.c b/js/infog/main.c
index 28e24dd976..b0f27ec594 100644
--- a/js/infog/main.c
+++ b/js/infog/main.c
@@ -1,3 +1,5 @@
+#define _GNU_SOURCE
+
#include <stddef.h>
#include <stdio.h>
#include <errno.h>
@@ -44,8 +46,6 @@ static gboolean onkeypress(GtkWidget *webView,
GdkEvent *event,
gpointer user_data);
-#define WEB_EXTENSIONS_DIRECTORY "/home/g/src/texinfo/GIT/js/infog/.libs"
-
static char *socket_file;
int socket_id;
@@ -310,6 +310,8 @@ socket_cb (GSocket *socket,
return true;
}
+char *extensions_directory;
+
static void
initialize_web_extensions (WebKitWebContext *context,
gpointer user_data)
@@ -350,8 +352,11 @@ initialize_web_extensions (WebKitWebContext *context,
atexit (&remove_socket);
}
- webkit_web_context_set_web_extensions_directory (
- context, WEB_EXTENSIONS_DIRECTORY);
+ char *d;
+ asprintf (&d, "%s/%s", extensions_directory, ".libs");
+ webkit_web_context_set_web_extensions_directory (context, d);
+ free (d);
+
webkit_web_context_set_web_extensions_initialization_user_data (
context, g_variant_new_bytestring (socket_file));
}
@@ -429,12 +434,33 @@ decide_policy_cb (WebKitWebView *web_view,
}
+void
+find_extensions_directory (int argc, char *argv[])
+{
+ char *p;
+ if (argc == 0 || !argv[0])
+ {
+ g_print ("cannot get program name; quitting\n");
+ exit (1);
+ }
+
+ if (!(p = strchr (argv[0], '/')))
+ {
+ g_print ("running installed program not yet supported\n");
+ exit (1);
+ }
+
+ extensions_directory = strdup (argv[0]);
+ extensions_directory[p - argv[0]] = '\0';
+}
+
static GMainLoop *main_loop;
int
-main(int argc, char* argv[])
+main (int argc, char *argv[])
{
- gtk_init(&argc, &argv);
+ gtk_init (&argc, &argv);
+ find_extensions_directory (argc, argv);
info_dir = getenv ("INFO_HTML_DIR");
if (!info_dir)
- [no subject], (continued)
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject],
Gavin D. Smith <=
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20