[gtk+] inspector: Add a reset button for settings



commit 47237ddd94371e0c42ad4b2d6ef25d219d78d350
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Sep 17 19:14:37 2015 -0400

    inspector: Add a reset button for settings
    
    This is exercising the new gtk_settings_reset_property api.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755008

 gtk/inspector/prop-editor.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/gtk/inspector/prop-editor.c b/gtk/inspector/prop-editor.c
index 3283027..0efbfa3 100644
--- a/gtk/inspector/prop-editor.c
+++ b/gtk/inspector/prop-editor.c
@@ -1535,12 +1535,20 @@ add_settings_info (GtkInspectorPropEditor *editor)
 }
 
 static void
+reset_setting (GtkInspectorPropEditor *editor)
+{
+  gtk_settings_reset_property (GTK_SETTINGS (editor->priv->object),
+                               editor->priv->name);
+}
+
+static void
 add_gtk_settings_info (GtkInspectorPropEditor *editor)
 {
   GObject *object;
   const gchar *name;
   GtkWidget *row;
   const gchar *source;
+  GtkWidget *button;
 
   object = editor->priv->object;
   name = editor->priv->name;
@@ -1551,6 +1559,14 @@ add_gtk_settings_info (GtkInspectorPropEditor *editor)
   row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
   gtk_container_add (GTK_CONTAINER (row), gtk_label_new (_("Source:")));
 
+  button = gtk_button_new_with_label (_("Reset"));
+  g_signal_connect_swapped (button, "clicked", G_CALLBACK (reset_setting), editor);
+
+  gtk_widget_set_halign (button, GTK_ALIGN_END);
+  gtk_widget_show (button);
+  gtk_widget_set_sensitive (button, FALSE);
+  gtk_box_pack_end (GTK_BOX (row), button, FALSE, FALSE, 0);
+
   switch (_gtk_settings_get_setting_source (GTK_SETTINGS (object), name))
     {
     case GTK_SETTINGS_SOURCE_DEFAULT:
@@ -1563,6 +1579,7 @@ add_gtk_settings_info (GtkInspectorPropEditor *editor)
       source = _("XSettings");
       break;
     case GTK_SETTINGS_SOURCE_APPLICATION:
+      gtk_widget_set_sensitive (button, TRUE);
       source = _("Application");
       break;
     default:


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