Add EngineFactory class.
authorHuang Peng <shawn.p.huang@gmail.com>
Fri, 18 Jul 2008 01:20:55 +0000 (09:20 +0800)
committerHuang Peng <shawn.p.huang@gmail.com>
Fri, 18 Jul 2008 01:20:55 +0000 (09:20 +0800)
ibus/Makefile.am
ibus/__init__.py
ibus/factory.py [new file with mode: 0644]

index b06bcc9..eca1e1c 100644 (file)
@@ -30,6 +30,7 @@ ibus_PYTHON = \
        connection.py \
        engine.py \
        exception.py \
+       factory.py \
        gtk.py \
        __init__.py \
        keysyms.py \
index 4d88f3e..b777d60 100644 (file)
@@ -29,3 +29,5 @@ from lookuptable import *
 from connection import *
 from lang import *
 from utility import *
+from engine import *
+from factory import *
diff --git a/ibus/factory.py b/ibus/factory.py
new file mode 100644 (file)
index 0000000..7273981
--- /dev/null
@@ -0,0 +1,86 @@
+# vim:set et sts=4 sw=4:
+#
+# ibus - The Input Bus
+#
+# Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+# Boston, MA  02111-1307  USA
+
+__all__ = (
+        "EngineFactoryBase",
+    )
+
+import ibus
+from ibus import interface
+
+class EngineFactoryBase(ibus.Object):
+    def __init__(self, info, engine_class, engine_path, conn, object_path):
+        super(EngineFactoryBase, self).__init__()
+        self.__proxy = EngineFactoryProxy (self, conn, object_path)
+        self.__info = info
+        self.__conn = conn
+        self.__engine_class = engine_class
+        self.__engine_path = engine_path
+        self.__engine_id = 1
+
+    def get_info(self):
+        return self.__info
+
+    def initialize(self):
+        pass
+
+    def uninitialize(self):
+        pass
+
+    def create_engine(self):
+        engine = engine_class(conn, engine_path + str(self.__engine_id))
+        self.__engine_id += 1
+        return engine
+
+    def do_destroy(self):
+        self.__proxy = None
+        self.__conn = None
+        self.__info = None
+        self.__engine_class = None
+        self.__engine_path = None
+        super(EngineBase,self).do_destroy()
+
+gobject.type_register(EngineFactoryBase)
+
+class EngineFactoryProxy(interface.IEngineFactory):
+    def __init__(self, factory, conn, object_path):
+        super(EngineFactoryProxy, self).__init__(dbusconn, object_path)
+        self.__conn = conn
+        self.__factory = factory
+
+    def GetInfo(self):
+        return self.__factory.get_info()
+
+    def Initialize(self):
+        return self.__factory.initialize()
+
+    def Uninitialize(self):
+        return self.__factory.uninitialize()
+
+    def CreateEngine(self):
+        return self.__factory.create_factory()
+
+    def Destroy(self):
+        self.__factory.destroy()
+        self.__factory = None
+        self.remove_from_connection ()
+        self.__conn = None
+