Make Thunar Prompt on Moving Files to Trash (Ubuntu)

I am currently using XUbuntu 12.04 (Precise). It contains Thunar 1.2.3 as file manager.

I tried several file managers and started to use Thunar, here is a few reason

  • I can browse parent directories by clicking to buttons/labels
  • Thunar is lighter comparing to Nautilus
  • Has a good design

But I don't like the behaviour sending files/folders to the trash (rubbish bin) without asking. Sometimes delete key on keyboard accidently pressed.
So every time you should examine the trash box to check if are there any files deleted accidently without your will.

I searched more and more to fix this bad situation. But I found no way.

Today, I  tought to develop simple background program to catch delete key and warn me if the active window is thunar.
I spent hours to do this due I have no experience on Linux programming.

I found some commands to use in bash script. But I was very tired. I have to sleep. :)


I woke up with a new idea. Why I don't try to edit the source code of Thunar and then compile it? 

So I started to search how can I achive this.

I noticed the latest version of Thunar is 1.6.
I wonder if the delete confirmation option is integrated in this version. I installed it by following commands.

sudo add-apt-repository ppa:xubuntu-dev/xfce-4.12
sudo apt-get update
sudo apt-get install thunar
sudo add-apt-repository -r ppa:xubuntu-dev/xfce-4.12

Then Thunar version became 1.6.2. 
But unfortunately, there is no asking for moving files to the trash when Delete key pressed. Bad news! :(
I don't understand the reason, why the developers of Thunar don't giving us an option for this.


So, I focused to edit the source code to ask me when sending files to the trash.
I downloaded the source code of Tuhar and while after examining the code, I found the related lines and edited them. (The lines numbers around 1800 in thunar/thunar-application.c file.)

After editing source code now I can compile it. Here is the steps for compilation.

./configure
make
sudo make install

If you want to create a package for installation later:

sudo checkinstall

And its time for testing... I select a file and pressed Delete key on keyboard.
And I get a prompt window asking me I am sure to move the file to trash! Hurray! :)

References / Thanks:

Share Share Editor: editor | Posted: 2013/01/04 | Views: 8553

Comments

9 + 5 =
outlander 10/13/2014 11:25:46
Thank you very much!

I also don't understand the reason, why the devs don't add this feature.

It seems that a lot of people ask for this as an OPTION, but they refuse with almost religiously motivated stubbornness.)))
editor 08/23/2014 02:23:04
Hello again Riccardo,

You can watch the video at following link:

https://archive.org/download/m1gin/4o%2Fshots%2F2013%2F2014-08-23_thunar_edit_code.webm

Hope it helps. :)
editor 08/22/2014 23:54:26
Hello Riccardo,
I don't know C, too. I finished the job by copying some commands for permanently delete.
Let me try record a short video for this, by applying it to latest Thunar (v1.6.3) source code.
Try to visit this page later.
Riccardo 08/22/2014 21:59:06
Hello, thanks for this news. I don't know C programming language, but I downloaded the tar.bz2 file and I found the line. May you also attach the needed code to implement the asking dialog box? Thank you :-) Cheers
Home | Search | Contact | Terms
Editor