mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 19:14:51 +00:00
load files from lyx_main.C instead of lyx_gui.C, do not add session-restored files to lastfile list.
* src/frontends/lyx_gui.h: add prototype for create_view * src/frontends/(gtk,qt3,qt4)/lyx_gui.C: separate start() * src/lyx_main.C: call create_view, load file, and call start git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14500 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
857eb02a5c
commit
c8e5ee867f
@ -140,8 +140,7 @@ void lyx_gui::parse_lyxrc()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int lyx_gui::start(string const & batch, std::vector<string> const & files,
|
LyXView * lyx_gui::create_view(unsigned int width, unsigned int height,
|
||||||
unsigned int width, unsigned int height,
|
|
||||||
int /*posx*/, int /*posy*/, bool)
|
int /*posx*/, int /*posy*/, bool)
|
||||||
{
|
{
|
||||||
int view_id = theApp->gui().newView(width, height);
|
int view_id = theApp->gui().newView(width, height);
|
||||||
@ -153,18 +152,21 @@ int lyx_gui::start(string const & batch, std::vector<string> const & files,
|
|||||||
view.show();
|
view.show();
|
||||||
view.init();
|
view.init();
|
||||||
|
|
||||||
|
return &view;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int lyx_gui::start(LyXView * view, string const & batch)
|
||||||
|
{
|
||||||
// FIXME: server code below needs moving
|
// FIXME: server code below needs moving
|
||||||
|
|
||||||
lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
|
lyxserver = new LyXServer(&view->getLyXFunc(), lyxrc.lyxpipes);
|
||||||
lyxsocket = new LyXServerSocket(&view.getLyXFunc(),
|
lyxsocket = new LyXServerSocket(&view->getLyXFunc(),
|
||||||
os::internal_path(package().temp_dir() + "/lyxsocket"));
|
os::internal_path(package().temp_dir() + "/lyxsocket"));
|
||||||
|
|
||||||
for_each(files.begin(), files.end(),
|
|
||||||
bind(&LyXView::loadLyXFile, &view, _1, true));
|
|
||||||
|
|
||||||
// handle the batch commands the user asked for
|
// handle the batch commands the user asked for
|
||||||
if (!batch.empty()) {
|
if (!batch.empty()) {
|
||||||
view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
|
view->getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
|
||||||
}
|
}
|
||||||
|
|
||||||
theApp->run();
|
theApp->run();
|
||||||
|
@ -27,6 +27,7 @@ class LyXComm;
|
|||||||
class LyXDataSocket;
|
class LyXDataSocket;
|
||||||
class LyXServerSocket;
|
class LyXServerSocket;
|
||||||
class FuncRequest;
|
class FuncRequest;
|
||||||
|
class LyXView;
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
struct RGBColor;
|
struct RGBColor;
|
||||||
}
|
}
|
||||||
@ -53,12 +54,16 @@ std::string const typewriter_font_name();
|
|||||||
void parse_lyxrc();
|
void parse_lyxrc();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the main event loop, after executing the given
|
* Create the main window with given geometry settings
|
||||||
* batch commands, and loading the given documents
|
|
||||||
*/
|
*/
|
||||||
int start(std::string const & batch, std::vector<std::string> const & files,
|
LyXView * create_view(unsigned int width, unsigned int height, int posx, int posy,
|
||||||
unsigned int width, unsigned int height, int posx, int posy,
|
bool maximize);
|
||||||
bool maximize);
|
|
||||||
|
/**
|
||||||
|
* Start the main event loop, after executing the given
|
||||||
|
* batch commands
|
||||||
|
*/
|
||||||
|
int start(LyXView* view, std::string const & batch);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter the main event loop (\sa LyX::exec2)
|
* Enter the main event loop (\sa LyX::exec2)
|
||||||
|
@ -233,8 +233,8 @@ void parse_lyxrc()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
int start(string const & batch, vector<string> const & files,
|
LyXView* create_view(unsigned int width, unsigned int height, int posx, int posy,
|
||||||
unsigned int width, unsigned int height, int posx, int posy, bool maximize)
|
bool maximize)
|
||||||
{
|
{
|
||||||
// this can't be done before because it needs the Languages object
|
// this can't be done before because it needs the Languages object
|
||||||
initEncodings();
|
initEncodings();
|
||||||
@ -258,18 +258,21 @@ int start(string const & batch, vector<string> const & files,
|
|||||||
} else
|
} else
|
||||||
view.show();
|
view.show();
|
||||||
|
|
||||||
|
return &view;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int start(LyXView * view, string const & batch)
|
||||||
|
{
|
||||||
// FIXME: some code below needs moving
|
// FIXME: some code below needs moving
|
||||||
|
|
||||||
lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
|
lyxserver = new LyXServer(&view->getLyXFunc(), lyxrc.lyxpipes);
|
||||||
lyxsocket = new LyXServerSocket(&view.getLyXFunc(),
|
lyxsocket = new LyXServerSocket(&view->getLyXFunc(),
|
||||||
os::internal_path(package().temp_dir() + "/lyxsocket"));
|
os::internal_path(package().temp_dir() + "/lyxsocket"));
|
||||||
|
|
||||||
for_each(files.begin(), files.end(),
|
|
||||||
bind(&LyXView::loadLyXFile, &view, _1, true));
|
|
||||||
|
|
||||||
// handle the batch commands the user asked for
|
// handle the batch commands the user asked for
|
||||||
if (!batch.empty()) {
|
if (!batch.empty()) {
|
||||||
view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
|
view->getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
|
||||||
}
|
}
|
||||||
|
|
||||||
int const status = qApp->exec();
|
int const status = qApp->exec();
|
||||||
|
@ -194,8 +194,7 @@ void parse_lyxrc()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
int start(string const & batch, vector<string> const & files,
|
LyXView * create_view(unsigned int width, unsigned int height, int posx, int posy,
|
||||||
unsigned int width, unsigned int height, int posx, int posy,
|
|
||||||
bool maximize)
|
bool maximize)
|
||||||
{
|
{
|
||||||
// this can't be done before because it needs the Languages object
|
// this can't be done before because it needs the Languages object
|
||||||
@ -233,18 +232,21 @@ int start(string const & batch, vector<string> const & files,
|
|||||||
|
|
||||||
view.show();
|
view.show();
|
||||||
|
|
||||||
|
return &view;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int start(LyXView * view, string const & batch)
|
||||||
|
{
|
||||||
// FIXME: some code below needs moving
|
// FIXME: some code below needs moving
|
||||||
|
|
||||||
lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
|
lyxserver = new LyXServer(&view->getLyXFunc(), lyxrc.lyxpipes);
|
||||||
lyxsocket = new LyXServerSocket(&view.getLyXFunc(),
|
lyxsocket = new LyXServerSocket(&view->getLyXFunc(),
|
||||||
os::internal_path(package().temp_dir() + "/lyxsocket"));
|
os::internal_path(package().temp_dir() + "/lyxsocket"));
|
||||||
|
|
||||||
for_each(files.begin(), files.end(),
|
|
||||||
bind(&LyXView::loadLyXFile, &view, _1, true));
|
|
||||||
|
|
||||||
// handle the batch commands the user asked for
|
// handle the batch commands the user asked for
|
||||||
if (!batch.empty()) {
|
if (!batch.empty()) {
|
||||||
view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
|
view->getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
|
||||||
}
|
}
|
||||||
|
|
||||||
int const status = qApp->exec();
|
int const status = qApp->exec();
|
||||||
|
@ -259,14 +259,6 @@ int LyX::exec2(int & argc, char * argv[])
|
|||||||
if (first_start)
|
if (first_start)
|
||||||
files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
|
files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
|
||||||
|
|
||||||
// if a file is specified, I assume that user wants to edit *that* file
|
|
||||||
if (files.empty() && lyxrc.load_session) {
|
|
||||||
vector<string> const & lastopened = session_->lastOpenedFiles();
|
|
||||||
files.insert(files.end(), lastopened.begin(), lastopened.end() );
|
|
||||||
}
|
|
||||||
// clear this list to save a few bytes of RAM
|
|
||||||
session_->clearLastOpenedFiles();
|
|
||||||
|
|
||||||
// Execute batch commands if available
|
// Execute batch commands if available
|
||||||
if (!batch_command.empty()) {
|
if (!batch_command.empty()) {
|
||||||
|
|
||||||
@ -355,9 +347,26 @@ int LyX::exec2(int & argc, char * argv[])
|
|||||||
width = 0;
|
width = 0;
|
||||||
height = 0;
|
height = 0;
|
||||||
}
|
}
|
||||||
|
// create the main window
|
||||||
|
LyXView * view = lyx_gui::create_view(width, height, posx, posy, maximize);
|
||||||
|
|
||||||
|
// load files
|
||||||
|
for_each(files.begin(), files.end(),
|
||||||
|
bind(&LyXView::loadLyXFile, view, _1, true));
|
||||||
|
|
||||||
return lyx_gui::start(batch_command, files, width, height, posx, posy, maximize);
|
// if a file is specified, I assume that user wants to edit *that* file
|
||||||
|
if (files.empty() && lyxrc.load_session) {
|
||||||
|
vector<string> const & lastopened = session_->lastOpenedFiles();
|
||||||
|
// do not add to the lastfile list since these files are restored from
|
||||||
|
// last seesion, and should be already there (regular files), or should
|
||||||
|
// not be added at all (help files).
|
||||||
|
for_each(lastopened.begin(), lastopened.end(),
|
||||||
|
bind(&LyXView::loadLyXFile, view, _1, false));
|
||||||
|
}
|
||||||
|
// clear this list to save a few bytes of RAM
|
||||||
|
session_->clearLastOpenedFiles();
|
||||||
|
|
||||||
|
return lyx_gui::start(view, batch_command);
|
||||||
} else {
|
} else {
|
||||||
// Something went wrong above
|
// Something went wrong above
|
||||||
quitLyX(false);
|
quitLyX(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user