1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-15 00:30:33 +03:00

system/station plugin providers: Don't override 'url'

By default the ttkHyperlinkLabels for 'system' and 'station' names have
their 'url' members set to the functions in EDMarketConnector.App.

The EDDB one used to override the function as it had to do that special
name -> EDDB ID lookup from systems.p.  When I changed the code to not
need that any more I didn't fully understand what these overrides were.

After updating the EDDB code I then made sure the same logic was also in
the other plugins which meant they *also* set static strings, overriding
the call to the EDMarketConnector.App functions (which chain through to
the current plugin providers).

Unfortunately I didn't quite update the EDSM code enough causing
journal_entry() code to *not* set a new system 'url' despite changing
the 'text'.  This meant that only CAPI updates (so docking and login)
caused the URL to change, despite updating the 'text' to the correct
system name.

Rather than have everything setting static strings just do away with the
overrides as they're not needed!
This commit is contained in:
Athanasius 2020-08-25 21:38:22 +01:00
parent f75d8c9c9c
commit 7617ce7e9c
3 changed files with 23 additions and 24 deletions

View File

@ -81,13 +81,9 @@ def plugin_app(parent: 'Tk'):
def prefs_changed(cmdr, is_beta):
# Override standard URL functions
if config.get('system_provider') == 'eddb':
this.system_link['url'] = system_url(this.system)
if config.get('station_provider') == 'eddb':
this.station_link['url'] = station_url(this.system, this.station)
# Do *NOT* set 'url' here, as it's set to a function that will call
# through correctly. We don't want a static string.
pass
def journal_entry(cmdr, is_beta, system, station, entry, state):
# Always update, even if we're not the *current* system or station provider.
@ -110,7 +106,8 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
# Only actually change URLs if we are current provider.
if config.get('system_provider') == 'eddb':
this.system_link['text'] = this.system
this.system_link['url'] = system_url(this.system) # Override standard URL function
# Do *NOT* set 'url' here, as it's set to a function that will call
# through correctly. We don't want a static string.
this.system_link.update_idletasks()
# But only actually change the URL if we are current station provider.
@ -124,7 +121,8 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
text = ''
this.station_link['text'] = text
this.station_link['url'] = station_url(this.system, this.station) # Override standard URL function
# Do *NOT* set 'url' here, as it's set to a function that will call
# through correctly. We don't want a static string.
this.station_link.update_idletasks()
@ -143,7 +141,8 @@ def cmdr_data(data, is_beta):
# Override standard URL functions
if config.get('system_provider') == 'eddb':
this.system_link['text'] = this.system
this.system_link['url'] = system_url(this.system)
# Do *NOT* set 'url' here, as it's set to a function that will call
# through correctly. We don't want a static string.
this.system_link.update_idletasks()
if config.get('station_provider') == 'eddb':
@ -156,5 +155,6 @@ def cmdr_data(data, is_beta):
else:
this.station_link['text'] = ''
this.station_link['url'] = station_url(this.system, this.station)
# Do *NOT* set 'url' here, as it's set to a function that will call
# through correctly. We don't want a static string.
this.station_link.update_idletasks()

View File

@ -297,7 +297,8 @@ def cmdr_data(data, is_beta):
if config.get('system_provider') == 'EDSM':
this.system_link['text'] = this.system
this.system_link['url'] = system_url(this.system)
# Do *NOT* set 'url' here, as it's set to a function that will call
# through correctly. We don't want a static string.
this.system_link.update_idletasks()
if config.get('station_provider') == 'EDSM':
if data['commander']['docked']:
@ -307,7 +308,8 @@ def cmdr_data(data, is_beta):
else:
this.station_link['text'] = ''
this.station_link['url'] = station_url(this.system, this.station)
# Do *NOT* set 'url' here, as it's set to a function that will call
# through correctly. We don't want a static string.
this.station_link.update_idletasks()

View File

@ -244,13 +244,6 @@ def prefs_changed(cmdr: str, is_beta: bool):
changed = config.getint('inara_out') != this.log.get()
config.set('inara_out', this.log.get())
# Override standard URL functions
if config.get('system_provider') == 'Inara':
this.system_link['url'] = system_url(this.system)
if config.get('station_provider') == 'Inara':
this.station_link['url'] = station_url(this.system, this.station)
if cmdr and not is_beta:
this.cmdr = cmdr
this.FID = None
@ -998,7 +991,8 @@ def journal_entry(cmdr: str, is_beta: bool, system: str, station: str, entry: Di
# Only actually change URLs if we are current provider.
if config.get('system_provider') == 'Inara':
this.system_link['text'] = this.system
this.system_link['url'] = system_url(this.system)
# Do *NOT* set 'url' here, as it's set to a function that will call
# through correctly. We don't want a static string.
this.system_link.update_idletasks()
if config.get('station_provider') == 'Inara':
@ -1010,7 +1004,8 @@ def journal_entry(cmdr: str, is_beta: bool, system: str, station: str, entry: Di
to_set = ''
this.station_link['text'] = to_set
this.station_link['url'] = station_url(this.system, this.station)
# Do *NOT* set 'url' here, as it's set to a function that will call
# through correctly. We don't want a static string.
this.station_link.update_idletasks()
@ -1030,7 +1025,8 @@ def cmdr_data(data, is_beta):
# Override standard URL functions
if config.get('system_provider') == 'Inara':
this.system_link['text'] = this.system
this.system_link['url'] = system_url(this.system)
# Do *NOT* set 'url' here, as it's set to a function that will call
# through correctly. We don't want a static string.
this.system_link.update_idletasks()
if config.get('station_provider') == 'Inara':
@ -1043,7 +1039,8 @@ def cmdr_data(data, is_beta):
else:
this.station_link['text'] = ''
this.station_link['url'] = station_url(this.system, this.station)
# Do *NOT* set 'url' here, as it's set to a function that will call
# through correctly. We don't want a static string.
this.station_link.update_idletasks()
if config.getint('inara_out') and not is_beta and not this.multicrew and credentials(this.cmdr):