# HG changeset patch # User Rick DeWitt # Date 1529599413 25200 # Thu Jun 21 09:43:33 2018 -0700 # Node ID a232e3e57d23ad5d67f14ea8ac4b145658a7a628 # Parent 8b1b394fd9a66633e5bacd480affdcd501dc7dad [mainapp] Add Information prompt per #5889 Adds new config boolean, new help tab toggle and show_information method. diff -r 8b1b394fd9a6 -r a232e3e57d23 chirp/ui/mainapp.py --- a/chirp/ui/mainapp.py Thu Jun 21 09:39:30 2018 -0700 +++ b/chirp/ui/mainapp.py Thu Jun 21 09:43:33 2018 -0700 @@ -626,6 +626,37 @@ CONF.set_bool(sql_key, not squelch, "state") return resp == gtk.RESPONSE_YES + def _show_information(self, radio, message): + if message is None: + return + + if CONF.get_bool("clone_information", "noconfirm"): + return + + d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK) + d.set_markup("" + _("{name} Information").format( + name=radio.get_name()) + "") + msg = _("{information}").format(information=message) + _again_msg = "Don't show information for any radio again" + + d.format_secondary_markup(msg) + + again = gtk.CheckButton(_(_again_msg)) + again.show() + again.connect("toggled", lambda action: + self.infomenu.set_active(not action.get_active())) + d.vbox.pack_start(again, 0, 0, 0) + h_button_box = d.vbox.get_children()[2] + try: + ok_button = h_button_box.get_children()[0] + ok_button.grab_default() + ok_button.grab_focus() + except AttributeError: + # don't grab focus on GTK+ 2.0 + pass + d.run() + d.destroy() + def _show_instructions(self, radio, message): if message is None: return @@ -635,12 +666,13 @@ d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK) d.set_markup("" + _("{name} Instructions").format( - name=radio.get_name()) + "") + name=radio.get_name()) + "") msg = _("{instructions}").format(instructions=message) + _again_msg = "Don't show instructions for any radio again" + d.format_secondary_markup(msg) - again = gtk.CheckButton( - _("Don't show instructions for any radio again")) + again = gtk.CheckButton(_(_again_msg)) again.show() again.connect("toggled", lambda action: self.clonemenu.set_active(not action.get_active())) @@ -669,6 +701,9 @@ # User does not want to proceed with experimental driver return + if rclass.get_prompts().display_info is True: + self._show_information(rclass, rclass.get_prompts().info) + self._show_instructions(rclass, rclass.get_prompts().pre_download) LOG.debug("User selected %s %s on port %s" % @@ -1520,6 +1555,10 @@ devaction = self.menu_ag.get_action(name) devaction.set_visible(action.get_active()) + def do_toggle_clone_information(self, action): + CONF.set_bool("clone_information", + not action.get_active(), "noconfirm") + def do_toggle_clone_instructions(self, action): CONF.set_bool("clone_instructions", not action.get_active(), "noconfirm") @@ -1620,6 +1659,8 @@ self.do_toggle_no_smart_tmode(_action) elif action == "developer": self.do_toggle_developer(_action) + elif action == "clone_information": + self.do_toggle_clone_information(_action) elif action == "clone_instructions": self.do_toggle_clone_instructions(_action) elif action in ["cut", "copy", "paste", "delete", @@ -1714,6 +1755,7 @@ + @@ -1809,6 +1851,7 @@ re = not conf.get_bool("no_report") hu = conf.get_bool("hide_unused", "memedit", default=True) dv = conf.get_bool("developer", "state") + cf = not conf.get_bool("clone_information", "noconfirm") ci = not conf.get_bool("clone_instructions", "noconfirm") st = not conf.get_bool("no_smart_tmode", "memedit") @@ -1818,6 +1861,8 @@ None, None, self.mh, hu), ('no_smart_tmode', None, _("Smart Tone Modes"), None, None, self.mh, st), + ('clone_information', None, _("Show Information"), + None, None, self.mh, cf), ('clone_instructions', None, _("Show Instructions"), None, None, self.mh, ci), ('developer', None, _("Enable Developer Functions"), @@ -1834,6 +1879,9 @@ self.add_accel_group(self.menu_uim.get_accel_group()) + self.infomenu = self.menu_uim.get_widget( + "/MenuBar/help/clone_information") + self.clonemenu = self.menu_uim.get_widget( "/MenuBar/help/clone_instructions")