[chirp_devel] [PATCH] Add support for settingvalue objects to be immutable
# HG changeset patch # User Dan Smith dsmith@danplanet.com # Date 1367701349 25200 # Node ID e924129f98b9d6b65ca12ca52d57ece8d2a95c12 # Parent 28d01422eb4585d7f3e35ca98afdd01675783fa1 Add support for settingvalue objects to be immutable
Use like this:
val = RadioSettingValueString(0, 7, _filter(_msg.line1)) val.set_mutable(False) rs = RadioSetting("sixpoweron_msg.line1", "6+Power-On Message 1", val)
diff -r 28d01422eb45 -r e924129f98b9 chirp/settings.py --- a/chirp/settings.py Sat May 04 12:12:18 2013 -0400 +++ b/chirp/settings.py Sat May 04 14:02:29 2013 -0700 @@ -29,6 +29,13 @@ self._current = None self._has_changed = False self._validate_callback = lambda x: x + self._mutable = True + + def set_mutable(self, mutable): + self._mutable = mutable + + def get_mutable(self): + return self._mutable
def changed(self): """Returns True if the setting has been changed since init""" @@ -39,6 +46,9 @@
def set_value(self, value): """Sets the current value, triggers changed""" + if not self.get_mutable(): + raise InvalidValueError("This value is not mutable") + if self._current != None and value != self._current: self._has_changed = True self._current = self._validate_callback(value) diff -r 28d01422eb45 -r e924129f98b9 chirpui/settingsedit.py --- a/chirpui/settingsedit.py Sat May 04 12:12:18 2013 -0400 +++ b/chirpui/settingsedit.py Sat May 04 14:02:29 2013 -0700 @@ -178,6 +178,8 @@ lalign.add(widget) lalign.show()
+ widget.set_sensitive(value.get_mutable()) + arraybox.pack_start(lalign, 1, 1, 1) widget.show() self._load_setting(value, widget)
On Sat, May 4, 2013 at 5:02 PM, Dan Smith dsmith@danplanet.com wrote:
# HG changeset patch # User Dan Smith dsmith@danplanet.com # Date 1367701349 25200 # Node ID e924129f98b9d6b65ca12ca52d57ece8d2a95c12 # Parent 28d01422eb4585d7f3e35ca98afdd01675783fa1 Add support for settingvalue objects to be immutable
Use like this:
val = RadioSettingValueString(0, 7, _filter(_msg.line1)) val.set_mutable(False) rs = RadioSetting("sixpoweron_msg.line1", "6+Power-On Message 1", val)
Dan, This looks like it is going to work great.
I did a qimport of this patch Then I did a qnew -ef mypatch_foobar
Your patch is already in line to get applied by you and I will just export my patch, right?
Jim
Your patch is already in line to get applied by you and I will just export my patch, right?
Yep, just pushed mine before applying and pushing yours.
Thanks!
participants (2)
-
Dan Smith
-
Jim Unroe