add web seed plugin

This commit is contained in:
Marcos Pinto 2007-08-14 19:16:47 +00:00
parent 8b4d40664e
commit 751dc5bf2b
2 changed files with 157 additions and 0 deletions

View File

@ -0,0 +1,68 @@
# Copyright (C) 2007 - Marcos Pinto <markybob@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
### Initialization ###
plugin_name = _("Web Seed")
plugin_author = "Marcos Pinto"
plugin_version = "0.1"
plugin_description = _("This plugin allows users to add web seeds to their torrents")
def deluge_init(deluge_path):
global path
path = deluge_path
def enable(core, interface):
global path
return webseedMenu(path, core, interface)
import deluge
import gtk
import os
class webseedMenu:
def __init__(self, path, core, interface):
print "Loading Web Seed plugin..."
self.path = path
self.core = core
self.interface = interface
self.glade = gtk.glade.XML(path + "/webseed.glade")
self.dialog = self.glade.get_widget("dialog")
# Add menu item to torrent context menu
self.menuitem_image = gtk.Image()
self.menuitem_image.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_MENU)
self.menuitem = gtk.ImageMenuItem(_("_Add Web Seed"))
self.menuitem.set_image(self.menuitem_image)
self.menuitem.connect("activate", self.webseed_clicked)
self.interface.torrent_menu.append(self.menuitem)
self.menuitem.show_all()
def update(self):
pass
def unload(self):
self.interface.torrent_menu.remove(self.menuitem)
def webseed_clicked(self, widget):
self.unique_ID = self.interface.get_selected_torrent()
self.dialog.show()
response = self.dialog.run()
self.dialog.hide()
if response:
self.core.add_url_seed(self.unique_ID, self.glade.get_widget("txt_url").get_text())

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--*- mode: xml -*-->
<glade-interface>
<widget class="GtkDialog" id="dialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Open Containing Folder Preferences</property>
<property name="default_width">400</property>
<property name="default_height">100</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
<property name="spacing">2</property>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">URL:</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkEntry" id="txt_url">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button_cancel">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button_ok">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-ok</property>
<property name="use_stock">True</property>
<property name="response_id">1</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>