summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/container/settingobject.py2
-rw-r--r--ranger/core/fm.py2
-rw-r--r--ranger/core/loader.py2
-rw-r--r--ranger/ext/signal_dispatcher.py103
-rw-r--r--ranger/gui/widgets/browserview.py2
-rw-r--r--test/tc_signal.py2
6 files changed, 5 insertions, 108 deletions
diff --git a/ranger/container/settingobject.py b/ranger/container/settingobject.py
index 51d6db1a..abdc19de 100644
--- a/ranger/container/settingobject.py
+++ b/ranger/container/settingobject.py
@@ -14,7 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from inspect import isfunction
-from ranger.ext.signal_dispatcher import SignalDispatcher
+from ranger.ext.signals import SignalDispatcher
 from ranger.core.shared import FileManagerAware
 
 ALLOWED_SETTINGS = {
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index cf3f4b20..18935cd3 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -32,7 +32,7 @@ from ranger.container import Bookmarks
 from ranger.core.runner import Runner
 from ranger.ext.get_executables import get_executables
 from ranger.fsobject import Directory
-from ranger.ext.signal_dispatcher import SignalDispatcher
+from ranger.ext.signals import SignalDispatcher
 from ranger import __version__
 from ranger.core.loader import Loader
 
diff --git a/ranger/core/loader.py b/ranger/core/loader.py
index 447483bd..4341595c 100644
--- a/ranger/core/loader.py
+++ b/ranger/core/loader.py
@@ -18,7 +18,7 @@ from time import time, sleep
 from subprocess import Popen, PIPE
 from time import time
 from ranger.core.shared import FileManagerAware
-from ranger.ext.signal_dispatcher import SignalDispatcher
+from ranger.ext.signals import SignalDispatcher
 import math
 import os
 import sys
diff --git a/ranger/ext/signal_dispatcher.py b/ranger/ext/signal_dispatcher.py
deleted file mode 100644
index 3f407bff..00000000
--- a/ranger/ext/signal_dispatcher.py
+++ /dev/null
@@ -1,103 +0,0 @@
-# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
-
-import weakref
-from types import MethodType
-
-class Signal(dict):
-	stopped = False
-	def __init__(self, **keywords):
-		dict.__init__(self, keywords)
-		self.__dict__ = self
-
-	def stop(self):
-		self.stopped = True
-
-
-class SignalHandler(object):
-	active = True
-	def __init__(self, signal_name, function, priority, pass_signal):
-		self.priority = max(0, min(1, priority))
-		self.signal_name = signal_name
-		self.function = function
-		self.pass_signal = pass_signal
-
-
-class SignalDispatcher(object):
-	def __init__(self):
-		self._signals = dict()
-
-	signal_clear = __init__
-
-	def signal_bind(self, signal_name, function, priority=0.5, weak=False):
-		assert isinstance(signal_name, str)
-		try:
-			handlers = self._signals[signal_name]
-		except:
-			handlers = self._signals[signal_name] = []
-		nargs = function.__code__.co_argcount
-
-		try:
-			instance = function.__self__
-		except:
-			if weak:
-				function = weakref.proxy(function)
-		else:
-			nargs -= 1
-			if weak:
-				function = (function.__func__, weakref.proxy(function.__self__))
-		handler = SignalHandler(signal_name, function, priority, nargs > 0)
-		handlers.append(handler)
-		handlers.sort(key=lambda handler: -handler.priority)
-		return handler
-
-	def signal_unbind(self, signal_handler):
-		try:
-			handlers = self._signals[signal_handler.signal_name]
-		except:
-			pass
-		else:
-			try:
-				handlers.remove(signal_handler)
-			except:
-				pass
-
-	def signal_emit(self, signal_name, **kw):
-		assert isinstance(signal_name, str)
-		if signal_name not in self._signals:
-			return True
-		handlers = self._signals[signal_name]
-		if not handlers:
-			return True
-
-		signal = Signal(origin=self, name=signal_name, **kw)
-
-		# propagate
-		for handler in tuple(handlers):
-			if handler.active:
-				try:
-					if isinstance(handler.function, tuple):
-						fnc = MethodType(*handler.function)
-					else:
-						fnc = handler.function
-					if handler.pass_signal:
-						fnc(signal)
-					else:
-						fnc()
-					if signal.stopped:
-						return False
-				except ReferenceError:
-					handlers.remove(handler)
-		return True
diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py
index 8a8f6e14..8857c15e 100644
--- a/ranger/gui/widgets/browserview.py
+++ b/ranger/gui/widgets/browserview.py
@@ -15,7 +15,7 @@
 
 """The BrowserView manages a set of BrowserColumns."""
 import curses
-from ranger.ext.signal_dispatcher import Signal
+from ranger.ext.signals import Signal
 from . import Widget
 from .browsercolumn import BrowserColumn
 from .pager import Pager
diff --git a/test/tc_signal.py b/test/tc_signal.py
index 3b1bac40..6547bbc3 100644
--- a/test/tc_signal.py
+++ b/test/tc_signal.py
@@ -21,7 +21,7 @@ if sys.path[1] != rangerpath:
 
 import unittest
 import gc
-from ranger.ext.signal_dispatcher import *
+from ranger.ext.signals import *
 
 class TestSignal(unittest.TestCase):
 	def setUp(self):