From b41a0252177de4617ed3e7265f1a351f2ac703f5 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Mon, 30 Nov 2009 03:50:28 +0000 Subject: [PATCH] Add button to Other preferences to associate magnet links with Deluge --- ChangeLog | 3 +- deluge/data/pixmaps/magnet.png | Bin 0 -> 906 bytes deluge/ui/gtkui/common.py | 32 +++++++ .../ui/gtkui/glade/preferences_dialog.glade | 90 ++++++++++++++++++ deluge/ui/gtkui/gtkui.py | 19 +--- deluge/ui/gtkui/preferences.py | 10 +- 6 files changed, 137 insertions(+), 17 deletions(-) create mode 100644 deluge/data/pixmaps/magnet.png 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 0000000000000000000000000000000000000000..a192cd8ad6f9e4aa47d8012f58aa362790e873d3 GIT binary patch literal 906 zcmV;519kj~P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L03N{r03N{s!)a7g00007bV*G`2iXf9 z6)+{D>DoI000Rn1L_t(I%axN|Xj^3*hoAS&IXO*}G_{HOFrBsSI!4#gxv`7k$AurW ztuh=snIKNA>!vL_!O7+jcHxDHAf+q1R*)iyXjK@}x-wx*K|#%AE8U#^Zc?{Eo25zH zoSc*MdgBTeM18J)|BL5$_4~tLwCvx{-|0Mhl>g1CzW&zst|NEcy5H^Y`S0>8$4)f= za`B@2Igv=585-_+uc!CEe{&?j&^IFh?0u~Djc7PbI2gQpbA4Txufl%-;J}NW>!kLV zy4JFGIu@g?WjF7191g|9;T8qTE|tVWCd2sn#A$$m_j@_`@{zkL0~LqeQVvAIw@>%> z^%XihI+Uwt>vp=6GjwIL9bVhpCIddXtQ?VESV%NCHN9PMq<#6<1P5PeKeVM`<4Mis z>eMyufpSk-`iXt}#yq-&^?PqkdlNKIIDq zs~#~;6J2u=42E_s<#L-$tN679csdr{>eD^V(xc?FYF#AU;|!H4v8O<;V> zF11t<6Z6wki8qfQzXYHGxRgtm-Yi1ghLQ&EavJJG{&GW;c_Ti4*6@=z%3a- ze%jc`q0H>{sg(MlP+$d@B^+lSWiKmNNg#w$LUV)?O5FHqb#}*u`TDvgM#jbf*gZAb z|NFFaGM^`D+e+BEMPV*3QoOk;Ru(O;Ut0a%nzrs2B>AnbVXZ&_d{$k 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)