Set '.torrent' extension by default when creating torrent.

This commit is contained in:
Alex Dedul 2007-07-16 23:17:53 +00:00
parent 9fcf4eb4c0
commit da4081b8b6
1 changed files with 11 additions and 4 deletions

View File

@ -95,11 +95,17 @@ class TorrentCreator:
return return
def torrent_chooserbutton_clicked(self, widget): def torrent_chooserbutton_clicked(self, widget):
filechooser = gtk.FileChooserDialog(title=_("Save file as..."), parent=None, action=gtk.FILE_CHOOSER_ACTION_SAVE, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK), backend=None) filechooser = gtk.FileChooserDialog(title=_("Save file as..."),
parent=None, action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OK, gtk.RESPONSE_OK), backend=None)
response = filechooser.run() response = filechooser.run()
# Update the torrentfile entry widget if a file was selected. # Update the torrentfile entry widget if a file was selected.
if response == gtk.RESPONSE_OK: if response == gtk.RESPONSE_OK:
self.glade.get_widget("torrentfile_entry").set_text(filechooser.get_filename()) torrent = filechooser.get_filename()
if not torrent.endswith(".torrent"):
torrent += ".torrent"
self.glade.get_widget("torrentfile_entry").set_text(torrent)
filechooser.destroy() filechooser.destroy()
@ -120,7 +126,7 @@ class TorrentCreator:
# Send alert to the user that we need a torrent filename to save to # Send alert to the user that we need a torrent filename to save to
deluge.dialogs.show_popup_warning(self.dialog, _("You must select a file to save the torrent as.")) deluge.dialogs.show_popup_warning(self.dialog, _("You must select a file to save the torrent as."))
return False return False
piece_size = self.glade.get_widget("piece_size_combobox") piece_size = self.glade.get_widget("piece_size_combobox")
piece_size = int(piece_size.get_model().get_value(piece_size.get_active_iter(), 0).split(" ")[0]) piece_size = int(piece_size.get_model().get_value(piece_size.get_active_iter(), 0).split(" ")[0])
@ -147,7 +153,8 @@ class TorrentCreator:
self.destroy() self.destroy()
# Create the torrent and add it to the queue if necessary # Create the torrent and add it to the queue if necessary
if self.core.create_torrent(torrent, source, trackers, comments, piece_size, author) == 1: if self.core.create_torrent(torrent, source, trackers, comments,
piece_size, author) == 1:
# Torrent was created successfully # Torrent was created successfully
if add_torrent: if add_torrent:
# We need to add this torrent to the queue # We need to add this torrent to the queue