[caribou/imcontext: 1/9] eh?
- From: Eitan Isaacson <eitani src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [caribou/imcontext: 1/9] eh?
- Date: Sat, 4 Jun 2011 21:09:30 +0000 (UTC)
commit 9944460ff115de5c3503348d826ba268abaa0042
Author: Eitan Isaacson <eitan monotonous org>
Date: Thu Jun 2 17:57:52 2011 -0700
eh?
Makefile.am | 4 +
configure.ac | 24 +++++++
im/Makefile.am | 1 +
im/gtk3/Makefile.am | 27 ++++++++
im/gtk3/caribou-im.c | 55 ++++++++++++++++
im/gtk3/caribou-imcontext.c | 144 +++++++++++++++++++++++++++++++++++++++++++
im/gtk3/caribou-imcontext.h | 35 ++++++++++
7 files changed, 290 insertions(+), 0 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 8b57e28..5a1866e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,7 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
SUBDIRS = caribou bin data po libcaribou
+
+if ENABLE_IM_MODULES
+SUBDIRS += im
+endif
\ No newline at end of file
diff --git a/configure.ac b/configure.ac
index d8d5af1..ec26491 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,6 +57,27 @@ AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The gettext package])
AM_GLIB_GNU_GETTEXT
+dnl == IM modules ==
+AC_ARG_ENABLE(im_modules,
+ AS_HELP_STRING([--disable-im-modules],
+ [Do not build im modules]),
+ [enable_im_modules=$enableval],
+ [enable_im_modules=yes]
+)
+AM_CONDITIONAL([ENABLE_IM_MODULES], [test x"$enable_im_modules" = x"yes"])
+
+if test x"$enable_im_modules" = x"yes"; then
+ PKG_CHECK_MODULES(GTK2, [
+ gtk+-2.0
+ ])
+ gtk2_binary_version=`$PKG_CONFIG --variable=gtk_binary_version gtk+-2.0`
+ GTK2_IM_MODULEDIR="$libdir"/gtk-2.0/$gtk2_binary_version/immodules
+
+ gtk3_binary_version=`$PKG_CONFIG --variable=gtk_binary_version gtk+-3.0`
+ GTK3_IM_MODULEDIR="$libdir"/gtk-3.0/$gtk3_binary_version/immodules
+fi
+
+dnl == GSettings ==
GLIB_GSETTINGS
dnl == intltool check ==
@@ -87,4 +108,7 @@ data/layouts/Makefile
data/layouts/touch/Makefile
data/layouts/scan/Makefile
libcaribou/Makefile
+im/Makefile
+im/gtk2/Makefile
+im/gtk3/Makefile
])
diff --git a/im/Makefile.am b/im/Makefile.am
new file mode 100644
index 0000000..8c1607e
--- /dev/null
+++ b/im/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = gtk3
diff --git a/im/gtk3/Makefile.am b/im/gtk3/Makefile.am
new file mode 100644
index 0000000..377e50c
--- /dev/null
+++ b/im/gtk3/Makefile.am
@@ -0,0 +1,27 @@
+immoduledir = @GTK2_IM_MODULEDIR@
+immodule_LTLIBRARIES = im-caribou.la
+
+im_caribou_la_SOURCES = \
+ caribou-im.c \
+ caribou-imcontext.c \
+ caribou-imcontext.h \
+ $(NULL)
+
+im_caribou_la_CFLAGS = \
+ @GTK2_CFLAGS@ \
+ @DBUS_CFLAGS@ \
+ -DG_LOG_DOMAIN=\"CARIBOU\" \
+ $(NULL)
+
+im_caribou_la_LIBADD = \
+ @GTK2_LIBS@ \
+ @DBUS_LIBS@ \
+ $(NULL)
+
+im_caribou_la_LDFLAGS = \
+ -avoid-version \
+ -module \
+ $(NULL)
+
+EXTRA_DIST = \
+ $(NULL)
diff --git a/im/gtk3/caribou-im.c b/im/gtk3/caribou-im.c
new file mode 100644
index 0000000..9022af2
--- /dev/null
+++ b/im/gtk3/caribou-im.c
@@ -0,0 +1,55 @@
+#include <gtk/gtk.h>
+#include <gtk/gtkimmodule.h>
+#include "caribou-imcontext.h"
+
+#define CARIBOU_LOCALDIR ""
+static const GtkIMContextInfo caribou_im_info = {
+ "caribou",
+ "Caribou OSK helper module",
+ "caribou",
+ "",
+ "*"
+};
+
+static const GtkIMContextInfo *info_list[] = {
+ &caribou_im_info
+};
+
+G_MODULE_EXPORT const gchar*
+g_module_check_init (GModule *module)
+{
+ return glib_check_version (GLIB_MAJOR_VERSION,
+ GLIB_MINOR_VERSION,
+ 0);
+}
+
+G_MODULE_EXPORT void
+im_module_init (GTypeModule *type_module)
+{
+ g_type_module_use (type_module);
+ caribou_init ();
+ caribou_im_context_register_type (type_module);
+}
+
+G_MODULE_EXPORT void
+im_module_exit (void)
+{
+}
+
+G_MODULE_EXPORT GtkIMContext *
+im_module_create (const gchar *context_id)
+{
+ if (g_strcmp0 (context_id, "caribou") == 0) {
+ CaribouIMContext *context = caribou_im_context_new ();
+ return (GtkIMContext *) context;
+ }
+ return NULL;
+}
+
+G_MODULE_EXPORT void
+im_module_list (const GtkIMContextInfo ***contexts,
+ gint *n_contexts)
+{
+ *contexts = info_list;
+ *n_contexts = G_N_ELEMENTS (info_list);
+}
diff --git a/im/gtk3/caribou-imcontext.c b/im/gtk3/caribou-imcontext.c
new file mode 100644
index 0000000..68d1607
--- /dev/null
+++ b/im/gtk3/caribou-imcontext.c
@@ -0,0 +1,144 @@
+#include <X11/keysym.h>
+
+static GType _caribou_imcontext_type = 0;
+static GtkIMContextClass *parent_class = NULL;
+
+static CaribouIMContext *focused_imcontext = NULL;
+static GtkWidget *focused_widget = NULL;
+
+GType caribou_imcontext_get_type ()
+{
+ if (_caribou_imcontext_type == 0)
+ caribou_imcontext_register_type (NULL);
+
+ return _caribou_imcontext_type;
+}
+
+void
+caribou_imcontext_register_type (GTypeModule *type_module)
+{
+ static const GTypeInfo caribou_imcontext_info = {
+ sizeof (CaribouIMContextClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) caribou_imcontext_class_init,
+ NULL,
+ NULL,
+ sizeof (CaribouIMContext),
+ 0,
+ (GInstanceInitFunc) caribou_imcontext_init,
+ };
+
+ if (_caribou_imcontext_type)
+ return;
+
+ if (type_module) {
+ _caribou_imcontext_type =
+ g_type_module_register_type(
+ type_module,
+ GTK_TYPE_IM_CONTEXT,
+ "CaribouIMContext",
+ &caribou_imcontext_info,
+ (GTypeFlags)0);
+ } else {
+ _caribou_imcontext_type =
+ g_type_register_static(
+ GTK_TYPE_IM_CONTEXT,
+ "CaribouIMContext",
+ &caribou_imcontext_info,
+ (GTypeFlags)0);
+ }
+}
+
+GtkIMContext *
+caribou_imcontext_new (void)
+{
+ CaribouIMContext *ic = CARIBOU_IMCONTEXT(g_object_new(CARIBOU_TYPE_IMCONTEXT, NULL));
+ return GTK_IM_CONTEXT(ic);
+}
+
+
+static void
+caribou_imcontext_finalize (GObject *object)
+{
+ CaribouIMContext *imcontext = CARIBOU_IMCONTEXT(object);
+ G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static void
+caribou_imcontext_init (CaribouIMContext *self)
+{
+}
+
+
+static void
+caribou_imcontext_focus_in (GtkIMContext *context)
+{
+}
+
+
+static void
+caribou_imcontext_focus_out (GtkIMContext *context)
+{
+}
+
+
+static gboolean
+caribou_imcontext_filter_key_event (GtkIMContext *context, GdkEventKey *event)
+{
+ return TRUE;
+}
+
+
+static void
+caribou_imcontext_reset (GtkIMContext *context)
+{
+}
+
+
+static void
+caribou_imcontext_get_preedit_string (GtkIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos)
+{
+ CaribouIMContext *imcontext = CARIBOU_IMCONTEXT(context);
+ *str = g_strdup ("Hello?");
+ *attrs = pango_attr_list_new();
+ *cursor_pos = 14;
+}
+
+
+static void
+caribou_imcontext_set_preedit_enabled (GtkIMContext *context, gboolean enabled)
+{
+ return;
+}
+
+
+static void
+caribou_imcontext_set_client_window (GtkIMContext *context, GdkWindow *window)
+{
+}
+
+
+static void
+caribou_imcontext_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
+{
+}
+
+static void
+caribou_imcontext_class_init (CaribouIMContextClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
+ parent_class = (GtkIMContextClass *)g_type_class_peek_parent(klass);
+ GtkIMContextClass *imclass = GTK_IM_CONTEXT_CLASS(klass);
+
+ gobject_class->finalize = caribou_imcontext_finalize;
+
+ imclass->focus_in = caribou_imcontext_focus_in;
+ imclass->focus_out = caribou_imcontext_focus_out;
+ imclass->filter_keypress = caribou_imcontext_filter_key_event;
+ imclass->reset = caribou_imcontext_reset;
+ imclass->set_client_window = caribou_imcontext_set_client_window;
+ imclass->get_preedit_string = caribou_imcontext_get_preedit_string;
+ imclass->set_cursor_location = caribou_imcontext_set_cursor_location;
+ imclass->set_use_preedit = caribou_imcontext_set_preedit_enabled;
+}
diff --git a/im/gtk3/caribou-imcontext.h b/im/gtk3/caribou-imcontext.h
new file mode 100644
index 0000000..717a7dc
--- /dev/null
+++ b/im/gtk3/caribou-imcontext.h
@@ -0,0 +1,35 @@
+#ifndef _CARIBOU_IMCONTEXT_H
+#define _CARIBOU_IMCONTEXT_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _CaribouIMContext CaribouIMContext;
+typedef struct _CaribouIMContextClass CaribouIMContextClass;
+
+#define CARIBOU_TYPE_IMCONTEXT (caribou_imcontext_get_type())
+#define CARIBOU_IMCONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CARIBOU_TYPE_IMCONTEXT, CaribouIMContext))
+#define CARIBOU_IMCONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), CARIBOU_TYPE_IMCONTEXT, CaribouIMContextClass))
+#define CARIBOU_IS_IMCONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), CARIBOU_TYPE_IMCONTEXT))
+#define CARIBOU_IS_IMCONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), CARIBOU_TYPE_IMCONTEXT))
+#define CARIBOU_IMCONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CARIBOU_TYPE_IMCONTEXT, CaribouIMContextClass))
+
+
+struct _CaribouIMContext {
+ GtkIMContext parent;
+};
+
+struct _CaribouIMContextClass {
+ GtkIMContextClass parent;
+};
+
+GType caribou_imcontext_get_type (void);
+
+void caribou_imcontext_register_type (GTypeModule *type_module);
+GtkIMContext *caribou_imcontext_new (void);
+
+
+G_END_DECLS
+
+#endif //_CARIBOU_IMCONTEXT_H
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]