[latexila] Structure action: shift right: undo changes on error
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Structure action: shift right: undo changes on error
- Date: Tue, 5 Jul 2011 22:14:17 +0000 (UTC)
commit 7d18f8c51f3c04f0feb544eb0f7d7f8f010366da
Author: SÃbastien Wilmet <swilmet src gnome org>
Date: Wed Jul 6 00:13:46 2011 +0200
Structure action: shift right: undo changes on error
TODO | 6 ------
src/document_structure.vala | 13 +++++++++++--
2 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/TODO b/TODO
index cf68ae1..f167753 100644
--- a/TODO
+++ b/TODO
@@ -9,12 +9,6 @@ LaTeXila 2.2
- Structure (list of chapters, sections, etc. to easily navigate in a document):
- Right click:
- shift left
- - shift right: if an error occurs but some changes are already made to the document,
- undo these changes.
-
- Shift left/right is new comparated to Kile. For example we have a big section (with
- subsections, etc.) and we want to shift it to the left so it becomes a chapter (the
- subsections becomes sections, etc.).
- When setting a model, expand all only if the tree is not too big
diff --git a/src/document_structure.vala b/src/document_structure.vala
index 6dffd3b..2d595ec 100644
--- a/src/document_structure.vala
+++ b/src/document_structure.vala
@@ -582,11 +582,17 @@ public class DocumentStructure : GLib.Object
_("The structure item already contains a sub-paragraph."));
_doc.begin_user_action ();
- bool success = shift_right (tree_iter);
+ bool doc_modified;
+ bool success = shift_right (tree_iter, out doc_modified);
_doc.end_user_action ();
if (! success)
+ {
+ if (doc_modified)
+ _doc.undo ();
+
throw new StructError.DATA_OUTDATED ("");
+ }
_model.shift_right (tree_iter);
return;
@@ -916,8 +922,10 @@ public class DocumentStructure : GLib.Object
iter = begin_line_iter;
}
- private bool shift_right (TreeIter tree_iter)
+ private bool shift_right (TreeIter tree_iter, out bool doc_modified = null)
{
+ doc_modified = false;
+
/* Get some data about the item */
StructType type;
TextMark mark;
@@ -977,6 +985,7 @@ public class DocumentStructure : GLib.Object
_doc.delete (begin_markup_name_iter, end_markup_name_iter);
_doc.insert (begin_markup_name_iter, new_markup_name, -1);
+ doc_modified = true;
/* Do the same for all the children */
int nb_children = _model.iter_n_children (tree_iter);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]