sugarlabs / write-activity

A simple word processor for the Sugar learning environment
GNU General Public License v2.0
2 stars 25 forks source link

Undo button not working #20

Closed jammily closed 7 years ago

jammily commented 7 years ago

The undo button can’t be selected (grayed out) after making changes.

quozl commented 7 years ago

This seems to be a problem in AbiWord, not in Write.

AbiWord provides only a limited method to know if undo is possible, the can-undo signal which gives us true or false, but you can't know the initial state.

This patch is useful for testing. At the moment with AbiWord 3.0.1 on Ubuntu 16.04, an empty document begins in a state that allows undo, so changing the default from False to True seems to help. Please test and confirm.

diff --git a/toolbar.py b/toolbar.py
index 591cccf..1fbdf22 100644
--- a/toolbar.py
+++ b/toolbar.py
@@ -72,10 +72,12 @@ class EditToolbar(Gtk.Toolbar):
         self.insert(separator, -1)
         separator.show()

-        undo = UndoButton(sensitive=False)
+        undo = UndoButton(sensitive=True)
         undo.connect('clicked', lambda button: pc.abiword_canvas.undo())
         pc.abiword_canvas.connect("can-undo", lambda abi, can_undo:
                                   undo.set_sensitive(can_undo))
+        pc.abiword_canvas.connect("can-undo", lambda abi, can_undo:
+                                  logging.error('can-undo %r' % can_undo))
         self.insert(undo, -1)
         undo.show()

Please also advise which version of AbiWord you are using.

jammily commented 7 years ago

It works!! :) I'm using Abiword version 2.9, Fedora 18, Sugar 0.110

quozl commented 7 years ago

Thanks for testing, @jammily.