texinfo-commits
[Top][All Lists]
Advanced

[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:15 -0400 (EDT)

branch: master
commit 4fb9ac6578f7a7f77193c1c1c2091499f4c2f77c
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun May 26 14:53:49 2019 +0100

    actually load the new indices and replace the completion list
---
 js/wkinfo/extension.c | 25 ++++++++-----------------
 js/wkinfo/infopath.c  | 10 +++++-----
 js/wkinfo/main.c      | 24 +++++++++++++++++++++++-
 3 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/js/wkinfo/extension.c b/js/wkinfo/extension.c
index 3f86d0ddd7..791b020c4e 100644
--- a/js/wkinfo/extension.c
+++ b/js/wkinfo/extension.c
@@ -58,40 +58,32 @@ static char *current_manual_dir;
 
 /* Called from request_callback. */
 void
-load_manual (char *manual, WebKitURIRequest  *request)
+load_manual (char *manual)
 {
-  char *new_manual = locate_manual (manual);
-  g_print ("NEW MANUAL AT %s\n", new_manual);
+  free (current_manual_dir);
+  current_manual_dir = locate_manual (manual);
+  g_print ("NEW MANUAL AT %s\n", current_manual_dir);
 
-  if (!new_manual)
+  if (!current_manual_dir)
     {
       free (manual);
       return;
     }
 
-  GString *s = g_string_new (NULL);
-  g_string_append (s, "file:");
-  g_string_append (s, new_manual);
-
   current_manual = manual;
 
-  webkit_uri_request_set_uri (request, s->str);
-
   /* Inform the main process the manual has changed so that it can
      load the indices. */
   GString *s1 = g_string_new (NULL);
   g_string_append (s1, "new-manual\n");
-  g_string_append (s1, s->str);
+  g_string_append (s1, current_manual_dir);
   g_string_append (s1, "\n");
 
   g_print ("SENDING %s\n", s1->str);
 
   send_datagram (s1);
 
-  g_string_free (s, TRUE);
   g_string_free (s1, TRUE);
-
-  free (new_manual);
 }
 
 gboolean
@@ -137,17 +129,17 @@ request_callback (WebKitWebPage     *web_page,
 
   if (!memcmp (uri, "file:", 5))
     {
-      g_print ("finding manual and node\n");
 
       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);
+      g_print ("finding manual and node %s:%s\n", manual, node);
 
       if (!current_manual || strcmp(manual, current_manual) != 0)
         {
-          load_manual (manual, request);
+          load_manual (manual);
         }
     }
 
@@ -208,7 +200,6 @@ find_indices (WebKitDOMHTMLCollection *links, gulong 
num_links)
       free (rel); free (id);
     }
 
-  g_print ("found index nodes %s\n", s->str);
   send_datagram (s);
   g_string_free (s, TRUE);
 }
diff --git a/js/wkinfo/infopath.c b/js/wkinfo/infopath.c
index 1a61051839..63402d0abd 100644
--- a/js/wkinfo/infopath.c
+++ b/js/wkinfo/infopath.c
@@ -43,17 +43,17 @@ locate_manual (const char *manual)
     }
   closedir (d);
 
-  free (s);
-  s = malloc (datadir_len + strlen ("/")
+  char *s2 = malloc (datadir_len + strlen ("/")
                     + strlen (manual) + strlen ("/index.html") + 1);
-  sprintf (s, "%s/%s/index.html", datadir, manual);
+  sprintf (s2, "%s/%s/index.html", datadir, manual);
 
   struct stat dummy;
-  if (stat (s, &dummy) == -1)
+  if (stat (s2, &dummy) == -1)
     {
-      fprintf (stderr, "no file %s\n", s);
+      fprintf (stderr, "no file %s\n", s2);
       return 0;
     }
+
   return s;
 }
 
diff --git a/js/wkinfo/main.c b/js/wkinfo/main.c
index 2df2548c0e..83222b6562 100644
--- a/js/wkinfo/main.c
+++ b/js/wkinfo/main.c
@@ -133,6 +133,12 @@ match_selected_cb (GtkEntryCompletion *widget,
   return FALSE;
 }
 
+void
+clear_completions (void)
+{
+  gtk_list_store_clear (index_store);
+}
+
 void
 save_completions (char *p)
 {
@@ -173,22 +179,29 @@ save_completions (char *p)
     }
 }
 
+static char *current_manual_dir;
+
 void
 load_index_nodes (char *p)
 {
   GString *s;
   char *q;
 
+  g_print ("index nodes %s\n", p);
+
   s = g_string_new (NULL);
 
   while ((q = strchr (p, '\n')))
     {
       *q = '\0';
       g_string_assign (s, "file:");
+      g_string_append (s, current_manual_dir);
+      g_string_append (s, "/");
       g_string_append (s, p);
       g_string_append (s, "?send-index");
 
       g_print ("load index node %s\n", s->str);
+      webkit_web_view_load_uri (hiddenWebView, s->str);
 
       p = q + 1;
     }
@@ -250,10 +263,19 @@ socket_cb (GSocket *socket,
       else if (!strcmp (buffer, "new-manual"))
         {
           g_print ("NEW MANUAL %s\n", p + 1);
+          clear_completions ();
+
+          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);
-          g_string_append (s, "?top-node");
+          free (current_manual_dir);
+          current_manual_dir = strdup (p + 1);
+          g_string_append (s, "/index.html?top-node");
           webkit_web_view_load_uri (hiddenWebView, s->str);
           g_string_free (s, TRUE);
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]