diff --git a/L10n/en.template b/L10n/en.template index 307841b2..56e45805 100644 --- a/L10n/en.template +++ b/L10n/en.template @@ -126,6 +126,15 @@ /* EDMarketConnector.py: Label for 'Copy' as in 'Copy and Paste'; ttkHyperlinkLabel.py: Label for 'Copy' as in 'Copy and Paste'; In files: EDMarketConnector.py:962; ttkHyperlinkLabel.py:53; */ "Copy" = "Copy"; +/* myNotebook.py: Label for 'Cut' as in 'Cut and Paste'; */ +"Cut" = "Cut"; + +/* myNotebook.py: Label for 'Paste' as in 'Copy and Paste'; */ +"Paste" = "Paste"; + +/* myNotebook.py: Label for 'Select All'; */ +"Select All" = "Select All"; + /* EDMarketConnector.py: CAPI auth aborted because of killswitch; EDMarketConnector.py: CAPI auth query aborted because of killswitch; In files: EDMarketConnector.py:973; EDMarketConnector.py:1067; */ "CAPI auth disabled by killswitch" = "CAPI auth disabled by killswitch"; diff --git a/myNotebook.py b/myNotebook.py index 8a3cf901..635af5c1 100644 --- a/myNotebook.py +++ b/myNotebook.py @@ -67,12 +67,14 @@ class EntryMenu(ttk.Entry): ttk.Entry.__init__(self, *args, **kwargs) self.menu = tk.Menu(self, tearoff=False) - self.menu.add_command(label="Copy", command=self.copy) - self.menu.add_command(label="Cut", command=self.cut) + self.menu.add_command(label=tr.tl("Copy"), command=self.copy) # LANG: Label for 'Copy' as in 'Copy and Paste' + self.menu.add_command(label=tr.tl("Cut"), command=self.cut) # LANG: Label for 'Cut' as in 'Cut and Paste' self.menu.add_separator() - self.menu.add_command(label="Paste", command=self.paste) + # LANG: Label for 'Paste' as in 'Copy and Paste' + self.menu.add_command(label=tr.tl("Paste"), command=self.paste) self.menu.add_separator() - self.menu.add_command(label="Select All", command=self.select_all) + # LANG: Label for 'Select All' + self.menu.add_command(label=tr.tl("Select All"), command=self.select_all) self.bind("", self.display_popup) diff --git a/ttkHyperlinkLabel.py b/ttkHyperlinkLabel.py index 3ec0a26d..6266d9fb 100644 --- a/ttkHyperlinkLabel.py +++ b/ttkHyperlinkLabel.py @@ -70,10 +70,6 @@ class HyperlinkLabel(tk.Label or ttk.Label): # type: ignore ttk.Label.__init__(self, master, **kw) self.bind('', self._click) - - self.menu = tk.Menu(tearoff=tk.FALSE) - # LANG: Label for 'Copy' as in 'Copy and Paste' - self.menu.add_command(label=tr.tl('Copy'), command=self.copy) # As in Copy and Paste self.bind('', self._contextmenu) self.bind('', self._enter) @@ -87,29 +83,6 @@ class HyperlinkLabel(tk.Label or ttk.Label): # type: ignore # Add Menu Options self.plug_options = kw.pop('plug_options', None) self.name = kw.get('name', None) - if self.name == 'ship': - self.menu.add_separator() - for url in plug.provides('shipyard_url'): - self.menu.add_command( - label=tr.tl("Open in {URL}").format(URL=url), # LANG: Open Element In Selected Provider - command=partial(self.open_shipyard, url) - ) - - if self.name == 'station': - self.menu.add_separator() - for url in plug.provides('station_url'): - self.menu.add_command( - label=tr.tl("Open in {URL}").format(URL=url), # LANG: Open Element In Selected Provider - command=partial(self.open_station, url) - ) - - if self.name == 'system': - self.menu.add_separator() - for url in plug.provides('system_url'): - self.menu.add_command( - label=tr.tl("Open in {URL}").format(URL=url), # LANG: Open Element In Selected Provider - command=partial(self.open_system, url) - ) def open_shipyard(self, url: str): """Open the Current Ship Loadout in the Selected Provider.""" @@ -122,14 +95,13 @@ class HyperlinkLabel(tk.Label or ttk.Label): # type: ignore return webbrowser.open(opener) else: # Avoid file length limits if possible - provider = config.get_str('shipyard_provider', default='EDSY') - target = plug.invoke(provider, 'EDSY', 'shipyard_url', loadout, monitor.is_beta) + target = plug.invoke(url, 'EDSY', 'shipyard_url', loadout, monitor.is_beta) file_name = path.join(config.app_dir_path, "last_shipyard.html") with open(file_name, 'w') as f: f.write(SHIPYARD_HTML_TEMPLATE.format( link=html.escape(str(target)), - provider_name=html.escape(str(provider)), + provider_name=html.escape(str(url)), ship_name=html.escape("Ship") )) @@ -212,8 +184,41 @@ class HyperlinkLabel(tk.Label or ttk.Label): # type: ignore webbrowser.open(url) def _contextmenu(self, event: tk.Event) -> None: + """ + Display the context menu when right-clicked. + + :param event: The event object. + """ + menu = tk.Menu(tearoff=tk.FALSE) + # LANG: Label for 'Copy' as in 'Copy and Paste' + menu.add_command(label=tr.tl('Copy'), command=self.copy) # As in Copy and Paste + + if self.name == 'ship': + menu.add_separator() + for url in plug.provides('shipyard_url'): + menu.add_command( + label=tr.tl("Open in {URL}").format(URL=url), # LANG: Open Element In Selected Provider + command=partial(self.open_shipyard, url) + ) + + if self.name == 'station': + menu.add_separator() + for url in plug.provides('station_url'): + menu.add_command( + label=tr.tl("Open in {URL}").format(URL=url), # LANG: Open Element In Selected Provider + command=partial(self.open_station, url) + ) + + if self.name == 'system': + menu.add_separator() + for url in plug.provides('system_url'): + menu.add_command( + label=tr.tl("Open in {URL}").format(URL=url), # LANG: Open Element In Selected Provider + command=partial(self.open_system, url) + ) + if self['text'] and (self.popup_copy(self['text']) if callable(self.popup_copy) else self.popup_copy): - self.menu.post(event.x_root, event.y_root) + menu.post(event.x_root, event.y_root) def copy(self) -> None: """Copy the current text to the clipboard."""