Open Containing Folder

Suggestions and discussion of future versions
Post Reply
silicontoad

Open Containing Folder

Post by silicontoad »

Hi,

I know this has been asked before here:
http://forum.deluge-torrent.org/viewtop ... 10&t=11045

I didn't want to awaken a 1year+ old post, so I'm posting a solution here for anyone else interested.

You will need the full build environment for Deluge, which implies you will need to build it from source. So far I've tested this under Ubuntu Lucid and FreeBSD 8 but since I haven't used any platform dependent code (correct me if I'm wrong) this should work elsewhere.

I've done some tinkering with 1.3.0-RC1, to get this to work. I modified menubar.py around line 314 to do the following:

Code: Select all

 def on_menuitem_open_folder_activate(self, data=None):
        log.debug("on_menuitem_open_folder")
        status_keys = ["name", "save_path"]
        def _on_torrent_status(status):
            #open torrent directly or open parent directory or open parent directory if torrent not a directory
            option = 3
            #open torrent directly or open parent directory or open parent directory if torrent not a directory
            if option==1:
                path = status["save_path"]
            elif option==2:
                path = os.path.join(status["save_path"],status["name"])
            else:
                path = status["save_path"];
                if os.path.isdir(path):
                    path = os.path.join(status["save_path"],status["name"])
                else:
                    path = status["save_path"]
            log.debug(path)
            deluge.common.open_file(path)
        for torrent_id in component.get("TorrentView").get_selected_torrents():
            component.get("SessionProxy").get_torrent_status(torrent_id, status_keys).addCallback(_on_torrent_status)
also you will need this at the top

Code: Select all

import os.path
I started to modify the glade UI files preferences_dialog.glade to allow the user to specify an option (as above) [this would sit on the Downloads tab, right below the Options section] but finding it increasingly difficult to find time at the moment. I know these variables won't necessarily be int's and most likely it's not the most elegant solution but it's a start.

you will need to change this variable according to the behaviour you desire

Code: Select all

#open torrent directly or open parent directory or open parent directory if torrent not a directory
option = 3
#open torrent directly or open parent directory or open parent directory if torrent not a directory
The idea I had was to have a radio button interface. The following options reflect the option to be set above.

[1]0| Open Parent #tooltip: default behaviour, open global directory
[2]0| Open Torrent #tooltip: open torrent, directory or file (can be dangerous for executables)
[3]0| Open Torrent if Dir otherwise open Parent #tooltip: like option 2 if and only if dir, otherwise option 1 - safer if executables involved

I know this modification would need to be reflected through the various interfaces supported by Deluge so I'm posting it here in case some gentle soul :) finds the time.

Toad
Post Reply