[chirp_devel] [PATCH] Make the UI enforce reasonable tone modes when tone columns are changed

Dan Smith
Sun Feb 17 11:55:12 PST 2013


# HG changeset patch
# User Dan Smith <dsmith at danplanet.com>
# Date 1361130894 28800
# Node ID 0aedb1e65b8fb3779d2f49949444318f218543e5
# Parent  3aeeaedfb5f721bf72c26a416b0a053f96173831
Make the UI enforce reasonable tone modes when tone columns are changed

This ensures that if the user touches one of the tone columns, that the
tone mode changes to an appropriate value so as not to confuse them.

Fixes #591

diff -r 3aeeaedfb5f7 -r 0aedb1e65b8f chirpui/memedit.py
--- a/chirpui/memedit.py	Sat Feb 16 21:30:58 2013 -0500
+++ b/chirpui/memedit.py	Sun Feb 17 11:54:54 2013 -0800
@@ -201,6 +201,49 @@
 
         return new
 
+    def ed_tone_field(self, _foo, path, new, col):
+        iter = self.store.get_iter(path)
+
+        # Python scoping hurts us here, so store this as a list
+        # that we can modify, instead of helpful variables :(
+        modes = list(self.store.get(iter,
+                                    self.col(_("Tone Mode")),
+                                    self.col(_("Cross Mode"))))
+
+        def _tm(*tmodes):
+            if modes[0] not in tmodes:
+                modes[0] = tmodes[0]
+                self.store.set(iter, self.col(_("Tone Mode")), modes[0])
+        def _cm(*cmodes):
+            if modes[0] == "Cross" and modes[1] not in cmodes:
+                modes[1] = cmodes[0]
+                self.store.set(iter, self.col(_("Cross Mode")), modes[1])
+
+        if col == self.col(_("DTCS Code")):
+            _tm("DTCS", "Cross")
+            _cm(*tuple([x for x in chirp_common.CROSS_MODES
+                        if x.startswith("DTCS->")]))
+        elif col == self.col(_("DTCS Rx Code")):
+            _tm("DTCS", "Cross")
+            _cm(*tuple([x for x in chirp_common.CROSS_MODES
+                        if x.endswith("->DTCS")]))
+        elif col == self.col(_("DTCS Pol")):
+            _tm("DTCS", "Cross")
+            _cm(*tuple([x for x in chirp_common.CROSS_MODES
+                        if "DTCS" in x]))
+        elif col == self.col(_("Tone")):
+            _tm("Tone", "Cross")
+            _cm(*tuple([x for x in chirp_common.CROSS_MODES
+                        if x.startswith("Tone->")]))
+        elif col == self.col(_("ToneSql")):
+            _tm("TSQL", "Cross")
+            _cm(*tuple([x for x in chirp_common.CROSS_MODES
+                        if x.endswith("->Tone")]))
+        elif col == self.col(_("Cross Mode")):
+            _tm("Cross")
+
+        return new
+
     def _get_cols_to_hide(self, iter):
         tmode, duplex = self.store.get(iter,
                                        self.col(_("Tone Mode")),
@@ -260,6 +303,12 @@
             _("Frequency") : self.ed_freq,
             _("Duplex") : self.ed_duplex,
             _("Offset") : self.ed_offset,
+            _("Tone") : self.ed_tone_field,
+            _("ToneSql"): self.ed_tone_field,
+            _("DTCS Code"): self.ed_tone_field,
+            _("DTCS Rx Code"): self.ed_tone_field,
+            _("DTCS Pol"): self.ed_tone_field,
+            _("Cross Mode"): self.ed_tone_field,
             }
 
         if funcs.has_key(cap):



More information about the chirp_devel mailing list