[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:22 -0400 (EDT) |
branch: master
commit 1d35cb46b2777a46085febe69eb1bcda5014a42e
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Mon Oct 21 16:50:32 2019 +0100
continue tree layout for toc
---
js/infog/extension.c | 10 +++++++++-
js/infog/main.c | 39 +++++++++++++++++++++++++++------------
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/js/infog/extension.c b/js/infog/extension.c
index e3acaa6e18..38076e3862 100644
--- a/js/infog/extension.c
+++ b/js/infog/extension.c
@@ -320,6 +320,8 @@ build_toc_string (GString *toc, WebKitDOMElement *elt)
if (!strcmp (s, "LI") || !strcmp (s, "li"))
{
e1 = webkit_dom_element_get_first_element_child (e);
+ e = webkit_dom_element_get_next_element_sibling (e);
+
s2 = webkit_dom_element_get_tag_name (e1);
if (!strcmp (s2, "a") || !strcmp (s2, "A"))
{
@@ -333,6 +335,10 @@ build_toc_string (GString *toc, WebKitDOMElement *elt)
first = 0;
g_string_append (toc, "+");
}
+ else if (!e)
+ {
+ g_string_append (toc, "-");
+ }
g_string_append (toc, s3);
g_string_append (toc, "\n");
}
@@ -347,7 +353,8 @@ build_toc_string (GString *toc, WebKitDOMElement *elt)
}
}
}
- e = webkit_dom_element_get_next_element_sibling (e);
+ else
+ break;
}
}
@@ -365,6 +372,7 @@ send_toc (WebKitDOMDocument *dom_document)
build_toc_string (toc, toc_elt);
+ g_print ("SEND TOB |%s|\n", toc->str);
packetize ("toc", toc);
g_string_free (toc, TRUE);
}
diff --git a/js/infog/main.c b/js/infog/main.c
index c3eb53afff..6fc1f1992f 100644
--- a/js/infog/main.c
+++ b/js/infog/main.c
@@ -237,6 +237,8 @@ int toc_empty = 1;
void
load_toc (char *p)
{
+ int last;
+
if (!toc_store)
{
toc_store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
@@ -253,6 +255,7 @@ load_toc (char *p)
char *q, *q2;
while ((q = strchr (p, '\n')))
{
+ last = 0;
*q++ = 0;
q2 = strchr (q, '\n');
if (!q2)
@@ -283,7 +286,18 @@ load_toc (char *p)
toc_iter = last_iter;
}
}
- else if (0 && *q == '-')
+ else if (*q == '-')
+ {
+ q++;
+ last = 1;
+ }
+
+ gtk_tree_store_append (toc_store, &last_iter, toc_iter_ptr);
+ gtk_tree_store_set (toc_store, &last_iter,
+ 0, p, 1, q, -1);
+ toc_empty = 0;
+
+ if (last)
{
GtkTreeIter parent;
q++;
@@ -293,20 +307,21 @@ load_toc (char *p)
}
else
{
- gtk_tree_model_iter_parent (GTK_TREE_MODEL(toc_store),
- &parent, toc_iter_ptr);
- toc_iter = parent;
- /* Then check if the parent itself was also the last entry.
- If so, keep on going up. */
+ bool result = gtk_tree_model_iter_parent
+ (GTK_TREE_MODEL(toc_store), &parent, &toc_iter);
+ if (result)
+ {
+ toc_iter = parent;
+ /* Then check if the parent itself was also the last entry.
+ If so, keep on going up. */
+ }
+ else
+ {
+ toc_iter_ptr = NULL; /* At top level. */
+ }
}
-
}
- gtk_tree_store_append (toc_store, &last_iter, toc_iter_ptr);
- gtk_tree_store_set (toc_store, &last_iter,
- 0, p, 1, q, -1);
- toc_empty = 0;
-
p = q2;
}
}
- [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