[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:23 -0400 (EDT) |
branch: master
commit 9d520446c61bb4a878c57d85068a0727369f7922
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Mon Oct 21 17:35:26 2019 +0100
correct tree layout for sidebar toc
---
js/infog/main.c | 39 ++++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 13 deletions(-)
diff --git a/js/infog/main.c b/js/infog/main.c
index 6fc1f1992f..131c4c5e33 100644
--- a/js/infog/main.c
+++ b/js/infog/main.c
@@ -241,7 +241,8 @@ load_toc (char *p)
if (!toc_store)
{
- toc_store = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+ toc_store = gtk_tree_store_new (3, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_BOOLEAN);
gtk_tree_view_set_model (toc_pane, GTK_TREE_MODEL(toc_store));
toc_renderer = gtk_cell_renderer_text_new ();
@@ -294,30 +295,42 @@ load_toc (char *p)
gtk_tree_store_append (toc_store, &last_iter, toc_iter_ptr);
gtk_tree_store_set (toc_store, &last_iter,
- 0, p, 1, q, -1);
+ 0, p, 1, q, 2, FALSE, -1);
toc_empty = 0;
if (last)
{
GtkTreeIter parent;
- q++;
+
+ /* 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
{
- 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
+ while (1)
{
- toc_iter_ptr = NULL; /* At top level. */
+ bool result = gtk_tree_model_iter_parent
+ (GTK_TREE_MODEL(toc_store), &parent, &toc_iter);
+ if (result)
+ {
+ toc_iter = parent;
+ }
+ else
+ {
+ toc_iter_ptr = NULL; /* At top level. */
+ break;
+ }
+
+ bool no_more;
+ gtk_tree_model_get (GTK_TREE_MODEL(toc_store),
+ &toc_iter, 2, &no_more, -1);
+
+ if (!no_more)
+ break;
}
}
}
- [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