[kupfer] data: Disambiguate like-named actions
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] data: Disambiguate like-named actions
- Date: Sat, 9 Jan 2010 20:22:30 +0000 (UTC)
commit 555302610d49b167e3658470af4140a86f6512e7
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Tue Jan 5 21:53:27 2010 +0100
data: Disambiguate like-named actions
If two actions, for the same object type, have the exact same name, we
disambiguate them by (for now) plugin module name.
kupfer/core/data.py | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/core/data.py b/kupfer/core/data.py
index 1775b45..c61c6ae 100644
--- a/kupfer/core/data.py
+++ b/kupfer/core/data.py
@@ -309,6 +309,24 @@ class SourceController (pretty.OutputMixin):
self.content_decorators = decos
def set_action_decorators(self, decos):
self.action_decorators = decos
+ for typ in self.action_decorators:
+ self._disambiguate_actions(self.action_decorators[typ])
+ def _disambiguate_actions(self, actions):
+ """Rename actions by the same name (adding a suffix)"""
+ # FIXME: Disambiguate by plugin name, not python module name
+ names = {}
+ renames = []
+ for action in actions:
+ name = unicode(action)
+ if name in names:
+ renames.append(names[name])
+ renames.append(action)
+ else:
+ names[name] = action
+ for action in renames:
+ self.output_debug("Disambiguate Action %s" % (action, ))
+ action.name += " (%s)" % (type(action).__module__.split(".")[-1],)
+
def clear_sources(self):
pass
def __contains__(self, src):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]