From 29312ba148c8e43e1b8cb4d9abc433d7404a0965 Mon Sep 17 00:00:00 2001 From: Peng Huang Date: Mon, 5 Dec 2011 14:21:00 -0500 Subject: [PATCH] Create simple engine --- Makefile.am | 1 + configure.ac | 2 + engine/Makefile.am | 100 ++++++++++++++++++++++++++++++++++++++++++++++++ engine/main.vala | 67 ++++++++++++++++++++++++++++++++ engine/simple.xml.in.in | 11 ++++++ src/ibusfactory.c | 2 +- 6 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 engine/Makefile.am create mode 100644 engine/main.vala create mode 100644 engine/simple.xml.in.in diff --git a/Makefile.am b/Makefile.am index b3ea36a..e0c79bf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -58,6 +58,7 @@ SUBDIRS = \ src \ util \ client \ + engine \ data \ m4 \ po \ diff --git a/configure.ac b/configure.ac index 53fac5e..1e4da6d 100644 --- a/configure.ac +++ b/configure.ac @@ -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 index 0000000..b3b46be --- /dev/null +++ b/engine/Makefile.am @@ -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 +# +# 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 index 0000000..9539d69 --- /dev/null +++ b/engine/main.vala @@ -0,0 +1,67 @@ +/* vim:set et sts=4 sw=4: + * + * ibus - The Input Bus + * + * Copyright(c) 2011 Peng Huang + * + * 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 index 0000000..4f626a5 --- /dev/null +++ b/engine/simple.xml.in.in @@ -0,0 +1,11 @@ + + + org.freedesktop.IBus.Simple + A table based simple engine + ${libexecdir}/ibus-engine-simple + @VERSION@ + Peng Huang <shawn.p.huang@gmail.com> + GPL + http://code.google.com/p/ibus + ibus + diff --git a/src/ibusfactory.c b/src/ibusfactory.c index 88c29dd..d6d1231 100644 --- a/src/ibusfactory.c +++ b/src/ibusfactory.c @@ -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 -- 2.7.4