--- Begin Message ---
- To: submit@bugs.debian.org
- Subject: btdownloadgui: does not remember previous download location
- From: Fraser Hanson <hansf10@telus.net>
- Date: Fri, 04 Jun 2004 17:07:51 -0700
- Message-id: <40C10ED7.3030400@telus.net>
Package: bittorrent
Version: 3.4.2-1
Severity: wishlist
*** Please type your report below this line ***
When btdownloadgui starts, the first thing it does is bring up a file
selection dialog and ask the user to choose where to put the downloaded
file. It always opens in the user's home directory. This gets annoying
during frequent use, if your target download directory is somewhere
else.
It would make more sense for btdownloadgui to remember the previous
download directory, and default to open there next time.
Attached is a patch to implement this. It creates a file called
.btdownloadgui in the current working directory (usually the user's home
directory) and stores chosen directory in that file, to be re-read next
time. It has been tested on Sarge only.
-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (990, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.4-ck1
Locale: LANG=C, LC_CTYPE=C (ignored: LC_ALL set to C)
12a13,14
> import os
>
30a33,84
> config_filename=".btdownloadgui"
> config_defaults = { "default_dir" : getcwd() }
> config = config_defaults.copy();
>
> def read_config_file():
>
> # Check if the config file exists
> filename = getcwd() + os.sep + config_filename
> if not os.access(filename, os.R_OK):
> return
>
> # Parse the config file
> input = open(filename)
> lines = input.readlines()
> line_number=0
> for line in lines:
> line_number+=1
> line = line.strip()
>
> # check for bad line
> if "=" not in line:
> raise "Error: Config file line %s: no =" % (line_number)
>
> # set variable to config file's value
> name, val = line.split("=",2)
> if name in config:
> config[name] = val
>
> def write_config_file():
> filename = getcwd() + os.sep + config_filename
>
> # Create the config file text
> lines = []
> for varname in config.iterkeys():
> if config[varname] != config_defaults[varname]:
> lines.append( "%s=%s\n" % (varname, config[varname] ) )
>
> # Write to the config file, if necessary
> if os.access(filename, os.W_OK):
> os.unlink(filename)
> if len(lines) == 0:
> return
> output = open(filename,"w")
> for line in lines:
> output.write(line)
> output.close()
>
>
235c289
< join(getcwd(), default), style = wxDD_DEFAULT_STYLE | wxDD_NEW_DIR_BUTTON)
---
> join(config["default_dir"], default), style = wxDD_DEFAULT_STYLE | wxDD_NEW_DIR_BUTTON)
237c291,297
< dl = wxFileDialog(self.frame, 'Choose file to save as, pick a partial download to resume', '', default, '*', wxSAVE)
---
> dl = wxFileDialog(
> self.frame,
> 'Choose file to save as, pick a partial download to resume',
> config["default_dir"],
> default,
> '*',
> wxSAVE)
242a303
> config["default_dir"] = os.path.dirname( dl.GetPath() )
275,278c336,343
< app = btWxApp(0, params)
< app.MainLoop()
< except:
< print_exc()
---
> try:
> read_config_file()
> app = btWxApp(0, params)
> app.MainLoop()
> except:
> print_exc()
> finally:
> write_config_file()
--- End Message ---