summaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
authorHuang Peng <shawn.p.huang@gmail.com>2009-02-05 10:39:56 +0800
committerHuang Peng <shawn.p.huang@gmail.com>2009-02-05 10:39:56 +0800
commitaedad1ea0a7fef604aa27f4b58433fd8f2ece29e (patch)
treeffcb531d8474bde18b90341bcd4eb639edd74525 /bindings
parent41ad46305a88637dd99f00a2d2a3f455505d357b (diff)
downloadibus-aedad1ea0a7fef604aa27f4b58433fd8f2ece29e.tar.gz
ibus-aedad1ea0a7fef604aa27f4b58433fd8f2ece29e.tar.xz
ibus-aedad1ea0a7fef604aa27f4b58433fd8f2ece29e.zip
re-implement ibus in c language.
Diffstat (limited to 'bindings')
-rw-r--r--bindings/Makefile.am24
-rw-r--r--bindings/python/Makefile.am80
-rw-r--r--bindings/python/common.h7
-rwxr-xr-xbindings/python/gendefs.sh3
-rw-r--r--bindings/python/ibus-types.defs27
-rw-r--r--bindings/python/ibus-virtual-methods.defs23
-rw-r--r--bindings/python/ibus.defs5
-rw-r--r--bindings/python/ibus.override11
-rw-r--r--bindings/python/ibusmodule.c29
9 files changed, 209 insertions, 0 deletions
diff --git a/bindings/Makefile.am b/bindings/Makefile.am
new file mode 100644
index 0000000..59fb9f4
--- /dev/null
+++ b/bindings/Makefile.am
@@ -0,0 +1,24 @@
+# vim:set noet ts=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
+
+SUBDIRS = \
+ python \
+ $(NULL)
diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
new file mode 100644
index 0000000..75a2e49
--- /dev/null
+++ b/bindings/python/Makefile.am
@@ -0,0 +1,80 @@
+# vim:set noet ts=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
+
+# pyexec_PYTHON =
+# pyexec_LTLIBRARIES = ibus.la
+#
+# INCLUDES = \
+# -I$(top_srcdir)/src \
+# -I$(top_builddir)/src \
+# $(NULL)
+#
+# ibus_la_SOURCES = ibus.c ibusmodule.c
+# ibus_la_CFLAGS = \
+# @PYTHON_CFLAGS@ \
+# @GLIB2_CFLAGS@ \
+# @GOBJECT2_CFLAGS@ \
+# @PYGOBJECT2_CFLAGS@ \
+# @DBUS_CFLAGS@ \
+# $(NULL)
+# ibus_la_LDFLAGS = \
+# @PYTHON_LIBS@ \
+# @GLIB2_LIBS@ \
+# @GOBJECT2_LIBS@ \
+# @DBUS_LIBS@ \
+# $(top_builddir)/src/libibus.la \
+# -avoid-version \
+# -module \
+# -export-symbols-regex "initibus" \
+# $(NULL)
+#
+# ibus-codegen.defs:
+# (cd $(srcdir); \
+# ./gendefs.sh; ) > ibus-codegen.defs
+#
+# IBUS_DEFS = \
+# ibus.defs \
+# ibus-types.defs \
+# ibus-func.defs \
+# ibus-virtual-methods.defs \
+# ibus.override \
+# $(NULL)
+#
+# ibus.c: $(IBUS_DEFS) ibus.override ibus-codegen.defs
+#
+# CLEANFILES = ibus.c ibus-codegen.defs
+# EXTRA_DIST = \
+# gendefs.sh \
+# common.h \
+# $(GIK_DEFS) \
+# $(NULL)
+#
+# PYGOBJECT_CODEGEN = pygobject-codegen-2.0
+#
+# .defs.c:
+# (cd $(srcdir)\
+# && $(PYGOBJECT_CODEGEN) \
+# -o $*.override \
+# -I $(abs_builddir) \
+# -p py$* $*.defs) > gen-$*.c \
+# && cp gen-$*.c $*.c \
+# && rm -f gen-$*.c
+#
diff --git a/bindings/python/common.h b/bindings/python/common.h
new file mode 100644
index 0000000..f3267ee
--- /dev/null
+++ b/bindings/python/common.h
@@ -0,0 +1,7 @@
+#ifndef __PY_COMMON_H_
+#define __PY_COMMON_H_
+
+#include <pygobject.h>
+#include <ibus.h>
+
+#endif //__PY_COMMON_H_
diff --git a/bindings/python/gendefs.sh b/bindings/python/gendefs.sh
new file mode 100755
index 0000000..bc92257
--- /dev/null
+++ b/bindings/python/gendefs.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+codegendir=`pkg-config pygobject-2.0 --variable=codegendir`
+python $codegendir/h2def.py -m ibus ../../src/*.h
diff --git a/bindings/python/ibus-types.defs b/bindings/python/ibus-types.defs
new file mode 100644
index 0000000..a077851
--- /dev/null
+++ b/bindings/python/ibus-types.defs
@@ -0,0 +1,27 @@
+;; (define-boxed EventKey
+;; (in-module "Gik")
+;; (c-name "GikEventKey")
+;; (gtype-id "GIK_TYPE_EVENT_KEY")
+;; (copy-func "gik_event_copy")
+;; (release-func "gik_event_free")
+;; (fields
+;; '("gint" "type")
+;; '("guint" "state")
+;; '("guint" "keyval")
+;; '("guint16" "hardware_keycode")
+;; '("guint" "is_modifier")
+;; )
+;; )
+;;
+;; (define-boxed Event
+;; (in-module "Gik")
+;; (c-name "GikEvent")
+;; (gtype-id "GIK_TYPE_EVENT")
+;; (copy-func "gik_event_copy")
+;; (release-func "gik_event_free")
+;; (fields
+;; '("gint" "type")
+;; '("GikEventKey" "key")
+;; )
+;; )
+;;
diff --git a/bindings/python/ibus-virtual-methods.defs b/bindings/python/ibus-virtual-methods.defs
new file mode 100644
index 0000000..542f0b4
--- /dev/null
+++ b/bindings/python/ibus-virtual-methods.defs
@@ -0,0 +1,23 @@
+;; For GikEngine class
+;; (define-virtual filter_keypress
+;; (of-object "GikEngine")
+;; (return-type "gboolean")
+;; (parameters
+;; '("GikEventKey*" "key")
+;; )
+;; )
+;;
+;; (define-virtual focus_in
+;; (of-object "GikEngine")
+;; (return-type "none")
+;; )
+;;
+;; (define-virtual focus_out
+;; (of-object "GikEngine")
+;; (return-type "none")
+;; )
+;;
+;; (define-virtual reset
+;; (of-object "GikEngine")
+;; (return-type "none")
+;; )
diff --git a/bindings/python/ibus.defs b/bindings/python/ibus.defs
new file mode 100644
index 0000000..eada9c8
--- /dev/null
+++ b/bindings/python/ibus.defs
@@ -0,0 +1,5 @@
+(include "ibus-types.defs")
+(include "ibus-func.defs")
+(include "ibus-virtual-methods.defs")
+(include "ibus-codegen.defs")
+
diff --git a/bindings/python/ibus.override b/bindings/python/ibus.override
new file mode 100644
index 0000000..a00771c
--- /dev/null
+++ b/bindings/python/ibus.override
@@ -0,0 +1,11 @@
+%%
+headers
+#include "common.h"
+%%
+modulename ibus
+%%
+import gobject.GObject as PyGObject_Type
+%%
+ignore-glob
+ *_get_type
+%%
diff --git a/bindings/python/ibusmodule.c b/bindings/python/ibusmodule.c
new file mode 100644
index 0000000..875ff88
--- /dev/null
+++ b/bindings/python/ibusmodule.c
@@ -0,0 +1,29 @@
+#include <Python.h>
+#include <pygobject.h>
+
+void pyibus_register_classes (PyObject *d);
+void pyibus_add_constants (PyObject *module, const gchar *strip_prefix);
+extern PyMethodDef pyibus_functions[];
+
+
+DL_EXPORT(void)
+initibus (void)
+{
+ PyObject *m, *d;
+
+ init_pygobject ();
+
+ m = Py_InitModule ("ibus", pyibus_functions);
+ d = PyModule_GetDict (m);
+
+ pyibus_register_classes (d);
+
+ if (PyErr_Occurred ()) {
+ Py_FatalError ("unable to initialise ibus module");
+ }
+ pyibus_add_constants (m, "GIK_");
+ if (PyErr_Occurred ()) {
+ Py_FatalError ("unable to initialise ibus module");
+ }
+}
+