[gnome-control-center] region: Don't use IBus if running in fallback mode



commit 658083fffa95a8787baf734f5b87d1a7e0cff2dc
Author: Rui Matos <tiagomatos gmail com>
Date:   Sun Aug 26 16:55:11 2012 +0200

    region: Don't use IBus if running in fallback mode
    
    In fallback mode we don't want to touch IBus since the gnome-shell UI
    isn't there to provide the full integrated user experience.
    
    We expect users to continue using existing IBus UIs in fallback mode.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=682864

 panels/region/gnome-region-panel-input.c |   45 ++++++++++++++++++++++-------
 1 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/panels/region/gnome-region-panel-input.c b/panels/region/gnome-region-panel-input.c
index eee5f12..50370ae 100644
--- a/panels/region/gnome-region-panel-input.c
+++ b/panels/region/gnome-region-panel-input.c
@@ -61,6 +61,7 @@ static GnomeXkbInfo *xkb_info = NULL;
 #ifdef HAVE_IBUS
 static IBusBus *ibus = NULL;
 static GHashTable *ibus_engines = NULL;
+static guint shell_name_watch_id = 0;
 
 static const gchar *supported_ibus_engines[] = {
   "bopomofo",
@@ -83,6 +84,11 @@ static GtkTreeModel *tree_view_get_actual_model (GtkTreeView *tv);
 static void
 clear_ibus (void)
 {
+  if (shell_name_watch_id > 0)
+    {
+      g_bus_unwatch_name (shell_name_watch_id);
+      shell_name_watch_id = 0;
+    }
   g_clear_pointer (&ibus_engines, g_hash_table_destroy);
   g_clear_object (&ibus);
 }
@@ -206,6 +212,26 @@ maybe_start_ibus (void)
                                         NULL,
                                         NULL));
 }
+
+static void
+on_shell_appeared (GDBusConnection *connection,
+                   const gchar     *name,
+                   const gchar     *name_owner,
+                   gpointer         data)
+{
+  GtkBuilder *builder = data;
+
+  if (!ibus)
+    {
+      ibus = ibus_bus_new_async ();
+      if (ibus_bus_is_connected (ibus))
+        fetch_ibus_engines (builder);
+      else
+        g_signal_connect_swapped (ibus, "connected",
+                                  G_CALLBACK (fetch_ibus_engines), builder);
+    }
+  maybe_start_ibus ();
+}
 #endif  /* HAVE_IBUS */
 
 static gboolean
@@ -982,17 +1008,14 @@ setup_input_tabs (GtkBuilder    *builder,
 
 #ifdef HAVE_IBUS
   ibus_init ();
-  if (!ibus)
-    {
-      ibus = ibus_bus_new_async ();
-      if (ibus_bus_is_connected (ibus))
-        fetch_ibus_engines (builder);
-      else
-        g_signal_connect_swapped (ibus, "connected",
-                                  G_CALLBACK (fetch_ibus_engines), builder);
-      g_object_weak_ref (G_OBJECT (builder), (GWeakNotify) clear_ibus, NULL);
-    }
-  maybe_start_ibus ();
+  shell_name_watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
+                                          "org.gnome.Shell",
+                                          G_BUS_NAME_WATCHER_FLAGS_NONE,
+                                          on_shell_appeared,
+                                          NULL,
+                                          builder,
+                                          NULL);
+  g_object_weak_ref (G_OBJECT (builder), (GWeakNotify) clear_ibus, NULL);
 #endif
 
   populate_with_active_sources (store);



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