diff options
| author | Nicolas <nick@zbm2.com> | 2020-12-21 23:55:11 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-21 23:55:11 +0000 |
| commit | d3be1fe2ce7e9d3581bc3ad44664e9ddce5b3aa1 (patch) | |
| tree | 5f30d24930e81c13a071369583d025abab3b0d3c | |
| parent | a98b8b7dbef5032ceefa2e085eca6c35d0d01fd0 (diff) | |
| parent | 2ab1f3618f01fa3e1ebe53cbb58ce915269a3c74 (diff) | |
| download | chirp-d3be1fe2ce7e9d3581bc3ad44664e9ddce5b3aa1.tar.gz chirp-d3be1fe2ce7e9d3581bc3ad44664e9ddce5b3aa1.tar.xz | |
Merge pull request #4 from mpoletiek/main
Upstream Update
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | chirp/ui/inputdialog.py | 69 | ||||
| -rw-r--r-- | chirp/ui/mainapp.py | 340 |
4 files changed, 214 insertions, 199 deletions
@@ -13,3 +13,6 @@ logs # Vscode stuff .vscode + +# Mac Stuff +.DS_Store @@ -14,6 +14,7 @@ py3-CHIRP has been tested in Python3.9 on various platforms. Known dependencies - future - six - pypiwin32 (for Windows) +- pyGObject ## Testing diff --git a/chirp/ui/inputdialog.py b/chirp/ui/inputdialog.py index 29a2971..79bed24 100644 --- a/chirp/ui/inputdialog.py +++ b/chirp/ui/inputdialog.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -import gtk +from gi.repository import Gtk import logging from chirp.ui.miscwidgets import make_choice @@ -22,21 +22,21 @@ from chirp.ui import reporting LOG = logging.getLogger(__name__) -class TextInputDialog(gtk.Dialog): +class TextInputDialog(Gtk.Dialog): def respond_ok(self, _): - self.response(gtk.RESPONSE_OK) + self.response(Gtk.RESPONSE_OK) def __init__(self, **args): - buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, - gtk.STOCK_OK, gtk.RESPONSE_OK) - gtk.Dialog.__init__(self, buttons=buttons, **args) + buttons = (Gtk.STOCK_CANCEL, Gtk.RESPONSE_CANCEL, + Gtk.STOCK_OK, Gtk.RESPONSE_OK) + Gtk.Dialog.__init__(self, buttons=buttons, **args) - self.label = gtk.Label() + self.label = Gtk.Label() self.label.set_size_request(300, 100) # pylint: disable-msg=E1101 self.vbox.pack_start(self.label, 1, 1, 0) - self.text = gtk.Entry() + self.text = Gtk.Entry() self.text.connect("activate", self.respond_ok, None) # pylint: disable-msg=E1101 self.vbox.pack_start(self.text, 1, 1, 0) @@ -45,15 +45,15 @@ class TextInputDialog(gtk.Dialog): self.text.show() -class ChoiceDialog(gtk.Dialog): +class ChoiceDialog(Gtk.Dialog): editable = False def __init__(self, choices, **args): - buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, - gtk.STOCK_OK, gtk.RESPONSE_OK) - gtk.Dialog.__init__(self, buttons=buttons, **args) + buttons = (Gtk.STOCK_CANCEL, Gtk.RESPONSE_CANCEL, + Gtk.STOCK_OK, Gtk.RESPONSE_OK) + Gtk.Dialog.__init__(self, buttons=buttons, **args) - self.label = gtk.Label() + self.label = Gtk.Label() self.label.set_size_request(300, 100) # pylint: disable-msg=E1101 self.vbox.pack_start(self.label, 1, 1, 0) @@ -69,7 +69,7 @@ class ChoiceDialog(gtk.Dialog): self.vbox.pack_start(self.choice, 1, 1, 0) self.choice.show() - self.set_default_response(gtk.RESPONSE_OK) + self.set_default_response(Gtk.RESPONSE_OK) class EditableChoiceDialog(ChoiceDialog): @@ -81,10 +81,10 @@ class EditableChoiceDialog(ChoiceDialog): self.choice.child.set_activates_default(True) -class ExceptionDialog(gtk.MessageDialog): +class ExceptionDialog(Gtk.MessageDialog): def __init__(self, exception, **args): - gtk.MessageDialog.__init__(self, buttons=gtk.BUTTONS_OK, - type=gtk.MESSAGE_ERROR, **args) + Gtk.MessageDialog.__init__(self, buttons=Gtk.BUTTONS_OK, + type=Gtk.MESSAGE_ERROR, **args) self.set_property("text", _("An error has occurred")) self.format_secondary_text(str(exception)) @@ -96,25 +96,22 @@ class ExceptionDialog(gtk.MessageDialog): LOG.error("----------------------------") -class FieldDialog(gtk.Dialog): +class FieldDialog(Gtk.Dialog): def __init__(self, **kwargs): if "buttons" not in kwargs.keys(): - kwargs["buttons"] = (gtk.STOCK_OK, gtk.RESPONSE_OK, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) - + kwargs["buttons"] = (Gtk.STOCK_OK, Gtk.RESPONSE_OK, + Gtk.STOCK_CANCEL, Gtk.RESPONSE_CANCEL) + # NJP self.set_default_response(Gtk.RESPONSE_OK) self.__fields = {} - self.set_default_response(gtk.RESPONSE_OK) - - gtk.Dialog.__init__(self, **kwargs) - + Gtk.Dialog.__init__(self, **kwargs) + def response(self, _): - LOG.debug("Blocking response") - return + LOG.debug("Blocking response") def add_field(self, label, widget, validator=None): - box = gtk.HBox(True, 2) + box = Gtk.HBox(True, 2) - lab = gtk.Label(label) + lab = Gtk.Label(label) lab.show() widget.set_size_request(150, -1) @@ -133,11 +130,11 @@ class FieldDialog(gtk.Dialog): return self.__fields.get(label, None) -class OverwriteDialog(gtk.MessageDialog): +class OverwriteDialog(Gtk.MessageDialog): def __init__(self, filename): - gtk.Dialog.__init__(self, - buttons=(_("Overwrite"), gtk.RESPONSE_OK, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) + Gtk.Dialog.__init__(self, + buttons=(_("Overwrite"), Gtk.RESPONSE_OK, + Gtk.STOCK_CANCEL, Gtk.RESPONSE_CANCEL)) self.set_property("text", _("File Exists")) @@ -149,9 +146,9 @@ class OverwriteDialog(gtk.MessageDialog): if __name__ == "__main__": # pylint: disable-msg=C0103 - d = FieldDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK)) - d.add_field("Foo", gtk.Entry()) + d = FieldDialog(buttons=(Gtk.STOCK_OK, Gtk.RESPONSE_OK)) + d.add_field("Foo", Gtk.Entry()) d.add_field("Bar", make_choice(["A", "B"])) d.run() - gtk.main() + Gtk.main() d.destroy() diff --git a/chirp/ui/mainapp.py b/chirp/ui/mainapp.py index 3265206..a2cd9e4 100644 --- a/chirp/ui/mainapp.py +++ b/chirp/ui/mainapp.py @@ -22,7 +22,7 @@ from glob import glob import shutil import time import logging -import gtk +from gi.repository import Gtk, Gdk import gobject import sys @@ -80,7 +80,7 @@ class ModifiedError(Exception): pass -class ChirpMain(gtk.Window): +class ChirpMain(Gtk.Window): def get_current_editorset(self): page = self.tabs.get_current_page() @@ -160,12 +160,12 @@ class ChirpMain(gtk.Window): for i in range(0, self.tabs.get_n_pages()): esets.append(self.tabs.get_nth_page(i)) - d = gtk.Dialog(title="Diff Radios", - buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL), + d = Gtk.Dialog(title="Diff Radios", + buttons=(Gtk.STOCK_OK, Gtk.RESPONSE_OK, + Gtk.STOCK_CANCEL, Gtk.RESPONSE_CANCEL), parent=self) - label = gtk.Label("") + label = Gtk.Label("") label.set_markup("<b>-1</b> for either Mem # does a full-file hex " + "dump with diffs highlighted.\n" + "<b>-2</b> for first Mem # shows " + @@ -180,10 +180,10 @@ class ChirpMain(gtk.Window): eset.filename)) choice_a = miscwidgets.make_choice(choices, False, choices[0]) choice_a.show() - chan_a = gtk.SpinButton() + chan_a = Gtk.SpinButton() chan_a.get_adjustment().set_all(1, -2, 999, 1, 10, 0) chan_a.show() - hbox = gtk.HBox(False, 3) + hbox = Gtk.HBox(False, 3) hbox.pack_start(choice_a, 1, 1, 1) hbox.pack_start(chan_a, 0, 0, 0) hbox.show() @@ -191,10 +191,10 @@ class ChirpMain(gtk.Window): choice_b = miscwidgets.make_choice(choices, False, choices[1]) choice_b.show() - chan_b = gtk.SpinButton() + chan_b = Gtk.SpinButton() chan_b.get_adjustment().set_all(1, -1, 999, 1, 10, 0) chan_b.show() - hbox = gtk.HBox(False, 3) + hbox = Gtk.HBox(False, 3) hbox.pack_start(choice_b, 1, 1, 1) hbox.pack_start(chan_b, 0, 0, 0) hbox.show() @@ -206,7 +206,7 @@ class ChirpMain(gtk.Window): sel_b = choice_b.get_active_text() sel_chan_b = chan_b.get_value() d.destroy() - if r == gtk.RESPONSE_CANCEL: + if r == Gtk.RESPONSE_CANCEL: return if sel_a == sel_b: @@ -280,7 +280,7 @@ class ChirpMain(gtk.Window): continue radiolist["%s %s" % (radio.VENDOR, radio.MODEL)] = drv - lab = gtk.Label("""<b><big>Unable to detect model!</big></b> + lab = Gtk.Label("""<b><big>Unable to detect model!</big></b> If you think that it is valid, you can select a radio model below to force an open attempt. If selecting the model manually works, please @@ -289,15 +289,15 @@ does not work, it is likely that you are trying to open some other type of file. """) - lab.set_justify(gtk.JUSTIFY_FILL) + lab.set_justify(Gtk.JUSTIFY_FILL) lab.set_line_wrap(True) lab.set_use_markup(True) lab.show() choice = miscwidgets.make_choice(sorted(radiolist.keys()), False, sorted(radiolist.keys())[0]) - d = gtk.Dialog(title="Detection Failed", - buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) + d = Gtk.Dialog(title="Detection Failed", + buttons=(Gtk.STOCK_OK, Gtk.RESPONSE_OK, + Gtk.STOCK_CANCEL, Gtk.RESPONSE_CANCEL)) d.vbox.pack_start(lab, 0, 0, 0) d.vbox.pack_start(choice, 0, 0, 0) d.vbox.set_spacing(5) @@ -306,7 +306,7 @@ of file. # d.set_resizable(False) r = d.run() d.destroy() - if r != gtk.RESPONSE_OK: + if r != Gtk.RESPONSE_OK: return try: rc = directory.DRV_TO_RADIO[radiolist[choice.get_active_text()]] @@ -406,7 +406,7 @@ of file. self._show_information(radio) def do_live_warning(self, radio): - d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK) + d = Gtk.MessageDialog(parent=self, buttons=Gtk.BUTTONS_OK) d.set_markup("<big><b>" + _("Note:") + "</b></big>") msg = _("The {vendor} {model} operates in <b>live mode</b>. " "This means that any changes you make are immediately sent " @@ -417,7 +417,7 @@ of file. msg = msg.format(vendor=radio.VENDOR, model=radio.MODEL) d.format_secondary_markup(msg) - again = gtk.CheckButton(_("Don't show this again")) + again = Gtk.CheckButton(_("Don't show this again")) again.show() d.vbox.pack_start(again, 0, 0, 0) d.run() @@ -484,7 +484,7 @@ of file. dlg = inputdialog.OverwriteDialog(fname) owrite = dlg.run() dlg.destroy() - if owrite == gtk.RESPONSE_OK: + if owrite == Gtk.RESPONSE_OK: break else: break @@ -537,14 +537,14 @@ of file. self.menu_ag.remove_action(old_action) file_basename = os.path.basename(fname).replace("_", "__") - action = gtk.Action( + action = Gtk.Action( action_name, "_%i. %s" % (i + 1, file_basename), _("Open recent file {name}").format(name=fname), "") action.connect("activate", lambda a, f: self.do_open(f), fname) mid = self.menu_uim.new_merge_id() self.menu_uim.add_ui(mid, path, action_name, action_name, - gtk.UI_MANAGER_MENUITEM, False) + Gtk.UI_MANAGER_MENUITEM, False) self.menu_ag.add_action(action) i += 1 @@ -594,7 +594,7 @@ of file. name = os.path.splitext(os.path.basename(config))[0] action_name = "stock-%i" % configs.index(config) path = "/MenuBar/radio/stock" - action = gtk.Action(action_name, + action = Gtk.Action(action_name, name, _("Import stock " "configuration {name}").format(name=name), @@ -603,14 +603,14 @@ of file. mid = self.menu_uim.new_merge_id() mid = self.menu_uim.add_ui(mid, path, action_name, action_name, - gtk.UI_MANAGER_MENUITEM, False) + Gtk.UI_MANAGER_MENUITEM, False) self.menu_ag.add_action(action) def _do_open_action(config): name = os.path.splitext(os.path.basename(config))[0] action_name = "openstock-%i" % configs.index(config) path = "/MenuBar/file/openstock" - action = gtk.Action(action_name, + action = Gtk.Action(action_name, name, _("Open stock " "configuration {name}").format(name=name), @@ -619,7 +619,7 @@ of file. mid = self.menu_uim.new_merge_id() mid = self.menu_uim.add_ui(mid, path, action_name, action_name, - gtk.UI_MANAGER_MENUITEM, False) + Gtk.UI_MANAGER_MENUITEM, False) self.menu_ag.add_action(action) configs = glob(os.path.join(stock_dir, "*.csv")) @@ -639,11 +639,11 @@ of file. "Do you want to proceed?") resp, squelch = common.show_warning(msg, text, title=title, - buttons=gtk.BUTTONS_YES_NO, + buttons=Gtk.BUTTONS_YES_NO, can_squelch=True) - if resp == gtk.RESPONSE_YES: + if resp == Gtk.RESPONSE_YES: CONF.set_bool(sql_key, not squelch, "state") - return resp == gtk.RESPONSE_YES + return resp == Gtk.RESPONSE_YES def _show_information(self, radio): message = radio.get_prompts().info @@ -653,13 +653,13 @@ of file. if CONF.get_bool("clone_information", "noconfirm"): return - d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK) + d = Gtk.MessageDialog(parent=self, buttons=Gtk.BUTTONS_OK) d.set_markup("<big><b>" + _("{name} Information").format( name=radio.get_name()) + "</b></big>") msg = _("{information}").format(information=message) d.format_secondary_markup(msg) - again = gtk.CheckButton( + again = Gtk.CheckButton( _("Don't show information for any radio again")) again.show() again.connect("toggled", lambda action: @@ -671,7 +671,7 @@ of file. ok_button.grab_default() ok_button.grab_focus() except AttributeError: - # don't grab focus on GTK+ 2.0 + # don't grab focus on Gtk.+ 2.0 pass d.run() d.destroy() @@ -683,13 +683,13 @@ of file. if CONF.get_bool("clone_instructions", "noconfirm"): return - d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK) + 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( + again = Gtk.CheckButton( _("Don't show instructions for any radio again")) again.show() again.connect("toggled", lambda action: @@ -701,7 +701,7 @@ of file. ok_button.grab_default() ok_button.grab_focus() except AttributeError: - # don't grab focus on GTK+ 2.0 + # don't grab focus on Gtk.+ 2.0 pass d.run() d.destroy() @@ -805,16 +805,16 @@ of file. if eset.is_modified(): dlg = miscwidgets.YesNoDialog( title=_("Save Changes?"), parent=self, - buttons=(gtk.STOCK_YES, gtk.RESPONSE_YES, - gtk.STOCK_NO, gtk.RESPONSE_NO, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) + buttons=(Gtk.STOCK_YES, Gtk.RESPONSE_YES, + Gtk.STOCK_NO, Gtk.RESPONSE_NO, + Gtk.STOCK_CANCEL, Gtk.RESPONSE_CANCEL)) dlg.set_text(_("File is modified, save changes before closing?")) res = dlg.run() dlg.destroy() - if res == gtk.RESPONSE_YES: + if res == Gtk.RESPONSE_YES: self.do_save(eset) - elif res != gtk.RESPONSE_NO: + elif res != Gtk.RESPONSE_NO: raise ModifiedError() eset.rthread.stop() @@ -859,9 +859,9 @@ of file. reporting.report_model_usage(eset.rthread.radio, "import", count > 0) def do_dmrmarc_prompt(self): - fields = {"1City": (gtk.Entry(), lambda x: x), - "2State": (gtk.Entry(), lambda x: x), - "3Country": (gtk.Entry(), lambda x: x), + fields = {"1City": (Gtk.Entry(), lambda x: x), + "2State": (Gtk.Entry(), lambda x: x), + "3Country": (Gtk.Entry(), lambda x: x), } d = inputdialog.FieldDialog(title=_("DMR-MARC Repeater Database Dump"), @@ -870,7 +870,7 @@ of file. d.add_field(k[1:], fields[k][0]) fields[k][0].set_text(CONF.get(k[1:], "dmrmarc") or "") - while d.run() == gtk.RESPONSE_OK: + while d.run() == Gtk.RESPONSE_OK: for k in sorted(fields.keys()): widget, validator = fields[k] try: @@ -887,7 +887,7 @@ of file. return False def do_dmrmarc(self, do_import): - self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) + self.window.set_cursor(Gdk.Cursor(Gdk.WATCH)) if not self.do_dmrmarc_prompt(): self.window.set_cursor(None) return @@ -898,9 +898,9 @@ of file. # Do this in case the import process is going to take a while # to make sure we process events leading up to this - gtk.gdk.window_process_all_updates() - while gtk.events_pending(): - gtk.main_iteration(False) + # NJP Gtk.Gdk.window_process_all_updates() + #while Gtk.events_pending(): + # Gtk.main_iteration(False) if do_import: eset = self.get_current_editorset() @@ -919,7 +919,7 @@ of file. def do_repeaterbook_political_prompt(self): if not CONF.get_bool("has_seen_credit", "repeaterbook"): - d = gtk.MessageDialog(parent=self, buttons=gtk.BUTTONS_OK) + d = Gtk.MessageDialog(parent=self, buttons=Gtk.BUTTONS_OK) d.set_markup("<big><big><b>RepeaterBook</b></big>\r\n" + "<i>North American Repeater Directory</i></big>") d.format_secondary_markup("For more information about this " + @@ -984,20 +984,22 @@ of file. chose_county = county.get_active_text() chose_band = band.get_active_text() d.destroy() - if r != gtk.RESPONSE_OK: + if r != Gtk.RESPONSE_OK: return False code = fips.FIPS_STATES[chose_state] county_id = fips.FIPS_COUNTIES[code][chose_county] freq = RB_BANDS[chose_band] CONF.set("state", str(code), "repeaterbook") + # Escape the '%' Should FIP_COUNTIES be changed? + county_id = county_id.replace('%', '%%') CONF.set("county", str(county_id), "repeaterbook") CONF.set("band", str(freq), "repeaterbook") return True def do_repeaterbook_political(self, do_import): - self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) + self.window.set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) if not self.do_repeaterbook_political_prompt(): self.window.set_cursor(None) return @@ -1013,7 +1015,7 @@ of file. try: county = CONF.get("county", "repeaterbook") except: - county = '%' # --All-- default + county = '%%' # --All-- default try: band = int(CONF.get("band", "repeaterbook")) @@ -1029,10 +1031,10 @@ of file. # Do this in case the import process is going to take a while # to make sure we process events leading up to this - with compat.py3safe(): - gtk.gdk.window_process_all_updates() - while gtk.events_pending(): - gtk.main_iteration(False) + # NJP with compat.py3safe(): + # Gtk.Gdk.window_process_all_updates() + # while Gtk.events_pending(): + # Gtk.main_iteration(False) fn = tempfile.mktemp(".csv") try: @@ -1078,8 +1080,8 @@ of file. break except: pass - fields = {"1Location": (gtk.Entry(), lambda x: x.get_text()), - "2Distance": (gtk.Entry(), lambda x: x.get_text()), + fields = {"1Location": (Gtk.Entry(), lambda x: x.get_text()), + "2Distance": (Gtk.Entry(), lambda x: x.get_text()), "3Band": (miscwidgets.make_choice( sorted(RB_BANDS.keys(), key=key_bands), False, default_band), @@ -1093,11 +1095,11 @@ of file. if isinstance(widget, miscwidgets.EditableChoiceBase): widget = widget.widget d.add_field(k[1:], widget) - if isinstance(fields[k][0], gtk.Entry): + if isinstance(fields[k][0], Gtk.Entry): fields[k][0].set_text( CONF.get(k[1:].lower(), "repeaterbook") or "") - while d.run() == gtk.RESPONSE_OK: + while d.run() == Gtk.RESPONSE_OK: valid = True for k, (widget, fn) in fields.items(): try: @@ -1117,7 +1119,9 @@ of file. return False def do_repeaterbook_proximity(self, do_import): - self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) + + # NJP self.window.set_cursor(Gtk.Gdk.Cursor(Gtk.Gdk.WATCH)) + self.window.set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) if not self.do_repeaterbook_proximity_prompt(): self.window.set_cursor(None) return @@ -1141,10 +1145,15 @@ of file. # Do this in case the import process is going to take a while # to make sure we process events leading up to this - with compat.py3safe(): - gtk.gdk.window_process_all_updates() - while gtk.events_pending(): - gtk.main_iteration(False) + # NJP Gtk.Gdk.window_process_all_updates() + + while Gtk.events_pending(): + Gtk.main_iteration() + + #with compat.py3safe(): + # Gtk.Gdk.window_process_all_updates() + # while Gtk.events_pending(): + # Gtk.main_iteration(False) fn = tempfile.mktemp(".csv") try: @@ -1200,18 +1209,18 @@ of file. "Only Working": (miscwidgets.make_choice(['', 'yes'], False), lambda x: str(x.get_active_text())), - "Latitude": (gtk.Entry(), lambda x: float(x.get_text())), - "Longitude": (gtk.Entry(), lambda x: float(x.get_text())), - "Range": (gtk.Entry(), lambda x: int(x.get_text())), + "Latitude": (Gtk.Entry(), lambda x: float(x.get_text())), + "Longitude": (Gtk.Entry(), lambda x: float(x.get_text())), + "Range": (Gtk.Entry(), lambda x: int(x.get_text())), } for name in sorted(fields.keys()): value, fn = fields[name] d.add_field(name, value) - while d.run() == gtk.RESPONSE_OK: + while d.run() == Gtk.RESPONSE_OK: query = "http://przemienniki.net/export/chirp.csv?" args = [] for name, (value, fn) in fields.items(): - if isinstance(value, gtk.Entry): + if isinstance(value, Gtk.Entry): contents = value.get_text() else: contents = value.get_active_text() @@ -1265,13 +1274,13 @@ of file. self.do_open_live(radio, read_only=True) def do_rfinder_prompt(self): - fields = {"1Email": (gtk.Entry(), lambda x: "@" in x), - "2Password": (gtk.Entry(), lambda x: x), - "3Latitude": (gtk.Entry(), + fields = {"1Email": (Gtk.Entry(), lambda x: "@" in x), + "2Password": (Gtk.Entry(), lambda x: x), + "3Latitude": (Gtk.Entry(), lambda x: float(x) < 90 and float(x) > -90), - "4Longitude": (gtk.Entry(), + "4Longitude": (Gtk.Entry(), lambda x: float(x) < 180 and float(x) > -180), - "5Range_in_Miles": (gtk.Entry(), + "5Range_in_Miles": (Gtk.Entry(), lambda x: int(x) > 0 and int(x) < 5000), } @@ -1281,7 +1290,7 @@ of file. fields[k][0].set_text(CONF.get(k[1:], "rfinder") or "") fields[k][0].set_visibility(k != "2Password") - while d.run() == gtk.RESPONSE_OK: + while d.run() == Gtk.RESPONSE_OK: valid = True for k in sorted(fields.keys()): widget, validator = fields[k] @@ -1303,7 +1312,7 @@ of file. return False def do_rfinder(self, do_import): - self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) + self.window.set_cursor(Gtk.Gdk.Cursor(Gtk.Gdk.WATCH)) if not self.do_rfinder_prompt(): self.window.set_cursor(None) return @@ -1316,9 +1325,9 @@ of file. # Do this in case the import process is going to take a while # to make sure we process events leading up to this - gtk.gdk.window_process_all_updates() - while gtk.events_pending(): - gtk.main_iteration(False) + Gtk.Gdk.window_process_all_updates() + while Gtk.events_pending(): + Gtk.main_iteration(False) if do_import: eset = self.get_current_editorset() @@ -1334,9 +1343,9 @@ of file. self.window.set_cursor(None) def do_radioreference_prompt(self): - fields = {"1Username": (gtk.Entry(), lambda x: x), - "2Password": (gtk.Entry(), lambda x: x), - "3Zipcode": (gtk.Entry(), lambda x: x), + fields = {"1Username": (Gtk.Entry(), lambda x: x), + "2Password": (Gtk.Entry(), lambda x: x), + "3Zipcode": (Gtk.Entry(), lambda x: x), } d = inputdialog.FieldDialog(title=_("RadioReference.com Query"), @@ -1346,7 +1355,7 @@ of file. fields[k][0].set_text(CONF.get(k[1:], "radioreference") or "") fields[k][0].set_visibility(k != "2Password") - while d.run() == gtk.RESPONSE_OK: + while d.run() == Gtk.RESPONSE_OK: valid = True for k in sorted(fields.keys()): widget, validator = fields[k] @@ -1368,7 +1377,7 @@ of file. return False def do_radioreference(self, do_import): - self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) + self.window.set_cursor(Gtk.Gdk.Cursor(Gtk.Gdk.WATCH)) if not self.do_radioreference_prompt(): self.window.set_cursor(None) return @@ -1379,9 +1388,9 @@ of file. # Do this in case the import process is going to take a while # to make sure we process events leading up to this - gtk.gdk.window_process_all_updates() - while gtk.events_pending(): - gtk.main_iteration(False) + Gtk.Gdk.window_process_all_updates() + while Gtk.events_pending(): + Gtk.main_iteration(False) if do_import: eset = self.get_current_editorset() @@ -1421,7 +1430,7 @@ of file. dlg = inputdialog.OverwriteDialog(filen) owrite = dlg.run() dlg.destroy() - if owrite != gtk.RESPONSE_OK: + if owrite != Gtk.RESPONSE_OK: return os.remove(filen) @@ -1429,17 +1438,17 @@ of file. reporting.report_model_usage(eset.rthread.radio, "export", count > 0) def do_about(self): - d = gtk.AboutDialog() + d = Gtk.AboutDialog() d.set_transient_for(self) import sys - verinfo = "GTK %s\nPyGTK %s\nPython %s\n" % ( - ".".join([str(x) for x in gtk.gtk_version]), - ".".join([str(x) for x in gtk.pygtk_version]), + verinfo = "Gtk. %s\nPyGtk. %s\nPython %s\n" % ( + ".".join([str(x) for x in Gtk.Gtk._version]), + ".".join([str(x) for x in Gtk.pyGtk._version]), sys.version.split()[0]) # Set url hook to handle user activating a URL link in the about dialog with compat.py3safe(): - gtk.about_dialog_set_url_hook( + Gtk.about_dialog_set_url_hook( lambda dlg, url: webbrowser.open(url)) d.set_name("CHIRP") @@ -1473,15 +1482,15 @@ of file. radio_name = "%s %s %s" % (eset.rthread.radio.VENDOR, eset.rthread.radio.MODEL, eset.rthread.radio.VARIANT) - d = gtk.Dialog(title=_("Select Columns"), + d = Gtk.Dialog(title=_("Select Columns"), parent=self, - buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, - gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) + buttons=(Gtk.STOCK_OK, Gtk.RESPONSE_OK, + Gtk.STOCK_CANCEL, Gtk.RESPONSE_CANCEL)) - vbox = gtk.VBox() + vbox = Gtk.VBox() vbox.show() - sw = gtk.ScrolledWindow() - sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) + sw = Gtk.ScrolledWindow() + sw.set_policy(Gtk.POLICY_NEVER, Gtk.POLICY_AUTOMATIC) sw.add_with_viewport(vbox) sw.show() d.vbox.pack_start(sw, 1, 1, 1) @@ -1489,7 +1498,7 @@ of file. d.set_resizable(False) labelstr = _("Visible columns for {radio}").format(radio=radio_name) - label = gtk.Label(labelstr) + label = Gtk.Label(labelstr) label.show() vbox.pack_start(label) @@ -1503,7 +1512,7 @@ of file. continue label = colspec[0] visible = memedit.get_column_visible(memedit.col(label)) - widget = gtk.CheckButton(label) + widget = Gtk.CheckButton(label) widget.set_active(visible) fields.append(widget) vbox.pack_start(widget, 1, 1, 1) @@ -1511,7 +1520,7 @@ of file. res = d.run() selected_columns = [] - if res == gtk.RESPONSE_OK: + if res == Gtk.RESPONSE_OK: for widget in fields: colnum = memedit.col(widget.get_label()) memedit.set_column_visible(colnum, widget.get_active()) @@ -1550,7 +1559,7 @@ of file. def do_toggle_report(self, action): if not action.get_active(): - d = gtk.MessageDialog(buttons=gtk.BUTTONS_YES_NO, parent=self) + d = Gtk.MessageDialog(buttons=Gtk.BUTTONS_YES_NO, parent=self) markup = "<b><big>" + _("Reporting is disabled") + "</big></b>" d.set_markup(markup) msg = _("The reporting feature of CHIRP is designed to help " @@ -1565,7 +1574,7 @@ of file. d.format_secondary_markup(msg.replace("\n", "\r\n")) r = d.run() d.destroy() - if r == gtk.RESPONSE_NO: + if r == Gtk.RESPONSE_NO: action.set_active(not action.get_active()) conf = config.get() @@ -1602,7 +1611,7 @@ of file. "will take effect")) d.label.set_line_wrap(True) r = d.run() - if r == gtk.RESPONSE_OK: + if r == Gtk.RESPONSE_OK: LOG.debug("Chose language %s" % d.choice.get_active_text()) conf = config.get() conf.set("language", d.choice.get_active_text(), "state") @@ -1622,7 +1631,7 @@ of file. # its normal better judgement directory.enable_reregistrations() - self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('#ea6262')) + self.modify_bg(Gtk.STATE_NORMAL, Gtk.Gdk.Color('#ea6262')) try: with file(filen) as module: @@ -1639,7 +1648,7 @@ of file. action = _action.get_name() if action == "quit": - gtk.main_quit() + Gtk.main_quit() elif action == "new": self.do_new() elif action == "open": @@ -1757,24 +1766,25 @@ of file. <menuitem action="download"/> <menuitem action="upload"/> <menu action="importsrc" name="importsrc"> - <menuitem action="idmrmarc"/> - <menuitem action="iradioreference"/> + <!-- <menuitem action="idmrmarc"/> + <menuitem action="iradioreference"/> --> <menu action="irbook" name="irbook"> <menuitem action="irbookpolitical"/> <menuitem action="irbookproximity"/> </menu> - <menuitem action="ipr"/> - <menuitem action="irfinder"/> + <!-- <menuitem action="ipr"/> + <menuitem action="irfinder"/> --> </menu> <menu action="querysrc" name="querysrc"> - <menuitem action="qdmrmarc"/> - <menuitem action="qradioreference"/> + <!-- <menuitem action="qdmrmarc"/> + <menuitem action="qradioreference"/> --> <menu action="qrbook" name="qrbook"> <menuitem action="qrbookpolitical"/> <menuitem action="qrbookproximity"/> </menu> + <!-- <menuitem action="qpr"/> - <menuitem action="qrfinder"/> + <menuitem action="qrfinder"/> --> </menu> <menu action="stock" name="stock"/> <separator/> @@ -1802,15 +1812,15 @@ of file. CTRL_KEY = "<Meta>" actions = [ ('file', None, _("_File"), None, None, self.mh), - ('new', gtk.STOCK_NEW, None, None, None, self.mh), - ('open', gtk.STOCK_OPEN, None, None, None, self.mh), + ('new', Gtk.STOCK_NEW, None, None, None, self.mh), + ('open', Gtk.STOCK_OPEN, None, None, None, self.mh), ('openstock', None, _("Open stock config"), None, None, self.mh), ('recent', None, _("_Recent"), None, None, self.mh), - ('save', gtk.STOCK_SAVE, None, None, None, self.mh), - ('saveas', gtk.STOCK_SAVE_AS, None, None, None, self.mh), + ('save', Gtk.STOCK_SAVE, None, None, None, self.mh), + ('saveas', Gtk.STOCK_SAVE_AS, None, None, None, self.mh), ('loadmod', None, _("Load Module"), None, None, self.mh), - ('close', gtk.STOCK_CLOSE, None, None, None, self.mh), - ('quit', gtk.STOCK_QUIT, None, None, None, self.mh), + ('close', Gtk.STOCK_CLOSE, None, None, None, self.mh), + ('quit', Gtk.STOCK_QUIT, None, None, None, self.mh), ('edit', None, _("_Edit"), None, None, self.mh), ('cut', None, _("_Cut"), "%sx" % CTRL_KEY, None, self.mh), ('copy', None, _("_Copy"), "%sc" % CTRL_KEY, None, self.mh), @@ -1872,9 +1882,9 @@ of file. None, None, self.mh), ('channel_defaults', None, _("Channel defaults"), None, None, self.mh), - ('cancelq', gtk.STOCK_STOP, None, "Escape", None, self.mh), + ('cancelq', Gtk.STOCK_STOP, None, "Escape", None, self.mh), ('help', None, _('Help'), None, None, self.mh), - ('about', gtk.STOCK_ABOUT, None, None, None, self.mh), + ('about', Gtk.STOCK_ABOUT, None, None, None, self.mh), ('gethelp', None, _("Get Help Online..."), None, None, self.mh), ] @@ -1900,8 +1910,8 @@ of file. None, None, self.mh, dv), ] - self.menu_uim = gtk.UIManager() - self.menu_ag = gtk.ActionGroup("MenuBar") + self.menu_uim = Gtk.UIManager() + self.menu_ag = Gtk.ActionGroup("MenuBar") self.menu_ag.add_actions(actions) self.menu_ag.add_toggle_actions(toggles) @@ -1922,7 +1932,7 @@ of file. return self.menu_uim.get_widget("/MenuBar") def make_tabs(self): - self.tabs = gtk.Notebook() + self.tabs = Gtk.Notebook() self.tabs.set_scrollable(True) return self.tabs @@ -1937,23 +1947,23 @@ of file. except ModifiedError: return False - gtk.main_quit() + Gtk.main_quit() return True def make_status_bar(self): - box = gtk.HBox(False, 2) + box = Gtk.HBox(False, 2) - self.sb_general = gtk.Statusbar() + self.sb_general = Gtk.Statusbar() self.sb_general.show() box.pack_start(self.sb_general, 1, 1, 1) - self.sb_radio = gtk.Statusbar() + self.sb_radio = Gtk.Statusbar() self.sb_radio.show() box.pack_start(self.sb_radio, 1, 1, 1) with compat.py3safe(quiet=True): - # Gtk2 had resize grips on the status bars, so remove them + # Gtk.2 had resize grips on the status bars, so remove them # if we can self.sb_general.set_has_resize_grip(False) self.sb_radio.set_has_resize_grip(True) @@ -1980,7 +1990,7 @@ of file. ] for name, key, fn in actions: - a = gtk.Action(name, name, name, "") + a = Gtk.Action(name, name, name, "") a.connect("activate", fn) self.menu_ag.add_action_with_accel(a, key) a.set_accel_group(accelg) @@ -2013,8 +2023,8 @@ of file. return CONF.set_int("last_update_check", int(time.time()), "state") - d = gtk.MessageDialog(buttons=gtk.BUTTONS_OK_CANCEL, parent=self, - type=gtk.MESSAGE_INFO) + d = Gtk.MessageDialog(buttons=Gtk.BUTTONS_OK_CANCEL, parent=self, + type=Gtk.MESSAGE_INFO) d.label.set_markup( _('A new version of CHIRP is available: ' + '{ver}. '.format(ver=version) + @@ -2023,7 +2033,7 @@ of file. 'http://chirp.danplanet.com</a>')) response = d.run() d.destroy() - if response == gtk.RESPONSE_OK: + if response == Gtk.RESPONSE_OK: webbrowser.open('http://chirp.danplanet.com/' 'projects/chirp/wiki/Download') @@ -2031,27 +2041,27 @@ of file. macapp = None # for KK7DS runtime <= R10 - try: - import gtk_osxapplication - macapp = gtk_osxapplication.OSXApplication() - except ImportError: - pass - - # for gtk-mac-integration >= 2.0.7 - try: - import gtkosx_application - macapp = gtkosx_application.Application() - except ImportError: - pass - - # for gtk-mac-integration 2.1.3 in brew - try: - from gi.repository import GtkosxApplication - macapp = GtkosxApplication.Application() - except ImportError: - pass - - # for gtk3 + #try: + # import Gtk._osxapplication + # macapp = Gtk._osxapplication.OSXApplication() + #except ImportError: + # pass + + # for Gtk.-mac-integration >= 2.0.7 + #try: + # import Gtk.osx_application + # macapp = Gtk.osx_application.Application() + #except ImportError: + # pass + + # for Gtk.-mac-integration 2.1.3 in brew + # try: + # from gi.repository import Gtk.osxApplication + # macapp = Gtk.osxApplication.Application() + # except ImportError: + # pass + + # for Gtk.3 try: import gi gi.require_version("Gtk", "3.0") @@ -2069,7 +2079,7 @@ of file. this_platform.find_resource(os.path.join("pixmaps", "chirp.png"))) if os.path.exists(icon): - icon_pixmap = gtk.gdk.pixbuf_new_from_file(icon) + icon_pixmap = Gtk.Gdk.pixbuf_new_from_file(icon) macapp.set_dock_icon_pixbuf(icon_pixmap) menu_bar.hide() @@ -2090,7 +2100,7 @@ of file. LOG.debug("Initialized MacOS support") def __init__(self, *args, **kwargs): - gtk.Window.__init__(self, *args, **kwargs) + Gtk.Window.__init__(self, *args, **kwargs) def expose(window, event=None): allocation = window.get_allocation() @@ -2098,23 +2108,27 @@ of file. CONF.set_int("window_h", allocation.height, "state") with compat.py3safe(quiet=True): - # GTK3 does not have 'expose_event' and I am not sure which + # Gtk.3 does not have 'expose_event' and I am not sure which # is a suitable replacement. We only need this to save window # size in the config, so don't warn about it. self.connect("expose_event", expose) def state_change(window, event): + # NJP CONF.set_bool( + # "window_maximized", + # event.new_window_state == Gtk.gdk.WINDOW_STATE_MAXIMIZED, + # "state") CONF.set_bool( "window_maximized", - event.new_window_state == gtk.gdk.WINDOW_STATE_MAXIMIZED, + event.new_window_state == Ggdk.WINDOW_STATE_MAXIMIZED, "state") - self.connect("window-state-event", state_change) + self.connect("window-state-event", state_change) d = CONF.get("last_dir", "state") if d and os.path.isdir(d): platform.get_platform().set_last_dir(d) - vbox = gtk.VBox(False, 2) + vbox = Gtk.VBox(False, 2) self._recent = [] @@ -2159,7 +2173,7 @@ of file. if not CONF.get_bool("warned_about_reporting") and \ not CONF.get_bool("no_report"): - d = gtk.MessageDialog(buttons=gtk.BUTTONS_OK, parent=self) + d = Gtk.MessageDialog(buttons=Gtk.BUTTONS_OK, parent=self) d.set_markup("<b><big>" + _("Error reporting is enabled") + "</big></b>") |
