[caribou: 21/23] Use async Bus.get_proxy()



commit aae4d8f894f253b1f5d5b1da540502437c37c0ec
Author: Nohemi Fernandez <nf68 cornell edu>
Date:   Wed Aug 10 17:10:28 2011 -0500

    Use async Bus.get_proxy()
    
    The sync version of this method would result in apps hanging
    briefly at startup, however in the async version a window may be
    created/focused before the async callback runs.

 modules/gtk3/caribou-gtk-module.vala |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/modules/gtk3/caribou-gtk-module.vala b/modules/gtk3/caribou-gtk-module.vala
index b6cc358..17ef41b 100644
--- a/modules/gtk3/caribou-gtk-module.vala
+++ b/modules/gtk3/caribou-gtk-module.vala
@@ -17,16 +17,21 @@ namespace Caribou {
 
         public GtkModule () {
             windows = new GLib.HashTable<Gtk.Window, bool> (null, null);
-            try {
-                display = Gdk.Display.get_default ();
+            display = Gdk.Display.get_default ();
 
-                keyboard = Bus.get_proxy_sync (BusType.SESSION,
-                                               "org.gnome.Caribou.Keyboard",
-                                               "/org/gnome/Caribou/Keyboard");
-                Gdk.window_add_filter (null, event_filter);
-            } catch (Error e) {
-                stderr.printf ("%s\n", e.message);
+            Bus.get_proxy.begin<Keyboard> (BusType.SESSION, "org.gnome.Caribou.Keyboard",
+                                           "/org/gnome/Caribou/Keyboard", 0, null, callback);
+
+            Gdk.window_add_filter (null, event_filter);
+        }
+
+        private void callback (GLib.Object? obj, GLib.AsyncResult res) {
+            try {
+                keyboard = Bus.get_proxy.end(res);
             }
+            catch (Error e) {
+                stderr.printf ("%s\n", e.message);
+             }
         }
 
         private Gdk.FilterReturn event_filter (Gdk.XEvent xevent, Gdk.Event evt) {



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