[gnome-terminal] app: Add setting to disable shell integration



commit 9cdb644a817b965fef810c14465da23a7e3084a4
Author: Christian Persch <chpe gnome org>
Date:   Sat Feb 15 15:42:01 2014 +0100

    app: Add setting to disable shell integration
    
    When the search provider is enabled at build time it can still
    be disabled at runtime.

 src/org.gnome.Terminal.gschema.xml |    5 +++++
 src/terminal-app.c                 |   32 ++++++++++++++++++--------------
 src/terminal-schemas.h             |    1 +
 3 files changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/src/org.gnome.Terminal.gschema.xml b/src/org.gnome.Terminal.gschema.xml
index 969d43d..10705e3 100644
--- a/src/org.gnome.Terminal.gschema.xml
+++ b/src/org.gnome.Terminal.gschema.xml
@@ -586,6 +586,11 @@
       </description>
     </key>
 
+    <key name="shell-integration-enabled" type="b">
+      <default>true</default>
+      <summary>Whether the shell integration is enabled</summary>
+    </key>
+
     <key name="encodings" type="as">
       <!-- Translators: Please note that this has to be a list of
            valid encodings (which are to be taken from the list in src/encoding.c).
diff --git a/src/terminal-app.c b/src/terminal-app.c
index f98a802..73d546a 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -355,10 +355,6 @@ terminal_app_init (TerminalApp *app)
 
   gtk_window_set_default_icon_name (GNOME_TERMINAL_ICON_NAME);
 
-#ifdef ENABLE_SEARCH_PROVIDER
-  app->search_provider = terminal_search_provider_new ();
-#endif /* ENABLE_SEARCH_PROVIDER */
-
   /* Desktop proxy settings */
   app->system_proxy_settings = g_settings_new (SYSTEM_PROXY_SETTINGS_SCHEMA);
 
@@ -407,10 +403,6 @@ terminal_app_finalize (GObject *object)
   g_object_unref (app->desktop_interface_settings);
   g_object_unref (app->system_proxy_settings);
 
-#ifdef ENABLE_SEARCH_PROVIDER
-  g_object_unref (app->search_provider);
-#endif /* ENABLE_SEARCH_PROVIDER */
-
   terminal_accels_shutdown ();
 
   G_OBJECT_CLASS (terminal_app_parent_class)->finalize (object);
@@ -433,11 +425,19 @@ terminal_app_dbus_register (GApplication    *application,
     return FALSE;
 
 #ifdef ENABLE_SEARCH_PROVIDER
-  if (!terminal_search_provider_dbus_register (app->search_provider,
-                                               connection,
-                                               TERMINAL_SEARCH_PROVIDER_PATH,
-                                               error))
-    return FALSE;
+  if (g_settings_get_boolean (app->global_settings, TERMINAL_SETTING_SHELL_INTEGRATION_KEY)) {
+    gs_unref_object TerminalSearchProvider *search_provider;
+
+    search_provider = terminal_search_provider_new ();
+
+    if (!terminal_search_provider_dbus_register (app->search_provider,
+                                                 connection,
+                                                 TERMINAL_SEARCH_PROVIDER_PATH,
+                                                 error))
+      return FALSE;
+
+    gs_transfer_out_value (&app->search_provider, &search_provider);
+  }
 #endif /* ENABLE_SEARCH_PROVIDER */
 
   object = terminal_object_skeleton_new (TERMINAL_FACTORY_OBJECT_PATH);
@@ -466,7 +466,11 @@ terminal_app_dbus_unregister (GApplication    *application,
   }
 
 #ifdef ENABLE_SEARCH_PROVIDER
-  terminal_search_provider_dbus_unregister (app->search_provider, connection, TERMINAL_SEARCH_PROVIDER_PATH);
+  if (app->search_provider) {
+    terminal_search_provider_dbus_unregister (app->search_provider, connection, 
TERMINAL_SEARCH_PROVIDER_PATH);
+    g_object_unref (app->search_provider);
+    app->search_provider = NULL;
+  }
 #endif /* ENABLE_SEARCH_PROVIDER */
 
   G_APPLICATION_CLASS (terminal_app_parent_class)->dbus_unregister (application,
diff --git a/src/terminal-schemas.h b/src/terminal-schemas.h
index c64bbec..443cf7b 100644
--- a/src/terminal-schemas.h
+++ b/src/terminal-schemas.h
@@ -73,6 +73,7 @@ G_BEGIN_DECLS
 #define TERMINAL_SETTING_ENCODINGS_KEY                  "encodings"
 #define TERMINAL_SETTING_NEW_TERMINAL_MODE_KEY          "new-terminal-mode"
 #define TERMINAL_SETTING_SCHEMA_VERSION                 "schema-version"
+#define TERMINAL_SETTING_SHELL_INTEGRATION_KEY          "shell-integration-enabled"
 
 #define TERMINAL_SETTINGS_LIST_LIST_KEY                 "list"
 #define TERMINAL_SETTINGS_LIST_DEFAULT_KEY              "default"


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