[gedit/libgpe] Python: Handle the old API for config dialog creation.



commit 55db35a41bdbcbb82bb7b9a6d526768ffb0a2284
Author: Steve Frécinaux <code istique net>
Date:   Thu Nov 5 20:00:29 2009 +0100

    Python: Handle the old API for config dialog creation.
    
    We now override do_create_configuration_dialog and do_is_configurable
    the same way we do for the other methods, so we can be backward
    compatible there too.

 bindings/python/__init__.py |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/bindings/python/__init__.py b/bindings/python/__init__.py
index bec07de..827890e 100644
--- a/bindings/python/__init__.py
+++ b/bindings/python/__init__.py
@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
+# ex:set ts=4 et sw=4 ai:
 #
 #    Gedit Python bindings
 #    Copyright (C) 2009  Steve Frécinaux
@@ -23,18 +24,27 @@ from gedit._gedit import *
 import gobject
 from gedit import _gedit
 
+def _method_is_overriden(plugin, method_name):
+    child_method = getattr(plugin.__class__, method_name)
+    parent_method = getattr(_gedit.Plugin, method_name)
+    return child_method != parent_method
+
 def _proxy_plugin_method(method_name):
     def method(self, window):
-        child_method = getattr(self.__class__, method_name)
-        parent_method = getattr(_gedit.Plugin, method_name)
-        if child_method != parent_method:
-            return child_method(self, window)
+        if _method_is_overriden(self, method_name):
+            return getattr(self, method_name)(window)
     return method
 
-
 class Plugin(_gedit.Plugin):
     do_activate = _proxy_plugin_method('activate')
     do_deactivate = _proxy_plugin_method('deactivate')
     do_update_ui = _proxy_plugin_method('update_ui')
 
+    def do_is_configurable(self):
+        return _method_is_overriden(self, 'create_configure_dialog')
+
+    def do_create_configure_dialog(self):
+        if _method_is_overriden(self, 'create_configure_dialog'):
+            return self.create_configure_dialog()
+
 gobject.type_register(Plugin)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]