mostly pep8 fixes

This commit is contained in:
Marcos Pinto 2007-07-13 01:13:13 +00:00
commit 63d19d05bc
15 changed files with 1048 additions and 1035 deletions

View file

@ -278,7 +278,7 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES. POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest If you develop a new program, and you want it to be of the greatest
@ -348,4 +348,3 @@ Public License instead of this License.
but you are not obligated to do so. If you do not wish to do so, delete but you are not obligated to do so. If you do not wish to do so, delete
this exception statement from your version. If you delete this exception this exception statement from your version. If you delete this exception
statement from all source files in the program, then also delete it here. statement from all source files in the program, then also delete it here.

35
README
View file

@ -12,9 +12,8 @@ Homepage: http://deluge-torrent.org
Installation Instructions: Installation Instructions:
========================== ==========================
First, make sure you have the proper bulid First, make sure you have the proper bulid dependencies installed. On a normal
dependencies installed. On a normal Debian Debian or Ubuntu system, those dependencies are:
or Ubuntu system, those dependencies are:
g++ g++
python-all-dev python-all-dev
@ -31,16 +30,13 @@ libboost-serialization-dev
libssl-dev libssl-dev
zlib1g-dev zlib1g-dev
But the names of the packages may vary But the names of the packages may vary depending on your OS / distro.
depending on your OS / distro.
Once you have the needed libraries installed, Once you have the needed libraries installed, build Deluge by running:
build Deluge by running:
python setup.py build python setup.py build
You shouldn't get any errors. Then run, as You shouldn't get any errors. Then run, as root (or by using sudo):
root (or by using sudo):
python setup.py install python setup.py install
@ -52,17 +48,12 @@ You can then run Deluge by executing:
Notes: Notes:
1) On some distributions, boost libraries are 1) On some distributions, boost libraries are renamed to have "-mt" at the end
renamed to have "-mt" at the end (boost_thread_mt (boost_thread_mt instead of boost_thread, for example), the "mt" indicating
instead of boost_thread, for example), the "mt" "multithreaded". In some cases it appears the distros lack symlinks to connect
indicating "multithreaded". In some cases it things. The solution is to either add symlinks from the short names to those
appears the distros lack symlinks to connect with "-mt", or to alter setup.py to look for the "-mt" versions.
things. The solution is to either add symlinks
from the short names to those with "-mt", or to
alter setup.py to look for the "-mt" versions.
2) After upgrading your Deluge installation, it 2) After upgrading your Deluge installation, it may fail to start. If this
may fail to start. If this happens to you, you happens to you, you need to remove your ~/.config/deluge directory to allow
need to remove your ~/.config/deluge directory Deluge to rebuild it's configuration file.
to allow Deluge to rebuild it's configuration
file.

View file

@ -1,11 +1,8 @@
NOTE: Deluge 0.5.1 uses an unstable build of libtorrent. This build differs
NOTE: Deluge 0.5.1 uses an unstable build of libtorrent. This from a clean libtorrent source checkout and has been hacked in order to get it
build differs from a clean libtorrent source checkout and has to work properly with Deluge. As a result, Deluge will likely not build
been hacked in order to get it to work properly with Deluge. properly against a vanilla libtorrent 0.12 installation or a nightly build of
As a result, Deluge will likely not build properly against a libtorrent 0.13. It is recommended that you build against our included
vanilla libtorrent 0.12 installation or a nightly build of libtorrent, as our build will not conflict with any installed libtorrent.
libtorrent 0.13. It is recommended that you build against our
included libtorrent, as our build will not conflict with any
installed libtorrent.
- zachtib - zachtib

View file

@ -32,7 +32,7 @@ def enable(core, interface):
### The Plugin ### ### The Plugin ###
DEFAULT_PREFS = { DEFAULT_PREFS = {
"ratios": [1.0, 1.5, 2.0, 3.0] "ratios": [1.0, 1.5, 2.0, 3.0]
} }
import deluge import deluge
@ -40,95 +40,95 @@ import gtk, gtk.glade
class DesiredRatio: class DesiredRatio:
def __init__(self, path, core, interface): def __init__(self, path, core, interface):
self.path = path self.path = path
self.core = core self.core = core
self.interface = interface self.interface = interface
self.set_ratios = {} self.set_ratios = {}
self.callback_ids = [] self.callback_ids = []
# Setup preferences # Setup preferences
self.config = deluge.pref.Preferences(filename=deluge.common.CONFIG_DIR + "/desired_ratio.conf", global_defaults=False, defaults=DEFAULT_PREFS) self.config = deluge.pref.Preferences(filename=deluge.common.CONFIG_DIR + "/desired_ratio.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 # 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_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("show", self.torrent_menu_show))
self.callback_ids.append(self.interface.torrent_menu.connect("hide", self.torrent_menu_hide)) self.callback_ids.append(self.interface.torrent_menu.connect("hide", self.torrent_menu_hide))
def torrent_menu_show(self, widget, data=None): def torrent_menu_show(self, widget, data=None):
# Get the selected torrent # Get the selected torrent
self.unique_ID = self.interface.get_selected_torrent() self.unique_ID = self.interface.get_selected_torrent()
# Make the sub-menu for the torrent menu # Make the sub-menu for the torrent menu
self.ratio_menuitem = gtk.MenuItem(_("_Desired Ratio")) self.ratio_menuitem = gtk.MenuItem(_("_Desired Ratio"))
self.ratio_menu = self.interface.build_menu_radio_list(self.config.get("ratios"), self.ratio_clicked, self.get_torrent_desired_ratio(), None, True, _("_Not Set"), 1) self.ratio_menu = self.interface.build_menu_radio_list(self.config.get("ratios"), self.ratio_clicked, self.get_torrent_desired_ratio(), None, True, _("_Not Set"), 1)
self.ratio_menuitem.set_submenu(self.ratio_menu) self.ratio_menuitem.set_submenu(self.ratio_menu)
self.interface.torrent_menu.append(self.ratio_menuitem) self.interface.torrent_menu.append(self.ratio_menuitem)
self.ratio_menuitem.show_all() self.ratio_menuitem.show_all()
def torrent_menu_hide(self, widget): def torrent_menu_hide(self, widget):
try: try:
self.interface.torrent_menu.remove(self.ratio_menuitem) self.interface.torrent_menu.remove(self.ratio_menuitem)
except AttributeError: except AttributeError:
pass pass
def update(self): def update(self):
pass pass
def unload(self): def unload(self):
# Disconnect all callbacks # Disconnect all callbacks
for callback_id in self.callback_ids: for callback_id in self.callback_ids:
self.interface.torrent_menu.disconnect(callback_id) self.interface.torrent_menu.disconnect(callback_id)
self.callback_ids = [] self.callback_ids = []
# Reset all desired ratios in the core # Reset all desired ratios in the core
for unique_ID, ratio in self.set_ratios.items(): for unique_ID, ratio in self.set_ratios.items():
if ratio >= 1: if ratio >= 1:
self.core.set_ratio(unique_ID, ratio) self.core.set_ratio(unique_ID, ratio)
self.set_ratios = {} self.set_ratios = {}
def ratio_clicked(self, widget): def ratio_clicked(self, widget):
value = widget.get_children()[0].get_text() value = widget.get_children()[0].get_text()
if value == _("Not Set"): if value == _("Not Set"):
value = -1 value = -1
if value == _("Other..."): if value == _("Other..."):
dialog_glade = gtk.glade.XML(deluge.common.get_glade_file("dgtkpopups.glade")) dialog_glade = gtk.glade.XML(deluge.common.get_glade_file("dgtkpopups.glade"))
speed_dialog = dialog_glade.get_widget("speed_dialog") speed_dialog = dialog_glade.get_widget("speed_dialog")
spin_speed = dialog_glade.get_widget("spin_speed") spin_speed = dialog_glade.get_widget("spin_speed")
spin_speed.set_value(self.get_torrent_desired_ratio()) spin_speed.set_value(self.get_torrent_desired_ratio())
spin_speed.set_increments(0.1, 1.0) spin_speed.set_increments(0.1, 1.0)
spin_speed.set_digits(1) spin_speed.set_digits(1)
spin_speed.set_range(1.0, 1000.0) spin_speed.set_range(1.0, 1000.0)
spin_speed.select_region(0, -1) spin_speed.select_region(0, -1)
response = speed_dialog.run() response = speed_dialog.run()
if response == 1: # OK Response if response == 1: # OK Response
value = spin_speed.get_value() value = spin_speed.get_value()
else: else:
speed_dialog.destroy() speed_dialog.destroy()
return return
speed_dialog.destroy() speed_dialog.destroy()
value = float(value) # Make sure the value is a float value = float(value) # Make sure the value is a float
# Set the ratio in the core and remember the setting # Set the ratio in the core and remember the setting
self.core.set_ratio(self.unique_ID, value) self.core.set_ratio(self.unique_ID, value)
self.set_ratios[self.unique_ID] = value self.set_ratios[self.unique_ID] = value
# Update the ratios list if necessary # Update the ratios list if necessary
if value not in self.config.get("ratios") and value >= 1: if value not in self.config.get("ratios") and value >= 1:
self.config.get("ratios").insert(0, value) self.config.get("ratios").insert(0, value)
self.config.get("ratios").pop() self.config.get("ratios").pop()
def get_torrent_desired_ratio(self): def get_torrent_desired_ratio(self):
if self.set_ratios.has_key(self.unique_ID): if self.set_ratios.has_key(self.unique_ID):
return self.set_ratios[self.unique_ID] return self.set_ratios[self.unique_ID]
else: else:
return -1 return -1

View file

@ -4,89 +4,89 @@ import deluge.common, deluge.pref, gtk, gtk.glade
# This plugin is intended to be used with Deluge's default GTK interface # This plugin is intended to be used with Deluge's default GTK interface
class plugin_Example: # The plugin's class class plugin_Example: # The plugin's class
## Your plugin's contructor should follow this format ## Your plugin's contructor should follow this format
## path = A string containing the path to the plugin ## path = A string containing the path to the plugin
## deluge_core = The active instance of the Deluge Manager ## deluge_core = The active instance of the Deluge Manager
## deluge_interface = The active instance of the Deluge Interface ## deluge_interface = The active instance of the Deluge Interface
def __init__(self, path, deluge_core, deluge_interface): def __init__(self, path, deluge_core, deluge_interface):
# Save the path, interface, and core so they can be used later # Save the path, interface, and core so they can be used later
self.path = path self.path = path
self.core = deluge_core self.core = deluge_core
self.interface = deluge_interface self.interface = deluge_interface
# Create an options file and try to load existing Values # Create an options file and try to load existing Values
self.config_file = deluge.common.CONFIG_DIR + "/example.conf" self.config_file = deluge.common.CONFIG_DIR + "/example.conf"
self.config = deluge.pref.Preferences() self.config = deluge.pref.Preferences()
try: try:
self.config.load(self.config_file) self.config.load(self.config_file)
except IOError: except IOError:
# File does not exist # File does not exist
pass pass
# Extract the configuration dialog from the gladefile # Extract the configuration dialog from the gladefile
self.glade = gtk.glade.XML(path + "/example.glade") self.glade = gtk.glade.XML(path + "/example.glade")
self.dialog = self.glade.get_widget("dialog") self.dialog = self.glade.get_widget("dialog")
self.dialog.set_icon_from_file(self.path + "/example-plugin.png") self.dialog.set_icon_from_file(self.path + "/example-plugin.png")
# Access the interface's toolbar # Access the interface's toolbar
self.toolbar = self.interface.toolbar self.toolbar = self.interface.toolbar
# Make a toolbar button # Make a toolbar button
icon = gtk.Image() icon = gtk.Image()
icon.set_from_file(self.path + "/example-plugin.png") # Toolbar items should be 22x22 pixel images icon.set_from_file(self.path + "/example-plugin.png") # Toolbar items should be 22x22 pixel images
self.button = gtk.ToolButton(icon_widget=icon, label="Example Plugin") self.button = gtk.ToolButton(icon_widget=icon, label="Example Plugin")
self.button.connect("clicked", self.clicked) # Connect the signal handler for the button self.button.connect("clicked", self.clicked) # Connect the signal handler for the button
self.toolbar.add(self.button) # Add button to toolbar self.toolbar.add(self.button) # Add button to toolbar
self.button.show_all() # Show the button self.button.show_all() # Show the button
## unload is called when the plugin is removed or Deluge is shut down ## unload is called when the plugin is removed or Deluge is shut down
def unload(self): def unload(self):
self.toolbar.remove(self.button) # Remove the button from the toolbar self.toolbar.remove(self.button) # Remove the button from the toolbar
self.config.save(self.config_file) self.config.save(self.config_file)
## update will be called every UPDATE_INTERVAL (usually about 1 second) ## update will be called every UPDATE_INTERVAL (usually about 1 second)
def update(self): def update(self):
# As this plugin doesn't need to do anything every interval, this # As this plugin doesn't need to do anything every interval, this
# function will remain empty # function will remain empty
pass pass
## This will be only called if your plugin is configurable ## This will be only called if your plugin is configurable
def configure(self): def configure(self):
entry1 = self.glade.get_widget("entry1") entry1 = self.glade.get_widget("entry1")
entry2 = self.glade.get_widget("entry2") entry2 = self.glade.get_widget("entry2")
try: try:
entry1.set_text(self.config.get("option1")) entry1.set_text(self.config.get("option1"))
entry2.set_text(self.config.get("option2")) entry2.set_text(self.config.get("option2"))
except: except:
entry1.set_text("") entry1.set_text("")
entry2.set_text("") entry2.set_text("")
self.dialog.show() self.dialog.show()
response = self.dialog.run() response = self.dialog.run()
self.dialog.hide() self.dialog.hide()
if response: if response:
self.config.set("option1", entry1.get_text()) self.config.set("option1", entry1.get_text())
self.config.set("option2", entry2.get_text()) self.config.set("option2", entry2.get_text())
## This will be called whenever self.button is clicked ## This will be called whenever self.button is clicked
def clicked(self, button): def clicked(self, button):
# Build a dialog from scratch rather than from a glade file # Build a dialog from scratch rather than from a glade file
dialog = gtk.Dialog(title="Example Plugin", parent=self.interface.window, dialog = gtk.Dialog(title="Example Plugin", parent=self.interface.window,
buttons=(gtk.STOCK_OK, 0)) buttons=(gtk.STOCK_OK, 0))
dialog.set_icon_from_file(self.path + "/example-plugin.png") dialog.set_icon_from_file(self.path + "/example-plugin.png")
try: try:
text = "This is a popup notification from Example Plugin\n" + \ text = "This is a popup notification from Example Plugin\n" + \
"Your value for option1 is %s\n"%self.config.get("option1") + \ "Your value for option1 is %s\n"%self.config.get("option1") + \
"and option2 is %s"%self.config.get("option2") "and option2 is %s"%self.config.get("option2")
except KeyError: except KeyError:
text = "This is a popup notification from Example Plugin\n" + \ text = "This is a popup notification from Example Plugin\n" + \
"If you had set options by configuring this plugin,\n" + \ "If you had set options by configuring this plugin,\n" + \
"they would appear here" "they would appear here"
label = gtk.Label(text) label = gtk.Label(text)
dialog.vbox.pack_start(label) dialog.vbox.pack_start(label)
dialog.show_all() dialog.show_all()
dialog.run() dialog.run()
dialog.hide() dialog.hide()
dialog.destroy() dialog.destroy()

View file

@ -15,15 +15,15 @@ def enable(core, interface):
class plugin_Hello: class plugin_Hello:
def __init__(self, path, deluge_core, deluge_interface): def __init__(self, path, deluge_core, deluge_interface):
self.path = path self.path = path
self.core = deluge_core self.core = deluge_core
self.interface = deluge_interface self.interface = deluge_interface
def unload(self): def unload(self):
pass pass
def update(self): def update(self):
print "Hello, World!" print "Hello, World!"

View file

@ -1,157 +1,157 @@
# netgraph plugin # netgraph plugin
class plugin_NetGraph: class plugin_NetGraph:
def __init__(self, path, deluge_core, deluge_interface): def __init__(self, path, deluge_core, deluge_interface):
import gtk import gtk
self.parent = deluge_interface self.parent = deluge_interface
self.location = path self.location = path
self.core = deluge_core self.core = deluge_core
self.image = gtk.Image() self.image = gtk.Image()
self.viewPort = gtk.Viewport() self.viewPort = gtk.Viewport()
self.viewPort.add(self.image) self.viewPort.add(self.image)
self.scrolledWindow = gtk.ScrolledWindow() self.scrolledWindow = gtk.ScrolledWindow()
self.scrolledWindow.add(self.viewPort) self.scrolledWindow.add(self.viewPort)
self.scrolledWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrolledWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.topWidget = self.scrolledWindow self.topWidget = self.scrolledWindow
self.parentNotebook = self.parent.notebook self.parentNotebook = self.parent.notebook
# print "Parent NOTEBOOK:", self.parentNotebook # print "Parent NOTEBOOK:", self.parentNotebook
self.parentNotebook.append_page(self.topWidget, gtk.Label("Graph")) self.parentNotebook.append_page(self.topWidget, gtk.Label("Graph"))
# print "My INDEX in parentNoteBook:", self.index # print "My INDEX in parentNoteBook:", self.index
self.image.show() self.image.show()
self.viewPort.show() self.viewPort.show()
self.scrolledWindow.show() self.scrolledWindow.show()
self.length = 60 self.length = 60
self.width = -1 self.width = -1
self.height = -1 self.height = -1
import pango import pango
self.pangoContext = self.parent.window.get_pango_context() self.pangoContext = self.parent.window.get_pango_context()
self.pangoLayout = pango.Layout(self.pangoContext) self.pangoLayout = pango.Layout(self.pangoContext)
self.savedUpSpeeds = [] self.savedUpSpeeds = []
self.savedDownSpeeds = [] self.savedDownSpeeds = []
self.bootupRuns = 3 # This ensures that we pass the resizing phase, with scrollbars, etc. self.bootupRuns = 3 # This ensures that we pass the resizing phase, with scrollbars, etc.
# So the first time it is viewed, we are all ready # So the first time it is viewed, we are all ready
def unload(self): # Shutdown is called when the plugin is deactivated def unload(self): # Shutdown is called when the plugin is deactivated
numPages = self.parentNotebook.get_n_pages() numPages = self.parentNotebook.get_n_pages()
for page in range(numPages): for page in range(numPages):
if self.parentNotebook.get_nth_page(page) == self.topWidget: if self.parentNotebook.get_nth_page(page) == self.topWidget:
self.parentNotebook.remove_page(page) self.parentNotebook.remove_page(page)
break break
def update(self): def update(self):
import gtk import gtk
session_info = self.core.get_state() session_info = self.core.get_state()
self.savedUpSpeeds.insert(0, session_info['upload_rate']) self.savedUpSpeeds.insert(0, session_info['upload_rate'])
if len(self.savedUpSpeeds) > self.length: if len(self.savedUpSpeeds) > self.length:
self.savedUpSpeeds.pop() self.savedUpSpeeds.pop()
self.savedDownSpeeds.insert(0, session_info['download_rate']) self.savedDownSpeeds.insert(0, session_info['download_rate'])
if len(self.savedDownSpeeds) > self.length: if len(self.savedDownSpeeds) > self.length:
self.savedDownSpeeds.pop() self.savedDownSpeeds.pop()
if not self.parentNotebook.get_nth_page(self.parentNotebook.get_current_page()) == \ if not self.parentNotebook.get_nth_page(self.parentNotebook.get_current_page()) == \
self.topWidget and not self.bootupRuns > 0: self.topWidget and not self.bootupRuns > 0:
return return
self.bootupRuns = max(self.bootupRuns - 1, 0) self.bootupRuns = max(self.bootupRuns - 1, 0)
extraWidth = self.scrolledWindow.get_vscrollbar().get_allocation().width * 1.5 extraWidth = self.scrolledWindow.get_vscrollbar().get_allocation().width * 1.5
extraHeight = self.scrolledWindow.get_hscrollbar().get_allocation().height * 1.5 extraHeight = self.scrolledWindow.get_hscrollbar().get_allocation().height * 1.5
allocation = self.scrolledWindow.get_allocation() allocation = self.scrolledWindow.get_allocation()
allocation.width = int(allocation.width) - extraWidth allocation.width = int(allocation.width) - extraWidth
allocation.height = int(allocation.height) - extraHeight allocation.height = int(allocation.height) - extraHeight
# Don't try to allocate a size too small, or you might crash # Don't try to allocate a size too small, or you might crash
if allocation.width < 2 or allocation.height < 2: if allocation.width < 2 or allocation.height < 2:
return return
# savedDownSpeeds = [1,2,3,2,1] # savedDownSpeeds = [1,2,3,2,1]
# savedUpSpeeds = [5,8,0,0,1,2] # savedUpSpeeds = [5,8,0,0,1,2]
# allocation = self.image.get_allocation() # allocation = self.image.get_allocation()
# allocation.width = 300 # allocation.width = 300
# allocation.height = 200 # allocation.height = 200
if not allocation.width == self.width or not allocation.height == self.height: if not allocation.width == self.width or not allocation.height == self.height:
# print "New Pixmap!" # print "New Pixmap!"
self.width = allocation.width self.width = allocation.width
self.height = allocation.height self.height = allocation.height
self.networkPixmap = gtk.gdk.Pixmap(None, self.width, self.height, 24) self.networkPixmap = gtk.gdk.Pixmap(None, self.width, self.height, 24)
self.image.set_from_pixmap(self.networkPixmap, None) self.image.set_from_pixmap(self.networkPixmap, None)
self.ctx = self.networkPixmap.cairo_create() self.ctx = self.networkPixmap.cairo_create()
self.networkPixmap.draw_rectangle(self.image.get_style().white_gc,True, 0, 0, self.width, self.height) self.networkPixmap.draw_rectangle(self.image.get_style().white_gc,True, 0, 0, self.width, self.height)
maxSpeed = max(max(self.savedDownSpeeds),max(self.savedUpSpeeds)) maxSpeed = max(max(self.savedDownSpeeds),max(self.savedUpSpeeds))
if maxSpeed == 0: if maxSpeed == 0:
return return
maxSpeed = maxSpeed*1.1 # Give some extra room on top maxSpeed = maxSpeed*1.1 # Give some extra room on top
self.drawSpeedPoly(self.savedDownSpeeds, (0.5,1, 0.5, 1.0), maxSpeed, True) self.drawSpeedPoly(self.savedDownSpeeds, (0.5,1, 0.5, 1.0), maxSpeed, True)
self.drawSpeedPoly(self.savedDownSpeeds, (0, 0.75,0, 1.0), maxSpeed, False) self.drawSpeedPoly(self.savedDownSpeeds, (0, 0.75,0, 1.0), maxSpeed, False)
self.drawSpeedPoly(self.savedUpSpeeds, (0.33,0.33,1.0, 0.5), maxSpeed, True) self.drawSpeedPoly(self.savedUpSpeeds, (0.33,0.33,1.0, 0.5), maxSpeed, True)
self.drawSpeedPoly(self.savedUpSpeeds, (0, 0, 1.0, 0.75), maxSpeed, False) self.drawSpeedPoly(self.savedUpSpeeds, (0, 0, 1.0, 0.75), maxSpeed, False)
meanUpSpeed = sum(self.savedUpSpeeds) /len(self.savedUpSpeeds) meanUpSpeed = sum(self.savedUpSpeeds) /len(self.savedUpSpeeds)
meanDownSpeed = sum(self.savedDownSpeeds)/len(self.savedDownSpeeds) meanDownSpeed = sum(self.savedDownSpeeds)/len(self.savedDownSpeeds)
shownSpeed = max(meanUpSpeed, meanDownSpeed) shownSpeed = max(meanUpSpeed, meanDownSpeed)
import deluge.common import deluge.common
self.pangoLayout.set_text(deluge.common.fspeed(shownSpeed)) self.pangoLayout.set_text(deluge.common.fspeed(shownSpeed))
self.networkPixmap.draw_layout(self.image.get_style().black_gc, self.networkPixmap.draw_layout(self.image.get_style().black_gc,
4, 4,
int(self.height - 1 - (self.height*shownSpeed/maxSpeed)), int(self.height - 1 - (self.height*shownSpeed/maxSpeed)),
self.pangoLayout) self.pangoLayout)
self.networkPixmap.draw_line(self.image.get_style().black_gc, self.networkPixmap.draw_line(self.image.get_style().black_gc,
0, int(self.height - (self.height*shownSpeed/maxSpeed)), 0, int(self.height - (self.height*shownSpeed/maxSpeed)),
self.width, int(self.height - (self.height*shownSpeed/maxSpeed))) self.width, int(self.height - (self.height*shownSpeed/maxSpeed)))
self.networkPixmap.draw_rectangle(self.image.get_style().black_gc,False, 0, 0, self.width-1, self.height-1) self.networkPixmap.draw_rectangle(self.image.get_style().black_gc,False, 0, 0, self.width-1, self.height-1)
self.image.queue_draw() self.image.queue_draw()
def tracePath(self, speeds, maxSpeed): def tracePath(self, speeds, maxSpeed):
lineWidth = 4 lineWidth = 4
self.ctx.set_line_width(lineWidth) self.ctx.set_line_width(lineWidth)
self.ctx.move_to(self.width + lineWidth,self.height + lineWidth) self.ctx.move_to(self.width + lineWidth,self.height + lineWidth)
self.ctx.line_to(self.width + lineWidth,int(self.height-(self.height*speeds[0]/maxSpeed))) self.ctx.line_to(self.width + lineWidth,int(self.height-(self.height*speeds[0]/maxSpeed)))
for i in range(len(speeds)): for i in range(len(speeds)):
self.ctx.line_to(int(self.width-1-((i*self.width)/(self.length-1))), self.ctx.line_to(int(self.width-1-((i*self.width)/(self.length-1))),
int(self.height-1-(self.height*speeds[i]/maxSpeed))) int(self.height-1-(self.height*speeds[i]/maxSpeed)))
self.ctx.line_to(int(self.width-1-(((len(speeds)-1)*self.width)/(self.length-1))), self.ctx.line_to(int(self.width-1-(((len(speeds)-1)*self.width)/(self.length-1))),
int(self.height)-1 + lineWidth) int(self.height)-1 + lineWidth)
self.ctx.close_path() self.ctx.close_path()
def drawSpeedPoly(self, speeds, color, maxSpeed, fill): def drawSpeedPoly(self, speeds, color, maxSpeed, fill):
self.tracePath(speeds, maxSpeed) self.tracePath(speeds, maxSpeed)
self.ctx.set_source_rgba(color[0],color[1],color[2], color[3]) self.ctx.set_source_rgba(color[0],color[1],color[2], color[3])
if fill: if fill:
self.ctx.fill() self.ctx.fill()
else: else:
self.ctx.stroke() self.ctx.stroke()

View file

@ -1,24 +1,24 @@
class plugin_NetworkHealth: class plugin_NetworkHealth:
def __init__(self, path, deluge_core, deluge_interface): def __init__(self, path, deluge_core, deluge_interface):
self.parent = deluge_interface # Using this, you can access the Deluge client self.parent = deluge_interface # Using this, you can access the Deluge client
self.core = deluge_core self.core = deluge_core
self.location = path self.location = path
self.counter = 30 self.counter = 30
self.maxCount = self.counter self.maxCount = self.counter
def update(self): def update(self):
session_info = self.core.get_state() session_info = self.core.get_state()
if not session_info['has_incoming_connections'] and \ if not session_info['has_incoming_connections'] and \
session_info['num_peers'] > 1: session_info['num_peers'] > 1:
message = "[No incoming connections]" message = "[No incoming connections]"
self.counter = self.counter - 1 self.counter = self.counter - 1
if self.counter < 0: if self.counter < 0:
# self.parent.addMessage("No incoming connections: you may be behind a firewall or router. Perhaps you need to forward the relevant ports.", "W") # self.parent.addMessage("No incoming connections: you may be behind a firewall or router. Perhaps you need to forward the relevant ports.", "W")
self.counter = self.maxCount*2 self.counter = self.maxCount*2
self.maxCount = self.counter self.maxCount = self.counter
else: else:
message = "[Health: OK]" message = "[Health: OK]"
self.counter = self.maxCount self.counter = self.maxCount
self.parent.statusbar_temp_msg = self.parent.statusbar_temp_msg + ' ' + message self.parent.statusbar_temp_msg = self.parent.statusbar_temp_msg + ' ' + message

View file

@ -1,243 +1,243 @@
import deluge.common, deluge.pref, gtk, copy, pickle, time import deluge.common, deluge.pref, gtk, copy, pickle, time
class plugin_Scheduler: class plugin_Scheduler:
def __init__(self, path, deluge_core, deluge_interface): def __init__(self, path, deluge_core, deluge_interface):
self.path = path self.path = path
self.core = deluge_core self.core = deluge_core
self.interface = deluge_interface self.interface = deluge_interface
self.days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] self.days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
self.conf_file = deluge.common.CONFIG_DIR + "/scheduler.conf" self.conf_file = deluge.common.CONFIG_DIR + "/scheduler.conf"
self.config = deluge.pref.Preferences() self.config = deluge.pref.Preferences()
self.button_state_temp = [[0] * 7 for dummy in xrange(24)] self.button_state_temp = [[0] * 7 for dummy in xrange(24)]
self.status = -1 self.status = -1
#Load config #Load config
try: try:
reader = open(self.conf_file, "rb") reader = open(self.conf_file, "rb")
data = pickle.load(reader) data = pickle.load(reader)
self.button_state = data[0] self.button_state = data[0]
self.dllimit = float(data[1][0]) self.dllimit = float(data[1][0])
self.ullimit = float(data[1][1]) self.ullimit = float(data[1][1])
reader.close() reader.close()
except: except:
self.button_state = [[0] * 7 for dummy in xrange(24)] self.button_state = [[0] * 7 for dummy in xrange(24)]
self.dllimit = float(-1) self.dllimit = float(-1)
self.ullimit = float(-1) self.ullimit = float(-1)
def unload(self): def unload(self):
self.resume() self.resume()
self.unlimit() self.unlimit()
def update(self): def update(self):
time_now = time.localtime(time.time()) time_now = time.localtime(time.time())
if self.status is not self.button_state[time_now[3]][time_now[6]]: if self.status is not self.button_state[time_now[3]][time_now[6]]:
self.status = self.button_state[time_now[3]][time_now[6]] self.status = self.button_state[time_now[3]][time_now[6]]
if self.status == 0: if self.status == 0:
self.resume() self.resume()
self.unlimit() self.unlimit()
elif self.status == 1: elif self.status == 1:
self.resume() self.resume()
elif self.status == 2: elif self.status == 2:
self.pause() self.pause()
if self.status == 1: if self.status == 1:
self.limit() self.limit()
def pause(self): def pause(self):
self.config.set("max_active_torrents", 0) self.config.set("max_active_torrents", 0)
self.core.apply_queue() self.core.apply_queue()
def resume(self): def resume(self):
self.config.set("max_active_torrents", -1) self.config.set("max_active_torrents", -1)
self.core.apply_queue() self.core.apply_queue()
def limit(self): def limit(self):
self.config.set("max_download_speed", float(self.dllimit)) self.config.set("max_download_speed", float(self.dllimit))
self.config.set("max_upload_speed", float(self.ullimit)) self.config.set("max_upload_speed", float(self.ullimit))
def unlimit(self): def unlimit(self):
self.interface.apply_prefs() self.interface.apply_prefs()
#Configuration dialog #Configuration dialog
def configure(self): def configure(self):
global scheduler_select global scheduler_select
self.button_state_temp = copy.deepcopy(self.button_state) self.button_state_temp = copy.deepcopy(self.button_state)
#dialog #dialog
dialog = gtk.Dialog("Scheduler Settings") dialog = gtk.Dialog("Scheduler Settings")
dialog.set_default_size(600, 270) dialog.set_default_size(600, 270)
#buttons #buttons
cancel_button = dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) cancel_button = dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
ok_button = dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK) ok_button = dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
#text #text
hover_text = gtk.Label() hover_text = gtk.Label()
dllimit_label = gtk.Label("Limit download to:") dllimit_label = gtk.Label("Limit download to:")
ullimit_label = gtk.Label("Limit upload to:") ullimit_label = gtk.Label("Limit upload to:")
#Select Widget #Select Widget
drawing = scheduler_select(self.button_state_temp, hover_text, self.days) drawing = scheduler_select(self.button_state_temp, hover_text, self.days)
#boxes #boxes
vbox_main = gtk.VBox() vbox_main = gtk.VBox()
hbox_main = gtk.HBox() hbox_main = gtk.HBox()
vbox_sub = gtk.VBox() vbox_sub = gtk.VBox()
hbox_limit = gtk.HBox() hbox_limit = gtk.HBox()
#seperator #seperator
sep = gtk.HSeparator() sep = gtk.HSeparator()
#spinbuttons #spinbuttons
dlinput = gtk.SpinButton() dlinput = gtk.SpinButton()
dlinput.set_numeric(True) dlinput.set_numeric(True)
dlinput.set_range(-1, 2048) dlinput.set_range(-1, 2048)
dlinput.set_increments(1, 10) dlinput.set_increments(1, 10)
dlinput.set_value(float(self.dllimit)) dlinput.set_value(float(self.dllimit))
ulinput = gtk.SpinButton() ulinput = gtk.SpinButton()
ulinput.set_numeric(True) ulinput.set_numeric(True)
ulinput.set_range(-1, 1024) ulinput.set_range(-1, 1024)
ulinput.set_increments(1, 10) ulinput.set_increments(1, 10)
ulinput.set_value(float(self.ullimit)) ulinput.set_value(float(self.ullimit))
#pack #pack
dialog.vbox.pack_start(vbox_main) dialog.vbox.pack_start(vbox_main)
vbox_main.pack_start(hbox_main) vbox_main.pack_start(hbox_main)
vbox_main.pack_start(hover_text, False, True, 5) vbox_main.pack_start(hover_text, False, True, 5)
vbox_main.pack_start(sep, False, True) vbox_main.pack_start(sep, False, True)
vbox_main.pack_start(hbox_limit, False, True, 5) vbox_main.pack_start(hbox_limit, False, True, 5)
hbox_main.pack_start(vbox_sub, False, True, 5) hbox_main.pack_start(vbox_sub, False, True, 5)
hbox_main.pack_start(drawing) hbox_main.pack_start(drawing)
hbox_limit.pack_start(dllimit_label, True, False) hbox_limit.pack_start(dllimit_label, True, False)
hbox_limit.pack_start(dlinput, True, False) hbox_limit.pack_start(dlinput, True, False)
hbox_limit.pack_start(ullimit_label, True, False) hbox_limit.pack_start(ullimit_label, True, False)
hbox_limit.pack_start(ulinput, True, False) hbox_limit.pack_start(ulinput, True, False)
for index in xrange(len(self.days)): for index in xrange(len(self.days)):
vbox_sub.pack_start(gtk.Label(self.days[index])) vbox_sub.pack_start(gtk.Label(self.days[index]))
#show #show
dialog.show_all() dialog.show_all()
#Save config #Save config
if dialog.run() == -5: if dialog.run() == -5:
self.status = -1 self.status = -1
self.button_state = copy.deepcopy(drawing.button_state) self.button_state = copy.deepcopy(drawing.button_state)
self.dllimit = float(dlinput.get_value()) self.dllimit = float(dlinput.get_value())
self.ullimit = float(ulinput.get_value()) self.ullimit = float(ulinput.get_value())
self.interface.apply_prefs() self.interface.apply_prefs()
writer = open(self.conf_file, "wb") writer = open(self.conf_file, "wb")
pickle.dump([drawing.button_state,[self.dllimit,self.ullimit]], writer) pickle.dump([drawing.button_state,[self.dllimit,self.ullimit]], writer)
writer.close() writer.close()
dialog.destroy() dialog.destroy()
class scheduler_select(gtk.DrawingArea): class scheduler_select(gtk.DrawingArea):
#connect signals - varaibles #connect signals - varaibles
def __init__(self, data, label, days): def __init__(self, data, label, days):
gtk.DrawingArea.__init__(self) gtk.DrawingArea.__init__(self)
self.set_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.LEAVE_NOTIFY_MASK) self.set_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.LEAVE_NOTIFY_MASK)
self.connect("expose_event", self.expose) self.connect("expose_event", self.expose)
self.connect("button_press_event", self.mouse_down) self.connect("button_press_event", self.mouse_down)
self.connect("button_release_event", self.mouse_up) self.connect("button_release_event", self.mouse_up)
self.connect("motion_notify_event", self.mouse_hover) self.connect("motion_notify_event", self.mouse_hover)
self.connect("leave_notify_event", self.mouse_leave) self.connect("leave_notify_event", self.mouse_leave)
self.colors = [[115.0/255, 210.0/255, 22.0/255], [237.0/255, 212.0/255, 0.0/255], [204.0/255, 0.0/255, 0.0/255]] self.colors = [[115.0/255, 210.0/255, 22.0/255], [237.0/255, 212.0/255, 0.0/255], [204.0/255, 0.0/255, 0.0/255]]
self.button_state = data self.button_state = data
self.button_state_temp = [[0] * 7 for dummy in xrange(24)] self.button_state_temp = [[0] * 7 for dummy in xrange(24)]
self.start_point = [0,0] self.start_point = [0,0]
self.hover_point = [-1,-1] self.hover_point = [-1,-1]
self.hover_label = label self.hover_label = label
self.hover_days = days self.hover_days = days
self.mouse_press = False self.mouse_press = False
#redraw the whole thing #redraw the whole thing
def expose(self, widget, event): def expose(self, widget, event):
self.context = self.window.cairo_create() self.context = self.window.cairo_create()
self.context.rectangle(event.area.x, event.area.y, event.area.width, event.area.height) self.context.rectangle(event.area.x, event.area.y, event.area.width, event.area.height)
self.context.clip() self.context.clip()
width = self.window.get_size()[0] width = self.window.get_size()[0]
height = self.window.get_size()[1] height = self.window.get_size()[1]
for y in xrange(7): for y in xrange(7):
for x in xrange(24): for x in xrange(24):
self.context.set_source_rgba(self.colors[self.button_state[x][y]][0], self.colors[self.button_state[x][y]][1], self.colors[self.button_state[x][y]][2], 0.7) self.context.set_source_rgba(self.colors[self.button_state[x][y]][0], self.colors[self.button_state[x][y]][1], self.colors[self.button_state[x][y]][2], 0.7)
self.context.rectangle(width*(6*x/145.0+1/145.0), height*(6*y/43.0+1/43.0), 5*width/145.0, 5*height/43.0) self.context.rectangle(width*(6*x/145.0+1/145.0), height*(6*y/43.0+1/43.0), 5*width/145.0, 5*height/43.0)
self.context.fill_preserve() self.context.fill_preserve()
self.context.set_source_rgba(0.5, 0.5, 0.5, 0.5) self.context.set_source_rgba(0.5, 0.5, 0.5, 0.5)
self.context.stroke() self.context.stroke()
#coordinates --> which box #coordinates --> which box
def get_point(self, event): def get_point(self, event):
size = self.window.get_size() size = self.window.get_size()
x = int((event.x-size[0]*0.5/145.0)/(6*size[0]/145.0)) x = int((event.x-size[0]*0.5/145.0)/(6*size[0]/145.0))
y = int((event.y-size[1]*0.5/43.0)/(6*size[1]/43.0)) y = int((event.y-size[1]*0.5/43.0)/(6*size[1]/43.0))
if x > 23: x = 23 if x > 23: x = 23
elif x < 0: x = 0 elif x < 0: x = 0
if y > 6: y = 6 if y > 6: y = 6
elif y < 0: y = 0 elif y < 0: y = 0
return [x,y] return [x,y]
#mouse down #mouse down
def mouse_down(self, widget, event): def mouse_down(self, widget, event):
self.mouse_press = True self.mouse_press = True
self.start_point = self.get_point(event) self.start_point = self.get_point(event)
self.button_state_temp = copy.deepcopy(self.button_state) self.button_state_temp = copy.deepcopy(self.button_state)
#if the same box -> change it #if the same box -> change it
def mouse_up(self, widget, event): def mouse_up(self, widget, event):
self.mouse_press = False self.mouse_press = False
end_point = self.get_point(event) end_point = self.get_point(event)
#change color on mouseclick depending on the button #change color on mouseclick depending on the button
if end_point[0] is self.start_point[0] and end_point[1] is self.start_point[1]: if end_point[0] is self.start_point[0] and end_point[1] is self.start_point[1]:
if event.button == 1: if event.button == 1:
self.button_state[end_point[0]][end_point[1]] += 1 self.button_state[end_point[0]][end_point[1]] += 1
if self.button_state[end_point[0]][end_point[1]] > 2: if self.button_state[end_point[0]][end_point[1]] > 2:
self.button_state[end_point[0]][end_point[1]] = 0 self.button_state[end_point[0]][end_point[1]] = 0
elif event.button == 3: elif event.button == 3:
self.button_state[end_point[0]][end_point[1]] -= 1 self.button_state[end_point[0]][end_point[1]] -= 1
if self.button_state[end_point[0]][end_point[1]] < 0: if self.button_state[end_point[0]][end_point[1]] < 0:
self.button_state[end_point[0]][end_point[1]] = 2 self.button_state[end_point[0]][end_point[1]] = 2
self.queue_draw() self.queue_draw()
#if box changed and mouse is pressed draw all boxes from start point to end point #if box changed and mouse is pressed draw all boxes from start point to end point
#set hover text etc.. #set hover text etc..
def mouse_hover(self, widget, event): def mouse_hover(self, widget, event):
if self.get_point(event) != self.hover_point: if self.get_point(event) != self.hover_point:
self.hover_point = self.get_point(event) self.hover_point = self.get_point(event)
self.hover_label.set_text(self.hover_days[self.hover_point[1]] + " " + str(self.hover_point[0]) + ":00 - " + str(self.hover_point[0]) + ":59") self.hover_label.set_text(self.hover_days[self.hover_point[1]] + " " + str(self.hover_point[0]) + ":00 - " + str(self.hover_point[0]) + ":59")
if self.mouse_press == True: if self.mouse_press == True:
self.button_state = copy.deepcopy(self.button_state_temp) self.button_state = copy.deepcopy(self.button_state_temp)
points = [[self.hover_point[0], self.start_point[0]], [self.hover_point[1], self.start_point[1]]] points = [[self.hover_point[0], self.start_point[0]], [self.hover_point[1], self.start_point[1]]]
for x in xrange(min(points[0]), max(points[0])+1): for x in xrange(min(points[0]), max(points[0])+1):
for y in xrange(min(points[1]), max(points[1])+1): for y in xrange(min(points[1]), max(points[1])+1):
self.button_state[x][y] = self.button_state[self.start_point[0]][self.start_point[1]] self.button_state[x][y] = self.button_state[self.start_point[0]][self.start_point[1]]
self.queue_draw() self.queue_draw()
#clear hover text on mouse leave #clear hover text on mouse leave
def mouse_leave(self, widget, event): def mouse_leave(self, widget, event):
self.hover_label.set_text("") self.hover_label.set_text("")
self.hover_point = [-1,-1] self.hover_point = [-1,-1]

View file

@ -1,156 +1,156 @@
class plugin_Search: class plugin_Search:
def __init__(self, path, deluge_core, deluge_interface): def __init__(self, path, deluge_core, deluge_interface):
import gtk, gtk.glade, os import gtk, gtk.glade, os
import deluge.common, deluge.dgtk, deluge.pref import deluge.common, deluge.dgtk, deluge.pref
self.core = deluge_core self.core = deluge_core
self.interface = deluge_interface self.interface = deluge_interface
self.conf_file = deluge.common.CONFIG_DIR + "/search.conf" self.conf_file = deluge.common.CONFIG_DIR + "/search.conf"
if not os.path.isfile(self.conf_file): if not os.path.isfile(self.conf_file):
f = open(self.conf_file, mode='w') f = open(self.conf_file, mode='w')
f.flush() f.flush()
f.close() f.close()
glade = gtk.glade.XML(path + "/searchdlg.glade") glade = gtk.glade.XML(path + "/searchdlg.glade")
self.dlg = glade.get_widget("search_dialog") self.dlg = glade.get_widget("search_dialog")
self.dlg.set_icon_from_file(deluge.common.get_pixmap("deluge32.png")) self.dlg.set_icon_from_file(deluge.common.get_pixmap("deluge32.png"))
self.view = glade.get_widget("search_view") self.view = glade.get_widget("search_view")
model = gtk.ListStore(str, str) model = gtk.ListStore(str, str)
self.view.set_model(model) self.view.set_model(model)
deluge.dgtk.add_text_column(self.view, "Name", 0) deluge.dgtk.add_text_column(self.view, "Name", 0)
deluge.dgtk.add_text_column(self.view, "Search String", 1) deluge.dgtk.add_text_column(self.view, "Search String", 1)
self.field_name = glade.get_widget("field_name") self.field_name = glade.get_widget("field_name")
self.field_search = glade.get_widget("field_search") self.field_search = glade.get_widget("field_search")
self.button_add = glade.get_widget("button_addsearch") self.button_add = glade.get_widget("button_addsearch")
self.button_del = glade.get_widget("button_delsearch") self.button_del = glade.get_widget("button_delsearch")
dic = { "add_clicked" : self.add_clicked, dic = { "add_clicked" : self.add_clicked,
"del_clicked" : self.del_clicked, "del_clicked" : self.del_clicked,
"row_clicked" : self.row_clicked, "row_clicked" : self.row_clicked,
"text_changed" : self.text_changed } "text_changed" : self.text_changed }
glade.signal_autoconnect(dic) glade.signal_autoconnect(dic)
self.view.get_selection().set_select_function(self.row_clicked) self.view.get_selection().set_select_function(self.row_clicked)
### Note: All other plugins should use self.interface.toolbar ### Note: All other plugins should use self.interface.toolbar
### when adding items to the toolbar ### when adding items to the toolbar
self.se = '' self.se = ''
self.toolbar = self.interface.wtree.get_widget("tb_right") self.toolbar = self.interface.wtree.get_widget("tb_right")
self.engines = deluge.pref.Preferences(self.conf_file, False) self.engines = deluge.pref.Preferences(self.conf_file, False)
self.search_entry = gtk.Entry() self.search_entry = gtk.Entry()
self.search_entry.connect("activate", self.torrent_search) self.search_entry.connect("activate", self.torrent_search)
self.search_item = gtk.ToolItem() self.search_item = gtk.ToolItem()
self.search_item.add(self.search_entry) self.search_item.add(self.search_entry)
self.search_icon = gtk.Image() self.search_icon = gtk.Image()
self.search_icon.set_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_MENU) self.search_icon.set_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_MENU)
self.menu_button = gtk.MenuToolButton(self.search_icon, "Choose an Engine") self.menu_button = gtk.MenuToolButton(self.search_icon, "Choose an Engine")
self.menu_button.set_is_important(True) self.menu_button.set_is_important(True)
self.menu_button.connect("clicked", self.torrent_search) self.menu_button.connect("clicked", self.torrent_search)
self.menu = gtk.Menu() self.menu = gtk.Menu()
self.manage_item = gtk.ImageMenuItem("Manage Engines") self.manage_item = gtk.ImageMenuItem("Manage Engines")
self.image = gtk.Image() self.image = gtk.Image()
self.image.set_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU) self.image.set_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU)
self.manage_item.set_image(self.image) self.manage_item.set_image(self.image)
self.manage_item.connect("activate", self.configure) self.manage_item.connect("activate", self.configure)
self.menu.add(self.manage_item) self.menu.add(self.manage_item)
self.menu_button.set_menu(self.menu) self.menu_button.set_menu(self.menu)
self.toolbar.insert(self.search_item, -1) self.toolbar.insert(self.search_item, -1)
self.toolbar.insert(self.menu_button, -1) self.toolbar.insert(self.menu_button, -1)
self.populate_search_menu() self.populate_search_menu()
self.toolbar.show_all() self.toolbar.show_all()
self.search_item.show_all() self.search_item.show_all()
self.menu_button.show_all() self.menu_button.show_all()
self.menu.show_all() self.menu.show_all()
def unload(self): def unload(self):
self.engines.save(self.conf_file) self.engines.save(self.conf_file)
self.toolbar.remove(self.search_item) self.toolbar.remove(self.search_item)
self.toolbar.remove(self.menu_button) self.toolbar.remove(self.menu_button)
def text_changed(self, args): def text_changed(self, args):
a = (self.field_name.get_text() != "") a = (self.field_name.get_text() != "")
b = (self.field_search.get_text() != "") b = (self.field_search.get_text() != "")
if(a and b): if(a and b):
self.button_add.set_sensitive(1) self.button_add.set_sensitive(1)
else: else:
self.button_add.set_sensitive(0) self.button_add.set_sensitive(0)
def add_clicked(self, args): def add_clicked(self, args):
self.view.get_model().append([self.field_name.get_text(), self.view.get_model().append([self.field_name.get_text(),
self.field_search.get_text()]) self.field_search.get_text()])
self.field_name.set_text("") self.field_name.set_text("")
self.field_search.set_text("") self.field_search.set_text("")
def del_clicked(self, args): def del_clicked(self, args):
(model, selection) = self.view.get_selection().get_selected() (model, selection) = self.view.get_selection().get_selected()
model.remove(selection) model.remove(selection)
self.button_del.set_sensitive(0) self.button_del.set_sensitive(0)
def row_clicked(self, args): def row_clicked(self, args):
self.button_del.set_sensitive(1) self.button_del.set_sensitive(1)
return True return True
def configure(self, widget=None): def configure(self, widget=None):
import gtk, gtk.glade import gtk, gtk.glade
from deluge import common from deluge import common
self.dlg.show_all() self.dlg.show_all()
model = self.view.get_model() model = self.view.get_model()
model.clear() model.clear()
for name in self.engines.keys(): for name in self.engines.keys():
self.view.get_model().append( (name, self.engines.get(name)) ) self.view.get_model().append( (name, self.engines.get(name)) )
self.button_add.set_sensitive(0) self.button_add.set_sensitive(0)
self.button_del.set_sensitive(0) self.button_del.set_sensitive(0)
result = self.dlg.run() result = self.dlg.run()
self.dlg.hide_all() self.dlg.hide_all()
if result == 1: if result == 1:
self.engines.clear() self.engines.clear()
the_iter = model.get_iter_first() the_iter = model.get_iter_first()
while the_iter is not None: while the_iter is not None:
self.engines.set(model.get_value(the_iter, 0), model.get_value(the_iter, 1)) self.engines.set(model.get_value(the_iter, 0), model.get_value(the_iter, 1))
the_iter = model.iter_next(the_iter) the_iter = model.iter_next(the_iter)
self.engines.save(self.conf_file) self.engines.save(self.conf_file)
self.populate_search_menu() self.populate_search_menu()
def update(self): def update(self):
pass pass
def torrent_search(self, widget=None): def torrent_search(self, widget=None):
from deluge import common from deluge import common
print "Searching with engine", self.se print "Searching with engine", self.se
url = self.engines.get(self.se) url = self.engines.get(self.se)
entry = self.search_entry.get_text() entry = self.search_entry.get_text()
print 'URL =', url print 'URL =', url
print 'Entry =', entry print 'Entry =', entry
entry = entry.replace(' ', '+') entry = entry.replace(' ', '+')
print 'URL =', url print 'URL =', url
print 'Entry =', entry print 'Entry =', entry
url = url.replace('${query}', entry) url = url.replace('${query}', entry)
print 'URL =', url print 'URL =', url
print 'Entry =', entry print 'Entry =', entry
common.open_url_in_browser(None, url) common.open_url_in_browser(None, url)
def populate_search_menu(self): def populate_search_menu(self):
import gtk import gtk
self.menu_button.set_label("Choose an Engine") self.menu_button.set_label("Choose an Engine")
for child in self.menu.get_children(): for child in self.menu.get_children():
self.menu.remove(child) self.menu.remove(child)
group = None group = None
i = 0 i = 0
for engine in self.engines.keys(): for engine in self.engines.keys():
rmi = gtk.RadioMenuItem(None, engine) rmi = gtk.RadioMenuItem(None, engine)
rmi.eng_name = engine rmi.eng_name = engine
rmi.connect("activate", self.select_search, rmi.eng_name) rmi.connect("activate", self.select_search, rmi.eng_name)
if (group != None): if (group != None):
rmi.set_group(group) rmi.set_group(group)
else: else:
group = rmi group = rmi
rmi.set_active(1) rmi.set_active(1)
self.menu.insert(rmi, i) self.menu.insert(rmi, i)
i = i + 1 i = i + 1
rmi.show() rmi.show()
self.menu.insert(self.manage_item, i) self.menu.insert(self.manage_item, i)
self.menu.show() self.menu.show()
def select_search(self, menuitem, engine_string): def select_search(self, menuitem, engine_string):
self.menu_button.set_label("Search " + engine_string) self.menu_button.set_label("Search " + engine_string)
self.se = engine_string self.se = engine_string

File diff suppressed because it is too large Load diff

View file

@ -20,9 +20,9 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with deluge. If not, write to: # along with deluge. If not, write to:
# The Free Software Foundation, Inc., # The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor # 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA. # Boston, MA 02110-1301, USA.
# #
# In addition, as a special exception, the copyright holders give # In addition, as a special exception, the copyright holders give
# permission to link the code of portions of this program with the OpenSSL # permission to link the code of portions of this program with the OpenSSL
@ -40,67 +40,67 @@ import os, os.path
import gettext, locale import gettext, locale
import deluge, deluge.common, deluge.interface import deluge, deluge.common, deluge.interface
try: try:
import dbus import dbus
dbus_version = getattr(dbus, 'version', (0,0,0)) dbus_version = getattr(dbus, 'version', (0,0,0))
if dbus_version >= (0,41,0) and dbus_version < (0,80,0): if dbus_version >= (0,41,0) and dbus_version < (0,80,0):
import dbus.glib import dbus.glib
elif dbus_version >= (0,80,0): elif dbus_version >= (0,80,0):
from dbus.mainloop.glib import DBusGMainLoop from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True) DBusGMainLoop(set_as_default=True)
else: else:
pass pass
except: dbus_imported = False except: dbus_imported = False
else: dbus_imported = True else: dbus_imported = True
parser = OptionParser(usage="%prog [options] [actions]", version=deluge.common.PROGRAM_VERSION) parser = OptionParser(usage="%prog [options] [actions]", version=deluge.common.PROGRAM_VERSION)
parser.add_option("--tray", dest="tray", help="start Deluge hidden in system tray", parser.add_option("--tray", dest="tray", help="start Deluge hidden in system tray",
metavar="TRAY", action="store_true") metavar="TRAY", action="store_true")
parser.add_option("--url", dest="url", help="Load a torrent from a URL", parser.add_option("--url", dest="url", help="Load a torrent from a URL",
metavar="URL", action="store") metavar="URL", action="store")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
def start_deluge(): def start_deluge():
print "Starting new Deluge session..." print "Starting new Deluge session..."
interface = deluge.interface.DelugeGTK() interface = deluge.interface.DelugeGTK()
add_args(interface) add_args(interface)
interface.start(options.tray) interface.start(options.tray)
def add_args(interface): def add_args(interface):
if options.url: if options.url:
interface.external_add_url(options.url) interface.external_add_url(options.url)
else: else:
for arg in args: for arg in args:
apath = os.path.abspath(arg) apath = os.path.abspath(arg)
if apath.endswith(".torrent"): if apath.endswith(".torrent"):
interface.external_add_torrent(apath) interface.external_add_torrent(apath)
else: else:
print "Error,", arg, " does not seem to be a .torrent file" print "Error,", arg, " does not seem to be a .torrent file"
if dbus_imported: if dbus_imported:
bus = dbus.SessionBus() bus = dbus.SessionBus()
dbus_objects = dbus.Interface(bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus'), 'org.freedesktop.DBus').ListNames() dbus_objects = dbus.Interface(bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus'), 'org.freedesktop.DBus').ListNames()
interface = None interface = None
if not "org.deluge_torrent.Deluge" in dbus_objects: if not "org.deluge_torrent.Deluge" in dbus_objects:
print "no existing Deluge session" print "no existing Deluge session"
start_deluge() start_deluge()
else: else:
## This connects to the deluge interface ## This connects to the deluge interface
print "create proxy object" print "create proxy object"
proxy = bus.get_object('org.deluge_torrent.Deluge', '/org/deluge_torrent/DelugeObject') proxy = bus.get_object('org.deluge_torrent.Deluge', '/org/deluge_torrent/DelugeObject')
print "create iface" print "create iface"
deluge_iface = dbus.Interface(proxy, 'org.deluge_torrent.Deluge') deluge_iface = dbus.Interface(proxy, 'org.deluge_torrent.Deluge')
print "send to iface" print "send to iface"
add_args(deluge_iface) add_args(deluge_iface)
else: else:
print "no existing Deluge session" print "no existing Deluge session"
start_deluge() start_deluge()

View file

@ -26,14 +26,14 @@
# this exception statement from your version. If you delete this exception # this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here. # statement from all source files in the program, then also delete it here.
NAME = "deluge" NAME = "deluge"
FULLNAME = "Deluge BitTorrent Client" FULLNAME = "Deluge BitTorrent Client"
VERSION = "0.5.2.7" VERSION = "0.5.2.90"
AUTHOR = "Zach Tibbitts, Alon Zakai, Marcos Pinto, Andrew Resch" AUTHOR = "Zach Tibbitts, Alon Zakai, Marcos Pinto, Andrew Resch"
EMAIL = "zach@collegegeek.org, kripkensteiner@gmail.com, marcospinto@dipconsultants.com, alonzakai@gmail.com" EMAIL = "zach@collegegeek.org, kripkensteiner@gmail.com, marcospinto@dipconsultants.com, alonzakai@gmail.com"
DESCRIPTION = "A bittorrent client written in PyGTK" DESCRIPTION = "A bittorrent client written in PyGTK"
URL = "http://deluge-torrent.org" URL = "http://deluge-torrent.org"
LICENSE = "GPLv2" LICENSE = "GPLv2"
import os, platform import os, platform
print "Attempting to detect your system information" print "Attempting to detect your system information"
@ -96,10 +96,12 @@ python_version = platform.python_version()[0:3]
# it has been removed to prevent confusion. # it has been removed to prevent confusion.
if not OS == "win": if not OS == "win":
EXTRA_COMPILE_ARGS = ["-Wno-missing-braces", "-DHAVE_INCLUDE_LIBTORRENT_ASIO____ASIO_HPP=1", EXTRA_COMPILE_ARGS = ["-Wno-missing-braces",
"-DHAVE_INCLUDE_LIBTORRENT_ASIO____ASIO_HPP=1",
"-DHAVE_INCLUDE_LIBTORRENT_ASIO_SSL_STREAM_HPP=1", "-DHAVE_INCLUDE_LIBTORRENT_ASIO_SSL_STREAM_HPP=1",
"-DHAVE_INCLUDE_LIBTORRENT_ASIO_IP_TCP_HPP=1", "-DHAVE_INCLUDE_LIBTORRENT_ASIO_IP_TCP_HPP=1",
"-DHAVE_PTHREAD=1", "-DTORRENT_USE_OPENSSL=1", "-DHAVE_SSL=1", "-DNDEBUG", "-O2"] "-DHAVE_PTHREAD=1", "-DTORRENT_USE_OPENSSL=1", "-DHAVE_SSL=1",
"-DNDEBUG", "-O2"]
if ARCH == "x64": if ARCH == "x64":
EXTRA_COMPILE_ARGS.append("-DAMD64") EXTRA_COMPILE_ARGS.append("-DAMD64")
@ -297,4 +299,3 @@ setup(name=NAME, fullname=FULLNAME, version=VERSION,
ext_modules=[deluge_core], ext_modules=[deluge_core],
cmdclass=cmdclass cmdclass=cmdclass
) )

View file

@ -38,7 +38,7 @@ import xdg.BaseDirectory
import gettext import gettext
PROGRAM_NAME = "Deluge" PROGRAM_NAME = "Deluge"
PROGRAM_VERSION = "0.5.2.7" PROGRAM_VERSION = "0.5.2.90"
CLIENT_CODE = "DE" CLIENT_CODE = "DE"
CLIENT_VERSION = "".join(PROGRAM_VERSION.split('.'))+"0"*(4 - len(PROGRAM_VERSION.split('.'))) CLIENT_VERSION = "".join(PROGRAM_VERSION.split('.'))+"0"*(4 - len(PROGRAM_VERSION.split('.')))

View file

@ -192,7 +192,7 @@ class Manager:
InvalidTorrentError) InvalidTorrentError)
# Start up the core # Start up the core
assert(len(version) == 4) assert(len(version) == 5)
deluge_core.init(client_ID, deluge_core.init(client_ID,
int(version[0]), int(version[0]),
int(version[1]), int(version[1]),