gtg team mailing list archive
-
gtg team
-
Mailing list archive
-
Message #03850
[Merge] lp:~parinporecha/gtg/pluginAPI_bug into lp:gtg
Parin Porecha has proposed merging lp:~parinporecha/gtg/pluginAPI_bug into lp:gtg.
Requested reviews:
Gtg developers (gtg)
Related bugs:
Bug #1228013 in Getting Things GNOME!: "pluginAPI's selection "changed" signal works only for last enabled plugin"
https://bugs.launchpad.net/gtg/+bug/1228013
For more details, see:
https://code.launchpad.net/~parinporecha/gtg/pluginAPI_bug/+merge/186877
This is a patch for the Bug #1228013 (pluginAPI's selection "changed" signal works only for last enabled plugin)
As this is concerned with a new plugin added, please get this branch https://code.launchpad.net/~parinporecha/gtg/pluginAPI_bug_test
and check if there are mistakes in any of the 2 plugins - 'Not today' and 'Yes today' (code for both is almost identical with the exception of button names, icons etc.), thereby checking if the bug is in fact valid or not
--
https://code.launchpad.net/~parinporecha/gtg/pluginAPI_bug/+merge/186877
Your team Gtg developers is requested to review the proposed merge of lp:~parinporecha/gtg/pluginAPI_bug into lp:gtg.
=== modified file 'GTG/core/plugins/api.py'
--- GTG/core/plugins/api.py 2013-02-25 07:35:07 +0000
+++ GTG/core/plugins/api.py 2013-09-20 19:57:19 +0000
@@ -49,7 +49,7 @@
"""
self.__requester = requester
self.__view_manager = view_manager
- self.selection_changed_callback = None
+ self.selection_changed_callback_listeners = []
if taskeditor:
self.__ui = taskeditor
self.__builder = self.__ui.get_builder()
@@ -64,8 +64,8 @@
"changed", self.__selection_changed)
def __selection_changed(self, selection):
- if self.selection_changed_callback:
- self.selection_changed_callback(selection)
+ for func in self.selection_changed_callback_listeners:
+ func(selection)
#=== Accessor methods ========================================================
def is_editor(self):
@@ -114,7 +114,13 @@
return self.__view_manager.browser.get_selected_tasks()
def set_active_selection_changed_callback(self, func):
- self.selection_changed_callback = func
+ if func not in self.selection_changed_callback_listeners:
+ self.selection_changed_callback_listeners.append(func)
+
+ def remove_active_selection_changed_callback(self, plugin_class):
+ new_list = [func for func in self.selection_changed_callback_listeners
+ if func.im_class != plugin_class]
+ self.selection_changed_callback_listeners = new_list
#=== Changing the UI =========================================================
def add_menu_item(self, item):
=== modified file 'GTG/core/plugins/engine.py'
--- GTG/core/plugins/engine.py 2013-08-17 06:20:51 +0000
+++ GTG/core/plugins/engine.py 2013-09-20 19:57:19 +0000
@@ -238,6 +238,8 @@
for api in self.plugin_apis:
if hasattr(plugin.instance, "deactivate"):
plugin.instance.deactivate(api)
+ classname = plugin.instance.deactivate.im_class
+ api.remove_active_selection_changed_callback(classname)
if api.is_editor():
if hasattr(plugin.instance, "onTaskClosed"):
plugin.instance.onTaskClosed(api)