mostly pep8 fixes

This commit is contained in:
Marcos Pinto 2007-07-13 01:13:13 +00:00
parent 77b5ce765b
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.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
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
this exception statement from your version. If you delete this exception
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:
==========================
First, make sure you have the proper bulid
dependencies installed. On a normal Debian
or Ubuntu system, those dependencies are:
First, make sure you have the proper bulid dependencies installed. On a normal
Debian or Ubuntu system, those dependencies are:
g++
python-all-dev
@ -31,16 +30,13 @@ libboost-serialization-dev
libssl-dev
zlib1g-dev
But the names of the packages may vary
depending on your OS / distro.
But the names of the packages may vary depending on your OS / distro.
Once you have the needed libraries installed,
build Deluge by running:
Once you have the needed libraries installed, build Deluge by running:
python setup.py build
You shouldn't get any errors. Then run, as
root (or by using sudo):
You shouldn't get any errors. Then run, as root (or by using sudo):
python setup.py install
@ -52,17 +48,12 @@ You can then run Deluge by executing:
Notes:
1) On some distributions, boost libraries are
renamed to have "-mt" at the end (boost_thread_mt
instead of boost_thread, for example), the "mt"
indicating "multithreaded". In some cases it
appears the distros lack symlinks to connect
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.
1) On some distributions, boost libraries are renamed to have "-mt" at the end
(boost_thread_mt instead of boost_thread, for example), the "mt" indicating
"multithreaded". In some cases it appears the distros lack symlinks to connect
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
may fail to start. If this happens to you, you
need to remove your ~/.config/deluge directory
to allow Deluge to rebuild it's configuration
file.
2) After upgrading your Deluge installation, it may fail to start. If this
happens to you, you need to remove your ~/.config/deluge directory 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 from a clean libtorrent source checkout and has
been hacked in order to get it to work properly with Deluge.
As a result, Deluge will likely not build properly against a
vanilla libtorrent 0.12 installation or a nightly build of
libtorrent 0.13. It is recommended that you build against our
included libtorrent, as our build will not conflict with any
installed libtorrent.
NOTE: Deluge 0.5.1 uses an unstable build of libtorrent. This build differs
from a clean libtorrent source checkout and has been hacked in order to get it
to work properly with Deluge. As a result, Deluge will likely not build
properly against a vanilla libtorrent 0.12 installation or a nightly build of
libtorrent 0.13. It is recommended that you build against our included
libtorrent, as our build will not conflict with any installed libtorrent.
- zachtib

View File

@ -32,103 +32,103 @@ def enable(core, interface):
### The Plugin ###
DEFAULT_PREFS = {
"ratios": [1.0, 1.5, 2.0, 3.0]
"ratios": [1.0, 1.5, 2.0, 3.0]
}
import deluge
import gtk, gtk.glade
class DesiredRatio:
def __init__(self, path, core, interface):
self.path = path
self.core = core
self.interface = interface
self.set_ratios = {}
self.callback_ids = []
def __init__(self, path, core, interface):
self.path = path
self.core = core
self.interface = interface
self.set_ratios = {}
self.callback_ids = []
# Setup preferences
self.config = deluge.pref.Preferences(filename=deluge.common.CONFIG_DIR + "/desired_ratio.conf", global_defaults=False, defaults=DEFAULT_PREFS)
# Setup preferences
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
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))
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()
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.ratio_menuitem = gtk.MenuItem(_("_Desired Ratio"))
# Make the sub-menu for the torrent menu
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.interface.torrent_menu.append(self.ratio_menuitem)
self.ratio_menuitem.set_submenu(self.ratio_menu)
self.interface.torrent_menu.append(self.ratio_menuitem)
self.ratio_menuitem.show_all()
self.ratio_menuitem.show_all()
def torrent_menu_hide(self, widget):
try:
self.interface.torrent_menu.remove(self.ratio_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 = []
def torrent_menu_hide(self, widget):
try:
self.interface.torrent_menu.remove(self.ratio_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 ratios in the core
for unique_ID, ratio in self.set_ratios.items():
if ratio >= 1:
self.core.set_ratio(unique_ID, ratio)
self.set_ratios = {}
def ratio_clicked(self, widget):
value = widget.get_children()[0].get_text()
if value == _("Not Set"):
value = -1
if value == _("Other..."):
dialog_glade = gtk.glade.XML(deluge.common.get_glade_file("dgtkpopups.glade"))
speed_dialog = dialog_glade.get_widget("speed_dialog")
spin_speed = dialog_glade.get_widget("spin_speed")
spin_speed.set_value(self.get_torrent_desired_ratio())
spin_speed.set_increments(0.1, 1.0)
spin_speed.set_digits(1)
spin_speed.set_range(1.0, 1000.0)
spin_speed.select_region(0, -1)
response = speed_dialog.run()
if response == 1: # OK Response
value = spin_speed.get_value()
else:
speed_dialog.destroy()
return
speed_dialog.destroy()
value = float(value) # Make sure the value is a float
# Set the ratio in the core and remember the setting
self.core.set_ratio(self.unique_ID, value)
self.set_ratios[self.unique_ID] = value
# Update the ratios list if necessary
if value not in self.config.get("ratios") and value >= 1:
self.config.get("ratios").insert(0, value)
self.config.get("ratios").pop()
def get_torrent_desired_ratio(self):
if self.set_ratios.has_key(self.unique_ID):
return self.set_ratios[self.unique_ID]
else:
return -1
# Reset all desired ratios in the core
for unique_ID, ratio in self.set_ratios.items():
if ratio >= 1:
self.core.set_ratio(unique_ID, ratio)
self.set_ratios = {}
def ratio_clicked(self, widget):
value = widget.get_children()[0].get_text()
if value == _("Not Set"):
value = -1
if value == _("Other..."):
dialog_glade = gtk.glade.XML(deluge.common.get_glade_file("dgtkpopups.glade"))
speed_dialog = dialog_glade.get_widget("speed_dialog")
spin_speed = dialog_glade.get_widget("spin_speed")
spin_speed.set_value(self.get_torrent_desired_ratio())
spin_speed.set_increments(0.1, 1.0)
spin_speed.set_digits(1)
spin_speed.set_range(1.0, 1000.0)
spin_speed.select_region(0, -1)
response = speed_dialog.run()
if response == 1: # OK Response
value = spin_speed.get_value()
else:
speed_dialog.destroy()
return
speed_dialog.destroy()
value = float(value) # Make sure the value is a float
# Set the ratio in the core and remember the setting
self.core.set_ratio(self.unique_ID, value)
self.set_ratios[self.unique_ID] = value
# Update the ratios list if necessary
if value not in self.config.get("ratios") and value >= 1:
self.config.get("ratios").insert(0, value)
self.config.get("ratios").pop()
def get_torrent_desired_ratio(self):
if self.set_ratios.has_key(self.unique_ID):
return self.set_ratios[self.unique_ID]
else:
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
class plugin_Example: # The plugin's class
## Your plugin's contructor should follow this format
## path = A string containing the path to the plugin
## deluge_core = The active instance of the Deluge Manager
## deluge_interface = The active instance of the Deluge Interface
def __init__(self, path, deluge_core, deluge_interface):
# Save the path, interface, and core so they can be used later
self.path = path
self.core = deluge_core
self.interface = deluge_interface
## Your plugin's contructor should follow this format
## path = A string containing the path to the plugin
## deluge_core = The active instance of the Deluge Manager
## deluge_interface = The active instance of the Deluge Interface
def __init__(self, path, deluge_core, deluge_interface):
# Save the path, interface, and core so they can be used later
self.path = path
self.core = deluge_core
self.interface = deluge_interface
# Create an options file and try to load existing Values
self.config_file = deluge.common.CONFIG_DIR + "/example.conf"
self.config = deluge.pref.Preferences()
try:
self.config.load(self.config_file)
except IOError:
# File does not exist
pass
# Extract the configuration dialog from the gladefile
self.glade = gtk.glade.XML(path + "/example.glade")
self.dialog = self.glade.get_widget("dialog")
self.dialog.set_icon_from_file(self.path + "/example-plugin.png")
# Access the interface's toolbar
self.toolbar = self.interface.toolbar
# Make a toolbar button
icon = gtk.Image()
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.connect("clicked", self.clicked) # Connect the signal handler for the button
self.toolbar.add(self.button) # Add button to toolbar
self.button.show_all() # Show the button
## unload is called when the plugin is removed or Deluge is shut down
def unload(self):
self.toolbar.remove(self.button) # Remove the button from the toolbar
self.config.save(self.config_file)
## update will be called every UPDATE_INTERVAL (usually about 1 second)
def update(self):
# As this plugin doesn't need to do anything every interval, this
# function will remain empty
pass
# Create an options file and try to load existing Values
self.config_file = deluge.common.CONFIG_DIR + "/example.conf"
self.config = deluge.pref.Preferences()
try:
self.config.load(self.config_file)
except IOError:
# File does not exist
pass
# Extract the configuration dialog from the gladefile
self.glade = gtk.glade.XML(path + "/example.glade")
self.dialog = self.glade.get_widget("dialog")
self.dialog.set_icon_from_file(self.path + "/example-plugin.png")
# Access the interface's toolbar
self.toolbar = self.interface.toolbar
# Make a toolbar button
icon = gtk.Image()
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.connect("clicked", self.clicked) # Connect the signal handler for the button
self.toolbar.add(self.button) # Add button to toolbar
self.button.show_all() # Show the button
## unload is called when the plugin is removed or Deluge is shut down
def unload(self):
self.toolbar.remove(self.button) # Remove the button from the toolbar
self.config.save(self.config_file)
## update will be called every UPDATE_INTERVAL (usually about 1 second)
def update(self):
# As this plugin doesn't need to do anything every interval, this
# function will remain empty
pass
## This will be only called if your plugin is configurable
def configure(self):
entry1 = self.glade.get_widget("entry1")
entry2 = self.glade.get_widget("entry2")
try:
entry1.set_text(self.config.get("option1"))
entry2.set_text(self.config.get("option2"))
except:
entry1.set_text("")
entry2.set_text("")
self.dialog.show()
response = self.dialog.run()
self.dialog.hide()
if response:
self.config.set("option1", entry1.get_text())
self.config.set("option2", entry2.get_text())
## This will be called whenever self.button is clicked
def clicked(self, button):
# Build a dialog from scratch rather than from a glade file
dialog = gtk.Dialog(title="Example Plugin", parent=self.interface.window,
buttons=(gtk.STOCK_OK, 0))
dialog.set_icon_from_file(self.path + "/example-plugin.png")
try:
text = "This is a popup notification from Example Plugin\n" + \
"Your value for option1 is %s\n"%self.config.get("option1") + \
"and option2 is %s"%self.config.get("option2")
except KeyError:
text = "This is a popup notification from Example Plugin\n" + \
"If you had set options by configuring this plugin,\n" + \
"they would appear here"
label = gtk.Label(text)
dialog.vbox.pack_start(label)
dialog.show_all()
dialog.run()
dialog.hide()
dialog.destroy()
## This will be only called if your plugin is configurable
def configure(self):
entry1 = self.glade.get_widget("entry1")
entry2 = self.glade.get_widget("entry2")
try:
entry1.set_text(self.config.get("option1"))
entry2.set_text(self.config.get("option2"))
except:
entry1.set_text("")
entry2.set_text("")
self.dialog.show()
response = self.dialog.run()
self.dialog.hide()
if response:
self.config.set("option1", entry1.get_text())
self.config.set("option2", entry2.get_text())
## This will be called whenever self.button is clicked
def clicked(self, button):
# Build a dialog from scratch rather than from a glade file
dialog = gtk.Dialog(title="Example Plugin", parent=self.interface.window,
buttons=(gtk.STOCK_OK, 0))
dialog.set_icon_from_file(self.path + "/example-plugin.png")
try:
text = "This is a popup notification from Example Plugin\n" + \
"Your value for option1 is %s\n"%self.config.get("option1") + \
"and option2 is %s"%self.config.get("option2")
except KeyError:
text = "This is a popup notification from Example Plugin\n" + \
"If you had set options by configuring this plugin,\n" + \
"they would appear here"
label = gtk.Label(text)
dialog.vbox.pack_start(label)
dialog.show_all()
dialog.run()
dialog.hide()
dialog.destroy()

View File

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

View File

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

View File

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

View File

@ -1,156 +1,156 @@
class plugin_Search:
def __init__(self, path, deluge_core, deluge_interface):
import gtk, gtk.glade, os
import deluge.common, deluge.dgtk, deluge.pref
self.core = deluge_core
self.interface = deluge_interface
self.conf_file = deluge.common.CONFIG_DIR + "/search.conf"
if not os.path.isfile(self.conf_file):
f = open(self.conf_file, mode='w')
f.flush()
f.close()
glade = gtk.glade.XML(path + "/searchdlg.glade")
self.dlg = glade.get_widget("search_dialog")
self.dlg.set_icon_from_file(deluge.common.get_pixmap("deluge32.png"))
self.view = glade.get_widget("search_view")
model = gtk.ListStore(str, str)
self.view.set_model(model)
deluge.dgtk.add_text_column(self.view, "Name", 0)
deluge.dgtk.add_text_column(self.view, "Search String", 1)
self.field_name = glade.get_widget("field_name")
self.field_search = glade.get_widget("field_search")
self.button_add = glade.get_widget("button_addsearch")
self.button_del = glade.get_widget("button_delsearch")
dic = { "add_clicked" : self.add_clicked,
"del_clicked" : self.del_clicked,
"row_clicked" : self.row_clicked,
"text_changed" : self.text_changed }
glade.signal_autoconnect(dic)
self.view.get_selection().set_select_function(self.row_clicked)
### Note: All other plugins should use self.interface.toolbar
### when adding items to the toolbar
self.se = ''
self.toolbar = self.interface.wtree.get_widget("tb_right")
self.engines = deluge.pref.Preferences(self.conf_file, False)
self.search_entry = gtk.Entry()
self.search_entry.connect("activate", self.torrent_search)
self.search_item = gtk.ToolItem()
self.search_item.add(self.search_entry)
self.search_icon = gtk.Image()
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.set_is_important(True)
self.menu_button.connect("clicked", self.torrent_search)
self.menu = gtk.Menu()
self.manage_item = gtk.ImageMenuItem("Manage Engines")
self.image = gtk.Image()
self.image.set_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU)
self.manage_item.set_image(self.image)
self.manage_item.connect("activate", self.configure)
self.menu.add(self.manage_item)
self.menu_button.set_menu(self.menu)
self.toolbar.insert(self.search_item, -1)
self.toolbar.insert(self.menu_button, -1)
self.populate_search_menu()
self.toolbar.show_all()
self.search_item.show_all()
self.menu_button.show_all()
self.menu.show_all()
def unload(self):
self.engines.save(self.conf_file)
self.toolbar.remove(self.search_item)
self.toolbar.remove(self.menu_button)
def text_changed(self, args):
a = (self.field_name.get_text() != "")
b = (self.field_search.get_text() != "")
if(a and b):
self.button_add.set_sensitive(1)
else:
self.button_add.set_sensitive(0)
def __init__(self, path, deluge_core, deluge_interface):
import gtk, gtk.glade, os
import deluge.common, deluge.dgtk, deluge.pref
self.core = deluge_core
self.interface = deluge_interface
self.conf_file = deluge.common.CONFIG_DIR + "/search.conf"
if not os.path.isfile(self.conf_file):
f = open(self.conf_file, mode='w')
f.flush()
f.close()
glade = gtk.glade.XML(path + "/searchdlg.glade")
self.dlg = glade.get_widget("search_dialog")
self.dlg.set_icon_from_file(deluge.common.get_pixmap("deluge32.png"))
self.view = glade.get_widget("search_view")
model = gtk.ListStore(str, str)
self.view.set_model(model)
deluge.dgtk.add_text_column(self.view, "Name", 0)
deluge.dgtk.add_text_column(self.view, "Search String", 1)
self.field_name = glade.get_widget("field_name")
self.field_search = glade.get_widget("field_search")
self.button_add = glade.get_widget("button_addsearch")
self.button_del = glade.get_widget("button_delsearch")
dic = { "add_clicked" : self.add_clicked,
"del_clicked" : self.del_clicked,
"row_clicked" : self.row_clicked,
"text_changed" : self.text_changed }
glade.signal_autoconnect(dic)
self.view.get_selection().set_select_function(self.row_clicked)
### Note: All other plugins should use self.interface.toolbar
### when adding items to the toolbar
self.se = ''
self.toolbar = self.interface.wtree.get_widget("tb_right")
self.engines = deluge.pref.Preferences(self.conf_file, False)
self.search_entry = gtk.Entry()
self.search_entry.connect("activate", self.torrent_search)
self.search_item = gtk.ToolItem()
self.search_item.add(self.search_entry)
self.search_icon = gtk.Image()
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.set_is_important(True)
self.menu_button.connect("clicked", self.torrent_search)
self.menu = gtk.Menu()
self.manage_item = gtk.ImageMenuItem("Manage Engines")
self.image = gtk.Image()
self.image.set_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU)
self.manage_item.set_image(self.image)
self.manage_item.connect("activate", self.configure)
self.menu.add(self.manage_item)
self.menu_button.set_menu(self.menu)
self.toolbar.insert(self.search_item, -1)
self.toolbar.insert(self.menu_button, -1)
self.populate_search_menu()
self.toolbar.show_all()
self.search_item.show_all()
self.menu_button.show_all()
self.menu.show_all()
def unload(self):
self.engines.save(self.conf_file)
self.toolbar.remove(self.search_item)
self.toolbar.remove(self.menu_button)
def text_changed(self, args):
a = (self.field_name.get_text() != "")
b = (self.field_search.get_text() != "")
if(a and b):
self.button_add.set_sensitive(1)
else:
self.button_add.set_sensitive(0)
def add_clicked(self, args):
self.view.get_model().append([self.field_name.get_text(),
self.field_search.get_text()])
self.field_name.set_text("")
self.field_search.set_text("")
def del_clicked(self, args):
(model, selection) = self.view.get_selection().get_selected()
model.remove(selection)
self.button_del.set_sensitive(0)
def row_clicked(self, args):
self.button_del.set_sensitive(1)
return True
def configure(self, widget=None):
import gtk, gtk.glade
from deluge import common
self.dlg.show_all()
model = self.view.get_model()
model.clear()
for name in self.engines.keys():
self.view.get_model().append( (name, self.engines.get(name)) )
self.button_add.set_sensitive(0)
self.button_del.set_sensitive(0)
result = self.dlg.run()
self.dlg.hide_all()
if result == 1:
self.engines.clear()
the_iter = model.get_iter_first()
while the_iter is not None:
self.engines.set(model.get_value(the_iter, 0), model.get_value(the_iter, 1))
the_iter = model.iter_next(the_iter)
self.engines.save(self.conf_file)
self.populate_search_menu()
def add_clicked(self, args):
self.view.get_model().append([self.field_name.get_text(),
self.field_search.get_text()])
self.field_name.set_text("")
self.field_search.set_text("")
def del_clicked(self, args):
(model, selection) = self.view.get_selection().get_selected()
model.remove(selection)
self.button_del.set_sensitive(0)
def row_clicked(self, args):
self.button_del.set_sensitive(1)
return True
def configure(self, widget=None):
import gtk, gtk.glade
from deluge import common
self.dlg.show_all()
model = self.view.get_model()
model.clear()
for name in self.engines.keys():
self.view.get_model().append( (name, self.engines.get(name)) )
self.button_add.set_sensitive(0)
self.button_del.set_sensitive(0)
result = self.dlg.run()
self.dlg.hide_all()
if result == 1:
self.engines.clear()
the_iter = model.get_iter_first()
while the_iter is not None:
self.engines.set(model.get_value(the_iter, 0), model.get_value(the_iter, 1))
the_iter = model.iter_next(the_iter)
self.engines.save(self.conf_file)
self.populate_search_menu()
def update(self):
pass
def torrent_search(self, widget=None):
from deluge import common
print "Searching with engine", self.se
url = self.engines.get(self.se)
entry = self.search_entry.get_text()
print 'URL =', url
print 'Entry =', entry
entry = entry.replace(' ', '+')
print 'URL =', url
print 'Entry =', entry
url = url.replace('${query}', entry)
print 'URL =', url
print 'Entry =', entry
common.open_url_in_browser(None, url)
def populate_search_menu(self):
import gtk
self.menu_button.set_label("Choose an Engine")
for child in self.menu.get_children():
self.menu.remove(child)
group = None
i = 0
for engine in self.engines.keys():
rmi = gtk.RadioMenuItem(None, engine)
rmi.eng_name = engine
rmi.connect("activate", self.select_search, rmi.eng_name)
if (group != None):
rmi.set_group(group)
else:
group = rmi
rmi.set_active(1)
self.menu.insert(rmi, i)
i = i + 1
rmi.show()
self.menu.insert(self.manage_item, i)
self.menu.show()
def update(self):
pass
def torrent_search(self, widget=None):
from deluge import common
print "Searching with engine", self.se
url = self.engines.get(self.se)
entry = self.search_entry.get_text()
print 'URL =', url
print 'Entry =', entry
entry = entry.replace(' ', '+')
print 'URL =', url
print 'Entry =', entry
url = url.replace('${query}', entry)
print 'URL =', url
print 'Entry =', entry
common.open_url_in_browser(None, url)
def populate_search_menu(self):
import gtk
self.menu_button.set_label("Choose an Engine")
for child in self.menu.get_children():
self.menu.remove(child)
group = None
i = 0
for engine in self.engines.keys():
rmi = gtk.RadioMenuItem(None, engine)
rmi.eng_name = engine
rmi.connect("activate", self.select_search, rmi.eng_name)
if (group != None):
rmi.set_group(group)
else:
group = rmi
rmi.set_active(1)
self.menu.insert(rmi, i)
i = i + 1
rmi.show()
self.menu.insert(self.manage_item, i)
self.menu.show()
def select_search(self, menuitem, engine_string):
self.menu_button.set_label("Search " + engine_string)
self.se = engine_string
def select_search(self, menuitem, engine_string):
self.menu_button.set_label("Search " + 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
# along with deluge. If not, write to:
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
#
# In addition, as a special exception, the copyright holders give
# 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 deluge, deluge.common, deluge.interface
try:
import dbus
dbus_version = getattr(dbus, 'version', (0,0,0))
if dbus_version >= (0,41,0) and dbus_version < (0,80,0):
import dbus.glib
elif dbus_version >= (0,80,0):
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
else:
pass
import dbus
dbus_version = getattr(dbus, 'version', (0,0,0))
if dbus_version >= (0,41,0) and dbus_version < (0,80,0):
import dbus.glib
elif dbus_version >= (0,80,0):
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
else:
pass
except: dbus_imported = False
else: dbus_imported = True
parser = OptionParser(usage="%prog [options] [actions]", version=deluge.common.PROGRAM_VERSION)
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",
metavar="URL", action="store")
metavar="URL", action="store")
(options, args) = parser.parse_args()
def start_deluge():
print "Starting new Deluge session..."
interface = deluge.interface.DelugeGTK()
add_args(interface)
interface.start(options.tray)
print "Starting new Deluge session..."
interface = deluge.interface.DelugeGTK()
add_args(interface)
interface.start(options.tray)
def add_args(interface):
if options.url:
interface.external_add_url(options.url)
else:
for arg in args:
apath = os.path.abspath(arg)
if apath.endswith(".torrent"):
interface.external_add_torrent(apath)
else:
print "Error,", arg, " does not seem to be a .torrent file"
if options.url:
interface.external_add_url(options.url)
else:
for arg in args:
apath = os.path.abspath(arg)
if apath.endswith(".torrent"):
interface.external_add_torrent(apath)
else:
print "Error,", arg, " does not seem to be a .torrent file"
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:
print "no existing Deluge session"
start_deluge()
else:
## This connects to the deluge interface
print "create proxy object"
proxy = bus.get_object('org.deluge_torrent.Deluge', '/org/deluge_torrent/DelugeObject')
print "create iface"
deluge_iface = dbus.Interface(proxy, 'org.deluge_torrent.Deluge')
print "send to iface"
if not "org.deluge_torrent.Deluge" in dbus_objects:
print "no existing Deluge session"
start_deluge()
else:
## This connects to the deluge interface
print "create proxy object"
proxy = bus.get_object('org.deluge_torrent.Deluge', '/org/deluge_torrent/DelugeObject')
print "create iface"
deluge_iface = dbus.Interface(proxy, 'org.deluge_torrent.Deluge')
print "send to iface"
add_args(deluge_iface)
add_args(deluge_iface)
else:
print "no existing Deluge session"
start_deluge()
print "no existing Deluge session"
start_deluge()

View File

@ -26,14 +26,14 @@
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
NAME = "deluge"
FULLNAME = "Deluge BitTorrent Client"
VERSION = "0.5.2.7"
AUTHOR = "Zach Tibbitts, Alon Zakai, Marcos Pinto, Andrew Resch"
EMAIL = "zach@collegegeek.org, kripkensteiner@gmail.com, marcospinto@dipconsultants.com, alonzakai@gmail.com"
NAME = "deluge"
FULLNAME = "Deluge BitTorrent Client"
VERSION = "0.5.2.90"
AUTHOR = "Zach Tibbitts, Alon Zakai, Marcos Pinto, Andrew Resch"
EMAIL = "zach@collegegeek.org, kripkensteiner@gmail.com, marcospinto@dipconsultants.com, alonzakai@gmail.com"
DESCRIPTION = "A bittorrent client written in PyGTK"
URL = "http://deluge-torrent.org"
LICENSE = "GPLv2"
URL = "http://deluge-torrent.org"
LICENSE = "GPLv2"
import os, platform
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.
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_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":
EXTRA_COMPILE_ARGS.append("-DAMD64")
@ -297,4 +299,3 @@ setup(name=NAME, fullname=FULLNAME, version=VERSION,
ext_modules=[deluge_core],
cmdclass=cmdclass
)

View File

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

View File

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