[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 c030e88044fffa1507588b86ac00c0727cae641b
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Mon Oct 21 16:30:56 2019 +0100
start on displaying tree in toc
---
js/infog/extension.c | 6 ++++++
js/infog/main.c | 44 ++++++++++++++++++++++++++++++++++++++++----
2 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/js/infog/extension.c b/js/infog/extension.c
index d57661877a..e3acaa6e18 100644
--- a/js/infog/extension.c
+++ b/js/infog/extension.c
@@ -311,6 +311,7 @@ build_toc_string (GString *toc, WebKitDOMElement *elt)
{
char *s, *s1, *s2, *s3;
WebKitDOMElement *e, *e1;
+ int first = 1;
e = webkit_dom_element_get_first_element_child (elt);
while (e)
@@ -327,6 +328,11 @@ build_toc_string (GString *toc, WebKitDOMElement *elt)
g_string_append (toc, "\n");
s3 = webkit_dom_element_get_attribute (e1, "href");
+ if (first)
+ {
+ first = 0;
+ g_string_append (toc, "+");
+ }
g_string_append (toc, s3);
g_string_append (toc, "\n");
}
diff --git a/js/infog/main.c b/js/infog/main.c
index 8fd74a7b70..c3eb53afff 100644
--- a/js/infog/main.c
+++ b/js/infog/main.c
@@ -228,11 +228,15 @@ load_index_nodes (char *p)
GtkCellRenderer *toc_renderer = 0;
GtkTreeViewColumn *toc_column = 0;
+GtkTreeIter toc_iter; /* The entry to add new entries under. */
+GtkTreeIter last_iter;
+
+GtkTreeIter *toc_iter_ptr;
+int toc_empty = 1;
+
void
load_toc (char *p)
{
- GtkTreeIter iter;
-
if (!toc_store)
{
toc_store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
@@ -269,9 +273,39 @@ load_toc (char *p)
}
}
- gtk_tree_store_append (toc_store, &iter, NULL);
- gtk_tree_store_set (toc_store, &iter,
+ if (*q == '+')
+ {
+ q++;
+ if (!toc_empty)
+ {
+ /* Add items under the last item added. */
+ toc_iter_ptr = &toc_iter;
+ toc_iter = last_iter;
+ }
+ }
+ else if (0 && *q == '-')
+ {
+ GtkTreeIter parent;
+ q++;
+ if (!toc_iter_ptr)
+ {
+ g_print ("BUG: toc_iter_ptr undef\n");
+ }
+ 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. */
+ }
+
+ }
+
+ 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;
}
@@ -360,6 +394,8 @@ socket_cb (GSocket *socket,
{
gtk_tree_selection_set_mode (toc_selection, GTK_SELECTION_NONE);
gtk_tree_store_clear (toc_store);
+ toc_iter_ptr = 0;
+ toc_empty = 1;
gtk_tree_selection_set_mode (toc_selection,
GTK_SELECTION_SINGLE);
/* If we do not change the selection mode, it appears that
- [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