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
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
|
||||
import deluge.component
|
||||
from torrentblocklist import TorrentBlockList
|
||||
from deluge.log import LOG as log
|
||||
from deluge.plugins.corepluginbase import CorePluginBase
|
||||
|
||||
class Core(CorePluginBase):
|
||||
def enable(self):
|
||||
deluge.component.get("Core").session.set_max_connections(0)
|
||||
self.blocklist = TorrentBlockList(self.plugin)
|
||||
self.plugin.register_hook("post_session_load", self._post_session_load)
|
||||
log.debug('Blocklist: Plugin enabled..')
|
||||
|
@ -57,7 +59,7 @@ class Core(CorePluginBase):
|
|||
## Hooks for core ##
|
||||
def _post_session_load(self):
|
||||
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
|
||||
import gobject
|
||||
gobject.idle_add(self.blocklist.import_list)
|
||||
|
@ -87,6 +89,17 @@ class Core(CorePluginBase):
|
|||
log.debug('Blocklist: Import started from GTK UI')
|
||||
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):
|
||||
log.debug("Blocklist: Set Options")
|
||||
self.blocklist.set_options(settings)
|
||||
|
|
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
|
||||
# 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
|
||||
import deluge.common # for pixmap
|
||||
import deluge.component # for systray
|
||||
import ui
|
||||
import gtk, gobject
|
||||
|
@ -72,13 +72,17 @@ class GtkUI(ui.UI):
|
|||
deluge.component.get("StatusBar").remove_item(self.blocklist_status)
|
||||
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):
|
||||
try:
|
||||
deluge.component.get("StatusBar").remove_item(self.blocklist_status)
|
||||
except:
|
||||
pass
|
||||
# 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):
|
||||
ui.client.block_list_count_ips(self.add_status_icon)
|
||||
|
@ -89,6 +93,11 @@ class GtkUI(ui.UI):
|
|||
log.debug('Blocklist: Import button')
|
||||
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):
|
||||
self.plugin.remove_preferences_page("Blocklist")
|
||||
|
||||
|
@ -113,7 +122,7 @@ class GtkUI(ui.UI):
|
|||
alignment = gtk.Alignment(0.5, 0.5, 1, 1)
|
||||
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_row_spacings(10)
|
||||
|
||||
|
@ -203,17 +212,25 @@ class GtkUI(ui.UI):
|
|||
self.load_on_start = gtk.CheckButton('Import blocklist on daemon startup')
|
||||
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.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)
|
||||
import_button.set_image(image)
|
||||
|
||||
table.attach(import_button, 0, 2, 6, 7)
|
||||
table.attach(import_button, 0, 2, 7, 8)
|
||||
|
||||
|
||||
# finish frame
|
||||
frame.set_label_widget(label)
|
||||
|
@ -247,7 +264,7 @@ class GtkUI(ui.UI):
|
|||
}
|
||||
ui.client.block_list_set_options(None, settings_dict)
|
||||
# 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):
|
||||
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 = {
|
||||
"url": "http://www.bluetack.co.uk/config/pipfilter.dat.gz",
|
||||
"load_on_start": "True",
|
||||
"load_on_start": True,
|
||||
"check_after_days": 2,
|
||||
"listtype": "gzmule",
|
||||
"timeout": 180,
|
||||
|
@ -118,7 +118,6 @@ class TorrentBlockList:
|
|||
def __init__(self, coreplugin):
|
||||
self.plugin = coreplugin # reference from plugin core
|
||||
log.info('Blocklist: TorrentBlockList instantiated')
|
||||
deluge.component.get("Core").session.set_max_connections(0)
|
||||
self.config = deluge.configmanager.ConfigManager("blocklist.conf", BLOCKLIST_PREFS)
|
||||
self.curr = 0
|
||||
self.load_options()
|
||||
|
@ -167,7 +166,7 @@ class TorrentBlockList:
|
|||
# Load newly set options to core plugin
|
||||
self.load_options()
|
||||
|
||||
def check_update(self):
|
||||
def check_update(self, force_check=False):
|
||||
log.info('Blocklist: Checking for updates')
|
||||
|
||||
try:
|
||||
|
@ -193,7 +192,7 @@ class TorrentBlockList:
|
|||
check_newer = False
|
||||
|
||||
# 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')
|
||||
|
||||
j = 0 # counter for loop
|
||||
|
@ -300,6 +299,9 @@ class TorrentBlockList:
|
|||
# CHECKSUM
|
||||
|
||||
log.info('Blocklist: List downloaded sucessfully')
|
||||
break
|
||||
|
||||
# Download completed
|
||||
|
||||
|
||||
def import_list(self):
|
||||
|
|
|
@ -44,7 +44,7 @@ setup(
|
|||
description=__doc__,
|
||||
author=__author__,
|
||||
packages=["blocklist"],
|
||||
package_data = {"blocklist": ["glade/*.glade"]},
|
||||
package_data = {"blocklist": ["data/*"]},
|
||||
entry_points="""
|
||||
[deluge.plugin.core]
|
||||
Blocklist = blocklist:CorePlugin
|
||||
|
|
Loading…
Reference in New Issue