diff --git a/ChangeLog b/ChangeLog index 17b40502e..b80089b0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,10 +6,11 @@ * Attempt to register as the default magnet uri handler in GNOME on startup * Properly show 100.00% and reduce number of progress bar updates during a torrent creation * Fix crash in Windows when creating a torrent + * Add button to Other preferences to associate magnet links with Deluge ==== Label ==== * Fix #1085 only use ints for specific options to prevent unhandled exception - + === Deluge 1.2.0_rc4 (24 November 2009) === ==== Core ==== * Fix deleting old .fastresume files with fresh configs diff --git a/deluge/data/pixmaps/magnet.png b/deluge/data/pixmaps/magnet.png new file mode 100644 index 000000000..a192cd8ad Binary files /dev/null and b/deluge/data/pixmaps/magnet.png differ diff --git a/deluge/ui/gtkui/common.py b/deluge/ui/gtkui/common.py index 66327c8c5..5b25fa537 100644 --- a/deluge/ui/gtkui/common.py +++ b/deluge/ui/gtkui/common.py @@ -228,3 +228,35 @@ def get_deluge_icon(): return icon_theme.load_icon("deluge", 64, 0) except: return get_logo(64) + +def associate_magnet_links(overwrite=False): + """ + Associates magnet links to Deluge. + + :param overwrite: if this is True, the current setting will be overwritten + :type overwrite: bool + :returns: True if association was set + :rtype: bool + + """ + if not deluge.common.windows_check(): + # gconf method is only available in a GNOME environment + try: + import gconf + except ImportError: + log.debug("gconf not available, so will not attempt to register magnet uri handler") + return False + else: + key = "/desktop/gnome/url-handlers/magnet/command" + gconf_client = gconf.client_get_default() + if (gconf_client.get(key) and overwrite) or not gconf_client.get(key): + # We are either going to overwrite the key, or do it if it hasn't been set yet + if gconf_client.set_string(key, "deluge '%s'"): + gconf_client.set_bool("/desktop/gnome/url-handlers/magnet/needs_terminal", False) + gconf_client.set_bool("/desktop/gnome/url-handlers/magnet/enabled", True) + log.info("Deluge registered as default magnet uri handler!") + return True + else: + log.error("Unable to register Deluge as default magnet uri handler.") + return False + return False diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade index f2d3052a9..d69c94fef 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.glade +++ b/deluge/ui/gtkui/glade/preferences_dialog.glade @@ -17,6 +17,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical 2 @@ -65,6 +66,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -415,6 +417,7 @@ True + vertical Prioritize first and last pieces of torrent @@ -498,6 +501,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -537,6 +541,7 @@ True + vertical True @@ -734,6 +739,7 @@ True + vertical 5 @@ -905,6 +911,7 @@ True + vertical True @@ -1104,6 +1111,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -1135,6 +1143,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -1168,6 +1177,7 @@ Either True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -1281,6 +1291,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -1320,6 +1331,7 @@ Disabled True + vertical 5 @@ -1778,6 +1790,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -1863,6 +1876,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical Show session speed in titlebar @@ -1913,6 +1927,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical Always show @@ -1982,6 +1997,7 @@ Disabled True + vertical Enable system tray icon @@ -2160,6 +2176,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -2201,6 +2218,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -2262,6 +2280,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -2337,6 +2356,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -2399,6 +2419,60 @@ Disabled 4 + + + True + 12 + + + True + start + + + True + True + True + + + + True + 2 + + + True + gtk-missing-image + + + 0 + + + + + True + Associate Magnet links with Deluge + + + 1 + + + + + + + False + False + 0 + + + + + + + False + False + 5 + + @@ -2436,6 +2510,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -2477,6 +2552,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -2661,6 +2737,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -2690,6 +2767,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical 5 @@ -2707,6 +2785,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical Queue new torrents to top @@ -2757,6 +2836,7 @@ Disabled True + vertical 5 @@ -2908,6 +2988,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical 2 @@ -3133,6 +3214,7 @@ Disabled True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -3160,6 +3242,7 @@ Disabled True + vertical 5 @@ -3936,6 +4019,7 @@ HTTP W/ Auth True + vertical True @@ -3967,6 +4051,7 @@ HTTP W/ Auth True + vertical 6 @@ -4320,6 +4405,7 @@ HTTP W/ Auth True + vertical True @@ -4351,6 +4437,7 @@ HTTP W/ Auth True + vertical True @@ -4460,6 +4547,7 @@ HTTP W/ Auth True + vertical True @@ -4868,6 +4956,7 @@ HTTP W/ Auth True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -4898,6 +4987,7 @@ HTTP W/ Auth True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index a35a92178..31123ccc6 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -81,6 +81,7 @@ from deluge.ui.tracker_icons import TrackerIcons from queuedtorrents import QueuedTorrents from addtorrentdialog import AddTorrentDialog import dialogs +import common import deluge.configmanager import deluge.common @@ -180,21 +181,9 @@ class GtkUI(object): return 1 SetConsoleCtrlHandler(win_handler) - # Attempt to register a magnet URI handler with gconf - try: - import gconf - except ImportError: - log.debug("gconf not available, so will not attempt to register magnet uri handler") - else: - key = "/desktop/gnome/url-handlers/magnet/command" - gconf_client = gconf.client_get_default() - if not gconf_client.get(key): - if gconf_client.set_string(key, "deluge '%s'"): - gconf_client.set_bool("/desktop/gnome/url-handlers/magnet/needs_terminal", False) - gconf_client.set_bool("/desktop/gnome/url-handlers/magnet/enabled", True) - log.info("Deluge registered as default magnet uri handler!") - else: - log.error("Unable to register Deluge as default magnet uri handler.") + # Attempt to register a magnet URI handler with gconf, but do not overwrite + # if already set by another program. + common.associate_magnet_links(False) # Make sure gtkui.conf has at least the defaults set self.config = deluge.configmanager.ConfigManager("gtkui.conf", DEFAULT_PREFS) diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 207716916..02b593e6a 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -60,6 +60,10 @@ class Preferences(component.Component): self.treeview = self.glade.get_widget("treeview") self.notebook = self.glade.get_widget("notebook") self.gtkui_config = ConfigManager("gtkui.conf") + + self.glade.get_widget("image_magnet").set_from_file( + deluge.common.get_pixmap("magnet.png")) + # Setup the liststore for the categories (tab pages) self.liststore = gtk.ListStore(int, str) self.treeview.set_model(self.liststore) @@ -105,7 +109,8 @@ class Preferences(component.Component): "on_button_rescan_plugins_clicked": self._on_button_rescan_plugins_clicked, "on_button_find_plugins_clicked": self._on_button_find_plugins_clicked, "on_button_cache_refresh_clicked": self._on_button_cache_refresh_clicked, - "on_combo_proxy_type_changed": self._on_combo_proxy_type_changed + "on_combo_proxy_type_changed": self._on_combo_proxy_type_changed, + "on_button_associate_magnet_clicked": self._on_button_associate_magnet_clicked }) # These get updated by requests done to the core @@ -982,3 +987,6 @@ class Preferences(component.Component): w = self.glade.get_widget(p + s + "_" + name) if w: w.show() + + def _on_button_associate_magnet_clicked(self, widget): + common.associate_magnet_links(True)