[meld] settings: Support one-way gsettings bindings and use for source view



commit 8ceb83ae9d3bd23d53e16d729332abfd89412a4a
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Jan 6 07:10:54 2019 +1000

    settings: Support one-way gsettings bindings and use for source view
    
    When these settings are changed on the sourceview, we absolutely do not
    want that to be propagated back to the gsettings store. Currently these
    settings *can't* be changed, so this isn't a problem. However, we're
    about to add some UI for that, so this is preparation.
    
    Also, probably most of our gsettings bindings should actually be one-
    way, but they do require actual thought.

 meld/settings.py   | 6 ++++++
 meld/sourceview.py | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/meld/settings.py b/meld/settings.py
index 601e9028..3cb9b576 100644
--- a/meld/settings.py
+++ b/meld/settings.py
@@ -106,6 +106,12 @@ def bind_settings(obj):
         settings_id, property_id = binding
         settings.bind(settings_id, obj, property_id, bind_flags)
 
+    bind_flags = (
+        Gio.SettingsBindFlags.GET | Gio.SettingsBindFlags.NO_SENSITIVITY)
+    for binding in getattr(obj, '__gsettings_bindings_view__', ()):
+        settings_id, property_id = binding
+        settings.bind(settings_id, obj, property_id, bind_flags)
+
 
 settings = None
 interface_settings = None
diff --git a/meld/sourceview.py b/meld/sourceview.py
index d3173be6..5004c81d 100644
--- a/meld/sourceview.py
+++ b/meld/sourceview.py
@@ -94,7 +94,7 @@ class MeldSourceView(GtkSource.View):
 
     __gtype_name__ = "MeldSourceView"
 
-    __gsettings_bindings__ = (
+    __gsettings_bindings_view__ = (
         ('highlight-current-line', 'highlight-current-line-local'),
         ('indent-width', 'tab-width'),
         ('insert-spaces-instead-of-tabs', 'insert-spaces-instead-of-tabs'),


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