[gnome-tweak-tool] Add a --verbose option



commit 3bdeb456bb2912d174e8a4b3ea566f7e46cd2b48
Author: John Stowers <john stowers gmail com>
Date:   Thu Jul 28 21:13:21 2011 +1200

    Add a --verbose option

 NEWS                |    1 +
 gnome-tweak-tool    |    3 +++
 gtweak/gconf.py     |    5 +++++
 gtweak/gsettings.py |    6 ++++++
 4 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index f73404a..e1f1489 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 3.1.0
    * Mark many strings as translatable.
    * Now appears as 'Advanced Settings' in GNOME shell search
+   * Add a -v,--verbose option that prints changed settings
 
 3.0.5
    * More autostart desktop file fixes. Try harder to autostart nautilus when
diff --git a/gnome-tweak-tool b/gnome-tweak-tool
index 1ef5741..2ffd910 100755
--- a/gnome-tweak-tool
+++ b/gnome-tweak-tool
@@ -57,6 +57,8 @@ if __name__ == '__main__':
                   help="Enable test and debug code")
     parser.add_option("-p", "--prefix",
                   help="Installation prefix (for gsettings schema, themes, etc)", metavar="[/, /usr]")
+    parser.add_option("-v", "--verbose", action="store_true",
+                  help="Print the names of settings modified")
     options, args = parser.parse_args()
 
     try:
@@ -82,6 +84,7 @@ if __name__ == '__main__':
     gtweak.PKG_DATA_DIR = PKG_DATA_DIR
     gtweak.ENABLE_TEST = options.test
     gtweak.APP_NAME = "gnome-tweak-tool"
+    gtweak.VERBOSE = options.verbose
 
     logging.basicConfig(format="%(levelname)-8s: %(message)s", level=logging.INFO)
 
diff --git a/gtweak/gconf.py b/gtweak/gconf.py
index 3b60d07..5a05ebf 100644
--- a/gtweak/gconf.py
+++ b/gtweak/gconf.py
@@ -18,6 +18,8 @@
 import subprocess
 import logging
 
+import gtweak
+
 from gi.repository import GConf
 
 class GConfSetting:
@@ -62,6 +64,9 @@ class GConfSetting:
             assert(False)
 
     def set_value(self, value):
+        if gtweak.VERBOSE:
+            print "Change: %s -> %s" % (self._key, value)
+
         if self._type == bool:
             self._client.set_bool(self._key, value)
         elif self._type == str:
diff --git a/gtweak/gsettings.py b/gtweak/gsettings.py
index b570162..0c41d44 100644
--- a/gtweak/gsettings.py
+++ b/gtweak/gsettings.py
@@ -68,6 +68,12 @@ class GSettingsSetting(Gio.Settings):
 
         self._schema = _SCHEMA_CACHE[schema_name]
 
+        if gtweak.VERBOSE:
+            self.connect("changed", self._on_changed)
+
+    def _on_changed(self, settings, key_name):
+        print "Change: %s %s -> %s" % (self.props.schema, key_name, self[key_name])
+
     def _setting_check_is_list(self, key):
         variant = Gio.Settings.get_value(self, key)
         return variant.get_type_string() == "as"



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