diff options
author | Santiago Collazo <scollazo@activitycentral.com> | 2013-01-04 19:40:23 (GMT) |
---|---|---|
committer | Santiago Collazo <scollazo@activitycentral.com> | 2013-01-04 19:40:23 (GMT) |
commit | 7d3476acbcb0d1d34601eddde9636b138bad9867 (patch) | |
tree | 3de3be44489092c0b792f44d6e7f264caa1ff09c | |
parent | 14be4aa03eaa15eed571d5c4c5af05597639f6ef (diff) | |
parent | 55b89a7b19aaac4b067439009656cf19bdccb143 (diff) |
Merge remote-tracking branch 'ajay/0.97.7-as-base' into devel
-rw-r--r-- | extensions/cpsection/network/view.py | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/extensions/cpsection/network/view.py b/extensions/cpsection/network/view.py index 6e7fb69..7a4f221 100644 --- a/extensions/cpsection/network/view.py +++ b/extensions/cpsection/network/view.py @@ -403,6 +403,50 @@ class GConfExclusiveOptionSetsBox(ExclusiveOptionSetsBox, GConfMixin): raise ValueError('Invalid value %r' % (value, )) +class SpecialGConfExclusiveOptionSetsBox(GConfExclusiveOptionSetsBox): + def __init__(self, top_name, top_gconf_key, gsettings_dconf, + dconf_key, option_sets, size_group=None): + GConfExclusiveOptionSetsBox.__init__(self, top_name, top_gconf_key, + gsettings_dconf, dconf_key, + option_sets, size_group) + self._initial_enabled_value = True + if self._undo_value == 'none': + self._initial_enabled_value = False + + def undo(self): + """Revert to original value if modified""" + if not self.changed: + return + logging.debug('Reverting %r to %r', self._gconf_key, self._undo_value) + self._set_gconf_value(self._undo_value) + + # Also, set the initial value for "org.gnome.system.proxy.http enabled" + logging.debug('Reverting org.gnome.system.proxy.http enabled to %r', self._initial_enabled_value) + GSETTINGS_PROXY_HTTP.set_boolean('enabled', self._initial_enabled_value) + + def _commit(self, widget): + """Commit the base key.""" + super(SpecialGConfExclusiveOptionSetsBox, self)._commit(None) + + """Plus commit the dconf key :: org.gnome.system.proxy.http enabled""" + # The logic to set the value is :: + # + # * If the mode is "none", the key is to be set to false. + # + # * If the mode is not "none" (in other words, it is "manual" + # or "automatic"), the key is to be set to true. + enabled_value = True + mode = self.get_value_for_gconf() + if mode == 'none': + enabled_value = False + + logging.debug('Setting org.gnome.system.proxy.http enabled to %r', enabled_value) + GSETTINGS_PROXY_HTTP.set_boolean('enabled', enabled_value) + + def changed(self): + return self._undo_value != self.get_value_for_gconf() + + class OptionalSettingsBox(Gtk.VBox): """ Container for settings (de)activated by a top-level setting @@ -770,7 +814,7 @@ class Network(SectionView): option_sets = [('None', 'none', Gtk.VBox()), ('Automatic', 'auto', automatic_proxy_box), ('Manual', 'manual', manual_proxy_box)] - option_sets_box = GConfExclusiveOptionSetsBox(_('Method:'), + option_sets_box = SpecialGConfExclusiveOptionSetsBox(_('Method:'), '/system/proxy/mode', GSETTINGS_PROXY, 'mode', |