More cleanup now self.window is gone

No need for self.main_window in gui object.
No need for hooks "init_qt" and "close_main_window".
This commit is contained in:
Neil Booth 2015-09-04 18:29:52 +09:00
parent bbd50ba83c
commit 835bc4e4aa
3 changed files with 8 additions and 19 deletions

View File

@ -228,6 +228,10 @@ class ElectrumGui:
self.config.set_key('gui_last_wallet', path) self.config.set_key('gui_last_wallet', path)
# add to recently visited # add to recently visited
w.update_recently_visited(path) w.update_recently_visited(path)
# initial configuration
if self.config.get('hide_gui') is True and self.tray.isVisible():
w.hide()
else:
w.show() w.show()
self.windows.append(w) self.windows.append(w)
self.build_tray_menu() self.build_tray_menu()
@ -251,20 +255,10 @@ class ElectrumGui:
if os.path.exists(last_wallet): if os.path.exists(last_wallet):
self.config.cmdline_options['default_wallet_path'] = last_wallet self.config.cmdline_options['default_wallet_path'] = last_wallet
# main window if not self.start_new_window(self.config.get_wallet_path(),
self.main_window = self.start_new_window(self.config.get_wallet_path(), self.config.get('url')):
self.config.get('url'))
if not self.main_window:
return return
# plugins interact with main window
run_hook('init_qt', self)
# initial configuration
if self.config.get('hide_gui') is True and self.tray.isVisible():
self.main_window.hide()
signal.signal(signal.SIGINT, lambda *args: self.app.quit()) signal.signal(signal.SIGINT, lambda *args: self.app.quit())
# main loop # main loop
@ -274,5 +268,4 @@ class ElectrumGui:
event = QtCore.QEvent(QtCore.QEvent.Clipboard) event = QtCore.QEvent(QtCore.QEvent.Clipboard)
self.app.sendEvent(self.app.clipboard(), event) self.app.sendEvent(self.app.clipboard(), event)
if self.tray:
self.tray.hide() self.tray.hide()

View File

@ -2802,7 +2802,6 @@ class ElectrumWindow(QMainWindow):
if self.qr_window: if self.qr_window:
self.qr_window.close() self.qr_window.close()
self.close_wallet() self.close_wallet()
run_hook('close_main_window')
self.gui_object.close_window(self) self.gui_object.close_window(self)
event.accept() event.accept()

View File

@ -149,9 +149,6 @@ def _run_hook(name, always, *args):
for p, f in f_list: for p, f in f_list:
if name == 'load_wallet': if name == 'load_wallet':
p.wallet = args[0] p.wallet = args[0]
if name == 'init_qt':
gui = args[0]
p.window = gui.main_window
if always or p.is_enabled(): if always or p.is_enabled():
try: try:
r = f(*args) r = f(*args)