[libadwaita/wip/exalm/about: 4/5] about-window: Fix list item counting




commit a2cb7c1f390ed1ceddb4288b0a1ceea53de87a65
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Jul 8 15:51:54 2022 +0400

    about-window: Fix list item counting
    
    n_item was counted from 1 normally, but from 0 if a list came right at the
    beginning - as it's reset to 1 at the end of a list. Stop doing that and
    always count it from 0.

 src/adw-about-window.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/adw-about-window.c b/src/adw-about-window.c
index 4bac8fb6..ee06ced6 100644
--- a/src/adw-about-window.c
+++ b/src/adw-about-window.c
@@ -724,12 +724,12 @@ start_element_handler (GMarkupParseContext  *context,
     if (!g_strcmp0 (element_name, "li")) {
       char *bullet;
 
-      if (pdata->n_item > 1)
+      if (pdata->n_item > 0)
         gtk_text_buffer_insert (pdata->buffer, &pdata->iter, "\n", -1);
 
       if (pdata->state == STATE_ORDERED_LIST) {
         pdata->state = STATE_ORDERED_ITEM;
-        bullet = g_strdup_printf ("%d. ", pdata->n_item);
+        bullet = g_strdup_printf ("%d. ", pdata->n_item + 1);
       } else {
         pdata->state = STATE_UNORDERED_ITEM;
         bullet = g_strdup ("• ");
@@ -802,7 +802,7 @@ end_element_handler (GMarkupParseContext  *context,
     pdata->state = STATE_NONE;
     pdata->section_start = -1;
     pdata->paragraph_start = -1;
-    pdata->n_item = 1;
+    pdata->n_item = 0;
     return;
   }
 
@@ -814,7 +814,7 @@ end_element_handler (GMarkupParseContext  *context,
     else
       g_assert_not_reached ();
 
-    if (pdata->section_start > 0 && pdata->n_item == 1) {
+    if (pdata->section_start > 0 && pdata->n_item == 0) {
        GtkTextIter start_iter;
        gtk_text_buffer_get_iter_at_offset (pdata->buffer, &start_iter,
                                            pdata->section_start);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]