[caribou/imcontext: 6/9] working kinda



commit 0d0b136ac709b2f4a5770799881cb3a424015978
Author: Eitan Isaacson <eitan monotonous org>
Date:   Fri Jun 3 17:43:46 2011 -0700

    working kinda

 im/gtk3/caribou-im.c           |    2 -
 im/gtk3/caribou-imcontext.vala |   51 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 3 deletions(-)
---
diff --git a/im/gtk3/caribou-im.c b/im/gtk3/caribou-im.c
index 9022af2..24a3def 100644
--- a/im/gtk3/caribou-im.c
+++ b/im/gtk3/caribou-im.c
@@ -27,8 +27,6 @@ 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
diff --git a/im/gtk3/caribou-imcontext.vala b/im/gtk3/caribou-imcontext.vala
index 9af874c..9e3a1f4 100644
--- a/im/gtk3/caribou-imcontext.vala
+++ b/im/gtk3/caribou-imcontext.vala
@@ -1,4 +1,53 @@
 namespace Caribou {
-    class IMContext : Gtk.IMContext {
+    [DBus(name = "org.gnome.Caribou.Keyboard")]
+    interface Keyboard : Object {
+        public abstract void set_cursor_location (int x, int y, int w, int h) 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;
+    }
+
+    class IMContext : Gtk.IMContextSimple {
+        private Gdk.Window window;
+        private Keyboard keyboard;
+
+        public IMContext () {
+        }
+
+        public override void focus_in () {
+            int x, y;
+            window.get_origin (out x, out y);
+            stdout.printf ("focus_in %d %d\n", x, y);
+            try {
+                keyboard.show ();
+                keyboard.set_entry_location (x, y,
+                                             window.get_width (),
+                                             window.get_height ());
+            } catch (IOError e) {
+                stderr.printf ("%s\n", e.message);
+            }
+        }
+
+        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.Antler",
+                                               "/org/gnome/Caribou/Antler");
+                keyboard.show ();
+            } catch (Error e) {
+                stderr.printf ("%s\n", e.message);
+            }
+            stdout.printf ("set_client_window\n");
+            //base.set_client_window (window);
+        }
     }
 }
\ No newline at end of file



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]