From 71c5115c118b55a3ee24f7b7e0decfded323b090 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 27 Jan 2015 23:51:23 +0800 Subject: [PATCH] gui: handle exit in explorer --- artiq/frontend/artiq_gui.py | 9 ++++----- artiq/gui/explorer.py | 16 +++++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/artiq/frontend/artiq_gui.py b/artiq/frontend/artiq_gui.py index dcbf1b54e..94985ef8c 100755 --- a/artiq/frontend/artiq_gui.py +++ b/artiq/frontend/artiq_gui.py @@ -67,8 +67,12 @@ def main(): atexit.register( lambda: loop.run_until_complete(parameters_win.sub_close())) + def exit(*args): + lmgr.save() + Gtk.main_quit(*args) explorer_win = lmgr.create_window(ExplorerWindow, "explorer", + exit, schedule_ctl, repository) loop.run_until_complete(explorer_win.load_controls()) @@ -76,11 +80,6 @@ def main(): parameters_win.show_all() explorer_win.show_all() - def exit(*args): - lmgr.save() - Gtk.main_quit(*args) - explorer_win.connect("delete-event", exit) - rtr = RTResults() loop.run_until_complete(rtr.sub_connect( args.server, args.port_notify)) diff --git a/artiq/gui/explorer.py b/artiq/gui/explorer.py index 03ae5a521..4882f8703 100644 --- a/artiq/gui/explorer.py +++ b/artiq/gui/explorer.py @@ -6,7 +6,7 @@ from artiq.gui.tools import Window, getitem class ExplorerWindow(Window): - def __init__(self, schedule_ctl, repository, layout_dict=dict()): + def __init__(self, exit_fn, schedule_ctl, repository, layout_dict=dict()): self.schedule_ctl = schedule_ctl self.repository = repository @@ -14,6 +14,7 @@ class ExplorerWindow(Window): title="Explorer", default_size=(800, 570), layout_dict=layout_dict) + self.connect("delete-event", exit_fn) topvbox = Gtk.VBox(spacing=6) self.add(topvbox) @@ -23,13 +24,14 @@ class ExplorerWindow(Window): windows = Gtk.MenuItem("Windows") windows_menu = Gtk.Menu() - scheduler = Gtk.MenuItem("Scheduler") - parameters = Gtk.MenuItem("Parameters") - quit = Gtk.MenuItem("Quit") - windows_menu.append(scheduler) - windows_menu.append(parameters) + menuitem = Gtk.MenuItem("Scheduler") + windows_menu.append(menuitem) + menuitem = Gtk.MenuItem("Parameters") + windows_menu.append(menuitem) windows_menu.append(Gtk.SeparatorMenuItem()) - windows_menu.append(quit) + menuitem = Gtk.MenuItem("Quit") + menuitem.connect("activate", exit_fn) + windows_menu.append(menuitem) windows.set_submenu(windows_menu) menubar.append(windows)