]> git.lyx.org Git - lyx.git/blobdiff - src/lyxvc.C
More fixes to insettabular/text (and some missing features added).
[lyx.git] / src / lyxvc.C
index 9ef4c774bb84f69427db0001046f413f01ffa855..de506a2c032c1c1fbd43329538e29825dda4ec70 100644 (file)
 #include "buffer.h"
 #include "gettext.h"
 #include "support/filetools.h"
+#include "support/lyxlib.h"
 #include "lyxfunc.h"
 #include "LyXView.h"
 
+using std::endl;
+using std::pair;
 
 LyXVC::LyXVC()
 {
@@ -33,9 +36,7 @@ LyXVC::~LyXVC()
                        fl_hide_form(browser->LaTeXLog);
                fl_free_form(browser->LaTeXLog);
        }
-       if (vcs) {
-               delete vcs;
-       }
+       delete vcs;
 }
 
 
@@ -59,9 +60,13 @@ bool LyXVC::file_found_hook(string const & fn)
 }
 
 
-bool LyXVC::file_not_found_hook(string const &)
+bool LyXVC::file_not_found_hook(string const & fn)
 {
-       // file is not under any VCS.
+       // Check if file is under RCS
+       if (!RCS::find_file(fn).empty())
+               return true;
+       if (!CVS::find_file(fn).empty())
+               return true;
        return false;
 }
 
@@ -78,14 +83,14 @@ void LyXVC::registrer()
        // so... we use RCS as default, later this should perhaps be
        // a lyxrc option.
        if (!vcs) {
-               vcs = new RCS(owner_->getFileName());
+               vcs = new RCS(owner_->fileName());
                vcs->owner(owner_);
        }
        
        // If the document is changed, we might want to save it
        if (!vcs->owner()->isLyxClean() && 
            AskQuestion(_("Changes in document:"),
-                       MakeDisplayPath(vcs->owner()->getFileName(),50),
+                       MakeDisplayPath(vcs->owner()->fileName(), 50),
                        _("Save document and proceed?"))) {
                vcs->owner()->getUser()->owner()
                        ->getLyXFunc()->Dispatch(LFUN_MENUWRITE);
@@ -98,15 +103,18 @@ void LyXVC::registrer()
        }
 
        lyxerr[Debug::LYXVC] << "LyXVC: registrer" << endl;
-       string tmp = askForText(_("LyX VC: Initial description"),
-                                _("(no initial description)"));
-       if (tmp.empty()) {
+       pair<bool, string> tmp =
+               askForText(_("LyX VC: Initial description"),
+                          _("(no initial description)"));
+       if (!tmp.first || tmp.second.empty()) {
+               // should we insist on checking tmp.second.empty()?
                lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl;
-               WriteAlert(_("Info"), _("This document has NOT been registered."));
+               WriteAlert(_("Info"),
+                          _("This document has NOT been registered."));
                return;
        }
        
-       vcs->registrer(tmp);
+       vcs->registrer(tmp.second);
 }
 
 
@@ -115,7 +123,7 @@ void LyXVC::checkIn()
        // If the document is changed, we might want to save it
        if (!vcs->owner()->isLyxClean() && 
            AskQuestion(_("Changes in document:"),
-                       MakeDisplayPath(vcs->owner()->getFileName(),50),
+                       MakeDisplayPath(vcs->owner()->fileName(), 50),
                        _("Save document and proceed?"))) {
                vcs->owner()->getUser()->owner()
                        ->getLyXFunc()->Dispatch(LFUN_MENUWRITE);
@@ -128,11 +136,15 @@ void LyXVC::checkIn()
        }
 
        lyxerr[Debug::LYXVC] << "LyXVC: checkIn" << endl;
-       string tmp = askForText(_("LyX VC: Log Message"));
-       if (tmp.empty()) tmp = "(no log msg)";
-
-       vcs->checkIn(tmp);
-       
+       pair<bool, string> tmp = askForText(_("LyX VC: Log Message"));
+       if (tmp.first) {
+               if (tmp.second.empty()) {
+                       tmp.second = _("(no log message)");
+               }
+               vcs->checkIn(tmp.second);
+       } else {
+               lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl;
+       }
 }
 
 
@@ -141,7 +153,7 @@ void LyXVC::checkOut()
        lyxerr[Debug::LYXVC] << "LyXVC: checkOut" << endl;
        if (!vcs->owner()->isLyxClean() 
            && !AskQuestion(_("Changes in document:"),
-                          MakeDisplayPath(vcs->owner()->getFileName(),50),
+                          MakeDisplayPath(vcs->owner()->fileName(), 50),
                           _("Ignore changes and proceed with check out?"))) {
                return;
        }
@@ -174,7 +186,7 @@ void LyXVC::undoLast()
 
 void LyXVC::toggleReadOnly()
 {
-       switch (vcs->stat()) {
+       switch (vcs->status()) {
        case VCS::UNLOCKED:
                lyxerr[Debug::LYXVC] << "LyXVC: toggle to locked" << endl;
                checkOut();
@@ -251,11 +263,11 @@ void LyXVC::viewLog(string const & fil)
                                    _("Close"));
                fl_set_object_lsize(obj, FL_NORMAL_SIZE);
                fl_set_object_callback(obj, C_LyXVC_logClose, 0);
-               obj = fl_add_button(FL_NORMAL_BUTTON,370,340,90,30,
+               obj = fl_add_button(FL_NORMAL_BUTTON, 370, 340, 90, 30,
                                    idex(_("Update|#Uu")));
-               fl_set_button_shortcut(obj,scex(_("Update|#Uu")),1);
-               fl_set_object_lsize(obj,FL_NORMAL_SIZE);
-               fl_set_object_callback(obj, C_LyXVC_logUpdate,0);
+               fl_set_button_shortcut(obj, scex(_("Update|#Uu")), 1);
+               fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+               fl_set_object_callback(obj, C_LyXVC_logUpdate, 0);
                fl_end_form();
                fl_set_form_atclose(browser->LaTeXLog, CancelCloseBoxCB, 0);
        }
@@ -268,7 +280,7 @@ void LyXVC::viewLog(string const & fil)
                fl_raise_form(browser->LaTeXLog);
        } else {
                fl_show_form(browser->LaTeXLog,
-                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("VC History"));
                if (ow < 0) {
                        ow = browser->LaTeXLog->w;
@@ -281,8 +293,8 @@ void LyXVC::viewLog(string const & fil)
 
 void LyXVC::showLog()
 {
-       string tmpf = tmpnam(0);
+       string tmpf = lyx::tempName();
        vcs->getLog(tmpf);
        viewLog(tmpf);
-       unlink(tmpf.c_str());
+       lyx::unlink(tmpf);
 }