4178: undo on note editor goes back to no text; added a reset method to styled text buffer and editor

svn: r15756
This commit is contained in:
Doug Blank 2010-08-16 23:25:07 +00:00
parent 21651501ca
commit fa09584578
3 changed files with 17 additions and 0 deletions

View File

@ -266,6 +266,8 @@ class EditNote(EditPrimary):
if self.obj:
self.empty = False
self.texteditor.set_text(self.obj.get_styledtext())
# Reset the undoable buffer:
self.texteditor.reset()
_LOG.debug("Initial Note: %s" % str(self.texteditor.get_text()))
else:
self.empty = True

View File

@ -382,6 +382,12 @@ class StyledTextEditor(gtk.TextView):
open_menu.show()
menu.prepend(open_menu)
def reset(self):
"""
Reset the undoable buffer
"""
self.textbuffer.reset()
# private methods
def _connect_signals(self):

View File

@ -194,6 +194,15 @@ class UndoableBuffer(gtk.TextBuffer):
toggles self.not_undoable_action"""
self.not_undoable_action = False
def reset(self):
"""
Resets buffer to initial state.
"""
self.undo_stack[:] = []
self.redo_stack[:] = []
self.not_undoable_action = False
self.undo_in_progress = False
def undo(self):
"""undo inserts or deletions