GNOME Bugzilla – Bug 137766
Text undo improvements (compress undo steps)
Last modified: 2004-12-22 21:47:04 UTC
Text undo is now implemented but it might be desirable to add some sort of undo compression for text changes. Right now an undo step is pushed for every change. It might also be a good idea to reduce the memory footprint of text undo steps by storing GValues for the changed properties instead of a complete text object. That would probably also help to implement the undo compression mentioned above.
I've implemented a nice way to reduce the memory footprint of text undo steps for the common case: 2004-03-20 Sven Neumann <sven@gimp.org> * app/widgets/gimppropwidgets.c (gimp_prop_size_entry_callback): avoid to set the unit property with every size change; only set it if it actually changed. * app/core/gimpimage-undo-push.c (gimp_image_undo_push_text_layer): allow to pass a GParamSpec that identifies a single text property to be changed. In this case, don't store a GimpText object on the undo stack but only the changed value. * app/tools/gimptexttool.c: use the new undo feature to reduce the memory footprint of text undo for the common case. * app/text/gimptextlayer.c: changed accordingly.
I don't want to make this a blocker but after playing a bit more with texts. I am now pretty sure that we need to implement undo compression here. I will try to find a solution and I would like to see it considered for 2.0.
Created attachment 25858 [details] [review] patch that implements text undo compression
Created attachment 25859 [details] new file app/text/gimptextundo.h
Created attachment 25860 [details] new file app/text/gimptextundo.c
The attached patch and the two new files implement text undo compression. No undo is pushed for text changes if all of the following conditions are true: - the last item on the undo stack is a text undo - the redo stack is empty - the last text undo changed the same text property - the last text undo happened less than 3 seconds ago The timing might need some tweaking. Perhaps 5 seconds is more appropriate.
I committed this now with some other small changes: 2004-03-21 Sven Neumann <sven@gimp.org> * app/core/gimpundo.[ch]: added gimp_undo_type_to_name() a similar function used to live in gimpimage-undo.[ch]. * app/core/gimpitemundo.c (gimp_item_undo_new): allow NULL as name and generate it from the undo_type then. * app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_undu(), new function that allows to push an undo on the image. * app/text/Makefile.am * app/text/text-types.h * app/text/gimptextundo.[ch]: added GimpTextUndo, derived from GimpItemUndo. * app/core/gimpimage-undo-push.c (gimp_image_undo_push_text_layer): use the new code and simply push a text undo here. * app/tools/gimptexttool.c: compress text undos by peeking at the undo stack. Fixes bug #137766.