* \endvar
*/
{ LFUN_BUFFER_CLOSE, "buffer-close", ReadOnly, Buffer },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_BUFFER_CLOSE_ALL
+ * \li Action: Closes all buffers.
+ * \li Notion: Closes all buffers, asking whether to save it, etc,
+ if a buffer has been modified.
+ * \li Syntax: buffer-close_all
+ * \endvar
+ */
+ { LFUN_BUFFER_CLOSE_ALL, "buffer-close-all", ReadOnly, Buffer },
/*!
* \var lyx::FuncCode lyx::LFUN_BUFFER_EXPORT
* \li Action: Exports the current buffer (document) to the given format.
// it can happen that this event arrives without selecting the view,
// e.g. when clicking the close button on a background window.
setFocus();
+ if (!closeBufferAll(true)) {
+ closing_ = false;
+ close_event->ignore();
+ return;
+ }
+
+ // Make sure that nothing will use this close to be closed View.
+ guiApp->unregisterView(this);
+
+ if (isFullScreen()) {
+ // Switch off fullscreen before closing.
+ toggleFullScreen();
+ updateDialogs();
+ }
+
+ // Make sure the timer time out will not trigger a statusbar update.
+ d.statusbar_timer_.stop();
+
+ // Saving fullscreen requires additional tweaks in the toolbar code.
+ // It wouldn't also work under linux natively.
+ if (lyxrc.allow_geometry_session) {
+ // Save this window geometry and layout.
+ saveLayout();
+ // Then the toolbar private states.
+ ToolbarMap::iterator end = d.toolbars_.end();
+ for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
+ it->second->saveSession();
+ // Now take care of all other dialogs:
+ map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
+ for (; it!= d.dialogs_.end(); ++it)
+ it->second->saveSession();
+ }
+
+ close_event->accept();
+}
+
+
+bool GuiView::closeBufferAll(bool tolastopened)
+{
GuiWorkArea * active_wa = currentMainWorkArea();
setCurrentWorkArea(active_wa);
if (b->parent()) {
// This is a child document, just close the tab
// after saving but keep the file loaded.
- if (!closeBuffer(*b, true, is_active_wa)) {
- closing_ = false;
- close_event->ignore();
- return;
- }
+ if (!closeBuffer(*b, tolastopened, is_active_wa))
+ return false;
continue;
}
Buffer * c = *it;
// If a child is dirty, do not close
// without user intervention
- if (!closeBuffer(*c, false)) {
- closing_ = false;
- close_event->ignore();
- return;
- }
+ if (!closeBuffer(*c, false))
+ return false;
}
QList<int> const ids = guiApp->viewIds();
}
// closeBuffer() needs buffer workArea still alive and
// set as currrent one, and destroys it
- if (b && !closeBuffer(*b, true, is_active_wa)) {
- closing_ = false;
- close_event->ignore();
- return;
- }
+ if (b && !closeBuffer(*b, tolastopened, is_active_wa))
+ return false;
}
}
- // Make sure that nothing will use this close to be closed View.
- guiApp->unregisterView(this);
-
- if (isFullScreen()) {
- // Switch off fullscreen before closing.
- toggleFullScreen();
- updateDialogs();
- }
-
- // Make sure the timer time out will not trigger a statusbar update.
- d.statusbar_timer_.stop();
-
- // Saving fullscreen requires additional tweaks in the toolbar code.
- // It wouldn't also work under linux natively.
- if (lyxrc.allow_geometry_session) {
- // Save this window geometry and layout.
- saveLayout();
- // Then the toolbar private states.
- ToolbarMap::iterator end = d.toolbars_.end();
- for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
- it->second->saveSession();
- // Now take care of all other dialogs:
- map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
- for (; it!= d.dialogs_.end(); ++it)
- it->second->saveSession();
- }
-
- close_event->accept();
+ return true;
}