[gtk+] inspector: Add a setting to disable the keybinding



commit 069a2603efb942cd4314fca97d8235e03b657858
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue May 13 14:16:53 2014 -0400

    inspector: Add a setting to disable the keybinding
    
    This will be needed for lockdown, e.g. on the login screen.
    https://bugzilla.gnome.org/show_bug.cgi?id=730007

 docs/reference/gtk/running.sgml        |   10 ++++++++--
 gtk/Makefile.am                        |   18 +++++++++---------
 gtk/gtkwindow.c                        |   29 ++++++++++++++++++++++++++++-
 gtk/org.gtk.Settings.Debug.gschema.xml |   17 +++++++++++++++++
 4 files changed, 62 insertions(+), 12 deletions(-)
---
diff --git a/docs/reference/gtk/running.sgml b/docs/reference/gtk/running.sgml
index f545667..36cac1c 100644
--- a/docs/reference/gtk/running.sgml
+++ b/docs/reference/gtk/running.sgml
@@ -529,6 +529,8 @@ nevertheless.
 <refsect2 id="interactive-debugging">
 <title>Interactive debugging</title>
 
+  <inlinegraphic fileref="inspector.png" format="PNG"></inlinegraphic>
+
   <para>
     GTK+ includes an interactive debugger which lets you explore the
     widget tree of any GTK+ application at runtime, as well as tweak
@@ -539,8 +541,12 @@ nevertheless.
     Control-Shift-D keyboard shortcuts, or pass set the
     <envar>GTK_DEBUG=interactive</envar> environment variable.
   </para>
-
-  <inlinegraphic fileref="inspector.png" format="PNG"></inlinegraphic>
+  <para>
+    In some situations, it may be inappropriate to give users access
+    to the interactive debugger. The keyboard shortcuts can be disabled
+    with the `enable-inspector-keybinding` key in the `org.gtk.Settings.Debug`
+    GSettings schema.
+  </para>
  
 </refsect2>
 
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 26539a9..f4e567d 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -1787,10 +1787,18 @@ endif
           --source builtin_icons stock-icons > gtkbuiltincache.h.tmp &&        \
        mv gtkbuiltincache.h.tmp gtkbuiltincache.h
 
+gsettings_SCHEMAS = \
+       org.gtk.Settings.FileChooser.gschema.xml \
+       org.gtk.Settings.ColorChooser.gschema.xml \
+       org.gtk.Settings.Debug.gschema.xml
+
+ GSETTINGS_RULES@
+
 EXTRA_DIST +=                   \
        $(resource_files)       \
        $(STOCK_ICONS)          \
        $(GENERATED_ICONS)      \
+       $(gsettings_SCHEMAS)    \
        gtk-win32.rc            \
        gtk-win32.rc.in         \
        gtkwin32embed.h         \
@@ -1809,15 +1817,7 @@ EXTRA_DIST +=                   \
        gtktypebuiltins.c.template \
        gtktypebuiltins.h.template \
        gtkprivatetypebuiltins.c.template \
-       gtkprivatetypebuiltins.h.template \
-       org.gtk.Settings.FileChooser.gschema.xml \
-       org.gtk.Settings.ColorChooser.gschema.xml
-
-gsettings_SCHEMAS = \
-       org.gtk.Settings.FileChooser.gschema.xml \
-       org.gtk.Settings.ColorChooser.gschema.xml
-
- GSETTINGS_RULES@
+       gtkprivatetypebuiltins.h.template
 
 install-data-local:
 
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 105e0e0..071c37e 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -12471,10 +12471,37 @@ gtk_window_set_interactive_debugging (gboolean enable)
     gtk_widget_hide (inspector_window);
 }
 
+static gboolean
+inspector_keybinding_enabled (void)
+{
+  GSettingsSchema *schema;
+  GSettings *settings;
+  gboolean enabled;
+
+  enabled = FALSE;
+
+  schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (),
+                                            "org.gtk.Settings.Debug",
+                                            FALSE);
+  if (schema)
+    {
+      settings = g_settings_new_full (schema, NULL, NULL);
+      enabled = g_settings_get_boolean (settings, "enable-inspector-keybinding");
+      g_object_unref (settings);
+      g_settings_schema_unref (schema);
+    }
+
+  return enabled;
+}
+
 static void
 gtk_window_toggle_debugging (GtkWindow *window)
 {
-  if (GTK_IS_WIDGET (inspector_window) && gtk_widget_is_visible (inspector_window))
+  if (!inspector_keybinding_enabled ())
+    return;
+
+  if (GTK_IS_WIDGET (inspector_window) &&
+      gtk_widget_is_visible (inspector_window))
     gtk_window_set_interactive_debugging (FALSE);
   else
     gtk_window_set_interactive_debugging (TRUE);
diff --git a/gtk/org.gtk.Settings.Debug.gschema.xml b/gtk/org.gtk.Settings.Debug.gschema.xml
new file mode 100644
index 0000000..db3ff64
--- /dev/null
+++ b/gtk/org.gtk.Settings.Debug.gschema.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+
+  <schema id='org.gtk.Settings.Debug' path='/org/gtk/settings/debug/'>
+    <key name='enable-inspector-keybinding' type='b'>
+      <default>true</default>
+      <summary>Enable inspector keybinding</summary>
+      <description>
+        If this setting is true, GTK+ lets the user open an interactive
+        debugging window with a keybinding. The default shortcuts for
+        the keybinding are Control-Shift-I and Control-Shift-D.
+      </description>
+    </key>
+  </schema>
+
+</schemalist>
+


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