]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_cb.C
minimal effort implementation of:
[lyx.git] / src / lyx_cb.C
index 3286ce49287ffc64d37baec7ff7946a7be7446fa..9086b5fd3ec1b1053fca2a800c9d4f13dc31ef75 100644 (file)
@@ -19,6 +19,7 @@
 #include "buffer.h"
 #include "bufferlist.h"
 #include "BufferView.h"
+#include "buffer_funcs.h"
 #include "cursor.h"
 #include "debug.h"
 #include "gettext.h"
@@ -98,7 +99,7 @@ bool quitting;        // flag, that we are quitting the program
 // Menu callbacks
 //
 
-bool MenuWrite(Buffer * buffer)
+bool menuWrite(Buffer * buffer)
 {
        if (buffer->save()) {
                LyX::ref().session().addLastFile(buffer->fileName());
@@ -115,13 +116,13 @@ bool MenuWrite(Buffer * buffer)
                text, 0, 1, _("&Rename"), _("&Cancel"));
 
        if (ret == 0)
-               return WriteAs(buffer);
+               return writeAs(buffer);
        return false;
 }
 
 
 
-bool WriteAs(Buffer * buffer, string const & filename)
+bool writeAs(Buffer * buffer, string const & filename)
 {
        string fname = buffer->fileName();
        string const oldname = fname;
@@ -129,7 +130,7 @@ bool WriteAs(Buffer * buffer, string const & filename)
        if (filename.empty()) {
 
                FileDialog fileDlg(_("Choose a filename to save document as"),
-                       LFUN_WRITEAS,
+                       LFUN_BUFFER_WRITE_AS,
                        make_pair(string(_("Documents|#o#O")),
                                  string(lyxrc.document_path)),
                        make_pair(string(_("Templates|#T#t")),
@@ -177,7 +178,7 @@ bool WriteAs(Buffer * buffer, string const & filename)
        bool unnamed = buffer->isUnnamed();
        buffer->setUnnamed(false);
 
-       if (!MenuWrite(buffer)) {
+       if (!menuWrite(buffer)) {
                buffer->setFileName(oldname);
                buffer->setUnnamed(unnamed);
                return false;
@@ -188,7 +189,7 @@ bool WriteAs(Buffer * buffer, string const & filename)
 }
 
 
-void QuitLyX(bool noask)
+void quitLyX(bool noask)
 {
        lyxerr[Debug::INFO] << "Running QuitLyX." << endl;
 
@@ -216,7 +217,7 @@ void QuitLyX(bool noask)
                Alert::warning(_("Unable to remove temporary directory"), msg);
        }
 
-       lyx_gui::exit();
+       lyx_gui::exit(0);
 }
 
 
@@ -284,7 +285,8 @@ int AutoSaveBuffer::generateChild()
                                // It is dangerous to do this in the child,
                                // but safe in the parent, so...
                                if (pid == -1)
-                                       bv_.owner()->message(_("Autosave failed!"));
+                                       // emit message signal.
+                                       bv_.buffer()->message(_("Autosave failed!"));
                        }
                }
                if (pid == 0) { // we are the child so...
@@ -297,7 +299,7 @@ int AutoSaveBuffer::generateChild()
 } // namespace anon
 
 
-void AutoSave(BufferView * bv)
+void autoSave(BufferView * bv)
        // should probably be moved into BufferList (Lgb)
        // Perfect target for a thread...
 {
@@ -310,7 +312,8 @@ void AutoSave(BufferView * bv)
                return;
        }
 
-       bv->owner()->message(_("Autosaving current document..."));
+       // emit message signal.
+       bv->buffer()->message(_("Autosaving current document..."));
 
        // create autosave filename
        string fname = bv->buffer()->filePath();
@@ -333,30 +336,23 @@ void AutoSave(BufferView * bv)
 // create new file with template
 // SERVERCMD !
 //
-void NewFile(BufferView * bv, string const & filename)
+void newFile(BufferView * bv, string const & filename)
 {
        // Split argument by :
        string name;
        string tmpname = split(filename, name, ':');
-#ifdef __EMX__ // Fix me! lyx_cb.C may not be low level enough to allow this.
-       if (name.length() == 1
-           && isalpha(static_cast<unsigned char>(name[0]))
-           && (prefixIs(tmpname, "/") || prefixIs(tmpname, "\\"))) {
-               name += ':';
-               name += token(tmpname, ':', 0);
-               tmpname = split(tmpname, ':');
-       }
-#endif
        lyxerr[Debug::INFO] << "Arg is " << filename
                            << "\nName is " << name
                            << "\nTemplate is " << tmpname << endl;
 
-       bv->newFile(name, tmpname);
+       Buffer * const b = newFile(name, tmpname);
+       if (b)
+               bv->setBuffer(b);
 }
 
 
 // Insert ascii file (if filename is empty, prompt for one)
-void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
+void insertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
 {
        if (!bv->available())
                return;
@@ -440,19 +436,19 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap
 
 // This function runs "configure" and then rereads lyx.defaults to
 // reconfigure the automatic settings.
-void Reconfigure(BufferView * bv)
+void reconfigure(BufferView * bv)
 {
-       bv->owner()->message(_("Running configure..."));
+       // emit message signal.
+       bv->buffer()->message(_("Running configure..."));
 
        // Run configure in user lyx directory
        Path p(package().user_support());
-       string const configure_script =
-               addName(package().system_support(), "configure.py");
-       string const configure_command = "python " + quoteName(configure_script);
+       string const configure_command = package().configure_command();
        Systemcall one;
        one.startscript(Systemcall::Wait, configure_command);
        p.pop();
-       bv->owner()->message(_("Reloading configuration..."));
+       // emit message signal.
+       bv->buffer()->message(_("Reloading configuration..."));
        lyxrc.read(libFileSearch(string(), "lyxrc.defaults"));
        // Re-read packages.lst
        LaTeXFeatures::getAvailable();