diff --git a/deluge/common.py b/deluge/common.py index ff7ca0937..b29f352af 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -64,6 +64,29 @@ def get_default_plugin_dir(): """Returns the default plugin directory""" return os.path.join(get_config_dir(), "plugins") +def windows_check(): + """Checks if the current platform is Windows. Returns True if it is Windows + and False if not.""" + import platform + if platform.system() in ('Windows', 'Microsoft'): + return True + else: + return False + +def get_pixmap(fname): + """Returns a pixmap file included with deluge""" + return pkg_resources.resource_filename("deluge", os.path.join("data", \ + "pixmaps", fname)) +def get_logo(size): + """Returns a deluge logo pixbuf based on the size parameter.""" + import gtk + if windows_check(): + return gtk.gdk.pixbuf_new_from_file_at_size(get_pixmap("deluge.png"), \ + size, size) + else: + return gtk.gdk.pixbuf_new_from_file_at_size(get_pixmap("deluge.svg"), \ + size, size) + ## Formatting text functions def fsize(fsize_b): @@ -116,24 +139,4 @@ def ftime(seconds): return '%dw %dd' % (weeks, days) return 'unknown' -def windows_check(): - import platform - if platform.system() in ('Windows', 'Microsoft'): - return True - else: - return False -def get_pixmap(fname): - import pkg_resources - from os import path - return pkg_resources.resource_filename("deluge", path.join("data", \ - "pixmaps", fname)) - -def get_logo(size): - import gtk - if windows_check(): - return gtk.gdk.pixbuf_new_from_file_at_size(get_pixmap("deluge.png"), \ - size, size) - else: - return gtk.gdk.pixbuf_new_from_file_at_size(get_pixmap("deluge.svg"), \ - size, size) diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade index 9c96608a6..e09d0a440 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.glade +++ b/deluge/ui/gtkui/glade/preferences_dialog.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -38,7 +38,6 @@ False - True @@ -107,7 +106,6 @@ True Ask where to save each download True - 0 True @@ -123,7 +121,6 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Store all downloads in: Store all downloads in: - 0 True True radio_ask_save @@ -196,7 +193,6 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Full allocation preallocates all of the space that is needed for the torrent and prevents disk fragmentation Use Full Allocation - 0 True True @@ -212,7 +208,6 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Compact allocation only allocates space as needed Use Compact Allocation - 0 True radio_full_allocation @@ -265,7 +260,6 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Enable selecting files for torrents before loading Enable selecting files for torrents before loading - 0 True @@ -279,7 +273,6 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Prioritize first and last pieces of files in torrent Prioritize first and last pieces of files in torrent - 0 True @@ -443,7 +436,6 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Test Active Port - 0 False @@ -468,7 +460,6 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Deluge will automatically choose a different port to use every time. Use Random Ports - 0 True @@ -562,7 +553,6 @@ Distributed hash table may improve the amount of active connections. Enable Mainline DHT True - 0 True @@ -609,7 +599,6 @@ Universal Plug and Play UPnP True - 0 True True @@ -625,7 +614,6 @@ NAT Port Mapping Protocol NAT-PMP True - 0 True True @@ -642,7 +630,6 @@ µTorrent Peer-Exchange µTorrent-PeX True - 0 True True @@ -777,7 +764,6 @@ Full Stream True Prefer to encrypt the entire stream True - 0 True @@ -882,71 +868,40 @@ Full Stream 2 15 - + True - The maximum upload speed for all torrents. Set -1 for unlimited. - 0 - Maximum Upload Speed (KiB/s): - - - 2 - 3 - GTK_FILL - - - - - True - The maximum number of connections allowed. Set -1 for unlimited. - 0 - Maximum Connections: - - - GTK_FILL - - - - - True - The maximum upload speed for all torrents. Set -1 for unlimited. - 0 - Maximum Upload Slots: + True + The maximum upload slots for all torrents. Set -1 for unlimited. + 1 + -1 -1 9000 1 10 10 + 1 + True + True + 1 + 2 3 4 GTK_FILL - + True True - The maximum number of connections allowed. Set -1 for unlimited. - 4 + The maximum upload speed for all torrents. Set -1 for unlimited. 1 -1 -1 9000 1 10 10 1 - True + 1 True - GTK_UPDATE_IF_VALID 1 2 - GTK_FILL - - - - - True - The maximum download speed for all torrents. Set -1 for unlimited. - 0 - Maximum Download Speed (KiB/s): - - - 1 - 2 + 2 + 3 GTK_FILL @@ -971,43 +926,74 @@ Full Stream - + True - True - The maximum upload speed for all torrents. Set -1 for unlimited. - 1 - -1 -1 9000 1 10 10 - 1 - 1 - True + The maximum download speed for all torrents. Set -1 for unlimited. + 0 + Maximum Download Speed (KiB/s): - 1 - 2 - 2 - 3 + 1 + 2 GTK_FILL - + True True - The maximum upload slots for all torrents. Set -1 for unlimited. + The maximum number of connections allowed. Set -1 for unlimited. + 4 1 -1 -1 9000 1 10 10 1 True True + GTK_UPDATE_IF_VALID 1 2 + GTK_FILL + + + + + True + The maximum upload speed for all torrents. Set -1 for unlimited. + 0 + Maximum Upload Slots: + + 3 4 GTK_FILL + + + True + The maximum number of connections allowed. Set -1 for unlimited. + 0 + Maximum Connections: + + + GTK_FILL + + + + + True + The maximum upload speed for all torrents. Set -1 for unlimited. + 0 + Maximum Upload Speed (KiB/s): + + + 2 + 3 + GTK_FILL + + @@ -1051,29 +1037,24 @@ Full Stream 2 15 - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Maximum Upload Slots: + True + The maximum upload slots per torrent. Set -1 for unlimited. + 1 + -1 -1 9000 1 10 10 + 1 + True + True + 1 + 2 1 2 GTK_FILL - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Maximum Connections: - - - GTK_FILL - - True @@ -1091,19 +1072,24 @@ Full Stream - + True - True - The maximum upload slots per torrent. Set -1 for unlimited. - 1 - -1 -1 9000 1 10 10 - 1 - True - True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Maximum Connections: + + + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Maximum Upload Slots: - 1 - 2 1 2 GTK_FILL @@ -1207,9 +1193,8 @@ Full Stream True Enable system tray icon True - 0 - True True + @@ -1222,7 +1207,6 @@ Full Stream False Minimize to tray on close True - 0 True @@ -1241,7 +1225,6 @@ Full Stream False Start in tray True - 0 True @@ -1262,8 +1245,8 @@ Full Stream True Password protect system tray True - 0 True + @@ -1282,8 +1265,9 @@ Full Stream True 5 - + True + False 0 Password: @@ -1343,6 +1327,7 @@ Full Stream True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 12 @@ -1352,14 +1337,31 @@ Full Stream 2 10 - + True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Open folder with: + True + True + + + + GTK_FILL + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Custom: + True + True + radio_open_folder_stock + - 1 - 2 1 2 GTK_FILL @@ -1389,36 +1391,20 @@ Thunar - + True + False True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Custom: - 0 - True - True - radio_open_folder_stock + 1 + 2 1 2 GTK_FILL - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Open folder with: - 0 - True - True - - - GTK_FILL - - @@ -1452,20 +1438,26 @@ Thunar True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 12 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 - Deluge will check our servers and will tell you if a newer version has been released - Be alerted about new releases - 0 - True + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Deluge will check our servers and will tell you if a newer version has been released + Be alerted about new releases + True + + False @@ -1536,7 +1528,6 @@ Thunar True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Yes, please send anonymous statistics - 0 True @@ -1639,7 +1630,6 @@ Thunar False - True @@ -1654,7 +1644,6 @@ Thunar False - True @@ -1679,10 +1668,6 @@ Thunar - - True - True - @@ -1702,7 +1687,6 @@ Thunar GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK gtk-cancel True - 0 @@ -1714,7 +1698,6 @@ Thunar GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK gtk-apply True - 0 @@ -1729,7 +1712,6 @@ Thunar GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK gtk-ok True - 0 diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtkui/mainwindow.py index 6150c7764..9945ae8c1 100644 --- a/deluge/ui/gtkui/mainwindow.py +++ b/deluge/ui/gtkui/mainwindow.py @@ -42,7 +42,7 @@ from toolbar import ToolBar from torrentview import TorrentView from torrentdetails import TorrentDetails from preferences import Preferences -from deluge.common import get_logo +import deluge.common from deluge.log import LOG as log @@ -54,7 +54,7 @@ class MainWindow: "glade/main_window.glade")) self.window = self.main_glade.get_widget("main_window") - self.window.set_icon(get_logo(32)) + self.window.set_icon(deluge.common.get_logo(32)) # Initialize various components of the gtkui self.menubar = MenuBar(self) diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 8252456e2..d6f49c6f9 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -38,7 +38,7 @@ import pkg_resources from deluge.log import LOG as log import deluge.ui.functions as functions -from deluge.common import get_logo +import deluge.common class Preferences: def __init__(self, window): @@ -47,7 +47,7 @@ class Preferences: pkg_resources.resource_filename("deluge.ui.gtkui", "glade/preferences_dialog.glade")) self.pref_dialog = self.glade.get_widget("pref_dialog") - self.pref_dialog.set_icon(get_logo(32)) + self.pref_dialog.set_icon(deluge.common.get_logo(32)) self.treeview = self.glade.get_widget("treeview") self.notebook = self.glade.get_widget("notebook") self.core = functions.get_core() @@ -82,13 +82,13 @@ class Preferences: index = self.notebook.append_page(widget) self.liststore.append([index, name]) - def get_config(self): + def get_core_config(self): """Get the configuration from the core.""" # Get the config dictionary from the core - self.config = functions.get_config(self.core) + self.core_config = functions.get_config(self.core) def show(self): - self.get_config() + self.get_core_config() # Update the preferences dialog to reflect current config settings ## Downloads tab ## @@ -100,53 +100,53 @@ class Preferences: # choose a download location.. It will be specific to the machine core # is running on. self.glade.get_widget("download_path_button").set_filename( - self.config["download_location"]) + self.core_config["download_location"]) self.glade.get_widget("radio_compact_allocation").set_active( - self.config["compact_allocation"]) + self.core_config["compact_allocation"]) self.glade.get_widget("radio_full_allocation").set_active( - not self.config["compact_allocation"]) + not self.core_config["compact_allocation"]) self.glade.get_widget("chk_prioritize_first_last_pieces").set_active( - self.config["prioritize_first_last_pieces"]) + self.core_config["prioritize_first_last_pieces"]) ## Network tab ## self.glade.get_widget("spin_port_min").set_value( - self.config["listen_ports"][0]) + self.core_config["listen_ports"][0]) self.glade.get_widget("spin_port_max").set_value( - self.config["listen_ports"][1]) + self.core_config["listen_ports"][1]) self.glade.get_widget("active_port_label").set_text( str(functions.get_listen_port(self.core))) self.glade.get_widget("chk_random_port").set_active( - self.config["random_port"]) + self.core_config["random_port"]) self.glade.get_widget("chk_dht").set_active( - self.config["dht"]) + self.core_config["dht"]) self.glade.get_widget("chk_upnp").set_active( - self.config["upnp"]) + self.core_config["upnp"]) self.glade.get_widget("chk_natpmp").set_active( - self.config["natpmp"]) + self.core_config["natpmp"]) self.glade.get_widget("chk_utpex").set_active( - self.config["utpex"]) + self.core_config["utpex"]) self.glade.get_widget("combo_encin").set_active( - self.config["enc_in_policy"]) + self.core_config["enc_in_policy"]) self.glade.get_widget("combo_encout").set_active( - self.config["enc_out_policy"]) + self.core_config["enc_out_policy"]) self.glade.get_widget("combo_enclevel").set_active( - self.config["enc_level"]) + self.core_config["enc_level"]) self.glade.get_widget("chk_pref_rc4").set_active( - self.config["enc_prefer_rc4"]) + self.core_config["enc_prefer_rc4"]) ## Bandwidth tab ## self.glade.get_widget("spin_max_connections_global").set_value( - self.config["max_connections_global"]) + self.core_config["max_connections_global"]) self.glade.get_widget("spin_max_download").set_value( - self.config["max_download_speed"]) + self.core_config["max_download_speed"]) self.glade.get_widget("spin_max_upload").set_value( - self.config["max_upload_speed"]) + self.core_config["max_upload_speed"]) self.glade.get_widget("spin_max_upload_slots_global").set_value( - self.config["max_upload_slots_global"]) + self.core_config["max_upload_slots_global"]) self.glade.get_widget("spin_max_connections_per_torrent").set_value( - self.config["max_connections_per_torrent"]) + self.core_config["max_connections_per_torrent"]) self.glade.get_widget("spin_max_upload_slots_per_torrent").set_value( - self.config["max_upload_slots_per_torrent"]) + self.core_config["max_upload_slots_per_torrent"]) ## Other tab ## # All of it is UI only. @@ -157,13 +157,13 @@ class Preferences: def set_config(self): """Sets all altered config values in the core""" # Get the values from the dialog - new_config = {} + new_core_config = {} ## Downloads tab ## - new_config["download_location"] = \ + new_core_config["download_location"] = \ self.glade.get_widget("download_path_button").get_filename() - new_config["compact_allocation"] = \ + new_core_config["compact_allocation"] = \ self.glade.get_widget("radio_compact_allocation").get_active() - new_config["prioritize_first_last_pieces"] = \ + new_core_config["prioritize_first_last_pieces"] = \ self.glade.get_widget( "chk_prioritize_first_last_pieces").get_active() @@ -173,51 +173,51 @@ class Preferences: self.glade.get_widget("spin_port_min").get_value_as_int()) listen_ports.append( self.glade.get_widget("spin_port_max").get_value_as_int()) - new_config["listen_ports"] = listen_ports - new_config["random_port"] = \ + new_core_config["listen_ports"] = listen_ports + new_core_config["random_port"] = \ self.glade.get_widget("chk_random_port").get_active() - new_config["dht"] = self.glade.get_widget("chk_dht").get_active() - new_config["upnp"] = self.glade.get_widget("chk_upnp").get_active() - new_config["natpmp"] = self.glade.get_widget("chk_natpmp").get_active() - new_config["utpex"] = self.glade.get_widget("chk_utpex").get_active() - new_config["enc_in_policy"] = \ + new_core_config["dht"] = self.glade.get_widget("chk_dht").get_active() + new_core_config["upnp"] = self.glade.get_widget("chk_upnp").get_active() + new_core_config["natpmp"] = self.glade.get_widget("chk_natpmp").get_active() + new_core_config["utpex"] = self.glade.get_widget("chk_utpex").get_active() + new_core_config["enc_in_policy"] = \ self.glade.get_widget("combo_encin").get_active() - new_config["enc_out_policy"] = \ + new_core_config["enc_out_policy"] = \ self.glade.get_widget("combo_encout").get_active() - new_config["enc_level"] = \ + new_core_config["enc_level"] = \ self.glade.get_widget("combo_enclevel").get_active() - new_config["enc_prefer_rc4"] = \ + new_core_config["enc_prefer_rc4"] = \ self.glade.get_widget("chk_pref_rc4").get_active() ## Bandwidth tab ## - new_config["max_connections_global"] = \ + new_core_config["max_connections_global"] = \ self.glade.get_widget( "spin_max_connections_global").get_value_as_int() - new_config["max_download_speed"] = \ + new_core_config["max_download_speed"] = \ self.glade.get_widget("spin_max_download").get_value() - new_config["max_upload_speed"] = \ + new_core_config["max_upload_speed"] = \ self.glade.get_widget("spin_max_upload").get_value() - new_config["max_upload_slots_global"] = \ + new_core_config["max_upload_slots_global"] = \ self.glade.get_widget( "spin_max_upload_slots_global").get_value_as_int() - new_config["max_connections_per_torrent"] = \ + new_core_config["max_connections_per_torrent"] = \ self.glade.get_widget( "spin_max_connections_per_torrent").get_value_as_int() - new_config["max_upload_slots_per_torrent"] = \ + new_core_config["max_upload_slots_per_torrent"] = \ self.glade.get_widget( "spin_max_upload_slots_per_torrent").get_value_as_int() config_to_set = {} - for key in new_config.keys(): + for key in new_core_config.keys(): # The values do not match so this needs to be updated - if self.config[key] != new_config[key]: - config_to_set[key] = new_config[key] + if self.core_config[key] != new_core_config[key]: + config_to_set[key] = new_core_config[key] # Set each changed config value in the core functions.set_config(config_to_set, self.core) # Update the configuration - self.config.update(config_to_set) + self.core_config.update(config_to_set) def hide(self): self.pref_dialog.hide() @@ -229,14 +229,39 @@ class Preferences: def on_toggle(self, widget): """Handles widget sensitivity based on radio/check button values.""" value = widget.get_active() - if widget == self.glade.get_widget('radio_save_all_to'): - self.glade.get_widget('download_path_button').set_sensitive(value) + # Disable the download path button if user wants to pick where each + # new torrent is saved. + if widget == self.glade.get_widget("radio_save_all_to"): + self.glade.get_widget("download_path_button").set_sensitive(value) - self.glade.get_widget('spin_port_min').set_sensitive( - not self.glade.get_widget('chk_random_port').get_active()) - self.glade.get_widget('spin_port_max').set_sensitive( - not self.glade.get_widget('chk_random_port').get_active()) + # Disable the port spinners if random ports is selected. + if widget == self.glade.get_widget("chk_random_port"): + self.glade.get_widget("spin_port_min").set_sensitive(not value) + self.glade.get_widget("spin_port_max").set_sensitive(not value) + # Disable all the tray options if tray is not used. + if widget == self.glade.get_widget("chk_use_tray"): + self.glade.get_widget("chk_min_on_close").set_sensitive(value) + self.glade.get_widget("chk_start_in_tray").set_sensitive(value) + self.glade.get_widget("chk_lock_tray").set_sensitive(value) + if value == True: + lock = self.glade.get_widget("chk_lock_tray").get_active() + self.glade.get_widget("txt_tray_passwd").set_sensitive(lock) + self.glade.get_widget("password_label").set_sensitive(lock) + else: + self.glade.get_widget("txt_tray_passwd").set_sensitive(value) + self.glade.get_widget("password_label").set_sensitive(value) + + if widget == self.glade.get_widget("chk_lock_tray"): + self.glade.get_widget("txt_tray_passwd").set_sensitive(value) + self.glade.get_widget("password_label").set_sensitive(value) + + # Disable the file manager combo box if custom is selected. + if widget == self.glade.get_widget("radio_open_folder_custom"): + self.glade.get_widget("combo_file_manager").set_sensitive(not value) + self.glade.get_widget("txt_open_folder_location").set_sensitive( + value) + def on_button_ok_clicked(self, data): log.debug("on_button_ok_clicked") self.set_config()