GNOME Bugzilla – Bug 603413
[PATCH] Disable Trash/Delete bindings when appropriate
Last modified: 2009-12-15 10:23:32 UTC
Created attachment 148788 [details] [review] Proposed patch When the user cannot delete the selected files, the Trash/Delete menu items are disabled. But the corresponding key bindings are not. As a result, a user pressing Delete on a file will get a series of errors (trash attempt errors out, then delete attempt errors out). But we know in advance that these errors will occur and should disable the keybinding (like all other menu items do when they are disabled thanks to GtkAction). Note that <shift>Delete is already correctly handled because it is attached to the GtkAction for Edit->Delete. To accomplish this, I made 'fake' GtkAction entries for Trash and Delete. Fake because they are not exposed as widgets anywhere. I use them just as convenient per-window mechanisms to disable/enable the keybindings. If there was a way to add more than one keybinding to a GtkAction, this goofiness could be dropped. Without the patch, the keybindings (Delete, KP_Delete, <shift>KP_Delete) are installed on the Gtk class, which isn't appropriate since multiple instances of the class could be around: some with the bindings enabled, some without. Thus the per-instance fake GtkActions. I recognize that this patch is slightly gross (invisible actions called "Trash3" don't excite me). I welcome feedback on better ways to achieve the same goal. Patch is against 2.28.1. To reproduce, just try to delete a file in a directory where you don't have permissions to add/delete files.
commited to gnome-2-28 and master.
There is a regression in this patch. If you press delete while renaming a file it will be trashed.
Also if you press delete in the notes sidebar or anywhere else.
fixed in master and 2.28.4