[gtk+] inspector: Disable non-functional controls



commit 88830744978e9f3fdeacc76028b59855743e47c6
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jul 10 10:33:27 2014 -0400

    inspector: Disable non-functional controls
    
    Some of the features we expose can be hardcoded via environment
    variables. In that case, don't confuse the user by letting them
    change settings that have no effect.

 gtk/inspector/general.c |   11 +++++++++++
 gtk/inspector/visual.c  |   16 ++++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
index ae8b2d7..cd00e38 100644
--- a/gtk/inspector/general.c
+++ b/gtk/inspector/general.c
@@ -15,6 +15,9 @@
  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "config.h"
+#include <glib/gi18n-lib.h>
+
 #include "general.h"
 
 #include "gtkprivate.h"
@@ -157,6 +160,14 @@ init_touch (GtkInspectorGeneral *gen)
   gtk_switch_set_active (GTK_SWITCH (gen->priv->touchscreen_switch), (gtk_get_debug_flags () & 
GTK_DEBUG_TOUCHSCREEN) != 0);
   g_signal_connect (gen->priv->touchscreen_switch, "notify::active",
                     G_CALLBACK (update_touchscreen), gen);
+
+  if (g_getenv ("GTK_TEST_TOUCHSCREEN") != 0)
+    {
+      /* hardcoded, nothing we can do */
+      gtk_switch_set_active (GTK_SWITCH (gen->priv->touchscreen_switch), TRUE);
+      gtk_widget_set_sensitive (gen->priv->touchscreen_switch, FALSE);
+      gtk_widget_set_tooltip_text (gen->priv->touchscreen_switch, _("Setting is hardcoded by 
GTK_TEST_TOUCHSCREEN"));
+    }
 }
 
 static void
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c
index 435198a..4970119 100644
--- a/gtk/inspector/visual.c
+++ b/gtk/inspector/visual.c
@@ -15,6 +15,8 @@
  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "config.h"
+#include <glib/gi18n-lib.h>
 #include "visual.h"
 
 #include "gtkprivate.h"
@@ -211,6 +213,13 @@ init_theme (GtkInspectorVisual *vis)
   g_hash_table_destroy (t);
 
   gtk_combo_box_set_active (GTK_COMBO_BOX (vis->priv->theme_combo), pos);
+
+  if (g_getenv ("GTK_THEME") != NULL)
+    {
+      /* theme is hardcoded, nothing we can do */
+      gtk_widget_set_sensitive (vis->priv->theme_combo, FALSE);
+      gtk_widget_set_tooltip_text (vis->priv->theme_combo , _("Theme is hardcoded by GTK_THEME"));
+    }
 }
 
 static void
@@ -230,6 +239,13 @@ init_dark (GtkInspectorVisual *vis)
   g_object_bind_property (vis->priv->dark_switch, "active",
                           gtk_settings_get_default (), "gtk-application-prefer-dark-theme",
                           G_BINDING_BIDIRECTIONAL);
+
+  if (g_getenv ("GTK_THEME") != NULL)
+    {
+      /* theme is hardcoded, nothing we can do */
+      gtk_widget_set_sensitive (vis->priv->dark_switch, FALSE);
+      gtk_widget_set_tooltip_text (vis->priv->dark_switch, _("Theme is hardcoded by GTK_THEME"));
+    }
 }
 
 static void


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