[gnote/gnome-3-16] Do not lose identation on first item when double



commit e1748eff55db852e41f8889bf96dea8e85455721
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Fri May 29 21:28:46 2015 +0300

    Do not lose identation on first item when double
    
    When using bulleted list, but double identation for each level, the
    first item on the list had no identation at all.
    Fixes Bug 749658.

 src/notebuffer.cpp |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/src/notebuffer.cpp b/src/notebuffer.cpp
index d258a2f..0bfb8b9 100644
--- a/src/notebuffer.cpp
+++ b/src/notebuffer.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2010-2014 Aurimas Cernius
+ * Copyright (C) 2010-2015 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -1487,6 +1487,12 @@ namespace gnote {
           } 
           else if (xml.get_name() == "list") {
             curr_depth++;
+            // If we are inside a <list-item> mark off
+            // that we have encountered some content
+            if (!list_stack.empty()) {
+              list_stack.pop_front();
+              list_stack.push_front(true);
+            }
             break;
           } 
           else if (xml.get_name() == "list-item") {
@@ -1561,11 +1567,14 @@ namespace gnote {
             DepthNoteTag::Ptr depth_tag = DepthNoteTag::Ptr::cast_dynamic(tag_start.tag);
 
             if (depth_tag && list_stack.front ()) {
-              NoteBuffer::Ptr::cast_dynamic(buffer)->insert_bullet (apply_start,
-                                                                    depth_tag->get_depth(),
-                                                                    depth_tag->get_direction());
-              buffer->remove_all_tags (apply_start, apply_start);
-              offset += 2;
+              NoteBuffer::Ptr note_buffer = NoteBuffer::Ptr::cast_dynamic(buffer);
+              // Do not insert bullet if it's already there
+              // this happens when using double identation in bullet list
+              if(note_buffer->find_depth_tag(apply_start) == 0) {
+                note_buffer->insert_bullet (apply_start, depth_tag->get_depth(), depth_tag->get_direction());
+                buffer->remove_all_tags (apply_start, apply_start);
+                offset += 2;
+              }
               list_stack.pop_front();
             } 
             else if (!depth_tag) {


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