Add configure --disable-key-snooper
authorPeng Huang <shawn.p.huang@gmail.com>
Mon, 3 May 2010 23:27:53 +0000 (07:27 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Mon, 3 May 2010 23:27:53 +0000 (07:27 +0800)
client/gtk2/ibusimcontext.c
configure.ac

index ea3daf3..afc4c93 100644 (file)
@@ -76,7 +76,7 @@ static guint    _signal_delete_surrounding_id = 0;
 static guint    _signal_retrieve_surrounding_id = 0;
 
 static const gchar * const _no_snooper_apps = NO_SNOOPER_APPS;
-static gboolean _use_key_snooper = TRUE;
+static gboolean _use_key_snooper = ENABLE_SNOOPER;
 
 static GtkIMContext *_focus_im_context = NULL;
 
@@ -288,21 +288,24 @@ ibus_im_context_class_init     (IBusIMContextClass *klass)
         g_signal_lookup ("retrieve-surrounding", G_TYPE_FROM_CLASS (klass));
     g_assert (_signal_retrieve_surrounding_id != 0);
 
-    if (g_getenv ("IBUS_DISABLE_SNOOPER") != NULL) {
-        /* disable snooper if env IBUS_DISABLE_SNOOPER is set */
-        _use_key_snooper = FALSE;
-    }
-    else {
-        /* disable snooper if app is in _no_snooper_apps */
-        gchar ** apps = g_strsplit (_no_snooper_apps, ",", 0);
-        gchar **p;
-        for (p = apps; *p != NULL; p++) {
-            if (g_strcmp0 (*p,  g_get_application_name ()) == 0) {
-                _use_key_snooper = FALSE;
-                break;
+    if (_use_key_snooper) {
+        if (g_getenv ("IBUS_DISABLE_SNOOPER") != NULL) {
+            /* disable snooper if env IBUS_DISABLE_SNOOPER is set */
+            _use_key_snooper = FALSE;
+        }
+        else {
+            /* disable snooper if app is in _no_snooper_apps */
+            const gchar * prgname = g_get_prgname ();
+            gchar ** apps = g_strsplit (_no_snooper_apps, ",", 0);
+            gchar **p;
+            for (p = apps; *p != NULL; p++) {
+                if (g_strcmp0 (*p,  prgname) == 0) {
+                    _use_key_snooper = FALSE;
+                    break;
+                }
             }
+            g_strfreev (apps);
         }
-        g_strfreev (apps);
     }
 
     if (_use_key_snooper) {
index b8861a5..7c38b8a 100644 (file)
@@ -202,7 +202,7 @@ if test x"$enable_python" != x"no"; then
         AS_HELP_STRING([--disable-dbus-python-check],
             [Do not check dbus-python]),
         [enable_dbus_python_check=$enableval],
-        [enable_dbus_python_check=yes],
+        [enable_dbus_python_check=yes]
     )
     PKG_CHECK_MODULES(DBUS_PYTHON,
         [dbus-python >= 0.83.0],
@@ -218,6 +218,19 @@ if test x"$enable_python" != x"no"; then
     fi
 fi
 
+# option for disable snooper applications
+AC_ARG_ENABLE(key-snooper,
+    AS_HELP_STRING([--disable-key-snooper],
+        [Disable key snooper in gtk im module]),
+    [enable_key_snooper=$enableval],
+    [enable_key_snooper=yes]
+)
+if test x"$enable_key_snooper" != x"no"; then
+    AC_DEFINE(ENABLE_SNOOPER, TRUE, [Enable key snooper])
+else
+    AC_DEFINE(ENABLE_SNOOPER, FALSE, [Enable key snooper])
+fi
+
 # option for no snooper applications
 AC_ARG_WITH(no-snooper-apps,
     AS_HELP_STRING([--with-no-snooper-apps[=app1,app2]],
@@ -225,7 +238,7 @@ AC_ARG_WITH(no-snooper-apps,
     NO_SNOOPER_APPS=$with_no_snooper_apps
 )
 AC_DEFINE_UNQUOTED(NO_SNOOPER_APPS, "$NO_SNOOPER_APPS",
-    [Does not enbale snooper in thos applications])
+    [Does not enbale key snooper in those applications])
 
 # check iso-codes
 PKG_CHECK_MODULES(ISOCODES, [
@@ -271,13 +284,15 @@ gconf/gconf.xml.in
 AC_OUTPUT
 AC_MSG_RESULT([
 Build options:
-  Version                  $VERSION
-  Install prefix           $prefix
-  Build shared libs        $enable_shared
-  Build static libs        $enable_static
-  Gtk immodule dir         $GTK_IM_MODULEDIR
-  Build python modules     $enable_python
-  Build gconf modules      $enable_gconf
-  Build document           $enable_gtk_doc
+  Version                   $VERSION
+  Install prefix            $prefix
+  Build shared libs         $enable_shared
+  Build static libs         $enable_static
+  Gtk immodule dir          $GTK_IM_MODULEDIR
+  Build python modules      $enable_python
+  Build gconf modules       $enable_gconf
+  Build document            $enable_gtk_doc
+  Enable key snooper        $enable_key_snooper
+  No snooper apps           "$NO_SNOOPER_APPS"
 ])