add wizard for first time setup

This commit is contained in:
Marcos Pinto 2007-08-26 06:18:11 +00:00
parent 91b6f6b26f
commit bcaec81edd
3 changed files with 649 additions and 5 deletions

466
glade/wizard.glade Normal file
View File

@ -0,0 +1,466 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.2.2 on Sun Aug 26 01:15:42 2007 by markybob@peg-->
<glade-interface>
<widget class="GtkAssistant" id="wizard">
<property name="width_request">500</property>
<property name="height_request">300</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="title" translatable="yes">First Launch Configuration</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<signal name="close" handler="close"/>
<signal name="cancel" handler="cancel"/>
<signal name="apply" handler="apply_prefs"/>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">This wizard will help you set up Deluge to your liking. If you are new to Deluge, please note that most of Deluge's functionality and features come in the form of plugins, which can be accessed by clicking on Preferences in the Edit menu.</property>
<property name="wrap">True</property>
</widget>
<packing>
<property name="page_type">GTK_ASSISTANT_PAGE_INTRO</property>
<property name="title">Deluge Configuration</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Deluge needs a range of ports that it will try to listen to for incoming connections. The default ports for bittorrent are 6881-6889, however, most ISPs block those ports, so you're encouraged to pick others, between 49152 and 65535. Alternatively, you can have Deluge automatically pick random ports for you.</property>
<property name="wrap">True</property>
</widget>
</child>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">From:</property>
</widget>
</child>
<child>
<widget class="GtkSpinButton" id="spin_port_min">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="adjustment">0 0 65535 1 10 10</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">To:</property>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_port_max">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="adjustment">0 0 65535 1 10 10</property>
</widget>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_random_ports">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Use _Random Ports</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="toggle"/>
</widget>
<packing>
<property name="position">4</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="title">Deluge Configuration</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Would you like Deluge to automatically download to a predefined location, or would you like to specify the download location every time?</property>
<property name="wrap">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">28</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radio_ask_save">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Ask where to save each file</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkRadioButton" id="radio_save_all_to">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Store all downloads in: </property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">radio_ask_save</property>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkFileChooserButton" id="download_path_button">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
<property name="title" translatable="yes">Select A Folder</property>
</widget>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</widget>
<packing>
<property name="title">Deluge Configuration</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkAlignment" id="alignment11">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Please select the *upload* speed of your connection, which we will use to automatically make suggestions for the settings below</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_rows">5</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Your Upload Line Speed:</property>
</widget>
</child>
<child>
<widget class="GtkAlignment" id="alignment12">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkComboBox" id="combo_upload_line">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="items" translatable="yes">28.8k
56k
64k
96k
128k
192k
256k
384k
512k
640k
768k
1Mbit
2Mbit
10Mbit
20Mbit
40Mbit
50Mbit
10Mbit</property>
<signal name="changed" handler="toggle"/>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment10">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkSpinButton" id="spin_max_connections_global">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="adjustment">0 -1 9000 1 10 10</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkSpinButton" id="spin_max_upload">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="adjustment">0 -1 9000 1 10 10</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkSpinButton" id="spin_max_upload_slots_global">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="adjustment">0 -1 9000 1 10 10</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment8">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkSpinButton" id="spin_torrents">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="adjustment">0 -1 100 1 10 10</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment9">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Maximum Connections:</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Maximum Upload Speed (KiB/s):</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Maximum Upload Slots:</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment7">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Maximum Active Torrents:</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="title">Deluge Configuration</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_send_info">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Help us improve Deluge by sending us your Python and PyGTK
versions, OS and processor types. Absolutely no other
information is sent.</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="page_type">GTK_ASSISTANT_PAGE_CONFIRM</property>
<property name="title">Deluge Configuration</property>
</packing>
</child>
</widget>
</glade-interface>

View File

@ -44,6 +44,7 @@ import deluge.common
import deluge.core
import deluge._dbus as dbus
import deluge.interface
import deluge.pref
parser = OptionParser(usage="%prog [options] [torrents to add]",
version=deluge.common.PROGRAM_VERSION)
@ -104,21 +105,21 @@ def get_cmd_line_torrents():
def start_deluge():
print "Starting new Deluge session..."
upgrade_old_persistent_state()
interface = deluge.interface.DelugeGTK()
interface.start(get_cmd_line_torrents())
bus = dbus.SessionBus()
dbus_objects = dbus.Interface(bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus'), 'org.freedesktop.DBus').ListNames()
if not "org.deluge_torrent.Deluge" in dbus_objects:
print "no existing Deluge session"
if not os.path.exists(os.path.join(deluge.common.CONFIG_DIR, 'firstrun')):
import deluge.wizard
deluge.wizard.WizardGTK()
start_deluge()
else:
## This connects to the deluge interface
print "create proxy object"

177
src/wizard.py Normal file
View File

@ -0,0 +1,177 @@
class WizardGTK:
def __init__(self):
import gtk
import gtk.glade
import os
import deluge
import deluge.common
import deluge.pref
self.wtree = gtk.glade.XML(deluge.common.get_glade_file("wizard.glade"), domain='deluge')
self.wtree.signal_autoconnect({'apply_prefs': self.apply_prefs,
'cancel': self.cancel,
'toggle': self.toggle,
'close': self.cancel})
self.window = self.wtree.get_widget("wizard")
#activate forward buttons for all pages
self.window.set_page_complete(self.wtree.get_widget('label1'), True)
self.window.set_page_complete(self.wtree.get_widget('vbox1'), True)
self.window.set_page_complete(self.wtree.get_widget('vbox2'), True)
self.window.set_page_complete(self.wtree.get_widget('vbox3'), True)
self.window.set_page_complete(self.wtree.get_widget('chk_send_info'), True)
config_file = deluge.common.CONFIG_DIR + "/prefs.state"
self.config = deluge.pref.Preferences(config_file, False,
defaults={"listen_on" : [6881,6889],
"send_info": True,
"random_port": False,
"max_active_torrents" : 8,
"max_upload_slots_global" : 15,
"max_connections_global" : 200,
"max_upload_speed" : -1,
"default_download_path" : os.path.expanduser("~/"),
"use_default_dir" : False
})
try:
self.config.load()
except IOError:
pass
else:
self.wtree.get_widget('spin_port_min').set_value(self.config.get("listen_on")[0])
self.wtree.get_widget('spin_port_max').set_value(self.config.get("listen_on")[1])
self.wtree.get_widget('chk_send_info').set_active(self.config.get("send_info"))
self.wtree.get_widget('chk_random_ports').set_active(self.config.get("random_port"))
self.wtree.get_widget('radio_save_all_to').set_active(self.config.get("use_default_dir"))
self.wtree.get_widget('download_path_button').set_filename(self.config.get("default_download_path"))
self.wtree.get_widget('spin_max_connections_global').set_value(self.config.get("max_connections_global"))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(self.config.get("max_upload_slots_global"))
self.wtree.get_widget('spin_max_upload').set_value(self.config.get("max_upload_speed"))
self.wtree.get_widget('spin_torrents').set_value(self.config.get("max_active_torrents"))
#show wizard
self.window.show()
gtk.main()
def toggle(self, args=None):
self.wtree.get_widget('spin_port_min').set_sensitive(
not self.wtree.get_widget('chk_random_ports').get_active())
self.wtree.get_widget('spin_port_max').set_sensitive(
not self.wtree.get_widget('chk_random_ports').get_active())
if self.wtree.get_widget('combo_upload_line').get_active_text() == "28k":
self.wtree.get_widget('spin_max_connections_global').set_value(float('25'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('1'))
self.wtree.get_widget('spin_max_upload').set_value(float('2'))
self.wtree.get_widget('spin_torrents').set_value(float('1'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "56k":
self.wtree.get_widget('spin_max_connections_global').set_value(float('30'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('3'))
self.wtree.get_widget('spin_max_upload').set_value(float('2'))
self.wtree.get_widget('spin_torrents').set_value(float('1'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "64k":
self.wtree.get_widget('spin_max_connections_global').set_value(float('75'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('2'))
self.wtree.get_widget('spin_max_upload').set_value(float('5'))
self.wtree.get_widget('spin_torrents').set_value(float('1'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "96k":
self.wtree.get_widget('spin_max_connections_global').set_value(float('75'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('3'))
self.wtree.get_widget('spin_max_upload').set_value(float('7'))
self.wtree.get_widget('spin_torrents').set_value(float('1'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "128k":
self.wtree.get_widget('spin_max_connections_global').set_value(float('88'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('3'))
self.wtree.get_widget('spin_max_upload').set_value(float('9'))
self.wtree.get_widget('spin_torrents').set_value(float('1'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "192k":
self.wtree.get_widget('spin_max_connections_global').set_value(float('90'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('3'))
self.wtree.get_widget('spin_max_upload').set_value(float('17'))
self.wtree.get_widget('spin_torrents').set_value(float('1'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "256k":
self.wtree.get_widget('spin_max_connections_global').set_value(float('130'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('3'))
self.wtree.get_widget('spin_max_upload').set_value(float('17'))
self.wtree.get_widget('spin_torrents').set_value(float('1'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "384k":
self.wtree.get_widget('spin_max_connections_global').set_value(float('230'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('4'))
self.wtree.get_widget('spin_max_upload').set_value(float('35'))
self.wtree.get_widget('spin_torrents').set_value(float('3'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "512k":
self.wtree.get_widget('spin_max_connections_global').set_value(float('250'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('4'))
self.wtree.get_widget('spin_max_upload').set_value(float('47'))
self.wtree.get_widget('spin_torrents').set_value(float('3'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "640k":
self.wtree.get_widget('spin_max_connections_global').set_value(float('375'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('4'))
self.wtree.get_widget('spin_max_upload').set_value(float('60'))
self.wtree.get_widget('spin_torrents').set_value(float('4'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "768k":
self.wtree.get_widget('spin_max_connections_global').set_value(float('450'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('5'))
self.wtree.get_widget('spin_max_upload').set_value(float('72'))
self.wtree.get_widget('spin_torrents').set_value(float('5'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "1Mbit":
self.wtree.get_widget('spin_max_connections_global').set_value(float('600'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('6'))
self.wtree.get_widget('spin_max_upload').set_value(float('92'))
self.wtree.get_widget('spin_torrents').set_value(float('5'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "2Mbit":
self.wtree.get_widget('spin_max_connections_global').set_value(float('750'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('8'))
self.wtree.get_widget('spin_max_upload').set_value(float('186'))
self.wtree.get_widget('spin_torrents').set_value(float('9'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "10Mbit":
self.wtree.get_widget('spin_max_connections_global').set_value(float('800'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('25'))
self.wtree.get_widget('spin_max_upload').set_value(float('1120'))
self.wtree.get_widget('spin_torrents').set_value(float('15'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "20Mbit":
self.wtree.get_widget('spin_max_connections_global').set_value(float('850'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('30'))
self.wtree.get_widget('spin_max_upload').set_value(float('2240'))
self.wtree.get_widget('spin_torrents').set_value(float('15'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "40Mbit":
self.wtree.get_widget('spin_max_connections_global').set_value(float('900'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('35'))
self.wtree.get_widget('spin_max_upload').set_value(float('4480'))
self.wtree.get_widget('spin_torrents').set_value(float('15'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "50Mbit":
self.wtree.get_widget('spin_max_connections_global').set_value(float('950'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('50'))
self.wtree.get_widget('spin_max_upload').set_value(float('5600'))
self.wtree.get_widget('spin_torrents').set_value(float('20'))
elif self.wtree.get_widget('combo_upload_line').get_active_text() == "100Mbit":
self.wtree.get_widget('spin_max_connections_global').set_value(float('1000'))
self.wtree.get_widget('spin_max_upload_slots_global').set_value(float('50'))
self.wtree.get_widget('spin_max_upload').set_value(float('11200'))
self.wtree.get_widget('spin_torrents').set_value(float('25'))
def create_file(self):
import os
import deluge
import deluge.common
f = open(os.path.join(deluge.common.CONFIG_DIR, 'firstrun'), 'w')
f.write("")
f.close
def cancel(self, args=None):
import gtk
self.create_file()
self.window.destroy()
gtk.main_quit()
def apply_prefs(self, args=None):
import gtk
self.create_file()
self.config.set('random_port', self.wtree.get_widget('chk_random_ports').get_active())
self.config.set("listen_on", [self.wtree.get_widget("spin_port_min").get_value(), self.wtree.get_widget("spin_port_max").get_value()])
self.config.set("send_info", self.wtree.get_widget("chk_send_info").get_active())
self.config.set("max_connections_global", int(self.wtree.get_widget('spin_max_connections_global').get_value()))
self.config.set("max_upload_slots_global", int(self.wtree.get_widget('spin_max_upload_slots_global').get_value()))
self.config.set("max_upload_speed", int(self.wtree.get_widget('spin_max_upload').get_value()))
self.config.set("max_active_torrents", int(self.wtree.get_widget('spin_torrents').get_value()))
self.config.set("use_default_dir", self.wtree.get_widget('radio_save_all_to').get_active())
self.config.set("default_download_path", self.wtree.get_widget('download_path_button').get_filename())
self.config.save()
gtk.main_quit()