Create simple engine
authorPeng Huang <shawn.p.huang@gmail.com>
Mon, 5 Dec 2011 19:21:00 +0000 (14:21 -0500)
committerPeng Huang <shawn.p.huang@gmail.com>
Tue, 21 Feb 2012 16:51:01 +0000 (11:51 -0500)
Makefile.am
configure.ac
engine/Makefile.am [new file with mode: 0644]
engine/main.vala [new file with mode: 0644]
engine/simple.xml.in.in [new file with mode: 0644]
src/ibusfactory.c

index b3ea36a..e0c79bf 100644 (file)
@@ -58,6 +58,7 @@ SUBDIRS =           \
        src             \
        util            \
        client          \
+       engine          \
        data            \
        m4              \
        po              \
index 53fac5e..1e4da6d 100644 (file)
@@ -456,6 +456,8 @@ src/Makefile
 src/ibusversion.h
 src/tests/Makefile
 bus/Makefile
+engine/Makefile
+engine/simple.xml.in
 util/Makefile
 util/IMdkit/Makefile
 data/Makefile
diff --git a/engine/Makefile.am b/engine/Makefile.am
new file mode 100644 (file)
index 0000000..b3b46be
--- /dev/null
@@ -0,0 +1,100 @@
+# vim:set noet ts=4:
+#
+# ibus - The Input Bus
+#
+# Copyright (c) 2010, Google Inc. All rights reserved.
+# Copyright (c) 2007-2010 Peng Huang <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
+
+libibus = $(top_builddir)/src/libibus-@IBUS_API_VERSION@.la
+
+INCLUDES = \
+       -I$(top_srcdir)/src \
+       -I$(top_builddir)/src \
+       $(NULL)
+
+AM_CFLAGS = \
+       @GLIB2_CFLAGS@ \
+       @GIO2_CFLAGS@ \
+       @GTHREAD2_CFLAGS@ \
+       $(INCLUDES) \
+       -DG_LOG_DOMAIN=\"IBUS\" \
+       -DPKGDATADIR=\"$(pkgdatadir)\" \
+       -DLIBEXECDIR=\"$(libexecdir)\" \
+       -DBINDIR=\"@bindir@\" \
+    -DIBUS_DISABLE_DEPRECATED \
+       -Wno-unused-variable \
+       -Wno-unused-but-set-variable \
+       -Wno-unused-function \
+       $(NULL)
+
+AM_LDADD = \
+       @GOBJECT2_LIBS@ \
+       @GLIB2_LIBS@ \
+       @GIO2_LIBS@ \
+       @GTHREAD2_LIBS@ \
+       $(libibus) \
+       $(NULL)
+
+AM_VALAFLAGS = \
+       --vapidir=$(top_builddir)/bindings/vala \
+       --pkg=ibus-1.0 \
+       $(NULL)
+
+libexec_PROGRAMS = \
+       ibus-engine-simple \
+       $(NULL)
+
+ibus_engine_simple_SOURCES = \
+       main.vala \
+       $(NULL)
+ibus_engine_simple_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(NULL)
+ibus_engine_simple_LDADD = \
+       $(AM_LDADD) \
+       $(NULL)
+ibus_engine_simple_DEPENDENCIES = \
+       $(libibus) \
+       $(NULL)
+
+component_DATA = \
+       simple.xml \
+       $(NULL)
+
+componentdir = $(pkgdatadir)/component
+
+CLEANFILES = \
+       simple.xml \
+       $(NULL)
+
+EXTRA_DIST = \
+       simple.xml.in.in \
+       $(NULL)
+
+simple.xml: simple.xml.in
+       $(AM_V_GEN) \
+       ( \
+               libexecdir=${libexecdir}; \
+               s=`cat $<`; \
+               eval "echo \"$${s}\""; \
+       ) > $@
+
+$(libibus):
+       $(MAKE) -C $(top_builddir)/src
+
+-include $(top_srcdir)/git.mk
diff --git a/engine/main.vala b/engine/main.vala
new file mode 100644 (file)
index 0000000..9539d69
--- /dev/null
@@ -0,0 +1,67 @@
+/* vim:set et sts=4 sw=4:
+ *
+ * ibus - The Input Bus
+ *
+ * Copyright(c) 2011 Peng Huang <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
+ */
+
+using IBus;
+
+class DummyEngine : IBus.EngineSimple {
+}
+
+public int main(string[] args) {
+    IBus.init();
+
+    IBus.Bus bus = new IBus.Bus();
+    if (!bus.is_connected()) {
+        warning("ibus-daemon does not exist.");
+        return 1;
+    }
+
+    uint flags = 
+        IBus.BusNameFlag.REPLACE_EXISTING |
+        IBus.BusNameFlag.ALLOW_REPLACEMENT;
+    uint retval = bus.request_name("org.freedesktop.IBus.Simple", flags);
+
+    if (retval == 0) {
+        warning("Registry bus name org.freedesktop.IBus.Simple failed!");
+        return 1;
+    }
+
+    bus.disconnected.connect((bus) => {
+        debug("bus disconnected");
+        IBus.quit();
+    });
+
+    IBus.Factory factory = new IBus.Factory(bus.get_connection());
+    
+    int id = 0;
+
+    factory.create_engine.connect((factory, name) => {
+        const string path = "/org/freedesktop/IBus/engine/simple/%d";
+        IBus.Engine engine = new IBus.Engine.type(
+            typeof(IBus.EngineSimple), name,
+            path.printf(++id), bus.get_connection());
+        return engine;
+    });
+
+    IBus.main();
+
+    return 0;
+}
diff --git a/engine/simple.xml.in.in b/engine/simple.xml.in.in
new file mode 100644 (file)
index 0000000..4f626a5
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<component>
+       <name>org.freedesktop.IBus.Simple</name>
+       <description>A table based simple engine</description>
+       <exec>${libexecdir}/ibus-engine-simple</exec>
+       <version>@VERSION@</version>
+       <author>Peng Huang &lt;shawn.p.huang@gmail.com&gt;</author>
+       <license>GPL</license>
+       <homepage>http://code.google.com/p/ibus</homepage>
+       <textdomain>ibus</textdomain>
+</component>
index 88c29dd..d6d1231 100644 (file)
@@ -164,7 +164,7 @@ ibus_factory_class_init (IBusFactoryClass *class)
      * IBusFactory::create-engine:
      * @factory: the factory which received the signal
      * @engine_name: the engine_name which received the signal
-     * @returns: (transfer none): An IBusEngine
+     * @returns: (transfer full): An IBusEngine
      *
      * The ::create-engine signal is a signal to create IBusEngine
      * with @engine_name, which gets emitted when IBusFactory