[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:29 -0400 (EDT) |
branch: master
commit ef2d7d7713a8aedcff1ca59520cee57ce496f077
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Mon Oct 19 17:57:28 2020 +0100
new-node and inform-new-node messages
---
js/infog/extension.c | 46 +++++++++++++++++++++++++++++++++++-----------
js/infog/main.c | 31 ++++++++++++++++++++++++++++++-
2 files changed, 65 insertions(+), 12 deletions(-)
diff --git a/js/infog/extension.c b/js/infog/extension.c
index 8d92feeb69..c7508630cc 100644
--- a/js/infog/extension.c
+++ b/js/infog/extension.c
@@ -131,15 +131,13 @@ request_callback (WebKitWebPage *web_page,
return FALSE;
}
- /* Links to other Texinfo manuals are rewritten to have the "private"
- URI scheme. */
- if (!memcmp (uri, "file:", 5)
- || !memcmp (uri, "private:", 8))
+ /* Web links to other Texinfo manuals are rewritten to have the "private"
+ URI scheme. Any relative links like "../MANUAL/NODE.html"
+ are absolute paths beginning "file:/" by the time this function
+ is called. */
+ if (!memcmp (uri, "private:", 8))
{
char *manual, *node;
- /* The links in the HTML files should be relative links like
- "../MANUAL/NODE.html" but by the time this function is called
- they are absolute paths beginning "file:/". */
parse_external_url (uri, &manual, &node);
if (!manual || !node)
{
@@ -152,19 +150,45 @@ request_callback (WebKitWebPage *web_page,
if (!current_manual || strcmp(manual, current_manual) != 0)
{
- if (!load_manual (manual))
- ;// return TRUE; /* Cancel load request */
+ load_manual (manual);
}
+
+ /* Ask main process to load node for us. */
GString *s = g_string_new (NULL);
g_string_append (s, "new-node\n");
g_string_append (s, node);
send_datagram (s);
g_string_free (s, TRUE);
- if (!memcmp (uri, "private:", 8))
- return TRUE;
+ return TRUE; /* Cancel load request */
}
+ else if (!memcmp (uri, "file:", 5))
+ {
+ /* Load file for real. */
+ char *manual, *node;
+ parse_external_url (uri, &manual, &node);
+ if (!manual || !node)
+ {
+ /* Possibly a *.css file or malformed link. */
+ free (manual); free (node);
+ return FALSE;
+ }
+
+ debug (1, "finding manual and node %s:%s\n", manual, node);
+
+ if (!current_manual || strcmp(manual, current_manual) != 0)
+ {
+ load_manual (manual);
+ }
+ /* Update sidebar */
+ GString *s = g_string_new (NULL);
+ g_string_append (s, "inform-new-node\n");
+ g_string_append (s, node);
+ send_datagram (s);
+ g_string_free (s, TRUE);
+ }
+
return FALSE;
}
diff --git a/js/infog/main.c b/js/infog/main.c
index a18899acce..1a3278ced0 100644
--- a/js/infog/main.c
+++ b/js/infog/main.c
@@ -495,6 +495,30 @@ switch_node (char *p)
}
}
+/* Used to load a new node. Used when the subprocess doesn't
+ know the absolute file name after loading a new manual. */
+void
+load_node (char *p)
+{
+ if (!current_manual_dir)
+ {
+ debug (1, "ABORT LOAD NODE %s\n", p);
+ return;
+ }
+
+ debug (1, "NEW NODE %s\n", p);
+
+ GString *s = g_string_new (NULL);
+ g_string_append (s, "file:");
+ g_string_append (s, current_manual_dir);
+ g_string_append (s, "/");
+ g_string_append (s, p);
+ g_string_append (s, ".html");
+ debug (1, "TRY LOAD %s\n", s->str);
+ webkit_web_view_load_uri (webView, s->str);
+ g_string_free (s, TRUE);
+}
+
gboolean
socket_cb (GSocket *socket,
@@ -560,7 +584,7 @@ socket_cb (GSocket *socket,
webkit_web_view_load_uri (hiddenWebView, s->str);
g_string_free (s, TRUE);
}
- else if (!strcmp (buffer, "new-node"))
+ else if (!strcmp (buffer, "inform-new-node"))
{
p++;
if (toc_paths)
@@ -568,6 +592,11 @@ socket_cb (GSocket *socket,
free (next_link); free (prev_link); free (up_link);
next_link = prev_link = up_link = 0;
}
+ else if (!strcmp (buffer, "new-node"))
+ {
+ p++;
+ load_node (p);
+ }
else if (!strcmp (buffer, "toc"))
{
p++;
- [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