Skip to content

Commit

Permalink
Add Edit->Copy menu item.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marginal committed Sep 19, 2015
1 parent e9028ff commit 6acf7fa
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 25 deletions.
22 changes: 20 additions & 2 deletions EDMarketConnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _click(self, event):
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):
Expand All @@ -85,6 +85,8 @@ def copy(self):

class AppWindow:

STATION_UNDOCKED = '-' # "Station" name to display when not docked

def __init__(self, master):

self.holdofftime = config.getint('querytime') + companion.holdoff
Expand Down Expand Up @@ -149,6 +151,10 @@ def __init__(self, master):
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
Expand All @@ -166,6 +172,10 @@ def __init__(self, master):
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
Expand Down Expand Up @@ -258,6 +268,7 @@ def getandsend(self, event=None, retrying=False):
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:
Expand All @@ -267,7 +278,7 @@ def getandsend(self, event=None, retrying=False):

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
Expand All @@ -289,6 +300,7 @@ def getandsend(self, event=None, retrying=False):

# 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)
Expand All @@ -310,6 +322,7 @@ def getandsend(self, event=None, retrying=False):
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)
Expand Down Expand Up @@ -409,6 +422,11 @@ def cooldown(self):
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('+')))
Expand Down
49 changes: 26 additions & 23 deletions L10n/en.template
Original file line number Diff line number Diff line change
@@ -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] */
Expand All @@ -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] */
Expand All @@ -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] */
Expand All @@ -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] */
Expand All @@ -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] */
Expand Down Expand Up @@ -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] */
Expand All @@ -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] */
Expand Down
3 changes: 3 additions & 0 deletions L10n/fr.strings
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,6 @@

/* As in Copy and Paste. [EDMarketConnector.py:51] */
"Copy" = "Copier";

/* Menu title. [EDMarketConnector.py:156] */
"Edit" = "Édition";
3 changes: 3 additions & 0 deletions L10n/it.strings
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,6 @@

/* As in Copy and Paste. [EDMarketConnector.py:51] */
"Copy" = "Copia";

/* Menu title. [EDMarketConnector.py:156] */
"Edit" = "Composizione";
3 changes: 3 additions & 0 deletions L10n/pl.strings
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,6 @@

/* As in Copy and Paste. [EDMarketConnector.py:51] */
"Copy" = "Kopiuj";

/* Menu title. [EDMarketConnector.py:156] */
"Edit" = "Edycja";
Binary file modified img/win.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6acf7fa

Please sign in to comment.