Mercurial > fife-parpg
comparison clients/editor/scripts/undomanager.py @ 256:e893afb4963b
* Fixed HistoryManager to work with linear undo
* Set UndoManager to use branched mode by default
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 08 Jun 2009 16:57:39 +0000 |
parents | 51cc05d862f2 |
children | 8b125ec749d7 |
comparison
equal
deleted
inserted
replaced
255:51cc05d862f2 | 256:e893afb4963b |
---|---|
30 | 30 |
31 def doSomething(): | 31 def doSomething(): |
32 # Adds an action to the undomanager | 32 # Adds an action to the undomanager |
33 undocallback = lambda: doSomethingElse() | 33 undocallback = lambda: doSomethingElse() |
34 redocallback = lambda: doSomething() | 34 redocallback = lambda: doSomething() |
35 action = UndoObject("Did something", "Something was done somewhere in the program.", "icon.png") | 35 description = "Something was done somewhere in the program." |
36 action = UndoObject(undocallback, redocallback, "Did something", description, "icon.png") | |
36 undomanager.addAction(action) | 37 undomanager.addAction(action) |
37 | 38 |
38 def doLotOfActions(): | 39 def doLotOfActions(): |
39 # Starts an actiongroup and adds three actions | 40 # Starts an actiongroup and adds three actions |
40 undomanager.startGroup("Did lot of actions", "Lot of actions was done somewhere in the program") | 41 undomanager.startGroup("Did lot of actions", "Lot of actions was done somewhere in the program") |
46 # This will create an actiongroup with three actions, and undo it | 47 # This will create an actiongroup with three actions, and undo it |
47 doLotOfActions() | 48 doLotOfActions() |
48 undomanager.undo() | 49 undomanager.undo() |
49 """ | 50 """ |
50 | 51 |
51 def __init__(self, branchedMode = False): | 52 def __init__(self, branchedMode = True): |
52 self._groups = [] | 53 self._groups = [] |
53 self._branched_mode = False | 54 self._branched_mode = branchedMode |
54 | 55 |
55 def warn(msg): | 56 def warn(msg): |
56 print "Warning: ",msg | 57 print "Warning: ",msg |
57 self.first_item = UndoStackItem(UndoObject(None, None)) | 58 self.first_item = UndoStackItem(UndoObject(None, None)) |
58 self.first_item.object.name = "First item" | 59 self.first_item.object.name = "First item" |