14

In Ubuntu 11.10, how can I set up nautilus so that when I select "Save as..." on Evince or some other PDF viewer, for a PDF I downloaded with the browser, it automatically suggests the folder 'Documents' for saving that pdf file?

Right now it just gives me the last folder that was used to save something before. I remember 11.04 was doing exactly this, which is convenient to keep all pdfs in a single folder.

RolandiXor
  • 51,541
719016
  • 6,217

3 Answers3

9

Why...

In this answer I'm concentrating on evince since you mentioned this as your key application in the question.

Looking at the source-code, the Save-As dialog only sets the default filename. Since no folder is defined, the GTK3 libraries assume that the Recently Used folders is the first folder to be displayed in the dialog.

GTK3 applications have to explicitly set the folder to first search in.

Personally I think the default folder for evince should be defined - as such you should file this on bugzilla as a bug/wish-list request.

How...

The following is one way way to force evince to default to the Documents folder rather than the previous recently used.

In summary, the source is changed to obtain the default Document folder and set this as the default folder for the Save-As dialog.

enter image description here

install the basic development tools

sudo apt-get install devscripts build-essential fakeroot 

get the source

cd ~/Downloads
mkdir build
cd build
apt-get source evince
cd evince*

make the change

Open ev-window.c

gedit shell/ev-window.c

Copy and paste the following into the file at the position shown in the image

const gchar *folder;
folder = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fc),
                             folder ? folder : g_get_home_dir ());

enter image description here

Save and close gedit

give it a unique package name

OK, we need to give the package a unique name to prevent repository updates from overwriting your changed package

gedit debian/changelog

now append +yourname to the top line version and save

i.e. evince (3.2.1-0ubuntu2+fossfreedom)

build the package

sudo apt-get build-dep evince
debuild -us -uc

N.B. this will download 161Mb of dependencies

Go for a coffee... and probably lunch!

cd ..
sudo dpkg -i evince_3.2*.deb

As an aside - to keep this new version of evince from being upgraded in the future, use synaptic to pin this version of evince.

fossfreedom
  • 172,746
4

Unfortunately, due to the way that the file-chooser dialogue has been coded in GTK+ 3.x, you cannot change this behaviour consistently.

The file-chooser will always revert to recent documents as the location, unless the application you are using is specifically coded to open a folder by default, and most applications do not have this option.

See this answer: Can I stop apps from selecting "Recently Used" by default in file chooser dialogs?

As you will read there, I did a lot of testing and there was no way around it. I'm sorry that you cannot get what you want in this case, but you can report a bug, and maybe they will implement the option.

RolandiXor
  • 51,541
2

You can use Libre Office for PDF and in Libre Office you can change default location for filetypes and its here ~/.libreoffice/3/user/gallery/ and in Libre Office its changable in Tools -> Options -> Paths -> Graphic

Plugins http://www.libreoffice.org/features/extensions/

By googling and finding https://superuser.com/questions/220647/executing-the-default-application-assigned-to-a-file-type-from-terminal-given AND http://www.packtpub.com/article/control-of-file-types-in-ubuntu AND http://silverwav.wordpress.com/2010/03/21/note-ubuntu-default-folders/ AND The file to change is a config file in a hidden folder in your home folder: gedit ~/.config/user-dirs.dirs make the changes as you like, save and close. And then, run xdg-user-dirs-update to reflect the changes. But how i dont know but something of all this is what i think should be in this way possible.

"Custom save locations could probably be hacked into Firefox since it can save actions based on file type already.

You could also write a shell script, then set Firefox to open the filetypes you wish with that script. Firefox will download the file to a temp directory and pass the filename to the script. The script would parse the output of file ${1} or do some regex matching on the file name, and take the appropriate action you desire (move to X, move to Y, etc).

This level of mime-type preferences will likely not be a feature of Gnome itself."

BTW Libreoffice has that possibility https://bugs.launchpad.net/ubuntu/+source/libreoffice/+bug/801130

Also you could always save to same folder but make script checking of folder and moving X type files.

I think it would be somehow done if its possible to make specific launcher for extension .pdf and in launcher to make default folder to be your desired.

How? I don't know but i hope this will help you find an answer.

Kangarooo
  • 5,075