[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:25 -0400 (EDT) |
branch: master
commit daa51a9005a039881522d20b541818c3e212e463
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Tue Oct 22 14:40:21 2019 +0100
move locate_manual call to main thread
---
js/infog/Makefile.am | 2 +-
js/infog/extension.c | 21 ++++++++++++++++++++-
js/infog/main.c | 32 ++++++++++++++++++--------------
3 files changed, 39 insertions(+), 16 deletions(-)
diff --git a/js/infog/Makefile.am b/js/infog/Makefile.am
index d9cabbdfc2..0646613855 100644
--- a/js/infog/Makefile.am
+++ b/js/infog/Makefile.am
@@ -10,7 +10,7 @@ libmyappwebextension_la_LDFLAGS = -module -avoid-version
-no-undefined
bin_PROGRAMS=infog
-infog_SOURCES=main.c common.h
+infog_SOURCES=main.c common.h infopath.c
AM_CFLAGS=`pkg-config --cflags gtk+-3.0 webkit2gtk-4.0`
diff --git a/js/infog/extension.c b/js/infog/extension.c
index 5a42c2b7f6..34ff3776cc 100644
--- a/js/infog/extension.c
+++ b/js/infog/extension.c
@@ -72,7 +72,7 @@ static char *current_manual_dir;
/* Called from request_callback. Return 0 on failure. */
int
-load_manual (char *manual)
+load_manual_old (char *manual)
{
free (current_manual_dir);
current_manual_dir = locate_manual (manual);
@@ -100,6 +100,25 @@ load_manual (char *manual)
return 1;
}
+int
+load_manual (char *manual)
+{
+ current_manual = manual;
+
+ /* Inform the main process the manual has changed so that it can
+ load the TOC and indices. */
+ g_print ("LOAD MANUAL %s\n", manual);
+ GString *s1 = g_string_new (NULL);
+ g_string_append (s1, "new-manual\n");
+ g_string_append (s1, manual);
+
+ send_datagram (s1);
+
+ g_string_free (s1, TRUE);
+
+ return 1;
+}
+
gboolean
request_callback (WebKitWebPage *web_page,
WebKitURIRequest *request,
diff --git a/js/infog/main.c b/js/infog/main.c
index cc5b352f4e..baaa84b245 100644
--- a/js/infog/main.c
+++ b/js/infog/main.c
@@ -17,6 +17,7 @@
#include <webkit2/webkit2.h>
#include "common.h"
+#include "infopath.h"
void
vmsg (char *fmt, va_list v)
@@ -179,6 +180,7 @@ save_completions (char *p)
}
}
+static char *current_manual;
static char *current_manual_dir;
char *index_list = 0;
@@ -305,11 +307,7 @@ load_toc (char *p)
/* Mark the parent entry as having no more children. */
gtk_tree_store_set (toc_store, &toc_iter, 2, TRUE, -1);
- if (!toc_iter_ptr)
- {
- g_print ("BUG: toc_iter_ptr undef\n");
- }
- else
+ if (toc_iter_ptr)
{
while (1)
{
@@ -417,6 +415,20 @@ socket_cb (GSocket *socket,
else if (!strcmp (buffer, "new-manual"))
{
debug (1, "NEW MANUAL %s\n", p + 1);
+
+ free (current_manual_dir);
+ current_manual_dir = locate_manual (p + 1);
+ debug (1, "NEW MANUAL AT %s\n", current_manual_dir);
+
+ if (!current_manual_dir)
+ {
+ debug (1, "MANUAL NOT FOUND\n");
+ break;
+ }
+
+ free (current_manual);
+ current_manual = strdup (p + 1);
+
clear_completions ();
if (toc_store)
{
@@ -431,18 +443,10 @@ socket_cb (GSocket *socket,
so toc_selected_cb runs and loads all the nodes in the old
manual. */
}
- debug (1, "CLEARED TOC %s\n", p + 1);
-
- char *q = strchr (p + 1, '\n');
- if (!q)
- break;
- *q = 0;
GString *s = g_string_new (NULL);
g_string_append (s, "file:");
- g_string_append (s, p + 1);
- free (current_manual_dir);
- current_manual_dir = strdup (p + 1);
+ g_string_append (s, current_manual_dir);
g_string_append (s, "/index.html?top-node");
webkit_web_view_load_uri (hiddenWebView, s->str);
g_string_free (s, TRUE);
- [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