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 322194 - Proposal: undo/redo in gtk
Proposal: undo/redo in gtk
Status: RESOLVED WONTFIX
Product: gtk+
Classification: Platform
Component: Widget: Other
2.18.x
Other All
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
: 156102 316551 351571 721933 785787 (view as bug list)
Depends on:
Blocks: 167501 171179
 
 
Reported: 2005-11-23 01:12 UTC by Yevgen Muntyan
Modified: 2017-08-10 12:27 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
The patch against gtk-2-8 branch (16.05 KB, patch)
2005-11-23 01:12 UTC, Yevgen Muntyan
none Details | Review
gtkundo.h (4.27 KB, text/plain)
2005-11-23 01:13 UTC, Yevgen Muntyan
  Details
gtkundo.c (14.45 KB, text/plain)
2005-11-23 01:14 UTC, Yevgen Muntyan
  Details
Updated patch (18.66 KB, patch)
2005-11-23 08:38 UTC, Yevgen Muntyan
none Details | Review
Updated patch, against CVS HEAD (18.25 KB, patch)
2006-03-11 08:05 UTC, Yevgen Muntyan
none Details | Review
gtkundo.c (14.43 KB, text/plain)
2006-03-11 10:45 UTC, Yevgen Muntyan
  Details
gtkundo.h (4.27 KB, text/plain)
2006-03-11 10:46 UTC, Yevgen Muntyan
  Details
the patch (46.78 KB, patch)
2006-03-11 10:47 UTC, Yevgen Muntyan
none Details | Review

Description Yevgen Muntyan 2005-11-23 01:12:01 UTC
Version details: gtk-2-8 branch

Here is an implementation of simple undo/redo stack and attaching it to 
GtkEntry. It's basically a rewrite of GtkSourceUndoManager from gtksourceview 
library.
Comment 1 Yevgen Muntyan 2005-11-23 01:12:52 UTC
Created attachment 55115 [details] [review]
The patch against gtk-2-8 branch
Comment 2 Yevgen Muntyan 2005-11-23 01:13:33 UTC
Created attachment 55116 [details]
gtkundo.h
Comment 3 Yevgen Muntyan 2005-11-23 01:14:09 UTC
Created attachment 55117 [details]
gtkundo.c
Comment 4 Yevgen Muntyan 2005-11-23 01:16:15 UTC
gtkundo.[ch] is the implementation of GtkUndoStack object, the object which 
holds undo and redo stacks. The patch adds these files to the library and adds 
undo/redo functionality to GtkEntry - to test, enter some text into an entry, 
press ctrl-z, shift-ctrl-z, and so on. 
Comment 5 Yevgen Muntyan 2005-11-23 08:38:59 UTC
Created attachment 55137 [details] [review]
Updated patch

Sorry, forgot to actually add 'enable-undo' property.
Comment 6 Olivier Le Thanh Duong 2005-11-24 00:00:08 UTC
*** Bug 156102 has been marked as a duplicate of this bug. ***
Comment 7 Yevgen Muntyan 2006-03-11 08:05:18 UTC
Created attachment 61074 [details] [review]
Updated patch, against CVS HEAD
Comment 8 Yevgen Muntyan 2006-03-11 10:45:19 UTC
Created attachment 61077 [details]
gtkundo.c
Comment 9 Yevgen Muntyan 2006-03-11 10:46:11 UTC
Created attachment 61078 [details]
gtkundo.h
Comment 10 Yevgen Muntyan 2006-03-11 10:47:54 UTC
Created attachment 61079 [details] [review]
the patch

Updated once again, this time it enables undo/redo in GtkTextView too.
Comment 11 Paolo Maggi 2006-05-14 18:49:01 UTC
I don't like very much your approach, I think the undo_manager idea we use in GtkSourceView is more object oriented and clean.

Your patch also does not solve most of the problem of the current undo manager in gtksourceview (see for http://live.gnome.org/GtkSourceView, bug #315116 and bug #307757).

We also need a way to store in a compact way the info needed to undo complex functions like "Replace All". And we should also allow applications to add new custom actions.
Comment 12 Yevgen Muntyan 2006-05-14 19:19:56 UTC
First of all, the patch adds Ctrl-Z thing to entries and textview, it doesn't try to solve all possible GtkSourceView and gedit problems, and noone was interested in this patch so far (except pbor which seems to be happy with this undo manager).
Once one says what is needed in the undo manager, it can be implemented.

> I don't like very much your approach, I think the undo_manager idea we use in
> GtkSourceView is more object oriented and clean.

I think it's exactly the same idea, actually. Or rather vice versa, this undo manager uses the same idea as the GtkSourceView's one.

About those two bugs:
About string representation: one can use action type to generate it, like if it's deletion, g_strdup_printf("Delete text %s", action->string);; or one can store the string representation right in the action, or whatever.
About text marks: it's really complicated business, and there is no solution that would serve everyone. Say, there are auxiliary text marks which must not be restored implicitly by undo or whatever (GtkTextBuffer creates lot of marks, for example).
I believe it's up to application what it wants to be able to undo. Another thing that undo manager should be flexible enough to allow applications to customize it without too much hassle, and it's a very important thing that requires thinking.
Comment 13 Reinout van Schouwen 2007-08-01 07:50:17 UTC
Yevgen, does your patch still apply? I believe this bug is still valid for GTK 2.11.x.
Comment 14 Yevgen Muntyan 2007-08-01 07:55:10 UTC
No idea if the patch still applies. Yes, bug is still there.
Comment 15 Reinout van Schouwen 2007-08-01 08:33:34 UTC
Updating version fields.
Comment 16 Cosimo Cecchi 2008-02-05 20:29:57 UTC
*** Bug 351571 has been marked as a duplicate of this bug. ***
Comment 17 Matthias Clasen 2009-03-25 16:40:30 UTC
So, I think something like this might be interesting. 
We should probably find a different name than 'Action' for this, since thats already taken inside GTK+.
How does your patch address extensibility, ie letting applications add their own extra undo action types ?
Comment 18 Javier Jardón (IRC: jjardon) 2009-09-25 03:15:53 UTC
Additional info from this thread: http://mail.gnome.org/archives/gtk-list/2009-September/msg00137.html 
and in this blog entry: http://berndth.blogspot.com/2009/09/chronically-underrated-undo.html

There are at least these implementations for undo/redo support:

 - gundo : http://github.com/herzi/gundo/
 - undo_stack: http://github.com/hb/undo_stack
Comment 19 Javier Jardón (IRC: jjardon) 2009-09-25 03:17:01 UTC
*** Bug 316551 has been marked as a duplicate of this bug. ***
Comment 20 Holger Berndt 2010-06-07 15:53:34 UTC
(In reply to comment #18)
> There are at least these implementations for undo/redo support:
> 
>  - gundo : http://github.com/herzi/gundo/
>  - undo_stack: http://github.com/hb/undo_stack

I've moved the second implementation into a gtk+ branch some time ago, so the updated link would be 
http://github.com/hb/gtk/tree/undo
Comment 21 Holger Berndt 2010-06-16 18:03:09 UTC
I started a brainstorm page for this bug at http://live.gnome.org/GTK%2B/Undo
Comment 22 Hiroyuki Ikezoe 2011-02-27 23:59:18 UTC
We should also consider about undo/redo stacks of input method, right?
Comment 23 Hiroyuki Ikezoe 2011-02-28 01:14:18 UTC
I've filed a new bug for input method. Bug 643439.
Comment 24 Paolo Borelli 2014-04-12 09:34:47 UTC
*** Bug 721933 has been marked as a duplicate of this bug. ***
Comment 25 Daniel Boles 2017-08-04 00:05:46 UTC
*** Bug 785787 has been marked as a duplicate of this bug. ***
Comment 26 Asif Ali Rizvan 2017-08-08 12:23:01 UTC
12 years has passed yet a proper undo framework idea for GTK was not imagined, but the devs can come up with gnome shell, extensions, new apps and a totally new design and paradigm for desktop, still don't have the creativity for an "undo framework"! Really?
Comment 27 Bastien Nocera 2017-08-08 12:37:29 UTC
(In reply to Asif Ali Rizvan from comment #26)
> 12 years has passed yet a proper undo framework idea for GTK was not
> imagined, but the devs can come up with gnome shell, extensions, new apps
> and a totally new design and paradigm for desktop, still don't have the
> creativity for an "undo framework"! Really?

This will be your first and last warning (yes, really). Code doesn't appear out of thin air, if you need something done, do it yourself or pay somebody to do it. None of us are in a position to tell others what they should work on.
Comment 28 Cédric Bellegarde 2017-08-09 09:23:03 UTC
IMO, GtkEntryBuffer API is not good enough. "deleted-text" signal should provide "deleted chars" like "inserted-text" to allow us to code simple GtkEntry history.

Actually, I need to monitory GtkEntryBuffer text to get what was deleted.
Comment 29 Matthias Clasen 2017-08-10 12:17:12 UTC
you are right, we shouldn't keep bugs open for 12 years