+ return flag;
+}
+
+
+bool GuiApplication::dispatch(FuncRequest const & cmd)
+{
+ switch(cmd.action) {
+
+ case LFUN_WINDOW_NEW:
+ createView(toqstr(cmd.argument()));
+ break;
+
+ case LFUN_WINDOW_CLOSE:
+ // update bookmark pit of the current buffer before window close
+ for (size_t i = 0; i < LyX::ref().session().bookmarks().size(); ++i)
+ theLyXFunc().gotoBookmark(i+1, false, false);
+ current_view_->close();
+ break;
+
+ case LFUN_LYX_QUIT:
+ // quitting is triggered by the gui code
+ // (leaving the event loop).
+ current_view_->message(from_utf8(N_("Exiting.")));
+ if (closeAllViews())
+ quit();
+ break;
+
+ case LFUN_SCREEN_FONT_UPDATE: {
+ // handle the screen font changes.
+ font_loader_.update();
+ // Backup current_view_
+ GuiView * view = current_view_;
+ // Set current_view_ to zero to forbid GuiWorkArea::redraw()
+ // to skip the refresh.
+ current_view_ = 0;
+ BufferList::iterator it = theBufferList().begin();
+ BufferList::iterator const end = theBufferList().end();
+ for (; it != end; ++it)
+ (*it)->changed();
+ // Restore current_view_
+ current_view_ = view;
+ break;
+ }
+
+ case LFUN_BUFFER_NEW:
+ if (viewCount() == 0
+ || (!lyxrc.open_buffers_in_tabs && current_view_->buffer() != 0))
+ createView();
+ current_view_->newDocument(to_utf8(cmd.argument()), false);
+ break;
+
+ case LFUN_BUFFER_NEW_TEMPLATE:
+ if (viewCount() == 0
+ || (!lyxrc.open_buffers_in_tabs && current_view_->buffer() != 0)) {
+ createView();
+ current_view_->newDocument(to_utf8(cmd.argument()), true);
+ if (!current_view_->buffer())
+ current_view_->close();
+ } else
+ current_view_->newDocument(to_utf8(cmd.argument()), true);
+ break;
+
+ case LFUN_FILE_OPEN:
+ if (viewCount() == 0
+ || (!lyxrc.open_buffers_in_tabs && current_view_->buffer() != 0)) {
+ createView();
+ current_view_->openDocument(to_utf8(cmd.argument()));
+ if (!current_view_->buffer())
+ current_view_->close();
+ } else
+ current_view_->openDocument(to_utf8(cmd.argument()));
+ break;
+
+ default:
+ // Notify the caller that the action has not been dispatched.
+ return false;
+ }
+
+ // The action has been dispatched.
+ return true;
+}
+
+
+void GuiApplication::resetGui()
+{
+ map<int, GuiView *>::iterator it;
+ for (it = views_.begin(); it != views_.end(); ++it)
+ it->second->resetDialogs();
+
+ dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
+}
+
+
+static void updateIds(map<int, GuiView *> const & stdmap, vector<int> & ids)
+{
+ ids.clear();
+ map<int, GuiView *>::const_iterator it;
+ for (it = stdmap.begin(); it != stdmap.end(); ++it)
+ ids.push_back(it->first);
+}
+
+
+void GuiApplication::createView(QString const & geometry_arg)
+{
+ if (global_menubar_)
+ global_menubar_->releaseKeyboard();
+
+ // create new view
+ updateIds(views_, view_ids_);
+ int id = 0;
+ while (views_.find(id) != views_.end())
+ id++;
+ GuiView * view = new GuiView(id);
+
+ // copy the icon size from old view
+ if (viewCount() > 0)
+ view->setIconSize(current_view_->iconSize());
+
+ // register view
+ views_[id] = view;
+ updateIds(views_, view_ids_);
+
+ view->show();
+ if (!geometry_arg.isEmpty()) {