GNOME Bugzilla – Bug 307757
Allow retrieving the last undo/redo action in string format
Last modified: 2020-11-13 23:32:32 UTC
This allows one to retreive the action that will be performed by a undo/redo as a string. For example "deletion of 'xxx'" or "typing of line feed" For the moment three special cases are handled: the line feed, the space, and the tab, more can be added if necessary.
Created attachment 47799 [details] [review] gtksourceview-action.patch First version of the patch: * implement two new functions: gchar * gtk_source_undo_manager_get_undo_action (GtkSourceUndoManager *um); gchar * gtk_source_undo_manager_get_redo_action (GtkSourceUndoManager *um); returning the string of the action that would be performed for an undo/redo * update the test widget to use an undo/redo label that is dynamically updated (it contains a leak, for the UndoRedoData but is it important ?) * Change the way signals are emitted, this is the most controversial change, but i don't think it should be a problem since the semantic of the function is preserved, the only difference is that it is emitted more often. Instead of emitting a "can-undo" and "can-redo" signal only when they switch state, I emit them everytime an new undo action is available, this is to allow programs to update their labels "live" with undo actions. The other solution would be to have new signals, but i don't think it is necessary.
Created attachment 47800 [details] [review] gedit-undo.patch First version of the patch. Implements the new undo action feature in gedit (new_mdi branch). The toolbars keep their label short, but the menu items show the action. An arbitrary limit of 25 is used to truncate the action, this has naty side effects. Maybe the gtksourcebuffer should return a struct containing the string alone and the type of the action (delete/insert), so we can truncate only the text, not the action..
Created attachment 47820 [details] [review] gtksourceview-action.patch New version. Truncate the text inside the action in gtksourceview, not in gedit. Try to be smart about spaces and things
Created attachment 47821 [details] [review] gedit-undo.patch New version: Remove troncature from gedit since it's done in gtksourceview Clea format I forgot to add popup menu undo item also shows the action in new gtksourceview patch
Hi If this was ever implemented, it doesn't appear on the menu or the text of the toolbar buttons anymore. Is this going to be implemented? Or has since then been removed on purpose? If so, this bug should probably be closed.
We are in deep freeze for the 3.x series, and 4.x isn't getting new API at this point. For GTK 4 (GtkSourceView 5), the undo management has been pushed into GTK directly so it is no longer something we can expose here.