fixed icon path, added gtk download list button
This commit is contained in:
parent
e0c5820bf0
commit
62c52e8740
|
@ -33,12 +33,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.
|
||||||
|
|
||||||
|
import deluge.component
|
||||||
from torrentblocklist import TorrentBlockList
|
from torrentblocklist import TorrentBlockList
|
||||||
from deluge.log import LOG as log
|
from deluge.log import LOG as log
|
||||||
from deluge.plugins.corepluginbase import CorePluginBase
|
from deluge.plugins.corepluginbase import CorePluginBase
|
||||||
|
|
||||||
class Core(CorePluginBase):
|
class Core(CorePluginBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
|
deluge.component.get("Core").session.set_max_connections(0)
|
||||||
self.blocklist = TorrentBlockList(self.plugin)
|
self.blocklist = TorrentBlockList(self.plugin)
|
||||||
self.plugin.register_hook("post_session_load", self._post_session_load)
|
self.plugin.register_hook("post_session_load", self._post_session_load)
|
||||||
log.debug('Blocklist: Plugin enabled..')
|
log.debug('Blocklist: Plugin enabled..')
|
||||||
|
@ -57,7 +59,7 @@ class Core(CorePluginBase):
|
||||||
## Hooks for core ##
|
## Hooks for core ##
|
||||||
def _post_session_load(self):
|
def _post_session_load(self):
|
||||||
log.info('Blocklist: Session load hook caught')
|
log.info('Blocklist: Session load hook caught')
|
||||||
if self.blocklist.load_on_start == True or self.blocklist.load_on_start == 'True':
|
if self.blocklist.load_on_start == True:
|
||||||
# Wait until an idle time to load block list
|
# Wait until an idle time to load block list
|
||||||
import gobject
|
import gobject
|
||||||
gobject.idle_add(self.blocklist.import_list)
|
gobject.idle_add(self.blocklist.import_list)
|
||||||
|
@ -86,6 +88,17 @@ class Core(CorePluginBase):
|
||||||
def export_import_list(self):
|
def export_import_list(self):
|
||||||
log.debug('Blocklist: Import started from GTK UI')
|
log.debug('Blocklist: Import started from GTK UI')
|
||||||
self.blocklist.import_list()
|
self.blocklist.import_list()
|
||||||
|
|
||||||
|
def export_download_list(self):
|
||||||
|
log.debug('Blocklist: Download started from GTK UI')
|
||||||
|
force_check = True
|
||||||
|
self.blocklist.check_update(force_check)
|
||||||
|
# Initialize download attempt
|
||||||
|
self.blocklist.attempt = 0
|
||||||
|
|
||||||
|
if self.blocklist.fetch == True:
|
||||||
|
self.blocklist.download()
|
||||||
|
|
||||||
|
|
||||||
def export_set_options(self, settings):
|
def export_set_options(self, settings):
|
||||||
log.debug("Blocklist: Set Options")
|
log.debug("Blocklist: Set Options")
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 705 B |
Binary file not shown.
After Width: | Height: | Size: 926 B |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -33,9 +33,9 @@
|
||||||
# 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.
|
||||||
|
|
||||||
import pkg_resources # remove possibly, double check
|
import os
|
||||||
|
import pkg_resources # access plugin egg
|
||||||
from deluge.log import LOG as log
|
from deluge.log import LOG as log
|
||||||
import deluge.common # for pixmap
|
|
||||||
import deluge.component # for systray
|
import deluge.component # for systray
|
||||||
import ui
|
import ui
|
||||||
import gtk, gobject
|
import gtk, gobject
|
||||||
|
@ -71,6 +71,10 @@ class GtkUI(ui.UI):
|
||||||
def disable(self):
|
def disable(self):
|
||||||
deluge.component.get("StatusBar").remove_item(self.blocklist_status)
|
deluge.component.get("StatusBar").remove_item(self.blocklist_status)
|
||||||
self.plugin.deregister_hook("on_apply_prefs", self.apply_prefs)
|
self.plugin.deregister_hook("on_apply_prefs", self.apply_prefs)
|
||||||
|
|
||||||
|
def get_pixmap(self, fname):
|
||||||
|
"""Returns a pixmap file included with plugin"""
|
||||||
|
return pkg_resources.resource_filename("blocklist", os.path.join("data", fname))
|
||||||
|
|
||||||
def add_status_icon(self, ip_count):
|
def add_status_icon(self, ip_count):
|
||||||
try:
|
try:
|
||||||
|
@ -78,7 +82,7 @@ class GtkUI(ui.UI):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
# self, image=None, stock=None, text=None, callback=None
|
# self, image=None, stock=None, text=None, callback=None
|
||||||
self.blocklist_status = deluge.component.get("StatusBar").add_item(deluge.common.get_pixmap("blocklist16.png"), None, str(ip_count) + " Blocked IP Ranges ", None)
|
self.blocklist_status = deluge.component.get("StatusBar").add_item(self.get_pixmap("blocklist16.png"), None, str(ip_count) + " Blocked IP Ranges ", None)
|
||||||
|
|
||||||
def get_ip_count(self):
|
def get_ip_count(self):
|
||||||
ui.client.block_list_count_ips(self.add_status_icon)
|
ui.client.block_list_count_ips(self.add_status_icon)
|
||||||
|
@ -89,6 +93,11 @@ class GtkUI(ui.UI):
|
||||||
log.debug('Blocklist: Import button')
|
log.debug('Blocklist: Import button')
|
||||||
gobject.timeout_add(20000, self.get_ip_count)
|
gobject.timeout_add(20000, self.get_ip_count)
|
||||||
|
|
||||||
|
def download_list(self, widget, data=None):
|
||||||
|
self.apply_prefs()
|
||||||
|
ui.client.block_list_download_list(None)
|
||||||
|
log.debug('Blocklist: Download button')
|
||||||
|
|
||||||
def unload_interface(self):
|
def unload_interface(self):
|
||||||
self.plugin.remove_preferences_page("Blocklist")
|
self.plugin.remove_preferences_page("Blocklist")
|
||||||
|
|
||||||
|
@ -113,7 +122,7 @@ class GtkUI(ui.UI):
|
||||||
alignment = gtk.Alignment(0.5, 0.5, 1, 1)
|
alignment = gtk.Alignment(0.5, 0.5, 1, 1)
|
||||||
alignment.set_padding(8, 5, 5, 5)
|
alignment.set_padding(8, 5, 5, 5)
|
||||||
|
|
||||||
table = gtk.Table(7, 2, False)
|
table = gtk.Table(8, 2, False)
|
||||||
table.set_col_spacings(8)
|
table.set_col_spacings(8)
|
||||||
table.set_row_spacings(10)
|
table.set_row_spacings(10)
|
||||||
|
|
||||||
|
@ -198,22 +207,30 @@ class GtkUI(ui.UI):
|
||||||
hbox2.pack_start(self.try_times)
|
hbox2.pack_start(self.try_times)
|
||||||
|
|
||||||
table.attach(hbox2, 0, 2, 4, 5)
|
table.attach(hbox2, 0, 2, 4, 5)
|
||||||
|
|
||||||
# sixth row
|
# sixth row
|
||||||
self.load_on_start = gtk.CheckButton('Import blocklist on daemon startup')
|
self.load_on_start = gtk.CheckButton('Import blocklist on daemon startup')
|
||||||
table.attach(self.load_on_start, 0, 2, 5, 6)
|
table.attach(self.load_on_start, 0, 2, 5, 6)
|
||||||
|
|
||||||
# DO I NEED THIS STILL I DONT KNOW THINK ABOUT IT AND ASK MYSELF AGAIN LATER K THX BYE
|
# download new list button
|
||||||
|
download_button = gtk.Button("_Download Blocklist", None, True)
|
||||||
|
download_button.connect("clicked", self.download_list, None)
|
||||||
|
|
||||||
# # import button (Check and possibly download)
|
pixbuf = gtk.gdk.pixbuf_new_from_file(self.get_pixmap("blocklist_download24.png"))
|
||||||
|
image = gtk.image_new_from_pixbuf(pixbuf)
|
||||||
|
download_button.set_image(image)
|
||||||
|
table.attach(download_button, 0, 2, 6, 7)
|
||||||
|
|
||||||
|
# import button (Check and possibly download)
|
||||||
import_button = gtk.Button("_Import Blocklist", None, True)
|
import_button = gtk.Button("_Import Blocklist", None, True)
|
||||||
import_button.connect("clicked", self.start_import, None)
|
import_button.connect("clicked", self.start_import, None)
|
||||||
|
|
||||||
pixbuf = gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap("blocklist_import24.png"))
|
pixbuf = gtk.gdk.pixbuf_new_from_file(self.get_pixmap("blocklist_import24.png"))
|
||||||
image = gtk.image_new_from_pixbuf(pixbuf)
|
image = gtk.image_new_from_pixbuf(pixbuf)
|
||||||
import_button.set_image(image)
|
import_button.set_image(image)
|
||||||
|
|
||||||
table.attach(import_button, 0, 2, 6, 7)
|
table.attach(import_button, 0, 2, 7, 8)
|
||||||
|
|
||||||
|
|
||||||
# finish frame
|
# finish frame
|
||||||
frame.set_label_widget(label)
|
frame.set_label_widget(label)
|
||||||
|
@ -247,7 +264,7 @@ class GtkUI(ui.UI):
|
||||||
}
|
}
|
||||||
ui.client.block_list_set_options(None, settings_dict)
|
ui.client.block_list_set_options(None, settings_dict)
|
||||||
# Needs to go in another thread or wait until window is closed
|
# Needs to go in another thread or wait until window is closed
|
||||||
gobject.idle_add(self.call_critical_setting)
|
#gobject.idle_add(self.call_critical_setting)
|
||||||
|
|
||||||
def call_critical_setting(self):
|
def call_critical_setting(self):
|
||||||
ui.client.block_list_critical_setting(None) # This checks to see if url or listtype changed, if so download & import
|
ui.client.block_list_critical_setting(None) # This checks to see if url or listtype changed, if so download & import
|
||||||
|
|
|
@ -49,7 +49,7 @@ from text import TextReader, GZMuleReader, PGZip
|
||||||
|
|
||||||
BLOCKLIST_PREFS = {
|
BLOCKLIST_PREFS = {
|
||||||
"url": "http://www.bluetack.co.uk/config/pipfilter.dat.gz",
|
"url": "http://www.bluetack.co.uk/config/pipfilter.dat.gz",
|
||||||
"load_on_start": "True",
|
"load_on_start": True,
|
||||||
"check_after_days": 2,
|
"check_after_days": 2,
|
||||||
"listtype": "gzmule",
|
"listtype": "gzmule",
|
||||||
"timeout": 180,
|
"timeout": 180,
|
||||||
|
@ -118,7 +118,6 @@ class TorrentBlockList:
|
||||||
def __init__(self, coreplugin):
|
def __init__(self, coreplugin):
|
||||||
self.plugin = coreplugin # reference from plugin core
|
self.plugin = coreplugin # reference from plugin core
|
||||||
log.info('Blocklist: TorrentBlockList instantiated')
|
log.info('Blocklist: TorrentBlockList instantiated')
|
||||||
deluge.component.get("Core").session.set_max_connections(0)
|
|
||||||
self.config = deluge.configmanager.ConfigManager("blocklist.conf", BLOCKLIST_PREFS)
|
self.config = deluge.configmanager.ConfigManager("blocklist.conf", BLOCKLIST_PREFS)
|
||||||
self.curr = 0
|
self.curr = 0
|
||||||
self.load_options()
|
self.load_options()
|
||||||
|
@ -167,7 +166,7 @@ class TorrentBlockList:
|
||||||
# Load newly set options to core plugin
|
# Load newly set options to core plugin
|
||||||
self.load_options()
|
self.load_options()
|
||||||
|
|
||||||
def check_update(self):
|
def check_update(self, force_check=False):
|
||||||
log.info('Blocklist: Checking for updates')
|
log.info('Blocklist: Checking for updates')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -193,7 +192,7 @@ class TorrentBlockList:
|
||||||
check_newer = False
|
check_newer = False
|
||||||
|
|
||||||
# If the program decides it is time to get a new list
|
# If the program decides it is time to get a new list
|
||||||
if check_newer == True:
|
if check_newer == True or force_check == True:
|
||||||
log.debug('Blocklist: Attempting check')
|
log.debug('Blocklist: Attempting check')
|
||||||
|
|
||||||
j = 0 # counter for loop
|
j = 0 # counter for loop
|
||||||
|
@ -300,6 +299,9 @@ class TorrentBlockList:
|
||||||
# CHECKSUM
|
# CHECKSUM
|
||||||
|
|
||||||
log.info('Blocklist: List downloaded sucessfully')
|
log.info('Blocklist: List downloaded sucessfully')
|
||||||
|
break
|
||||||
|
|
||||||
|
# Download completed
|
||||||
|
|
||||||
|
|
||||||
def import_list(self):
|
def import_list(self):
|
||||||
|
|
|
@ -44,7 +44,7 @@ setup(
|
||||||
description=__doc__,
|
description=__doc__,
|
||||||
author=__author__,
|
author=__author__,
|
||||||
packages=["blocklist"],
|
packages=["blocklist"],
|
||||||
package_data = {"blocklist": ["glade/*.glade"]},
|
package_data = {"blocklist": ["data/*"]},
|
||||||
entry_points="""
|
entry_points="""
|
||||||
[deluge.plugin.core]
|
[deluge.plugin.core]
|
||||||
Blocklist = blocklist:CorePlugin
|
Blocklist = blocklist:CorePlugin
|
||||||
|
|
Loading…
Reference in New Issue