1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich,
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
17 #include FORMS_H_LOCATION
19 #include "layout_forms.h"
23 #include "insets/insetref.h"
24 #include "insets/insetlabel.h"
25 #include "insets/figinset.h"
27 #include "minibuffer.h"
29 #include "bufferlist.h"
31 #include "lyx_gui_misc.h"
33 #include "BufferView.h"
34 #include "lastfiles.h"
35 #include "bufferview_funcs.h"
36 #include "support/FileInfo.h"
37 #include "support/syscall.h"
38 #include "support/filetools.h"
39 #include "support/path.h"
40 #include "lyxserver.h"
43 #include "CutAndPaste.h"
48 using std::back_inserter;
52 using std::istream_iterator;
58 extern Combox * combo_language;
59 extern Combox * combo_language2;
60 extern BufferList bufferlist;
61 extern void show_symbols_form();
62 extern FD_form_title * fd_form_title;
63 extern FD_form_character * fd_form_character;
64 extern FD_form_preamble * fd_form_preamble;
65 extern FD_form_figure * fd_form_figure;
67 extern BufferView * current_view; // called too many times in this file...
69 extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */
72 extern bool send_fax(string const & fname, string const & sendcmd);
75 extern void MenuSendto();
77 extern LyXServer * lyxserver;
79 // this should be static, but I need it in buffer.C
80 bool quitting; // flag, that we are quitting the program
81 extern bool finished; // all cleanup done just let it run through now.
83 char ascii_type; /* for selection notify callbacks */
85 bool scrolling = false;
87 // This is used to make the dreaded font toggle problem hopefully go
88 // away. Definitely not the best solution, but I think it sorta works.
89 bool toggleall = true;
92 This is the inset locking stuff needed for mathed --------------------
94 an inset can simple call LockInset in it's edit call and *ONLY* in it's
96 Inset::Edit() can only be called by the main lyx module.
98 Then the inset may modify the menu's and/or iconbars.
100 Unlocking is either done by LyX or the inset itself with a UnlockInset-call
102 During the lock, all button and keyboard events will be modified
103 and send to the inset through the following inset-features. Note that
104 Inset::InsetUnlock will be called from inside UnlockInset. It is meant
105 to contain the code for restoring the menus and things like this.
108 virtual void InsetButtonPress(int x, int y, int button);
109 virtual void InsetButtonRelease(int x, int y, int button);
110 virtual void InsetKeyPress(XKeyEvent *ev);
111 virtual void InsetMotionNotify(int x, int y, int state);
112 virtual void InsetUnlock();
114 If a inset wishes any redraw and/or update it just has to call
116 It's is completly irrelevant, where the inset is. UpdateInset will
117 find it in any paragraph in any buffer.
118 Of course the_locking_inset and the insets in the current paragraph/buffer
119 are checked first, so no performance problem should occur.
121 Hope that's ok for the beginning, Alejandro,
122 sorry that I needed so much time,
127 //void UpdateInset(BufferView * bv, Inset * inset, bool mark_dirty = true);
129 /* these functions return 1 if an error occured,
131 // Now they work only for updatable insets. [Alejandro 080596]
132 //int LockInset(UpdatableInset * inset);
133 void ToggleLockedInsetCursor(int x, int y, int asc, int desc);
134 //void FitLockedInsetCursor(long x, long y, int asc, int desc);
135 //int UnlockInset(UpdatableInset * inset);
136 //void LockedInsetStoreUndo(Undo::undo_kind kind);
138 /* this is for asyncron updating. UpdateInsetUpdateList will be called
139 automatically from LyX. Just insert the Inset into the Updatelist */
140 //void UpdateInsetUpdateList();
141 //void PutInsetIntoInsetUpdateList(Inset * inset);
143 //InsetUpdateStruct * InsetUpdateList = 0;
147 -----------------------------------------------------------------------
150 /* some function prototypes */
152 int RunLinuxDoc(BufferView *, int, string const &);
153 int RunDocBook(int, string const &);
154 bool MenuWrite(Buffer * buf);
155 bool MenuWriteAs(Buffer * buffer);
156 void MenuReload(Buffer * buf);
157 void MenuLayoutSave();
160 void ShowMessage(Buffer const * buf,
163 string const & msg3, int delay)
166 buf->getUser()->owner()->getMiniBuffer()->Set(msg1, msg2,
169 lyxerr << msg1 << msg2 << msg3 << endl;
181 // should be moved to lyxfunc.C
182 bool MenuWrite(Buffer * buffer)
184 XFlush(fl_get_display());
185 if (!buffer->save()) {
186 string fname = buffer->fileName();
187 string s = MakeAbsPath(fname);
188 if (AskQuestion(_("Save failed. Rename and try again?"),
189 MakeDisplayPath(s, 50),
190 _("(If not, document is not saved.)"))) {
191 return MenuWriteAs(buffer);
195 lastfiles->newFile(buffer->fileName());
201 // should be moved to BufferView.C
202 // Half of this func should be in LyXView, the rest in BufferView.
203 bool MenuWriteAs(Buffer * buffer)
205 // Why do we require BufferView::text to be able to write a
206 // document? I see no point in that. (Lgb)
207 //if (!bv->text) return;
209 string fname = buffer->fileName();
210 string oldname = fname;
213 ProhibitInput(current_view);
214 fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
215 fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
217 if (!IsLyXFilename(fname))
220 if (buffer->isUnnamed()) {
221 fname = fileDlg.Select(_("Enter Filename to Save Document as"),
226 fname = fileDlg.Select(_("Enter Filename to Save Document as"),
229 OnlyFilename(fname));
231 AllowInput(current_view);
236 // Make sure the absolute filename ends with appropriate suffix
237 string s = MakeAbsPath(fname);
238 if (!IsLyXFilename(s))
241 // Same name as we have already?
243 if (!AskQuestion(_("Same name as document already has:"),
244 MakeDisplayPath(s, 50),
247 // Falls through to name change and save
249 // No, but do we have another file with this name open?
250 else if (bufferlist.exists(s)) {
251 if (AskQuestion(_("Another document with same name open!"),
252 MakeDisplayPath(s, 50),
253 _("Replace with current document?")))
255 bufferlist.close(bufferlist.getBuffer(s));
257 // Ok, change the name of the buffer, but don't save!
258 buffer->setFileName(s);
261 ShowMessage(buffer, _("Document renamed to '"),
262 MakeDisplayPath(s), _("', but not saved..."));
265 } // Check whether the file exists
268 if (myfile.isOK() && !AskQuestion(_("Document already exists:"),
269 MakeDisplayPath(s, 50),
274 // Ok, change the name of the buffer
275 buffer->setFileName(s);
277 bool unnamed = buffer->isUnnamed();
278 buffer->setUnnamed(false);
280 // Small bug: If the save fails, we have irreversible changed the name
282 // Hope this is fixed this way! (Jug)
283 if (!MenuWrite(buffer)) {
284 buffer->setFileName(oldname);
285 buffer->setUnnamed(unnamed);
286 ShowMessage(buffer, _("Document could not be saved!"),
287 _("Holding the old name."), MakeDisplayPath(oldname));
290 // now remove the oldname autosave file if existant!
291 removeAutosaveFile(oldname);
296 int MenuRunChktex(Buffer * buffer)
300 if (buffer->isSGML()) {
301 WriteAlert(_("Chktex does not work with SGML derived documents."));
304 ret = buffer->runChktex();
310 s = _("No warnings found.");
311 } else if (ret == 1) {
312 s = _("One warning found.");
313 t = _("Use 'Edit->Go to Error' to find it.");
316 s += _(" warnings found.");
317 t = _("Use 'Edit->Go to Error' to find them.");
319 WriteAlert(_("Chktex run successfully"), s, t);
321 WriteAlert(_("Error!"), _("It seems chktex does not work."));
327 void MenuFax(Buffer * buffer)
329 // Generate postscript file
330 if (!Exporter::Export(buffer, "ps", true))
334 string const ps = OnlyFilename(ChangeExtension(buffer->fileName(),
337 string path = OnlyPath (buffer->fileName());
338 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
339 path = buffer->tmppath;
342 if (!lyxrc.fax_program.empty()) {
343 string help2 = subst(lyxrc.fax_program, "$$FName", ps);
345 Systemcalls one(Systemcalls::System, help2);
347 send_fax(ps, lyxrc.fax_command);
354 lyxerr.debug() << "Running QuitLyX." << endl;
356 if (!bufferlist.QwriteAll())
359 lastfiles->writeFile(lyxrc.lastfiles);
361 // Set a flag that we do quitting from the program,
362 // so no refreshes are necessary.
365 // close buffers first
366 bufferlist.closeAll();
368 // do any other cleanup procedures now
369 lyxerr.debug() << "Deleting tmp dir " << system_tempdir << endl;
371 DestroyLyXTmpDir(system_tempdir);
378 void AutoSave(BufferView * bv)
379 // should probably be moved into BufferList (Lgb)
380 // Perfect target for a thread...
382 if (!bv->available())
385 if (bv->buffer()->isBakClean() || bv->buffer()->isReadonly()) {
386 // We don't save now, but we'll try again later
387 bv->owner()->resetAutosaveTimer();
391 bv->owner()->getMiniBuffer()->Set(_("Autosaving current document..."));
393 // create autosave filename
394 string fname = OnlyPath(bv->buffer()->fileName());
396 fname += OnlyFilename(bv->buffer()->fileName());
399 // tmp_ret will be located (usually) in /tmp
400 // will that be a problem?
401 string tmp_ret = tmpnam(0);
403 pid_t pid = fork(); // If you want to debug the autosave
404 // you should set pid to -1, and comment out the
406 if (pid == 0 || pid == -1) {
407 // pid = -1 signifies that lyx was unable
408 // to fork. But we will do the save
411 if (!tmp_ret.empty()) {
412 bv->buffer()->writeFile(tmp_ret, 1);
413 // assume successful write of tmp_ret
414 if (lyx::rename(tmp_ret, fname)) {
416 // most likely couldn't move between filesystems
417 // unless write of tmp_ret failed
418 // so remove tmp file (if it exists)
419 lyx::unlink(tmp_ret);
426 // failed to write/rename tmp_ret so try writing direct
427 if (!bv->buffer()->writeFile(fname, 1)) {
428 // It is dangerous to do this in the child,
429 // but safe in the parent, so...
431 bv->owner()->getMiniBuffer()->Set(_("Autosave Failed!"));
434 if (pid == 0) { // we are the child so...
439 bv->buffer()->markBakClean();
440 bv->owner()->resetAutosaveTimer();
445 // Copyright CHT Software Service GmbH
448 // create new file with template
451 Buffer * NewLyxFile(string const & filename)
453 // Split argument by :
455 string tmpname = split(filename, name, ':');
456 #ifdef __EMX__ // Fix me! lyx_cb.C may not be low level enough to allow this.
457 if (name.length() == 1
458 && isalpha(static_cast<unsigned char>(name[0]))
459 && (prefixIs(tmpname, "/") || prefixIs(tmpname, "\\"))) {
461 name += token(tmpname, ':', 0);
462 tmpname = split(tmpname, ':');
465 lyxerr.debug() << "Arg is " << filename
466 << "\nName is " << name
467 << "\nTemplate is " << tmpname << endl;
469 // find a free buffer
470 Buffer * tmpbuf = bufferlist.newFile(name, tmpname);
472 lastfiles->newFile(tmpbuf->fileName());
477 // Insert ascii file (if filename is empty, prompt for one)
478 void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
483 if (!bv->available()) return;
487 fname = fileDlg.Select(_("File to Insert"),
488 bv->owner()->buffer()->filepath,
491 if (fname.empty()) return;
496 if (!fi.readable()) {
497 WriteFSAlert(_("Error! Specified file is unreadable: "),
498 MakeDisplayPath(fname, 50));
502 ifstream ifs(fname.c_str());
504 WriteFSAlert(_("Error! Cannot open specified file: "),
505 MakeDisplayPath(fname, 50));
509 ifs.unsetf(ios::skipws);
510 istream_iterator<char> ii(ifs);
511 istream_iterator<char> end;
512 #if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
513 // We use this until the compilers get better...
515 copy(ii, end, back_inserter(tmp));
516 string tmpstr(tmp.begin(), tmp.end());
518 // This is what we want to use and what we will use once the
519 // compilers get good enough.
520 //string tmpstr(ii, end); // yet a reason for using std::string
521 // alternate approach to get the file into a string:
523 copy(ii, end, back_inserter(tmpstr));
528 // clear the selection
531 bv->text->InsertStringA(bv, tmpstr);
533 bv->text->InsertStringB(bv, tmpstr);
534 bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
538 void MenuInsertLabel(string const & arg)
541 ProhibitInput(current_view);
544 result = askForText(_("Enter new label to insert:"));
546 label = frontStrip(strip(result.second));
549 if (!label.empty()) {
550 InsetCommandParams p( "label", label );
551 InsetLabel * inset = new InsetLabel( p );
552 current_view->insertInset( inset );
554 AllowInput(current_view);
558 // This is _only_ used in Toolbar_pimpl.C, move it there and get rid of
559 // current_view. (Lgb)
560 void LayoutsCB(int sel, void *, Combox *)
562 string tmp = tostr(sel);
563 current_view->owner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO,
568 void MenuLayoutCharacter()
570 static int ow = -1, oh;
572 if (fd_form_character->form_character->visible) {
573 fl_raise_form(fd_form_character->form_character);
575 fl_show_form(fd_form_character->form_character,
576 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
577 _("Character Style"));
579 ow = fd_form_character->form_character->w;
580 oh = fd_form_character->form_character->h;
582 fl_set_form_minsize(fd_form_character->form_character, ow, oh);
587 bool UpdateLayoutPreamble()
590 if (!current_view->available())
594 fl_set_input(fd_form_preamble->input_preamble,
595 current_view->buffer()->params.preamble.c_str());
597 if (current_view->buffer()->isReadonly()) {
598 fl_deactivate_object(fd_form_preamble->input_preamble);
599 fl_deactivate_object(fd_form_preamble->button_ok);
600 fl_deactivate_object(fd_form_preamble->button_apply);
601 fl_set_object_lcol(fd_form_preamble->button_ok, FL_INACTIVE);
602 fl_set_object_lcol(fd_form_preamble->button_apply, FL_INACTIVE);
605 fl_activate_object(fd_form_preamble->input_preamble);
606 fl_activate_object(fd_form_preamble->button_ok);
607 fl_activate_object(fd_form_preamble->button_apply);
608 fl_set_object_lcol(fd_form_preamble->button_ok, FL_BLACK);
609 fl_set_object_lcol(fd_form_preamble->button_apply, FL_BLACK);
611 } else if (fd_form_preamble->form_preamble->visible) {
612 fl_hide_form(fd_form_preamble->form_preamble);
618 void MenuLayoutPreamble()
620 static int ow = -1, oh;
622 if (UpdateLayoutPreamble()) {
623 if (fd_form_preamble->form_preamble->visible) {
624 fl_raise_form(fd_form_preamble->form_preamble);
626 fl_show_form(fd_form_preamble->form_preamble,
627 FL_PLACE_MOUSE | FL_FREE_SIZE,
629 _("LaTeX Preamble"));
631 ow = fd_form_preamble->form_preamble->w;
632 oh = fd_form_preamble->form_preamble->h;
634 fl_set_form_minsize(fd_form_preamble->form_preamble,
641 void MenuLayoutSave()
643 if (!current_view->available())
646 if (AskQuestion(_("Do you want to save the current settings"),
647 _("for Character, Document, Paper and Quotes"),
648 _("as default for new documents?")))
649 current_view->buffer()->saveParamsAsDefaults();
653 // This is both GUI and LyXFont dependent. Don't know where to put it. (Asger)
654 // Well, it's mostly GUI dependent, so I guess it will stay here. (Asger)
655 LyXFont const UserFreeFont(BufferParams const & params)
657 LyXFont font(LyXFont::ALL_IGNORE);
659 int pos = fl_get_choice(fd_form_character->choice_family);
661 case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break;
662 case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break;
663 case 3: font.setFamily(LyXFont::SANS_FAMILY); break;
664 case 4: font.setFamily(LyXFont::TYPEWRITER_FAMILY); break;
665 case 5: font.setFamily(LyXFont::INHERIT_FAMILY); break;
668 pos = fl_get_choice(fd_form_character->choice_series);
670 case 1: font.setSeries(LyXFont::IGNORE_SERIES); break;
671 case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break;
672 case 3: font.setSeries(LyXFont::BOLD_SERIES); break;
673 case 4: font.setSeries(LyXFont::INHERIT_SERIES); break;
676 pos = fl_get_choice(fd_form_character->choice_shape);
678 case 1: font.setShape(LyXFont::IGNORE_SHAPE); break;
679 case 2: font.setShape(LyXFont::UP_SHAPE); break;
680 case 3: font.setShape(LyXFont::ITALIC_SHAPE); break;
681 case 4: font.setShape(LyXFont::SLANTED_SHAPE); break;
682 case 5: font.setShape(LyXFont::SMALLCAPS_SHAPE); break;
683 case 6: font.setShape(LyXFont::INHERIT_SHAPE); break;
686 pos = fl_get_choice(fd_form_character->choice_size);
688 case 1: font.setSize(LyXFont::IGNORE_SIZE); break;
689 case 2: font.setSize(LyXFont::SIZE_TINY); break;
690 case 3: font.setSize(LyXFont::SIZE_SCRIPT); break;
691 case 4: font.setSize(LyXFont::SIZE_FOOTNOTE); break;
692 case 5: font.setSize(LyXFont::SIZE_SMALL); break;
693 case 6: font.setSize(LyXFont::SIZE_NORMAL); break;
694 case 7: font.setSize(LyXFont::SIZE_LARGE); break;
695 case 8: font.setSize(LyXFont::SIZE_LARGER); break;
696 case 9: font.setSize(LyXFont::SIZE_LARGEST); break;
697 case 10: font.setSize(LyXFont::SIZE_HUGE); break;
698 case 11: font.setSize(LyXFont::SIZE_HUGER); break;
699 case 12: font.setSize(LyXFont::INCREASE_SIZE); break;
700 case 13: font.setSize(LyXFont::DECREASE_SIZE); break;
701 case 14: font.setSize(LyXFont::INHERIT_SIZE); break;
704 pos = fl_get_choice(fd_form_character->choice_bar);
706 case 1: font.setEmph(LyXFont::IGNORE);
707 font.setUnderbar(LyXFont::IGNORE);
708 font.setNoun(LyXFont::IGNORE);
709 font.setLatex(LyXFont::IGNORE);
711 case 2: font.setEmph(LyXFont::TOGGLE); break;
712 case 3: font.setUnderbar(LyXFont::TOGGLE); break;
713 case 4: font.setNoun(LyXFont::TOGGLE); break;
714 case 5: font.setLatex(LyXFont::TOGGLE); break;
715 case 6: font.setEmph(LyXFont::INHERIT);
716 font.setUnderbar(LyXFont::INHERIT);
717 font.setNoun(LyXFont::INHERIT);
718 font.setLatex(LyXFont::INHERIT);
722 pos = fl_get_choice(fd_form_character->choice_color);
724 case 1: font.setColor(LColor::ignore); break;
725 case 2: font.setColor(LColor::none); break;
726 case 3: font.setColor(LColor::black); break;
727 case 4: font.setColor(LColor::white); break;
728 case 5: font.setColor(LColor::red); break;
729 case 6: font.setColor(LColor::green); break;
730 case 7: font.setColor(LColor::blue); break;
731 case 8: font.setColor(LColor::cyan); break;
732 case 9: font.setColor(LColor::magenta); break;
733 case 10: font.setColor(LColor::yellow); break;
734 case 11: font.setColor(LColor::inherit); break;
737 int const choice = combo_language2->get();
739 font.setLanguage(ignore_language);
740 else if (choice == 2)
741 font.setLanguage(params.language);
743 font.setLanguage(languages.getLanguage(combo_language2->getline()));
749 /* callbacks for form form_title */
750 extern "C" void TimerCB(FL_OBJECT *, long)
752 // only if the form still exists
753 if (lyxrc.show_banner
755 && fd_form_title->form_title) {
756 if (fd_form_title->form_title->visible) {
757 fl_hide_form(fd_form_title->form_title);
759 fl_free_form(fd_form_title->form_title);
760 fd_form_title->form_title = 0;
765 /* callbacks for form form_character */
767 extern "C" void CharacterApplyCB(FL_OBJECT *, long)
769 // we set toggleall locally here, since it should be true for
770 // all other uses of ToggleAndShow() (JMarc)
771 toggleall = fl_get_button(fd_form_character->check_toggle_all);
772 ToggleAndShow(current_view, UserFreeFont(current_view->buffer()->params));
773 current_view->setState();
778 extern "C" void CharacterCloseCB(FL_OBJECT *, long)
780 fl_hide_form(fd_form_character->form_character);
784 extern "C" void CharacterOKCB(FL_OBJECT *ob, long data)
786 CharacterApplyCB(ob, data);
787 CharacterCloseCB(ob, data);
791 /* callbacks for form form_preamble */
793 extern "C" void PreambleCancelCB(FL_OBJECT *, long)
795 fl_hide_form(fd_form_preamble->form_preamble);
799 extern "C" void PreambleApplyCB(FL_OBJECT *, long)
801 if (!current_view->available())
804 current_view->buffer()->params.preamble =
805 fl_get_input(fd_form_preamble->input_preamble);
806 current_view->buffer()->markDirty();
807 current_view->owner()->getMiniBuffer()->Set(_("LaTeX preamble set"));
811 extern "C" void PreambleOKCB(FL_OBJECT * ob, long data)
813 PreambleApplyCB(ob, data);
814 PreambleCancelCB(ob, data);
820 if (fd_form_figure->form_figure->visible) {
821 fl_raise_form(fd_form_figure->form_figure);
823 fl_show_form(fd_form_figure->form_figure,
824 FL_PLACE_MOUSE, FL_FULLBORDER,
830 /* callbacks for form form_figure */
832 void FigureApplyCB(FL_OBJECT *, long)
834 if (!current_view->available())
837 Buffer * buffer = current_view->buffer();
838 if(buffer->isReadonly()) // paranoia
841 current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
842 if (fl_get_button(fd_form_figure->radio_inline)) {
843 InsetFig * new_inset = new InsetFig(100, 20, *buffer);
844 current_view->insertInset(new_inset);
845 current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
846 new_inset->Edit(current_view, 0, 0, 0);
850 current_view->hideCursor();
851 current_view->update(BufferView::SELECT|BufferView::FITCUR);
852 current_view->beforeChange();
854 current_view->text->SetCursorParUndo(current_view->buffer());
855 current_view->text->FreezeUndo();
857 current_view->text->BreakParagraph(current_view);
858 current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
860 if (current_view->text->cursor.par()->Last()) {
861 current_view->text->CursorLeft(current_view);
863 current_view->text->BreakParagraph(current_view);
864 current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
867 // The standard layout should always be numer 0;
868 current_view->text->SetLayout(current_view, 0);
871 if (current_view->text->cursor.par()->footnoteflag ==
872 LyXParagraph::NO_FOOTNOTE) {
875 SetParagraph(current_view, 0, 0,
877 VSpace (0.3 * buffer->params.spacing.getValue(),
880 buffer->params.spacing.getValue(),
882 LYX_ALIGN_CENTER, string(), 0);
885 current_view->text->SetParagraph(current_view, 0, 0,
887 VSpace(VSpace::NONE),
888 VSpace(VSpace::NONE),
895 current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
897 Inset * new_inset = new InsetFig(100, 100, *buffer);
898 current_view->insertInset(new_inset);
899 new_inset->Edit(current_view, 0, 0, 0);
900 current_view->update(BufferView::SELECT|BufferView::FITCUR);
901 current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
902 current_view->text->UnFreezeUndo();
903 current_view->setState();
907 extern "C" void FigureCancelCB(FL_OBJECT *, long)
909 fl_hide_form(fd_form_figure->form_figure);
913 extern "C" void FigureOKCB(FL_OBJECT * ob, long data)
915 FigureApplyCB(ob, data);
916 FigureCancelCB(ob, data);
920 // This function runs "configure" and then rereads lyx.defaults to
921 // reconfigure the automatic settings.
922 void Reconfigure(BufferView * bv)
924 bv->owner()->getMiniBuffer()->Set(_("Running configure..."));
926 // Run configure in user lyx directory
928 Systemcalls one(Systemcalls::System,
929 AddName(system_lyxdir, "configure"));
931 bv->owner()->getMiniBuffer()->Set(_("Reloading configuration..."));
932 lyxrc.read(LibFileSearch(string(), "lyxrc.defaults"));
933 WriteAlert(_("The system has been reconfigured."),
934 _("You need to restart LyX to make use of any"),
935 _("updated document class specifications."));