[gnome-tweak-tool] Make GSettingsComboTweak react to changes on underlying setting



commit fc43f980fdcab7b2fa6c50c50fe7bae8947af783
Author: Rui Matos <tiagomatos gmail com>
Date:   Sat Oct 6 18:59:09 2012 +0200

    Make GSettingsComboTweak react to changes on underlying setting
    
    https://bugzilla.gnome.org/show_bug.cgi?id=685619

 gtweak/widgets.py |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/gtweak/widgets.py b/gtweak/widgets.py
index f0d83ea..f20b55a 100644
--- a/gtweak/widgets.py
+++ b/gtweak/widgets.py
@@ -232,12 +232,25 @@ class GSettingsComboTweak(_GSettingsTweak):
         if len(key_options):
             assert len(key_options[0]) == 2
 
-        combo = build_combo_box_text(
+        self.combo = build_combo_box_text(
                     self.settings.get_string(self.key_name),
                     *key_options)
-        combo.connect('changed', self._on_combo_changed)
-        self.widget = build_label_beside_widget(self.name, combo)
-        self.widget_for_size_group = combo
+        self.combo.connect('changed', self._on_combo_changed)
+        self.widget = build_label_beside_widget(self.name, self.combo)
+        self.widget_for_size_group = self.combo
+
+        self.settings.connect('changed::'+self.key_name, self._on_setting_changed)
+
+    def _on_setting_changed(self, setting, key):
+        assert key == self.key_name
+        val = self.settings.get_string(key)
+        model = self.combo.get_model()
+        for row in model:
+            if val == row[0]:
+                self.combo.set_active_iter(row.iter)
+                return
+
+        self.combo.set_active(-1)
 
     def _on_combo_changed(self, combo):
         _iter = combo.get_active_iter()



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