adding First/Last piece priority plugin

This commit is contained in:
Marcos Pinto 2007-07-15 09:20:45 +00:00
parent 23f744cada
commit e84d6cf588
6 changed files with 482 additions and 334 deletions

View File

@ -166,7 +166,6 @@ namespace libtorrent
virtual std::auto_ptr<alert> clone() const virtual std::auto_ptr<alert> clone() const
{ return std::auto_ptr<alert>(new invalid_request_alert(*this)); } { return std::auto_ptr<alert>(new invalid_request_alert(*this)); }
tcp::endpoint ip; tcp::endpoint ip;
peer_request request; peer_request request;
peer_id pid; peer_id pid;

View File

@ -0,0 +1,113 @@
# Copyright (C) 2007 - Marcos Pinto <markybob@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
### Initialization ###
plugin_name = _("First/Last Priority")
plugin_author = "Marcos Pinto"
plugin_version = "0.1"
plugin_description = _("Set the highest priority to the first and last pieces.")
def deluge_init(deluge_path):
global path
path = deluge_path
def enable(core, interface):
global path
return FirstLast(path, core, interface)
### The Plugin ###
DEFAULT_PREFS = {
"flpriorities": [7]
}
import deluge
import gtk, gtk.glade
class FirstLast:
def __init__(self, path, core, interface):
self.path = path
self.core = core
self.interface = interface
self.set_flpriorities = {}
self.callback_ids = []
# Setup preferences
self.config = deluge.pref.Preferences(filename=deluge.common.CONFIG_DIR + "/firstlast_priorty.conf", global_defaults=False, defaults=DEFAULT_PREFS)
# Connect to events for the torrent menu so we know when to build and remove our sub-menu
self.callback_ids.append(self.interface.torrent_menu.connect_after("realize", self.torrent_menu_show))
self.callback_ids.append(self.interface.torrent_menu.connect("show", self.torrent_menu_show))
self.callback_ids.append(self.interface.torrent_menu.connect("hide", self.torrent_menu_hide))
def torrent_menu_show(self, widget, data=None):
# Get the selected torrent
self.unique_ID = self.interface.get_selected_torrent()
# Make the sub-menu for the torrent menu
self.flp_menuitem = gtk.MenuItem(_("_First/Last Priority"))
self.flp_menu = self.interface.build_menu_radio_list(self.config.get("flpriorities"), self.flp_clicked, self.get_torrent_flp(), None, True, _("_Not Set"), 1, None, True)
self.flp_menuitem.set_submenu(self.flp_menu)
self.interface.torrent_menu.append(self.flp_menuitem)
self.flp_menuitem.show_all()
def torrent_menu_hide(self, widget):
try:
self.interface.torrent_menu.remove(self.flp_menuitem)
except AttributeError:
pass
def update(self):
pass
def unload(self):
# Disconnect all callbacks
for callback_id in self.callback_ids:
self.interface.torrent_menu.disconnect(callback_id)
self.callback_ids = []
# Reset all desired flpriorities in the core
for unique_ID, flp in self.set_flpriorities.items():
if flp > 1:
self.core.set_flp(unique_ID, flp)
self.set_flpriorities = {}
def flp_clicked(self, widget):
value = widget.get_children()[0].get_text()
if value == _("Not Set"):
value = 1
if value == _("Activated"):
value = 7
value = int(value) # Make sure the value is an int
# Set the flp in the core and remember the setting
self.core.set_flp(self.unique_ID, value)
self.set_flpriorities[self.unique_ID] = value
def get_torrent_flp(self):
if self.set_flpriorities.has_key(self.unique_ID):
return self.set_flpriorities[self.unique_ID]
else:
return 1

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2007-07-12 15:08-0500\n" "POT-Creation-Date: 2007-07-14 21:30-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -16,225 +16,196 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: glade/delugegtk.glade:22 #: glade/delugegtk.glade:201
msgid "Add Torrent"
msgstr ""
#: glade/delugegtk.glade:23
msgid "Add"
msgstr ""
#: glade/delugegtk.glade:36 glade/dgtkpopups.glade:6
msgid "Remove Torrent"
msgstr ""
#: glade/delugegtk.glade:37
msgid "Remove"
msgstr ""
#: glade/delugegtk.glade:49
msgid "Clear Finished Torrents"
msgstr ""
#: glade/delugegtk.glade:50
msgid "Clear"
msgstr ""
#: glade/delugegtk.glade:72
msgid "Start or Pause torrent"
msgstr ""
#: glade/delugegtk.glade:73
msgid "Start"
msgstr ""
#: glade/delugegtk.glade:86
msgid "Queue Torrent Up"
msgstr ""
#: glade/delugegtk.glade:87
msgid "Up"
msgstr ""
#: glade/delugegtk.glade:100
msgid "Queue Torrent Down"
msgstr ""
#: glade/delugegtk.glade:101
msgid "Down"
msgstr ""
#: glade/delugegtk.glade:122
msgid "Change Deluge preferences"
msgstr ""
#: glade/delugegtk.glade:123
msgid "Preferences"
msgstr ""
#: glade/delugegtk.glade:135
msgid "Open the plugins dialog"
msgstr ""
#: glade/delugegtk.glade:136 glade/dgtkpopups.glade:209
#: glade/plugin_dialog.glade:80
msgid "Plugins"
msgstr ""
#: glade/delugegtk.glade:185
msgid "_File"
msgstr ""
#: glade/delugegtk.glade:192 glade/tray_menu.glade:27
msgid "_Add Torrent"
msgstr ""
#: glade/delugegtk.glade:207
msgid "Add _URL"
msgstr ""
#: glade/delugegtk.glade:215
msgid "_Clear Completed"
msgstr ""
#: glade/delugegtk.glade:248
msgid "_Edit"
msgstr ""
#: glade/delugegtk.glade:265
msgid "Pl_ugins"
msgstr ""
#: glade/delugegtk.glade:284
msgid "_Torrent"
msgstr ""
#: glade/delugegtk.glade:291
msgid "_View"
msgstr ""
#: glade/delugegtk.glade:299
msgid "_Toolbar"
msgstr ""
#: glade/delugegtk.glade:308
msgid "_Details"
msgstr ""
#: glade/delugegtk.glade:317
msgid "Columns"
msgstr ""
#: glade/delugegtk.glade:325 src/interface.py:459 src/interface.py:625
msgid "Size"
msgstr ""
#: glade/delugegtk.glade:334 src/interface.py:460
msgid "Status"
msgstr ""
#: glade/delugegtk.glade:343 src/interface.py:461
msgid "Seeders"
msgstr ""
#: glade/delugegtk.glade:352 glade/delugegtk.glade:1093 src/interface.py:462
msgid "Peers"
msgstr ""
#: glade/delugegtk.glade:361 src/interface.py:463 src/interface.py:596
#: src/interface.py:943 src/interface.py:957
msgid "Down Speed"
msgstr ""
#: glade/delugegtk.glade:370 src/interface.py:464 src/interface.py:597
#: src/interface.py:944 src/interface.py:958
msgid "Up Speed"
msgstr ""
#: glade/delugegtk.glade:379
msgid "Time Remaining"
msgstr ""
#: glade/delugegtk.glade:388
msgid "Share Ratio"
msgstr ""
#: glade/delugegtk.glade:405
msgid "_Help"
msgstr ""
#: glade/delugegtk.glade:422 glade/delugegtk.glade:423
msgid "Help translate this application"
msgstr ""
#: glade/delugegtk.glade:535
msgid "<b>Next Announce:</b>"
msgstr ""
#: glade/delugegtk.glade:556
msgid "<b>Tracker Status:</b>"
msgstr ""
#: glade/delugegtk.glade:578
msgid "<b>Tracker:</b>"
msgstr ""
#: glade/delugegtk.glade:599
msgid "<b>Pieces:</b>"
msgstr ""
#: glade/delugegtk.glade:620
msgid "<b>Total Size:</b>"
msgstr ""
#: glade/delugegtk.glade:642
msgid "<b>Name:</b>"
msgstr ""
#: glade/delugegtk.glade:739
msgid "<b>Torrent Info</b>"
msgstr ""
#: glade/delugegtk.glade:793
msgid "<b>ETA:</b>"
msgstr ""
#: glade/delugegtk.glade:814
msgid "<b>Peers:</b>"
msgstr ""
#: glade/delugegtk.glade:835 glade/delugegtk.glade:856
msgid "<b>Speed:</b>"
msgstr ""
#: glade/delugegtk.glade:874
msgid "<b>Share Ratio:</b>"
msgstr ""
#: glade/delugegtk.glade:892
msgid "<b>Seeders:</b>"
msgstr ""
#: glade/delugegtk.glade:910
msgid "<b>Uploaded:</b>"
msgstr ""
#: glade/delugegtk.glade:928
msgid "<b>Downloaded:</b>" msgid "<b>Downloaded:</b>"
msgstr "" msgstr ""
#: glade/delugegtk.glade:1040 #: glade/delugegtk.glade:215
msgid "<b>Uploaded:</b>"
msgstr ""
#: glade/delugegtk.glade:233
msgid "<b>Seeders:</b>"
msgstr ""
#: glade/delugegtk.glade:251
msgid "<b>Share Ratio:</b>"
msgstr ""
#: glade/delugegtk.glade:270 glade/delugegtk.glade:289
msgid "<b>Speed:</b>"
msgstr ""
#: glade/delugegtk.glade:310
msgid "<b>Peers:</b>"
msgstr ""
#: glade/delugegtk.glade:331
msgid "<b>ETA:</b>"
msgstr ""
#: glade/delugegtk.glade:357
msgid "<b>Statistics</b>" msgid "<b>Statistics</b>"
msgstr "" msgstr ""
#: glade/delugegtk.glade:1065 #: glade/delugegtk.glade:480
msgid "<b>Name:</b>"
msgstr ""
#: glade/delugegtk.glade:499
msgid "<b>Total Size:</b>"
msgstr ""
#: glade/delugegtk.glade:520
msgid "<b>Pieces:</b>"
msgstr ""
#: glade/delugegtk.glade:542
msgid "<b>Tracker:</b>"
msgstr ""
#: glade/delugegtk.glade:563
msgid "<b>Tracker Status:</b>"
msgstr ""
#: glade/delugegtk.glade:584
msgid "<b>Next Announce:</b>"
msgstr ""
#: glade/delugegtk.glade:603
msgid "<b>Torrent Info</b>"
msgstr ""
#: glade/delugegtk.glade:629
msgid "Details" msgid "Details"
msgstr "" msgstr ""
#: glade/delugegtk.glade:1123 #: glade/delugegtk.glade:656 glade/delugegtk.glade:893 src/interface.py:464
msgid "Peers"
msgstr ""
#: glade/delugegtk.glade:685
msgid "Files" msgid "Files"
msgstr "" msgstr ""
#: glade/delugegtk.glade:726
msgid "_File"
msgstr ""
#: glade/delugegtk.glade:733 glade/tray_menu.glade:27
msgid "_Add Torrent"
msgstr ""
#: glade/delugegtk.glade:748
msgid "Add _URL"
msgstr ""
#: glade/delugegtk.glade:756
msgid "_Clear Completed"
msgstr ""
#: glade/delugegtk.glade:789
msgid "_Edit"
msgstr ""
#: glade/delugegtk.glade:806
msgid "Pl_ugins"
msgstr ""
#: glade/delugegtk.glade:825
msgid "_Torrent"
msgstr ""
#: glade/delugegtk.glade:832
msgid "_View"
msgstr ""
#: glade/delugegtk.glade:840
msgid "_Toolbar"
msgstr ""
#: glade/delugegtk.glade:849
msgid "_Details"
msgstr ""
#: glade/delugegtk.glade:858
msgid "Columns"
msgstr ""
#: glade/delugegtk.glade:866 src/interface.py:461 src/interface.py:653
msgid "Size"
msgstr ""
#: glade/delugegtk.glade:875 src/interface.py:462
msgid "Status"
msgstr ""
#: glade/delugegtk.glade:884 src/interface.py:463
msgid "Seeders"
msgstr ""
#: glade/delugegtk.glade:902 src/interface.py:465 src/interface.py:615
#: src/interface.py:986 src/interface.py:1000
msgid "Down Speed"
msgstr ""
#: glade/delugegtk.glade:911 src/interface.py:466 src/interface.py:616
#: src/interface.py:987 src/interface.py:1001
msgid "Up Speed"
msgstr ""
#: glade/delugegtk.glade:920
msgid "Time Remaining"
msgstr ""
#: glade/delugegtk.glade:929
msgid "Share Ratio"
msgstr ""
#: glade/delugegtk.glade:946
msgid "_Help"
msgstr ""
#: glade/delugegtk.glade:954
msgid "Help translate this application"
msgstr ""
#: glade/delugegtk.glade:955
msgid "Translate This Application..."
msgstr ""
#: glade/delugegtk.glade:1027
msgid "Add Torrent"
msgstr ""
#: glade/delugegtk.glade:1041 glade/dgtkpopups.glade:6
msgid "Remove Torrent"
msgstr ""
#: glade/delugegtk.glade:1054
msgid "Clear Finished Torrents"
msgstr ""
#: glade/delugegtk.glade:1077
msgid "Start or Pause torrent"
msgstr ""
#: glade/delugegtk.glade:1091
msgid "Queue Torrent Up"
msgstr ""
#: glade/delugegtk.glade:1105
msgid "Queue Torrent Down"
msgstr ""
#: glade/delugegtk.glade:1127
msgid "Change Deluge preferences"
msgstr ""
#: glade/delugegtk.glade:1140
msgid "Open the plugins dialog"
msgstr ""
#: glade/dgtkpopups.glade:41 #: glade/dgtkpopups.glade:41
msgid "" msgid ""
"<span size=\"large\"><b>Are you sure you want to remove the selected torrent" "<span size=\"large\"><b>Are you sure you want to remove the selected torrent"
@ -261,6 +232,10 @@ msgstr ""
msgid "Clear Finished" msgid "Clear Finished"
msgstr "" msgstr ""
#: glade/dgtkpopups.glade:209 glade/plugin_dialog.glade:80
msgid "Plugins"
msgstr ""
#: glade/dgtkpopups.glade:260 #: glade/dgtkpopups.glade:260
msgid "Speed:" msgid "Speed:"
msgstr "" msgstr ""
@ -650,191 +625,194 @@ msgstr ""
msgid "_Quit" msgid "_Quit"
msgstr "" msgstr ""
#: src/common.py:58 src/interface.py:436 #: src/common.py:59 src/interface.py:438
msgid "Infinity" msgid "Infinity"
msgstr "" msgstr ""
#: src/common.py:71 #: src/common.py:72
#, python-format #, python-format
msgid "%.1f KiB" msgid "%.1f KiB"
msgstr "" msgstr ""
#: src/common.py:74 #: src/common.py:75
#, python-format #, python-format
msgid "%.1f MiB" msgid "%.1f MiB"
msgstr "" msgstr ""
#: src/common.py:76 #: src/common.py:77
#, python-format #, python-format
msgid "%.1f GiB" msgid "%.1f GiB"
msgstr "" msgstr ""
#: src/common.py:124 #: src/common.py:127
msgid "Error: no webbrowser found" msgid "Error: no webbrowser found"
msgstr "" msgstr ""
#: src/core.py:129 #: src/core.py:128
#, python-format msgid "bytes needed"
msgid "%d %d bytes needed"
msgstr "" msgstr ""
#: src/core.py:346 #: src/core.py:346
msgid "File was not found" msgid "File was not found"
msgstr "" msgstr ""
#: src/interface.py:206 src/interface.py:212 src/interface.py:266 #: src/core.py:394
#: src/interface.py:288 msgid "Asked for a torrent that doesn't exist"
msgid "KiB/s"
msgstr "" msgstr ""
#: src/interface.py:259 src/interface.py:270 src/interface.py:292 #: src/core.py:552 src/interface.py:876
msgid "Other..."
msgstr ""
#: src/interface.py:267 src/interface.py:289 src/interface.py:927
#: src/interface.py:933 src/interface.py:937
msgid "Unlimited"
msgstr ""
#: src/interface.py:315
msgid "Deluge is locked"
msgstr ""
#: src/interface.py:317
msgid ""
"Deluge is password protected.\n"
"To show the Deluge window, please enter your password"
msgstr ""
#: src/interface.py:444
msgid "Unknown"
msgstr ""
#: src/interface.py:458
msgid "Name"
msgstr ""
#: src/interface.py:465
msgid "ETA"
msgstr ""
#: src/interface.py:466
msgid "Ratio"
msgstr ""
#: src/interface.py:515 src/interface.py:554 src/interface.py:916
msgid "Resume"
msgstr ""
#: src/interface.py:518 src/interface.py:557 src/interface.py:919
msgid "Pause"
msgstr ""
#: src/interface.py:544
msgid "Pause/Resume"
msgstr ""
#: src/interface.py:593
msgid "IP Address"
msgstr ""
#: src/interface.py:594
msgid "Client"
msgstr ""
#: src/interface.py:595
msgid "Percent Complete"
msgstr ""
#: src/interface.py:623
msgid "Download"
msgstr ""
#: src/interface.py:624
msgid "Filename"
msgstr ""
#: src/interface.py:626
msgid "Progress"
msgstr ""
#: src/interface.py:737
#, python-format
msgid "Paused %s"
msgstr ""
#: src/interface.py:833
msgid "" msgid ""
"You cannot move torrent to a different partition. Please fix your " "You cannot move torrent to a different partition. Please fix your "
"preferences" "preferences"
msgstr "" msgstr ""
#: src/interface.py:943 src/interface.py:956 #: src/interface.py:203 src/interface.py:209 src/interface.py:264
#: src/interface.py:286
msgid "KiB/s"
msgstr ""
#: src/interface.py:227 src/interface.py:265 src/interface.py:287
#: src/interface.py:970 src/interface.py:976 src/interface.py:980
msgid "Unlimited"
msgstr ""
#: src/interface.py:257 src/interface.py:268 src/interface.py:290
msgid "Other..."
msgstr ""
#: src/interface.py:313
msgid "Deluge is locked"
msgstr ""
#: src/interface.py:315
msgid ""
"Deluge is password protected.\n"
"To show the Deluge window, please enter your password"
msgstr ""
#: src/interface.py:446
msgid "Unknown"
msgstr ""
#: src/interface.py:460
msgid "Name"
msgstr ""
#: src/interface.py:467
msgid "ETA"
msgstr ""
#: src/interface.py:468
msgid "Ratio"
msgstr ""
#: src/interface.py:531 src/interface.py:570 src/interface.py:959
msgid "Resume"
msgstr ""
#: src/interface.py:534 src/interface.py:573 src/interface.py:962
msgid "Pause"
msgstr ""
#: src/interface.py:560
msgid "Pause/Resume"
msgstr ""
#: src/interface.py:612
msgid "IP Address"
msgstr ""
#: src/interface.py:613
msgid "Client"
msgstr ""
#: src/interface.py:614
msgid "Percent Complete"
msgstr ""
#: src/interface.py:651
msgid "Download"
msgstr ""
#: src/interface.py:652
msgid "Filename"
msgstr ""
#: src/interface.py:654
msgid "Progress"
msgstr ""
#: src/interface.py:781
#, python-format
msgid "Paused %s"
msgstr ""
#: src/interface.py:986 src/interface.py:999
msgid "Connections" msgid "Connections"
msgstr "" msgstr ""
#: src/interface.py:956 #: src/interface.py:999
msgid "Deluge Bittorrent Client" msgid "Deluge Bittorrent Client"
msgstr "" msgstr ""
#: src/interface.py:1121 #: src/interface.py:1147
msgid "" msgid ""
"An error occured while trying to add the torrent. It's possible your ." "An error occured while trying to add the torrent. It's possible your ."
"torrent file is corrupted." "torrent file is corrupted."
msgstr "" msgstr ""
#: src/interface.py:1123 #: src/interface.py:1149
msgid "The torrent you've added seems to already be in Deluge." msgid "The torrent you've added seems to already be in Deluge."
msgstr "" msgstr ""
#: src/interface.py:1127 #: src/interface.py:1153
msgid "There is not enough free disk space to complete your download." msgid "There is not enough free disk space to complete your download."
msgstr "" msgstr ""
#: src/interface.py:1128 #: src/interface.py:1154
msgid "Space Needed:" msgid "Space Needed:"
msgstr "" msgstr ""
#: src/interface.py:1129 #: src/interface.py:1155
msgid "Available Space:" msgid "Available Space:"
msgstr "" msgstr ""
#: src/interface.py:1141 #: src/interface.py:1170
msgid "Add torrent from URL" msgid "Add torrent from URL"
msgstr "" msgstr ""
#: src/interface.py:1145 #: src/interface.py:1174
msgid "Enter the URL of the .torrent to download" msgid "Enter the URL of the .torrent to download"
msgstr "" msgstr ""
#: src/interface.py:1246 #: src/interface.py:1269
msgid "Warning - all downloaded files for this torrent will be deleted!" msgid "Warning - all downloaded files for this torrent will be deleted!"
msgstr "" msgstr ""
#: src/dialogs.py:183 #: src/dialogs.py:184
msgid "Plugin" msgid "Plugin"
msgstr "" msgstr ""
#: src/dialogs.py:185 #: src/dialogs.py:186
msgid "Enabled" msgid "Enabled"
msgstr "" msgstr ""
#: src/dialogs.py:252 #: src/dialogs.py:253
msgid "translator-credits" msgid "translator-credits"
msgstr "" msgstr ""
#: src/dialogs.py:292 #: src/dialogs.py:293
msgid "Choose a .torrent file" msgid "Choose a .torrent file"
msgstr "" msgstr ""
#: src/dialogs.py:297 #: src/dialogs.py:298
msgid "Torrent files" msgid "Torrent files"
msgstr "" msgstr ""
#: src/dialogs.py:301 #: src/dialogs.py:302
msgid "All files" msgid "All files"
msgstr "" msgstr ""
#: src/dialogs.py:322 #: src/dialogs.py:323
msgid "Choose a download directory" msgid "Choose a download directory"
msgstr "" msgstr ""

View File

@ -860,3 +860,6 @@ class Manager:
def replace_trackers(self, unique_ID, trackers): def replace_trackers(self, unique_ID, trackers):
return deluge_core.replace_trackers(unique_ID, trackers) return deluge_core.replace_trackers(unique_ID, trackers)
def set_flp(self, unique_ID, num):
return deluge_core.set_flp(unique_ID, int(num))

View File

@ -1422,6 +1422,27 @@ static PyObject *torrent_replace_trackers(PyObject *self, PyObject *args)
h.force_reannounce(); h.force_reannounce();
return Py_None; return Py_None;
} }
static PyObject *torrent_set_flp(PyObject *self, PyObject *args)
{
python_long unique_ID;
int num;
if (!PyArg_ParseTuple(args, "ii", &unique_ID, &num))
return NULL;
long index = get_index_from_unique_ID(unique_ID);
if (PyErr_Occurred())
return NULL;
torrent_t &t = M_torrents->at(index);
torrent_status s = t.handle.status();
const torrent_info &i = t.handle.get_torrent_info();
int npieces = i.num_pieces();
t.handle.piece_priority(0, num);
t.handle.piece_priority(npieces, num);
return Py_None;
}
//==================== //====================
// Python Module data // Python Module data
//==================== //====================
@ -1468,6 +1489,7 @@ static PyMethodDef deluge_core_methods[] =
{"proxy_settings", torrent_proxy_settings, METH_VARARGS, "."}, {"proxy_settings", torrent_proxy_settings, METH_VARARGS, "."},
{"get_trackers", torrent_get_trackers, METH_VARARGS, "."}, {"get_trackers", torrent_get_trackers, METH_VARARGS, "."},
{"replace_trackers", torrent_replace_trackers, METH_VARARGS, "."}, {"replace_trackers", torrent_replace_trackers, METH_VARARGS, "."},
{"set_flp", torrent_set_flp, METH_VARARGS, "."},
{NULL} {NULL}
}; };

View File

@ -202,13 +202,13 @@ class DelugeGTK:
self.submenu_bwdownset = self.build_menu_radio_list( self.submenu_bwdownset = self.build_menu_radio_list(
self.config.get("tray_downloadspeedlist"), self.tray_setbwdown, self.config.get("tray_downloadspeedlist"), self.tray_setbwdown,
self.config.get("max_download_speed"), _("KiB/s"), self.config.get("max_download_speed"), _("KiB/s"),
show_notset=True) show_notset=True, show_other=True)
# Create the Upload speed list sub-menu # Create the Upload speed list sub-menu
self.submenu_bwupset = self.build_menu_radio_list( self.submenu_bwupset = self.build_menu_radio_list(
self.config.get("tray_uploadspeedlist"), self.tray_setbwup, self.config.get("tray_uploadspeedlist"), self.tray_setbwup,
self.config.get("max_upload_speed"), _("KiB/s"), self.config.get("max_upload_speed"), _("KiB/s"),
show_notset=True) show_notset=True, show_other=True)
# Add the sub-menus to the tray menu # Add the sub-menus to the tray menu
self.tray_glade.get_widget("download_limit").set_submenu(self.submenu_bwdownset) self.tray_glade.get_widget("download_limit").set_submenu(self.submenu_bwdownset)
@ -220,15 +220,19 @@ class DelugeGTK:
def build_menu_radio_list(self, value_list, callback, pref_value=None, def build_menu_radio_list(self, value_list, callback, pref_value=None,
suffix=None, show_notset=False, suffix=None, show_notset=False,
notset_label=None, notset_lessthan=0, show_other=False): notset_label=None, notset_lessthan=0, show_other=False, show_activated=False, activated_label=None):
# Build a menu with radio menu items from a list and connect them to the callback # Build a menu with radio menu items from a list and connect them to the callback
# The pref_value is what you would like to test for the default active radio item # The pref_value is what you would like to test for the default active radio item
# Setting show_unlimited will include an Unlimited radio item # Setting show_unlimited will include an Unlimited radio item
if notset_label is None: if notset_label is None:
notset_label = _("Unlimited") notset_label = _("Unlimited")
menu = gtk.Menu()
if activated_label is None:
activated_label = _("Activated")
menu = gtk.Menu()
group = None group = None
if show_activated is False:
for value in sorted(value_list): for value in sorted(value_list):
if suffix != None: if suffix != None:
menuitem = gtk.RadioMenuItem(group, str(value) + " " + suffix) menuitem = gtk.RadioMenuItem(group, str(value) + " " + suffix)
@ -245,14 +249,43 @@ class DelugeGTK:
menu.append(menuitem) menu.append(menuitem)
if show_activated is True:
for value in sorted(value_list):
menuitem = gtk.RadioMenuItem(group, str(activated_label))
group = menuitem
if value == pref_value and pref_value != None:
menuitem.set_active(True)
if callback != None:
menuitem.connect("toggled", callback)
menu.append(menuitem)
# if show_activated is True:
# for value in sorted(value_list):
# menuitem = gtk.RadioMenuItem(group, activated_label)
# group = menuitem
#
# if value == 1:
# menuitem.set_active(False)
# else:
# menuitem.set_active(True)
# menuitem.connect("toggled", callback)
# menu.append(menuitem)
if show_notset: if show_notset:
menuitem = gtk.RadioMenuItem(group, notset_label) menuitem = gtk.RadioMenuItem(group, notset_label)
if pref_value < notset_lessthan and pref_value != None: if pref_value < notset_lessthan and pref_value != None:
menuitem.set_active(True) menuitem.set_active(True)
if show_activated and pref_value == 1:
menuitem.set_active(True)
menuitem.connect("toggled", callback) menuitem.connect("toggled", callback)
menu.append(menuitem) menu.append(menuitem)
# Add the Other... menuitem # Add the Other... menuitem
if show_other is True:
menuitem = gtk.SeparatorMenuItem() menuitem = gtk.SeparatorMenuItem()
menu.append(menuitem) menu.append(menuitem)
menuitem = gtk.MenuItem(_("Other...")) menuitem = gtk.MenuItem(_("Other..."))