mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 17:42:20 +03:00
Notify plugins on program closing
This commit is contained in:
parent
c8ff0a9701
commit
91ee6f3722
@ -819,6 +819,7 @@ class AppWindow:
|
|||||||
hotkeymgr.unregister()
|
hotkeymgr.unregister()
|
||||||
interactions.close()
|
interactions.close()
|
||||||
monitor.close()
|
monitor.close()
|
||||||
|
plug.notify_stop()
|
||||||
self.eddn.close()
|
self.eddn.close()
|
||||||
self.updater.close()
|
self.updater.close()
|
||||||
self.session.close()
|
self.session.close()
|
||||||
|
14
PLUGINS.md
14
PLUGINS.md
@ -32,6 +32,18 @@ def plugin_start():
|
|||||||
|
|
||||||
Any errors or print statements from your plugin will appear in `%TMP%\EDMarketConnector.log` on Windows or `$TMPDIR/EDMarketConnector.log` on Mac.
|
Any errors or print statements from your plugin will appear in `%TMP%\EDMarketConnector.log` on Windows or `$TMPDIR/EDMarketConnector.log` on Mac.
|
||||||
|
|
||||||
|
This gets called when the user closes the program:
|
||||||
|
|
||||||
|
```python
|
||||||
|
def plugin_stop():
|
||||||
|
"""
|
||||||
|
EDMC is closing
|
||||||
|
"""
|
||||||
|
print "Farewell cruel world!"
|
||||||
|
```
|
||||||
|
|
||||||
|
If your plugin uses one or more threads to handle Events then stop and join() the threads before returning from this function.
|
||||||
|
|
||||||
# Plugin Hooks
|
# Plugin Hooks
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
@ -94,7 +106,7 @@ this.status["text"] = "Happy!"
|
|||||||
|
|
||||||
## Events
|
## Events
|
||||||
|
|
||||||
Once you have created your plugin and EDMC has loaded it there are four other functions you can define to be notified by EDMC when something happens: `journal_entry()`, `interaction()`, `cmdr_data()` and `prefs_changed()`.
|
Once you have created your plugin and EDMC has loaded it there are three other functions you can define to be notified by EDMC when something happens: `journal_entry()`, `interaction()` and `cmdr_data()`.
|
||||||
|
|
||||||
Your events all get called on the main tkinter loop so be sure not to block for very long or the EDMC will appear to freeze. If you have a long running operation then you should take a look at how to do background updates in tkinter - http://effbot.org/zone/tkinter-threads.htm
|
Your events all get called on the main tkinter loop so be sure not to block for very long or the EDMC will appear to freeze. If you have a long running operation then you should take a look at how to do background updates in tkinter - http://effbot.org/zone/tkinter-threads.htm
|
||||||
|
|
||||||
|
18
plug.py
18
plug.py
@ -132,6 +132,24 @@ def load_plugins():
|
|||||||
imp.release_lock()
|
imp.release_lock()
|
||||||
|
|
||||||
|
|
||||||
|
def notify_stop():
|
||||||
|
"""
|
||||||
|
Notify each plugin that the program is closing.
|
||||||
|
If your plugin uses threads then stop and join() them before returning.
|
||||||
|
versionadded:: 2.3.7
|
||||||
|
"""
|
||||||
|
error = None
|
||||||
|
for plugin in PLUGINS:
|
||||||
|
plugin_stop = plugin._get_func('plugin_stop')
|
||||||
|
if plugin_stop:
|
||||||
|
try:
|
||||||
|
newerror = plugin_stop()
|
||||||
|
error = error or newerror
|
||||||
|
except:
|
||||||
|
print_exc()
|
||||||
|
return error
|
||||||
|
|
||||||
|
|
||||||
def notify_prefs_cmdr_changed(cmdr, is_beta):
|
def notify_prefs_cmdr_changed(cmdr, is_beta):
|
||||||
"""
|
"""
|
||||||
Notify each plugin that the Cmdr has been changed while the settings dialog is open.
|
Notify each plugin that the Cmdr has been changed while the settings dialog is open.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user