PCManFM Patch - Confirm Delete

  • Last updated: January 7, 2014

Update 6-30-08 (PCManFM v4.5): As of v0.4.5, PCManFM started to add an integrated feature to disable delete confirmation, fulfilling the goal of this patch. (The upcoming official feature appears to disable confirmation when a trash can is used.) This new feature does not yet fully work but the code is similar to this patch. Since the author is clearly working on this feature and it is incompatible with this patch, I do no anticipate releasing patches to work with any version of PCManFM beyond v0.4.3.

Updated again: Newer versions of PCManFM now support everything offered by this patch. This patch is obsolete.


The patched preferences menu
This patch adds the option to enable/disable delete confirmation in PCManFM, a popular, light-weight, tabbed file browser. Default behavior in PCManFM is to always prompt the user for confirmation when deleting a file (the classic "Are you sure?" prompt), a feature some find inconvenient. This patch adds an option to the Preferences menu that allows the user to select whether or not they wish to be prompted on deletion.

To the right is what the Preferences menu looks like after the patch. (The dark colors are due to my GTK theme, they have nothing to do with the patch.)


Patch version: v2 (June 26, 2008)
Last tested against: PCManFM v0.4.3

Applying the Patch

Applying the patch is simple. First download and extract the PCManFM code. Then apply the patch to the source. Either:

...from the parent directory with:

$ ls
pcman-   confirm_delete.patch
$ patch -p0 < confirm_delete.patch

...or from the actual source directory with

$ ls
AUTHORS      config.guess          libtool
COPYING      config.h              ltmain.sh
ChangeLog    config.h.in           missing
INSTALL      config.log            mkinstalldirs
Makefile     config.status         pcmanfm.desktop
Makefile.am  config.sub            pcmanfm.desktop.in
Makefile.in  configure             pcmanfm.png
NEWS         configure.in          please_read_README_carefully_before_packaging
README       confirm_delete.patch  po
TODO         data                  src
aclocal.m4   depcomp               stamp-h1
autogen.sh   install-sh
$ patch -p1 < confirm_delete.patch

You can then compile PCManFM with the standard:

$ ./configure
$ make
$ make install

Technical Notes

Patching was pretty minimal, save for one file: pcmanfm-{$version}/data/ui/prefdlg.glade . In the original source, practically the entire XML UI design file is devoid of whitespace, including newlines (for optimization), which makes a nimble patch for it impossible, thus this entire file must be redistributed. This file holds the entire visual layout for the Preferences menu, thus the patched prefdlg.glade file will have to be updated whenever the official PCManFM package updates the Preferences menu layout (something unlikely to happen).

Aside from that issue, since the editing was very simple and inline with the basic structure of the program itself, I see no reason why it shouldn't work for on many PCManFM releases to come. (If things change, I'll update the patch, though.)

Auto Patching in Arch Linux

Some OSs lend themselves to compiling from source very easily. If you use such an OS, like Arch Linux, you may wish to write a script to apply the patch and rebuild the package. For Arch Linux, move the patch to your /var/abs/local/pcmanfm directory and add the patch to the PKGBUILD via:

$ cd /var/abs/local/pcmanfm
$ sed -i "s_cd\ \$startdir/src/pcmanfm-\$pkgver_cd\ \$startdir/src/pcmanfm\
-\$pkgver\npatch\ -p1<../../confirm\_delete.patch_g" PKGBUILD