9 #include FORMS_H_LOCATION
11 #include "vc-backend.h"
13 #include "lyx_gui_misc.h"
16 #include "support/filetools.h"
32 if (browser->LaTeXLog->visible)
33 fl_hide_form(browser->LaTeXLog);
34 fl_free_form(browser->LaTeXLog);
42 bool LyXVC::file_found_hook(string const & fn)
45 // Check if file is under RCS
46 if (!(found_file = RCS::find_file(fn)).empty()) {
47 vcs = new RCS(found_file);
51 // Check if file is under CVS
52 if (!(found_file = CVS::find_file(fn)).empty()) {
53 vcs = new CVS(found_file, fn);
57 // file is not under any VCS.
62 bool LyXVC::file_not_found_hook(string const &)
64 // file is not under any VCS.
69 void LyXVC::buffer(Buffer * buf)
75 void LyXVC::registrer()
77 // it is very likely here that the vcs is not created yet...
78 // so... we use RCS as default, later this should perhaps be
81 vcs = new RCS(owner_->getFileName());
85 // If the document is changed, we might want to save it
86 if (!vcs->owner()->isLyxClean() &&
87 AskQuestion(_("Changes in document:"),
88 MakeDisplayPath(vcs->owner()->getFileName(),50),
89 _("Save document and proceed?"))) {
90 vcs->owner()->getUser()->owner()
91 ->getLyXFunc()->Dispatch(LFUN_MENUWRITE);
94 // Maybe the save fails, or we answered "no". In both cases,
95 // the document will be dirty, and we abort.
96 if (!vcs->owner()->isLyxClean()) {
100 lyxerr[Debug::LYXVC] << "LyXVC: registrer" << endl;
101 string tmp = askForText(_("LyX VC: Initial description"),
102 _("(no initial description)"));
104 lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl;
105 WriteAlert(_("Info"), _("This document has NOT been registered."));
113 void LyXVC::checkIn()
115 // If the document is changed, we might want to save it
116 if (!vcs->owner()->isLyxClean() &&
117 AskQuestion(_("Changes in document:"),
118 MakeDisplayPath(vcs->owner()->getFileName(),50),
119 _("Save document and proceed?"))) {
120 vcs->owner()->getUser()->owner()
121 ->getLyXFunc()->Dispatch(LFUN_MENUWRITE);
124 // Maybe the save fails, or we answered "no". In both cases,
125 // the document will be dirty, and we abort.
126 if (!vcs->owner()->isLyxClean()) {
130 lyxerr[Debug::LYXVC] << "LyXVC: checkIn" << endl;
131 string tmp = askForText(_("LyX VC: Log Message"));
132 if (tmp.empty()) tmp = "(no log msg)";
139 void LyXVC::checkOut()
141 lyxerr[Debug::LYXVC] << "LyXVC: checkOut" << endl;
142 if (!vcs->owner()->isLyxClean()
143 && !AskQuestion(_("Changes in document:"),
144 MakeDisplayPath(vcs->owner()->getFileName(),50),
145 _("Ignore changes and proceed with check out?"))) {
156 lyxerr[Debug::LYXVC] << "LyXVC: revert" << endl;
157 // Here we should check if the buffer is dirty. And if it is
158 // we should warn the user that reverting will discard all
159 // changes made since the last check in.
160 if (AskQuestion(_("When you revert, you will loose all changes made"),
161 _("to the document since the last check in."),
162 _("Do you still want to do it?"))) {
169 void LyXVC::undoLast()
175 void LyXVC::toggleReadOnly()
177 switch (vcs->stat()) {
179 lyxerr[Debug::LYXVC] << "LyXVC: toggle to locked" << endl;
183 lyxerr[Debug::LYXVC] << "LyXVC: toggle to unlocked" << endl;
192 if (vcs) return true;
197 string const & LyXVC::version() const
199 return vcs->version();
203 string const & LyXVC::locker() const
205 return vcs->locker();
209 // This is a hack anyway so I'll put it here in the mean time.
210 void LyXVC::logClose(FL_OBJECT * obj, long)
212 LyXVC * This = static_cast<LyXVC*>(obj->form->u_vdata);
213 fl_hide_form(This->browser->LaTeXLog);
217 // and, hack over hack, here is a C wrapper :)
218 extern "C" void C_LyXVC_logClose(FL_OBJECT * ob, long data)
220 LyXVC::logClose(ob, data);
224 void LyXVC::logUpdate(FL_OBJECT * obj, long)
226 LyXVC * This = static_cast<LyXVC*>(obj->form->u_vdata);
230 extern "C" void C_LyXVC_logUpdate(FL_OBJECT *ob, long data)
232 LyXVC::logUpdate(ob, data);
236 void LyXVC::viewLog(string const & fil)
238 static int ow = -1, oh;
242 browser = (FD_LaTeXLog *) fl_calloc(1, sizeof(*browser));
244 browser->LaTeXLog = fl_bgn_form(FL_NO_BOX, 470, 380);
245 browser->LaTeXLog->u_vdata = this;
246 obj = fl_add_box(FL_UP_BOX, 0, 0, 470, 380, "");
247 browser->browser_latexlog = fl_add_browser(FL_NORMAL_BROWSER,
250 obj = fl_add_button(FL_RETURN_BUTTON, 270, 340, 90, 30,
252 fl_set_object_lsize(obj, FL_NORMAL_SIZE);
253 fl_set_object_callback(obj, C_LyXVC_logClose, 0);
254 obj = fl_add_button(FL_NORMAL_BUTTON,370,340,90,30,
255 idex(_("Update|#Uu")));
256 fl_set_button_shortcut(obj,scex(_("Update|#Uu")),1);
257 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
258 fl_set_object_callback(obj, C_LyXVC_logUpdate,0);
260 fl_set_form_atclose(browser->LaTeXLog, CancelCloseBoxCB, 0);
263 if (!fl_load_browser(browser->browser_latexlog, fil.c_str()))
264 fl_add_browser_line(browser->browser_latexlog,
265 _("No VC History!"));
267 if (browser->LaTeXLog->visible) {
268 fl_raise_form(browser->LaTeXLog);
270 fl_show_form(browser->LaTeXLog,
271 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
274 ow = browser->LaTeXLog->w;
275 oh = browser->LaTeXLog->h;
277 fl_set_form_minsize(browser->LaTeXLog, ow, oh);
282 void LyXVC::showLog()
284 string tmpf = tmpnam(0);
287 unlink(tmpf.c_str());