From 533cbbde5bb9ea2bd3b72b681f507c42a20d8eb9 2012-06-15 06:41:37 From: Paul Ivanov Date: 2012-06-15 06:41:37 Subject: [PATCH] UI: expose confirm_restart via menu checkbox There's a limitation to this implementation where the checkbox may not represent the state of confirm_restart for the current tab, but it does get set the appropriate value if it is ever toggled. --- diff --git a/IPython/frontend/qt/console/mainwindow.py b/IPython/frontend/qt/console/mainwindow.py index 6881c66..b4ec540 100644 --- a/IPython/frontend/qt/console/mainwindow.py +++ b/IPython/frontend/qt/console/mainwindow.py @@ -552,6 +552,15 @@ class MainWindow(QtGui.QMainWindow): self.kernel_menu.addSeparator() + self.confirm_restart_kernel_action = QtGui.QAction("Confirm kernel restart", + self, + checkable=True, + checked=self.active_frontend.confirm_restart, + triggered=self.toggle_confirm_restart_active_frontend + ) + + self.add_menu_action(self.kernel_menu, self.confirm_restart_kernel_action) + def _make_dynamic_magic(self,magic): """Return a function `fun` that will execute `magic` on active frontend. @@ -832,6 +841,16 @@ class MainWindow(QtGui.QMainWindow): def interrupt_kernel_active_frontend(self): self.active_frontend.request_interrupt_kernel() + def toggle_confirm_restart_active_frontend(self): + widget = self.active_frontend + widget.confirm_restart = not widget.confirm_restart + # XXX: whenever tabs are switched, the checkbox may not be + # representative of the state of the active widget. The next line + # ensures that at least after toggling, the checkbox represents the + # state this widget is in. + self.confirm_restart_kernel_action.setChecked(widget.confirm_restart) + + def cut_active_frontend(self): widget = self.active_frontend if widget.can_cut():