After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 137766 - Text undo improvements (compress undo steps)
Text undo improvements (compress undo steps)
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Tools
git master
Other All
: Normal enhancement
: 2.0
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks: 136740
 
 
Reported: 2004-03-20 14:19 UTC by Sven Neumann
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch that implements text undo compression (14.27 KB, patch)
2004-03-21 20:35 UTC, Sven Neumann
none Details | Review
new file app/text/gimptextundo.h (2.04 KB, text/plain)
2004-03-21 20:36 UTC, Sven Neumann
  Details
new file app/text/gimptextundo.c (6.51 KB, text/plain)
2004-03-21 20:37 UTC, Sven Neumann
  Details

Description Sven Neumann 2004-03-20 14:19:37 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.
Comment 1 Sven Neumann 2004-03-20 17:18:46 UTC
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.
Comment 2 Sven Neumann 2004-03-21 02:21:05 UTC
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.
Comment 3 Sven Neumann 2004-03-21 20:35:59 UTC
Created attachment 25858 [details] [review]
patch that implements text undo compression
Comment 4 Sven Neumann 2004-03-21 20:36:59 UTC
Created attachment 25859 [details]
new file app/text/gimptextundo.h
Comment 5 Sven Neumann 2004-03-21 20:37:37 UTC
Created attachment 25860 [details]
new file app/text/gimptextundo.c
Comment 6 Sven Neumann 2004-03-21 20:43:36 UTC
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.
Comment 7 Sven Neumann 2004-03-21 23:13:49 UTC
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.