From bcaec81eddf0585183abae7ff8e9a7c43f753f8f Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Sun, 26 Aug 2007 06:18:11 +0000 Subject: [PATCH] add wizard for first time setup --- glade/wizard.glade | 466 +++++++++++++++++++++++++++++++++++++++++++++ scripts/deluge | 11 +- src/wizard.py | 177 +++++++++++++++++ 3 files changed, 649 insertions(+), 5 deletions(-) create mode 100644 glade/wizard.glade create mode 100644 src/wizard.py diff --git a/glade/wizard.glade b/glade/wizard.glade new file mode 100644 index 000000000..8a46cdbe0 --- /dev/null +++ b/glade/wizard.glade @@ -0,0 +1,466 @@ + + + + + + 500 + 300 + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + First Launch Configuration + GTK_WIN_POS_CENTER + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 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. + True + + + GTK_ASSISTANT_PAGE_INTRO + Deluge Configuration + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 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. + True + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + From: + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 0 65535 1 10 10 + + + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + To: + + + 2 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 0 65535 1 10 10 + + + 3 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Use _Random Ports + True + 0 + True + + + + 4 + + + + + 1 + + + + + Deluge Configuration + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Would you like Deluge to automatically download to a predefined location, or would you like to specify the download location every time? + True + + + False + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + False + False + 28 + 1 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Ask where to save each file + 0 + True + True + + + False + False + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Store all downloads in: + 0 + True + True + radio_ask_save + + + + + False + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER + Select A Folder + + + + + 1 + + + + + False + False + 3 + + + + + Deluge Configuration + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Please select the *upload* speed of your connection, which we will use to automatically make suggestions for the settings below + GTK_JUSTIFY_CENTER + True + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + 2 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Your Upload Line Speed: + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 28.8k +56k +64k +96k +128k +192k +256k +384k +512k +640k +768k +1Mbit +2Mbit +10Mbit +20Mbit +40Mbit +50Mbit +10Mbit + + + + + + 1 + 2 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 -1 9000 1 10 10 + + + + + 1 + 2 + 1 + 2 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 -1 9000 1 10 10 + + + + + 1 + 2 + 2 + 3 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 -1 9000 1 10 10 + + + + + 1 + 2 + 3 + 4 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 -1 100 1 10 10 + + + + + 1 + 2 + 4 + 5 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Maximum Connections: + + + + + 1 + 2 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Maximum Upload Speed (KiB/s): + + + + + 2 + 3 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Maximum Upload Slots: + + + + + 3 + 4 + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Maximum Active Torrents: + + + + + 4 + 5 + + + + + + + 1 + + + + + Deluge Configuration + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Help us improve Deluge by sending us your Python and PyGTK +versions, OS and processor types. Absolutely no other +information is sent. + True + 0 + True + True + + + GTK_ASSISTANT_PAGE_CONFIRM + Deluge Configuration + + + + diff --git a/scripts/deluge b/scripts/deluge index ccebe5b6c..3657228bf 100755 --- a/scripts/deluge +++ b/scripts/deluge @@ -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" diff --git a/src/wizard.py b/src/wizard.py new file mode 100644 index 000000000..a39cde159 --- /dev/null +++ b/src/wizard.py @@ -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()