mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 15:57:14 +03:00
Add Edit->Copy menu item.
This commit is contained in:
parent
e9028ff7a6
commit
6acf7fa18a
@ -75,7 +75,7 @@ class HyperlinkLabel(ttk.Label):
|
||||
webbrowser.open(self.urlfn(self['text']))
|
||||
|
||||
def _contextmenu(self, event):
|
||||
if self['text'] and self['text'] != '-':
|
||||
if self['text'] and self['text'] != AppWindow.STATION_UNDOCKED:
|
||||
self.menu.post(platform == 'darwin' and event.x_root + 1 or event.x_root, event.y_root)
|
||||
|
||||
def copy(self):
|
||||
@ -85,6 +85,8 @@ class HyperlinkLabel(ttk.Label):
|
||||
|
||||
class AppWindow:
|
||||
|
||||
STATION_UNDOCKED = '-' # "Station" name to display when not docked
|
||||
|
||||
def __init__(self, master):
|
||||
|
||||
self.holdofftime = config.getint('querytime') + companion.holdoff
|
||||
@ -149,6 +151,10 @@ class AppWindow:
|
||||
apple_menu.add_command(label=_("About {APP}").format(APP=applongname), command=lambda:self.w.call('tk::mac::standardAboutPanel')) # App menu entry on OSX
|
||||
apple_menu.add_command(label=_("Check for Updates..."), command=lambda:self.updater.checkForUpdates())
|
||||
menubar.add_cascade(menu=apple_menu)
|
||||
self.edit_menu = tk.Menu(menubar, name='edit')
|
||||
self.edit_menu.add_command(label=_('Copy'), accelerator='Command-c', state=tk.DISABLED, command=self.copy) # As in Copy and Paste
|
||||
menubar.add_cascade(label=_('Edit'), menu=self.edit_menu) # Menu title
|
||||
self.w.bind('<Command-c>', self.copy)
|
||||
window_menu = tk.Menu(menubar, name='window')
|
||||
menubar.add_cascade(label=_('Window'), menu=window_menu) # Menu title on OSX
|
||||
# https://www.tcl.tk/man/tcl/TkCmd/tk_mac.htm
|
||||
@ -166,6 +172,10 @@ class AppWindow:
|
||||
file_menu.add_separator()
|
||||
file_menu.add_command(label=_("Exit"), command=self.onexit) # Item in the File menu on Windows
|
||||
menubar.add_cascade(label=_("File"), menu=file_menu) # Menu title on Windows
|
||||
self.edit_menu = tk.Menu(menubar, tearoff=tk.FALSE)
|
||||
self.edit_menu.add_command(label=_('Copy'), accelerator='Ctrl+C', state=tk.DISABLED, command=self.copy) # As in Copy and Paste
|
||||
menubar.add_cascade(label=_('Edit'), menu=self.edit_menu) # Menu title
|
||||
self.w.bind('<Control-c>', self.copy)
|
||||
self.w.protocol("WM_DELETE_WINDOW", self.onexit)
|
||||
if platform == 'linux2':
|
||||
# Fix up menu to use same styling as everything else
|
||||
@ -258,6 +268,7 @@ class AppWindow:
|
||||
self.system['image'] = ''
|
||||
self.status['text'] = _('Fetching station data...')
|
||||
self.button['state'] = tk.DISABLED
|
||||
self.edit_menu.entryconfigure(_('Copy'), state=tk.DISABLED)
|
||||
self.w.update_idletasks()
|
||||
|
||||
try:
|
||||
@ -267,7 +278,7 @@ class AppWindow:
|
||||
|
||||
self.cmdr['text'] = data.get('commander') and data.get('commander').get('name') or ''
|
||||
self.system['text'] = data.get('lastSystem') and data.get('lastSystem').get('name') or ''
|
||||
self.station['text'] = data.get('commander') and data.get('commander').get('docked') and data.get('lastStarport') and data.get('lastStarport').get('name') or (EDDB.system(self.system['text']) and '-' or '')
|
||||
self.station['text'] = data.get('commander') and data.get('commander').get('docked') and data.get('lastStarport') and data.get('lastStarport').get('name') or (EDDB.system(self.system['text']) and self.STATION_UNDOCKED or '')
|
||||
|
||||
config.set('querytime', querytime)
|
||||
self.holdofftime = querytime + companion.holdoff
|
||||
@ -289,6 +300,7 @@ class AppWindow:
|
||||
|
||||
# Stuff we can do while waiting for retry
|
||||
|
||||
self.edit_menu.entryconfigure(_('Copy'), state=tk.NORMAL)
|
||||
self.edsm.start_lookup(self.system['text'], EDDB.system(self.system['text']))
|
||||
self.system['image'] = self.edsm.result['img']
|
||||
self.w.after(int(EDSM_POLL * 1000), self.edsmpoll)
|
||||
@ -310,6 +322,7 @@ class AppWindow:
|
||||
h.write(json.dumps(data, indent=2, sort_keys=True))
|
||||
|
||||
if not retrying:
|
||||
self.edit_menu.entryconfigure(_('Copy'), state=tk.NORMAL)
|
||||
self.edsm.start_lookup(self.system['text'], EDDB.system(self.system['text']))
|
||||
self.system['image'] = self.edsm.result['img']
|
||||
self.w.after(int(EDSM_POLL * 1000), self.edsmpoll)
|
||||
@ -409,6 +422,11 @@ class AppWindow:
|
||||
self.button['text'] = _('Update') # Update button in main window
|
||||
self.button['state'] = tk.NORMAL
|
||||
|
||||
def copy(self, event=None):
|
||||
if self.system['text']:
|
||||
self.w.clipboard_clear()
|
||||
self.w.clipboard_append(self.station['text'] == self.STATION_UNDOCKED and self.system['text'] or '%s,%s' % (self.system['text'], self.station['text']))
|
||||
|
||||
def onexit(self, event=None):
|
||||
if platform!='darwin' or self.w.winfo_rooty()>0: # http://core.tcl.tk/tk/tktview/c84f660833546b1b84e7
|
||||
config.set('geometry', '+{1}+{2}'.format(*self.w.geometry().split('+')))
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* Use same text as E:D Launcher's verification dialog. [prefs.py:319] */
|
||||
"A verification code has now been sent to the{CR}email address associated with your Elite account." = "A verification code has now been sent to the{CR}email address associated with your Elite account.";
|
||||
|
||||
/* App menu entry on OSX. [EDMarketConnector.py:149] */
|
||||
/* App menu entry on OSX. [EDMarketConnector.py:151] */
|
||||
"About {APP}" = "About {APP}";
|
||||
|
||||
/* Folder selection button on Windows. [prefs.py:113] */
|
||||
@ -10,16 +10,16 @@
|
||||
/* Folder selection button on OSX. [prefs.py:112] */
|
||||
"Change..." = "Change...";
|
||||
|
||||
/* [EDMarketConnector.py:150] */
|
||||
/* [EDMarketConnector.py:152] */
|
||||
"Check for Updates..." = "Check for Updates...";
|
||||
|
||||
/* Privacy setting. [prefs.py:152] */
|
||||
"Cmdr name" = "Cmdr name";
|
||||
|
||||
/* Main window. [EDMarketConnector.py:123] */
|
||||
/* Main window. [EDMarketConnector.py:125] */
|
||||
"Cmdr:" = "Cmdr:";
|
||||
|
||||
/* Update button in main window. [EDMarketConnector.py:406] */
|
||||
/* Update button in main window. [EDMarketConnector.py:419] */
|
||||
"cooldown {SS}s" = "cooldown {SS}s";
|
||||
|
||||
/* As in Copy and Paste. [EDMarketConnector.py:51] */
|
||||
@ -28,10 +28,13 @@
|
||||
/* Section heading in settings. [prefs.py:70] */
|
||||
"Credentials" = "Credentials";
|
||||
|
||||
/* [EDMarketConnector.py:367] */
|
||||
/* Menu title. [EDMarketConnector.py:156] */
|
||||
"Edit" = "Edit";
|
||||
|
||||
/* [EDMarketConnector.py:380] */
|
||||
"Error: Can't connect to EDDN" = "Error: Can't connect to EDDN";
|
||||
|
||||
/* [EDMarketConnector.py:372] */
|
||||
/* [EDMarketConnector.py:385] */
|
||||
"Error: Connection to EDDN timed out" = "Error: Connection to EDDN timed out";
|
||||
|
||||
/* [companion.py:110] */
|
||||
@ -40,13 +43,13 @@
|
||||
/* [companion.py:104] */
|
||||
"Error: Server is down" = "Error: Server is down";
|
||||
|
||||
/* Item in the File menu on Windows. [EDMarketConnector.py:167] */
|
||||
/* Item in the File menu on Windows. [EDMarketConnector.py:173] */
|
||||
"Exit" = "Exit";
|
||||
|
||||
/* [EDMarketConnector.py:259] */
|
||||
/* [EDMarketConnector.py:269] */
|
||||
"Fetching station data..." = "Fetching station data...";
|
||||
|
||||
/* Menu title on Windows. [EDMarketConnector.py:168] */
|
||||
/* Menu title on Windows. [EDMarketConnector.py:174] */
|
||||
"File" = "File";
|
||||
|
||||
/* Output folder prompt on Windows. [prefs.py:111] */
|
||||
@ -64,10 +67,10 @@
|
||||
/* Section heading in settings on OSX. [prefs.py:125] */
|
||||
"Keyboard shortcut" = "Keyboard shortcut";
|
||||
|
||||
/* [EDMarketConnector.py:326] */
|
||||
/* [EDMarketConnector.py:339] */
|
||||
"Last updated at {HH}:{MM}:{SS}" = "Last updated at {HH}:{MM}:{SS}";
|
||||
|
||||
/* [EDMarketConnector.py:209] */
|
||||
/* [EDMarketConnector.py:219] */
|
||||
"Logging in..." = "Logging in...";
|
||||
|
||||
/* [prefs.py:102] */
|
||||
@ -124,10 +127,10 @@
|
||||
/* [prefs.py:96] */
|
||||
"Send station data to the Elite Dangerous Data Network" = "Send station data to the Elite Dangerous Data Network";
|
||||
|
||||
/* [EDMarketConnector.py:346] */
|
||||
/* [EDMarketConnector.py:359] */
|
||||
"Sending data to EDDN..." = "Sending data to EDDN...";
|
||||
|
||||
/* Item in the File menu on Windows. [EDMarketConnector.py:165] */
|
||||
/* Item in the File menu on Windows. [EDMarketConnector.py:171] */
|
||||
"Settings" = "Settings";
|
||||
|
||||
/* [prefs.py:106] */
|
||||
@ -136,40 +139,40 @@
|
||||
/* [prefs.py:104] */
|
||||
"Ship loadout in E:D Shipyard format" = "Ship loadout in E:D Shipyard format";
|
||||
|
||||
/* [EDMarketConnector.py:353] */
|
||||
/* [EDMarketConnector.py:366] */
|
||||
"Station doesn't have a market!" = "Station doesn't have a market!";
|
||||
|
||||
/* [EDMarketConnector.py:351] */
|
||||
/* [EDMarketConnector.py:364] */
|
||||
"Station doesn't have anything!" = "Station doesn't have anything!";
|
||||
|
||||
/* Main window. [EDMarketConnector.py:125] */
|
||||
/* Main window. [EDMarketConnector.py:127] */
|
||||
"Station:" = "Station:";
|
||||
|
||||
/* Main window. [EDMarketConnector.py:124] */
|
||||
/* Main window. [EDMarketConnector.py:126] */
|
||||
"System:" = "System:";
|
||||
|
||||
/* Update button in main window. [EDMarketConnector.py:130] */
|
||||
/* Update button in main window. [EDMarketConnector.py:132] */
|
||||
"Update" = "Update";
|
||||
|
||||
/* Use same text as E:D Launcher's login dialog. [prefs.py:75] */
|
||||
"Username (Email)" = "Username (Email)";
|
||||
|
||||
/* Shouldn't happen. [EDMarketConnector.py:283] */
|
||||
/* Shouldn't happen. [EDMarketConnector.py:294] */
|
||||
"What are you flying?!" = "What are you flying?!";
|
||||
|
||||
/* Shouldn't happen. [EDMarketConnector.py:280] */
|
||||
/* Shouldn't happen. [EDMarketConnector.py:291] */
|
||||
"Where are you?!" = "Where are you?!";
|
||||
|
||||
/* Output folder prompt on OSX. [prefs.py:110] */
|
||||
"Where:" = "Where:";
|
||||
|
||||
/* Shouldn't happen. [EDMarketConnector.py:277] */
|
||||
/* Shouldn't happen. [EDMarketConnector.py:288] */
|
||||
"Who are you?!" = "Who are you?!";
|
||||
|
||||
/* Menu title on OSX. [EDMarketConnector.py:153] */
|
||||
/* Menu title on OSX. [EDMarketConnector.py:159] */
|
||||
"Window" = "Window";
|
||||
|
||||
/* [EDMarketConnector.py:329] */
|
||||
/* [EDMarketConnector.py:342] */
|
||||
"You're not docked at a station!" = "You're not docked at a station!";
|
||||
|
||||
/* Shortcut settings prompt on OSX. [prefs.py:133] */
|
||||
|
@ -174,3 +174,6 @@
|
||||
|
||||
/* As in Copy and Paste. [EDMarketConnector.py:51] */
|
||||
"Copy" = "Copier";
|
||||
|
||||
/* Menu title. [EDMarketConnector.py:156] */
|
||||
"Edit" = "Édition";
|
||||
|
@ -175,3 +175,6 @@
|
||||
|
||||
/* As in Copy and Paste. [EDMarketConnector.py:51] */
|
||||
"Copy" = "Copia";
|
||||
|
||||
/* Menu title. [EDMarketConnector.py:156] */
|
||||
"Edit" = "Composizione";
|
||||
|
@ -174,3 +174,6 @@
|
||||
|
||||
/* As in Copy and Paste. [EDMarketConnector.py:51] */
|
||||
"Copy" = "Kopiuj";
|
||||
|
||||
/* Menu title. [EDMarketConnector.py:156] */
|
||||
"Edit" = "Edycja";
|
||||
|
BIN
img/win.png
BIN
img/win.png
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 5.6 KiB |
Loading…
x
Reference in New Issue
Block a user