[caribou: 1/23] Add Caribou to GTK_MODULES
- From: Eitan Isaacson <eitani src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [caribou: 1/23] Add Caribou to GTK_MODULES
- Date: Fri, 12 Aug 2011 07:47:15 +0000 (UTC)
commit 35fbd7d84509a6f4c7df8274450733fd0afd9044
Author: Nohemi Fernandez <nf68 cornell edu>
Date: Thu Jul 28 11:35:55 2011 -0500
Add Caribou to GTK_MODULES
The Caribou IM module would override any other modules the user is
utilizing; by adding it to the GTK_MODULES the user can decide whether
or not to enable the module (enabled automatically for onscreen
keyboard) and will avoid override. There is also no dependency for
the abstract class GtkIMContextSimple.
Makefile.am | 2 +-
caribou/antler/window.py | 4 +-
configure.ac | 46 ++++----
im/gtk2/caribou-im.c | 1 -
im/gtk2/caribou-imcontext.vala | 1 -
im/gtk3/caribou-im.c | 53 ---------
{im => modules}/Makefile.am | 4 +-
{im => modules}/gtk2/Makefile.am | 20 ++--
modules/gtk2/caribou-gtk-modules.vala | 1 +
modules/gtk2/caribou-module.c | 1 +
{im => modules}/gtk2/vapi-fixes.vapi | 0
{im => modules}/gtk3/Makefile.am | 20 ++--
.../gtk3/caribou-gtk-modules.vala | 113 +++++++++++---------
modules/gtk3/caribou-module.c | 21 ++++
{im => modules}/gtk3/vapi-fixes.vapi | 0
15 files changed, 131 insertions(+), 156 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 9f4eb5b..6196fc2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,3 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
-SUBDIRS = caribou bin data po libcaribou im tools
+SUBDIRS = caribou bin data po libcaribou modules tools
diff --git a/caribou/antler/window.py b/caribou/antler/window.py
index a72203e..c567a93 100644
--- a/caribou/antler/window.py
+++ b/caribou/antler/window.py
@@ -386,9 +386,9 @@ class AntlerWindowDocked(AntlerWindow):
x, y = self.get_position()
return self.animated_move(x + self.get_allocated_width(), y)
- def hide(self):
+ def hide(self, timestamp):
animation = self._roll_out()
- animation.connect('completed', lambda x: AntlerWindow.hide(self))
+ animation.connect('completed', lambda x: AntlerWindow.hide(self, timestamp))
class AntlerWindowEntry(AntlerWindow):
def __init__(self, keyboard_view_factory):
diff --git a/configure.ac b/configure.ac
index 004aedf..5ba155d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,41 +57,39 @@ 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_gtk3_module,
- AS_HELP_STRING([--enable-im-gtk3-module],
- [Build GTK3 im module]),
- [enable_gtk3_im_module=$enableval],
- [enable_gtk3_im_module=no]
+dnl == GTK modules ==
+AC_ARG_ENABLE(gtk3_module,
+ AS_HELP_STRING([--enable-gtk3-module],
+ [Build GTK3 module]),
+ [enable_gtk3_module=$enableval],
+ [enable_gtk3_module=yes]
)
-AM_CONDITIONAL([ENABLE_GTK3_IM_MODULE], [test x"$enable_gtk3_im_module" = x"yes"])
+AM_CONDITIONAL([ENABLE_GTK3_MODULES], [test x"$enable_gtk3_module" = x"yes"])
-if test x"$enable_gtk3_im_module" = x"yes"; then
+if test x"$enable_gtk3_module" = x"yes"; then
PKG_CHECK_MODULES(GTK3, [
gtk+-3.0
])
- gtk3_binary_version=`$PKG_CONFIG --variable=gtk_binary_version gtk+-3.0`
- GTK3_IM_MODULEDIR="$libdir"/gtk-3.0/$gtk3_binary_version/immodules
- AC_SUBST(GTK3_IM_MODULEDIR)
+ GTK3_MODULES_DIR="$libdir"/gtk-3.0/modules
+ AC_SUBST(GTK3_MODULES_DIR)
fi
-AC_ARG_ENABLE(im_gtk2_module,
- AS_HELP_STRING([--enable-im-gtk2-module],
- [Build GTK2 im module]),
- [enable_gtk2_im_module=$enableval],
- [enable_gtk2_im_module=no]
+AC_ARG_ENABLE(gtk2_module,
+ AS_HELP_STRING([--enable-gtk2-module],
+ [Build GTK2 module]),
+ [enable_gtk2_module=$enableval],
+ [enable_gtk2_module=yes]
)
-AM_CONDITIONAL([ENABLE_GTK2_IM_MODULE], [test x"$enable_gtk2_im_module" = x"yes"])
+AM_CONDITIONAL([ENABLE_GTK2_MODULES], [test x"$enable_gtk2_module" = x"yes"])
-if test x"$enable_gtk2_im_module" = x"yes"; then
+if test x"$enable_gtk2_module" = 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
- AC_SUBST(GTK2_IM_MODULEDIR)
+ GTK2_MODULES_DIR="$libdir"/gtk-2.0/modules
+ AC_SUBST(GTK2_MODULES_DIR)
fi
dnl == GSettings ==
@@ -126,8 +124,8 @@ data/layouts/touch/Makefile
data/layouts/scan/Makefile
data/layouts/fullscale/Makefile
libcaribou/Makefile
-im/Makefile
-im/gtk3/Makefile
-im/gtk2/Makefile
+modules/Makefile
+modules/gtk3/Makefile
+modules/gtk2/Makefile
tools/Makefile
])
diff --git a/im/Makefile.am b/modules/Makefile.am
similarity index 52%
rename from im/Makefile.am
rename to modules/Makefile.am
index db39a37..47ecbb7 100644
--- a/im/Makefile.am
+++ b/modules/Makefile.am
@@ -1,9 +1,9 @@
SUBDIRS =
-if ENABLE_GTK3_IM_MODULE
+if ENABLE_GTK3_MODULES
SUBDIRS += gtk3
endif
-if ENABLE_GTK2_IM_MODULE
+if ENABLE_GTK2_MODULES
SUBDIRS += gtk2
endif
diff --git a/im/gtk2/Makefile.am b/modules/gtk2/Makefile.am
similarity index 52%
rename from im/gtk2/Makefile.am
rename to modules/gtk2/Makefile.am
index 6c8dea4..cff49fd 100644
--- a/im/gtk2/Makefile.am
+++ b/modules/gtk2/Makefile.am
@@ -1,29 +1,29 @@
-immoduledir = @GTK2_IM_MODULEDIR@
-immodule_LTLIBRARIES = im-caribou.la
+gtk_modulesdir = @GTK2_MODULES_DIR@
+gtk_modules_LTLIBRARIES = libcaribou.la
-im_caribou_la_SOURCES = \
- caribou-imcontext.vala \
- caribou-im.c \
+libcaribou_la_SOURCES = \
+ caribou-gtk-modules.vala \
+ caribou-module.c \
$(NULL)
-im_caribou_la_VALAFLAGS = \
- -h caribou-imcontext.h \
+libcaribou_la_VALAFLAGS = \
+ -h caribou-gtk-modules.h \
--vapidir=. \
--pkg vapi-fixes \
--pkg gtk+-2.0 \
-D GTK2 \
$(VALAGLAFS)
-im_caribou_la_CFLAGS = \
+libcaribou_la_CFLAGS = \
@GTK2_CFLAGS@ \
-DG_LOG_DOMAIN=\"CARIBOU\" \
$(NULL)
-im_caribou_la_LIBADD = \
+libcaribou_la_LIBADD = \
@GTK2_LIBS@ \
$(NULL)
-im_caribou_la_LDFLAGS = \
+libcaribou_la_LDFLAGS = \
-avoid-version \
-module \
$(NULL)
diff --git a/modules/gtk2/caribou-gtk-modules.vala b/modules/gtk2/caribou-gtk-modules.vala
new file mode 120000
index 0000000..5b7285b
--- /dev/null
+++ b/modules/gtk2/caribou-gtk-modules.vala
@@ -0,0 +1 @@
+../gtk3/caribou-gtk-modules.vala
\ No newline at end of file
diff --git a/modules/gtk2/caribou-module.c b/modules/gtk2/caribou-module.c
new file mode 120000
index 0000000..e08e22e
--- /dev/null
+++ b/modules/gtk2/caribou-module.c
@@ -0,0 +1 @@
+../gtk3/caribou-module.c
\ No newline at end of file
diff --git a/im/gtk2/vapi-fixes.vapi b/modules/gtk2/vapi-fixes.vapi
similarity index 100%
rename from im/gtk2/vapi-fixes.vapi
rename to modules/gtk2/vapi-fixes.vapi
diff --git a/im/gtk3/Makefile.am b/modules/gtk3/Makefile.am
similarity index 51%
rename from im/gtk3/Makefile.am
rename to modules/gtk3/Makefile.am
index 4863c55..54ef4cc 100644
--- a/im/gtk3/Makefile.am
+++ b/modules/gtk3/Makefile.am
@@ -1,28 +1,28 @@
-immoduledir = @GTK3_IM_MODULEDIR@
-immodule_LTLIBRARIES = im-caribou.la
+gtk_modulesdir = @GTK3_MODULES_DIR@
+gtk_modules_LTLIBRARIES = libcaribou.la
-im_caribou_la_SOURCES = \
- caribou-imcontext.vala \
- caribou-im.c \
+libcaribou_la_SOURCES = \
+ caribou-gtk-modules.vala \
+ caribou-module.c \
$(NULL)
-im_caribou_la_VALAFLAGS = \
- -h caribou-imcontext.h \
+libcaribou_la_VALAFLAGS = \
+ -h caribou-gtk-modules.h \
--vapidir=. \
--pkg vapi-fixes \
--pkg gtk+-3.0 \
$(VALAGLAFS)
-im_caribou_la_CFLAGS = \
+libcaribou_la_CFLAGS = \
@GTK3_CFLAGS@ \
-DG_LOG_DOMAIN=\"CARIBOU\" \
$(NULL)
-im_caribou_la_LIBADD = \
+libcaribou_la_LIBADD = \
@GTK3_LIBS@ \
$(NULL)
-im_caribou_la_LDFLAGS = \
+libcaribou_la_LDFLAGS = \
-avoid-version \
-module \
$(NULL)
diff --git a/im/gtk3/caribou-imcontext.vala b/modules/gtk3/caribou-gtk-modules.vala
similarity index 57%
rename from im/gtk3/caribou-imcontext.vala
rename to modules/gtk3/caribou-gtk-modules.vala
index 75de7a5..bc87737 100644
--- a/im/gtk3/caribou-imcontext.vala
+++ b/modules/gtk3/caribou-gtk-modules.vala
@@ -5,15 +5,71 @@ namespace Caribou {
throws IOError;
public abstract void set_entry_location (int x, int y, int w, int h)
throws IOError;
- public abstract void show () throws IOError;
- public abstract void hide () throws IOError;
+ public abstract void show (uint32 timestamp) throws IOError;
+ public abstract void hide (uint32 timestamp) throws IOError;
}
- class IMContext : Gtk.IMContextSimple {
- private Gdk.Window window;
+ class GtkModules {
+ private GLib.List<Gtk.Window> windows;
private Keyboard keyboard;
- public IMContext () {
+ public GtkModules () {
+ windows = new GLib.List<Gtk.Window>();
+ try {
+ keyboard = Bus.get_proxy_sync (BusType.SESSION,
+ "org.gnome.Caribou.Keyboard",
+ "/org/gnome/Caribou/Keyboard");
+ } catch (Error e) {
+ stderr.printf ("%s\n", e.message);
+ }
+
+ add_tracker ();
+
+ GLib.Timeout.add (60, () => { add_tracker ();
+ return true; });
+ }
+
+ private void add_tracker () {
+ GLib.List<weak Gtk.Window> toplevels;
+
+ toplevels = Gtk.Window.list_toplevels();
+ foreach (Gtk.Window window in toplevels) {
+ if (windows.find(window) == null) {
+ window.notify["has-toplevel-focus"].connect(get_top_level_focus);
+ windows.append(window);
+ }
+ }
+ }
+
+ private void get_top_level_focus (Object obj, ParamSpec prop) {
+ Gtk.Window window = (Gtk.Window) obj;
+ if (window.has_toplevel_focus)
+ focus_tracker (window, window.get_focus());
+ }
+
+ private void focus_tracker (Gtk.Window window, Gtk.Widget? widget) {
+ uint32 timestamp = Gtk.get_current_event_time();
+ if (widget != null && (widget is Gtk.Entry || widget is Gtk.TextView) && widget is Gtk.Editable) {
+ Atk.Object focus_object = widget.get_accessible();
+ Gdk.Window current_window = widget.get_window();
+ int x=0, y=0, w=0, h=0;
+ if (current_window != null && !get_acc_geometry (focus_object, out x, out y, out w, out h)) {
+ get_origin_geometry (current_window, out x, out y, out w, out h);
+ }
+ try {
+ keyboard.show (timestamp);
+ keyboard.set_entry_location (x, y, w, h);
+ } catch (IOError e) {
+ stderr.printf ("%s\n", e.message);
+ }
+ }
+ else {
+ try {
+ keyboard.hide (timestamp);
+ } catch (IOError e) {
+ stderr.printf("%s\n", e.message);
+ }
+ }
}
private void get_origin_geometry (Gdk.Window window,
@@ -78,52 +134,5 @@ namespace Caribou {
return true;
}
- private Gtk.Widget get_window_widget () {
- void *p = null;
- window.get_user_data (&p);
- return p as Gtk.Widget;
- }
-
- public override void focus_in () {
- GLib.Timeout.add (100, () => {
- int x=0, y=0, w=0, h=0;
- Gtk.Widget widget = get_window_widget ();
-
- Atk.Object acc = widget.get_accessible ();
-
- if (!get_acc_geometry (acc, out x, out y, out w, out h)) {
- get_origin_geometry (window, out x, out y, out w, out h);
- }
-
- try {
- keyboard.show ();
- keyboard.set_entry_location (x, y, w, h);
- } catch (IOError e) {
- stderr.printf ("%s\n", e.message);
- }
- return false;
- });
- }
-
-
- public override void focus_out () {
- try {
- keyboard.hide ();
- } catch (IOError e) {
- stderr.printf ("%s\n", e.message);
- }
- }
-
- public override void set_client_window (Gdk.Window window) {
- this.window = window;
-
- try {
- keyboard = Bus.get_proxy_sync (BusType.SESSION,
- "org.gnome.Caribou.Keyboard",
- "/org/gnome/Caribou/Keyboard");
- } catch (Error e) {
- stderr.printf ("%s\n", e.message);
- }
- }
}
}
diff --git a/modules/gtk3/caribou-module.c b/modules/gtk3/caribou-module.c
new file mode 100644
index 0000000..228383f
--- /dev/null
+++ b/modules/gtk3/caribou-module.c
@@ -0,0 +1,21 @@
+#include <gtk/gtk.h>
+#include <gtk/gtkimmodule.h>
+#include "caribou-gtk-modules.h"
+#include <stdio.h>
+
+#define CARIBOU_LOCALDIR ""
+
+G_MODULE_EXPORT CaribouGtkModules *
+gtk_module_init (gint *argc, gchar ***argv[]) {
+ CaribouGtkModules *context = caribou_gtk_modules_new ();
+ return context;
+}
+
+G_MODULE_EXPORT const gchar*
+g_module_check_init (GModule *module)
+{
+ return glib_check_version (GLIB_MAJOR_VERSION,
+ GLIB_MINOR_VERSION,
+ 0);
+}
+
diff --git a/im/gtk3/vapi-fixes.vapi b/modules/gtk3/vapi-fixes.vapi
similarity index 100%
rename from im/gtk3/vapi-fixes.vapi
rename to modules/gtk3/vapi-fixes.vapi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]