GNOME Bugzilla – Bug 322194
Proposal: undo/redo in gtk
Last modified: 2017-08-10 12:27:47 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.
Created attachment 55115 [details] [review] The patch against gtk-2-8 branch
Created attachment 55116 [details] gtkundo.h
Created attachment 55117 [details] gtkundo.c
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.
Created attachment 55137 [details] [review] Updated patch Sorry, forgot to actually add 'enable-undo' property.
*** Bug 156102 has been marked as a duplicate of this bug. ***
Created attachment 61074 [details] [review] Updated patch, against CVS HEAD
Created attachment 61077 [details] gtkundo.c
Created attachment 61078 [details] gtkundo.h
Created attachment 61079 [details] [review] the patch Updated once again, this time it enables undo/redo in GtkTextView too.
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.
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.
Yevgen, does your patch still apply? I believe this bug is still valid for GTK 2.11.x.
No idea if the patch still applies. Yes, bug is still there.
Updating version fields.
*** Bug 351571 has been marked as a duplicate of this bug. ***
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 ?
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
*** Bug 316551 has been marked as a duplicate of this bug. ***
(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
I started a brainstorm page for this bug at http://live.gnome.org/GTK%2B/Undo
We should also consider about undo/redo stacks of input method, right?
I've filed a new bug for input method. Bug 643439.
*** Bug 721933 has been marked as a duplicate of this bug. ***
*** Bug 785787 has been marked as a duplicate of this bug. ***
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?
(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.
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.
you are right, we shouldn't keep bugs open for 12 years