[chirp_devel] [PATCH 0 of 6] Clone help messages
Here is another version that puts the string in a RadioPrompts object.
Tom KD7LXL
P.S. Now I understand why they call it a patch bomb.
# HG changeset patch # User Tom Hayward tom@tomh.us # Date 1381263400 25200 # Node ID 4f5c50bf03253205ce13e9cbc9e73d139140426b # Parent f7658c8abf415a92aef21c20687ac4e3ee1c89c5 Add RadioPrompts class for storing prompt strings. #1163
diff -r f7658c8abf41 -r 4f5c50bf0325 chirp/chirp_common.py --- a/chirp/chirp_common.py Mon Oct 07 09:03:24 2013 -0700 +++ b/chirp/chirp_common.py Tue Oct 08 13:16:40 2013 -0700 @@ -643,7 +643,14 @@ import sys
sys.stderr.write("\r%s" % status) - + + +class RadioPrompts: + """Radio prompt strings""" + experimental = None + pre_download = None + pre_upload = None +
BOOLEAN = [True, False]
@@ -956,6 +963,11 @@ """Return a printable name for this radio""" return "%s %s" % (cls.VENDOR, cls.MODEL)
+ @classmethod + def get_prompts(cls): + """Return a set of strings for use in prompts""" + return RadioPrompts() + def set_pipe(self, pipe): """Set the serial object to be used for communications""" self.pipe = pipe
# HG changeset patch # User Tom Hayward tom@tomh.us # Date 1381264007 25200 # Node ID 17aa6b70b1b31926157becda152e2afd652d3b21 # Parent 4f5c50bf03253205ce13e9cbc9e73d139140426b Add instructions for clone mode radios. #1163
diff -r 4f5c50bf0325 -r 17aa6b70b1b3 chirpui/mainapp.py --- a/chirpui/mainapp.py Tue Oct 08 13:16:40 2013 -0700 +++ b/chirpui/mainapp.py Tue Oct 08 13:26:47 2013 -0700 @@ -564,7 +564,7 @@ return True
title = _("Proceed with experimental driver?") - text = rclass.get_experimental_warning() + text = rclass.get_prompts().experimental msg = _("This radio's driver is experimental. " "Do you want to proceed?") resp, squelch = common.show_warning(msg, text, @@ -575,6 +575,26 @@ CONF.set_bool(sql_key, not squelch, "state") return resp == gtk.RESPONSE_YES
+ def _show_instructions(self, radio, message): + if message is None: + return + + if CONF.get_bool("clone_instructions", "noconfirm"): + return + + d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK) + d.set_markup("<big><b>" + _("{name} Instructions").format( + name=radio.get_name()) + "</b></big>") + msg = _("{instructions}").format(instructions=message) + d.format_secondary_markup(msg) + + again = gtk.CheckButton(_("Don't show instructions for any radio again")) + again.show() + d.vbox.pack_start(again, 0, 0, 0) + d.run() + d.destroy() + CONF.set_bool("clone_instructions", again.get_active(), "noconfirm") + def do_download(self, port=None, rtype=None): d = clone.CloneSettingsDialog(parent=self) settings = d.run() @@ -588,6 +608,8 @@ # User does not want to proceed with experimental driver return
+ self._show_instructions(rclass, rclass.get_prompts().pre_download) + print "User selected %s %s on port %s" % (rclass.VENDOR, rclass.MODEL, settings.port) @@ -631,6 +653,8 @@ # User does not want to proceed with experimental driver return
+ self._show_instructions(radio, radio.get_prompts().pre_upload) + try: ser = serial.Serial(port=settings.port, baudrate=radio.BAUD_RATE,
# HG changeset patch # User Tom Hayward tom@tomh.us # Date 1381264009 25200 # Node ID e5907751a6a62ca157fbb95067995db6320b7e30 # Parent 17aa6b70b1b31926157becda152e2afd652d3b21 [uv5r] Update experimental warning to use RadioPrompts. #1163
diff -r 17aa6b70b1b3 -r e5907751a6a6 chirp/uv5r.py --- a/chirp/uv5r.py Tue Oct 08 13:26:47 2013 -0700 +++ b/chirp/uv5r.py Tue Oct 08 13:26:49 2013 -0700 @@ -475,13 +475,15 @@ ]
@classmethod - def get_experimental_warning(cls): - return ('Due to the fact that the manufacturer continues to ' + def get_prompts(cls): + rp = chirp_common.RadioPrompts() + rp.experimental = ('Due to the fact that the manufacturer continues to ' 'release new versions of the firmware with obscure and ' 'hard-to-track changes, this driver may not work with ' 'your device. Thus far and to the best knowledge of the ' 'author, no UV-5R radios have been harmed by using CHIRP. ' 'However, proceed at your own risk!') + return rp
def get_features(self): rf = chirp_common.RadioFeatures()
# HG changeset patch # User Tom Hayward tom@tomh.us # Date 1381264010 25200 # Node ID cbf81b8d32390c42172e68aea5aff6c2500b33b0 # Parent e5907751a6a62ca157fbb95067995db6320b7e30 [anytone] Update experimental warning to use RadioPrompts. #1163
diff -r e5907751a6a6 -r cbf81b8d3239 chirp/anytone.py --- a/chirp/anytone.py Tue Oct 08 13:26:49 2013 -0700 +++ b/chirp/anytone.py Tue Oct 08 13:26:50 2013 -0700 @@ -306,8 +306,10 @@ ]
@classmethod - def get_experimental_warning(cls): - return "FOO" + def get_prompts(cls): + rp = chirp_common.RadioPrompts() + rp.experimental = "FOO" + return rp
def get_features(self): rf = chirp_common.RadioFeatures()
# HG changeset patch # User Tom Hayward tom@tomh.us # Date 1381264010 25200 # Node ID 677a4172a8cbddeac8097a023d5ea4c5d899dacc # Parent cbf81b8d32390c42172e68aea5aff6c2500b33b0 [wouxun] Update experimental warning to use RadioPrompts. #1163
diff -r cbf81b8d3239 -r 677a4172a8cb chirp/wouxun.py --- a/chirp/wouxun.py Tue Oct 08 13:26:50 2013 -0700 +++ b/chirp/wouxun.py Tue Oct 08 13:26:50 2013 -0700 @@ -111,13 +111,15 @@ """
@classmethod - def get_experimental_warning(cls): - return ('This version of the Wouxun driver allows you to modify the ' + def get_prompts(cls): + rp = chirp_common.RadioPrompts() + rp.experimental = ('This version of the Wouxun driver allows you to modify the ' 'frequency range settings of your radio. This has been tested ' 'and reports from other users indicate that it is a safe ' 'thing to do. However, modifications to this value may have ' 'unintended consequences, including damage to your device. ' 'You have been warned. Proceed at your own risk!') + return rp
@classmethod def _get_querymodel(cls):
# HG changeset patch # User Tom Hayward tom@tomh.us # Date 1381264011 25200 # Node ID 355db7a469386daed17738a2955ed5653eae9e39 # Parent 677a4172a8cbddeac8097a023d5ea4c5d899dacc [ft1802] Add instructions for clone mode. #1163
diff -r 677a4172a8cb -r 355db7a46938 chirp/ft1802.py --- a/chirp/ft1802.py Tue Oct 08 13:26:50 2013 -0700 +++ b/chirp/ft1802.py Tue Oct 08 13:26:51 2013 -0700 @@ -26,6 +26,7 @@ from chirp import chirp_common, bitwise, directory, yaesu_clone from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean +from textwrap import dedent
MEM_FORMAT = """ #seekto 0x06ea; @@ -88,6 +89,21 @@ _block_lengths = [10, 8001] _memsize = 8011
+ @classmethod + def get_prompts(cls): + rp = chirp_common.RadioPrompts() + rp.pre_download = _(dedent("""\ + 1. Turn radio off. + 2. Connect cable to mic jack. + 3. Press and hold in the [LOW(A/N)] key while turning the radio on. + 4. <b>After clicking OK</b>, press the [MHz(SET)] key to send image.""")) + rp.pre_upload = _(dedent("""\ + 1. Turn radio off. + 2. Connect cable to mic jack. + 3. Press and hold in the [LOW(A/N)] key while turning the radio on. + 4. Press the [D/MR(MW)] key ("--WAIT--" will appear on the LCD).""")) + return rp + def get_features(self): rf = chirp_common.RadioFeatures()
participants (1)
-
Tom Hayward