X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyx_cb.C;h=a31535504570b11336175ca9f51cdcb5366cd4f2;hb=0c978e6a3fb133c97d95e87715add6bae26f7837;hp=7e9cbb003a92697a8f314c7341ee043e04c41915;hpb=bd659b25fb6e2df5d02273ee1ce4699aa5723e2e;p=lyx.git diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 7e9cbb003a..a315355045 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -17,10 +17,10 @@ #include FORMS_H_LOCATION #include "lyx.h" #include "layout_forms.h" -#include "form1.h" +//#include "form1.h" #include "lyx_main.h" #include "lyx_cb.h" -#include "insets/insetref.h" +//#include "insets/insetref.h" #include "insets/insetlabel.h" #include "insets/figinset.h" #include "lyxfunc.h" @@ -30,18 +30,19 @@ #include "filedlg.h" #include "lyx_gui_misc.h" #include "LyXView.h" -#include "BufferView.h" +//#include "BufferView.h" #include "lastfiles.h" #include "bufferview_funcs.h" #include "support/FileInfo.h" #include "support/syscall.h" #include "support/filetools.h" #include "support/path.h" -#include "lyxserver.h" +//#include "support/lyxlib.h" +//#include "lyxserver.h" #include "lyxrc.h" #include "lyxtext.h" -#include "CutAndPaste.h" -#include "exporter.h" +//#include "CutAndPaste.h" +//#include "exporter.h" using std::ifstream; using std::copy; @@ -68,10 +69,13 @@ extern BufferView * current_view; // called too many times in this file... extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */ +#if 0 extern bool send_fax(string const & fname, string const & sendcmd); +#endif + extern void MenuSendto(); -extern LyXServer * lyxserver; +//extern LyXServer * lyxserver; // this should be static, but I need it in buffer.C bool quitting; // flag, that we are quitting the program @@ -159,13 +163,11 @@ void ShowMessage(Buffer const * buf, string const & msg2, string const & msg3, int delay) { - if (lyxrc.use_gui) { + if (lyxrc.use_gui) buf->getUser()->owner()->getMiniBuffer()->Set(msg1, msg2, msg3, delay); - } else { - // can somebody think of something more clever? cerr? - cout << msg1 << msg2 << msg3 << endl; - } + else + lyxerr << msg1 << msg2 << msg3 << endl; } @@ -180,7 +182,7 @@ void ShowMessage(Buffer const * buf, // should be moved to lyxfunc.C bool MenuWrite(Buffer * buffer) { - XFlush(fl_display); + XFlush(fl_get_display()); if (!buffer->save()) { string fname = buffer->fileName(); string s = MakeAbsPath(fname); @@ -216,29 +218,23 @@ bool MenuWriteAs(Buffer * buffer) if (!IsLyXFilename(fname)) fname += ".lyx"; - if (buffer->isUnnamed()) { - fname = fileDlg.Select(_("Enter Filename to Save Document as"), - "", - "*.lyx", - ""); - } else { - fname = fileDlg.Select(_("Enter Filename to Save Document as"), - OnlyPath(fname), - "*.lyx", - OnlyFilename(fname)); - } + fname = fileDlg.Select(_("Enter Filename to Save Document as"), + OnlyPath(fname), + "*.lyx", + OnlyFilename(fname)); + AllowInput(current_view); - if (fname.empty()) { + if (fname.empty()) return false; - } + // Make sure the absolute filename ends with appropriate suffix string s = MakeAbsPath(fname); if (!IsLyXFilename(s)) s += ".lyx"; // Same name as we have already? - if (s == oldname) { + if (!buffer->isUnnamed() && s == oldname) { if (!AskQuestion(_("Same name as document already has:"), MakeDisplayPath(s, 50), _("Save anyway?"))) @@ -246,7 +242,7 @@ bool MenuWriteAs(Buffer * buffer) // Falls through to name change and save } // No, but do we have another file with this name open? - else if (bufferlist.exists(s)) { + else if (!buffer->isUnnamed() && bufferlist.exists(s)) { if (AskQuestion(_("Another document with same name open!"), MakeDisplayPath(s, 50), _("Replace with current document?"))) @@ -254,7 +250,7 @@ bool MenuWriteAs(Buffer * buffer) bufferlist.close(bufferlist.getBuffer(s)); // Ok, change the name of the buffer, but don't save! - buffer->fileName(s); + buffer->setFileName(s); buffer->markDirty(); ShowMessage(buffer, _("Document renamed to '"), @@ -271,7 +267,7 @@ bool MenuWriteAs(Buffer * buffer) } // Ok, change the name of the buffer - buffer->fileName(s); + buffer->setFileName(s); buffer->markDirty(); bool unnamed = buffer->isUnnamed(); buffer->setUnnamed(false); @@ -280,7 +276,7 @@ bool MenuWriteAs(Buffer * buffer) // of the document. // Hope this is fixed this way! (Jug) if (!MenuWrite(buffer)) { - buffer->fileName(oldname); + buffer->setFileName(oldname); buffer->setUnnamed(unnamed); ShowMessage(buffer, _("Document could not be saved!"), _("Holding the old name."), MakeDisplayPath(oldname)); @@ -322,7 +318,7 @@ int MenuRunChktex(Buffer * buffer) return ret; } - +#if 0 void MenuFax(Buffer * buffer) { // Generate postscript file @@ -345,6 +341,7 @@ void MenuFax(Buffer * buffer) } else send_fax(ps, lyxrc.fax_command); } +#endif void QuitLyX() @@ -396,8 +393,6 @@ void AutoSave(BufferView * bv) // tmp_ret will be located (usually) in /tmp // will that be a problem? - string tmp_ret = tmpnam(0); - pid_t pid = fork(); // If you want to debug the autosave // you should set pid to -1, and comment out the // fork. @@ -406,6 +401,8 @@ void AutoSave(BufferView * bv) // to fork. But we will do the save // anyway. bool failed = false; + + string tmp_ret = lyx::tempName(); if (!tmp_ret.empty()) { bv->buffer()->writeFile(tmp_ret, 1); // assume successful write of tmp_ret @@ -571,7 +568,7 @@ void MenuLayoutCharacter() fl_raise_form(fd_form_character->form_character); } else { fl_show_form(fd_form_character->form_character, - FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER, + FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, _("Character Style")); if (ow < 0) { ow = fd_form_character->form_character->w; @@ -623,7 +620,7 @@ void MenuLayoutPreamble() } else { fl_show_form(fd_form_preamble->form_preamble, FL_PLACE_MOUSE | FL_FREE_SIZE, - FL_FULLBORDER, + FL_TRANSIENT, _("LaTeX Preamble")); if (ow < 0) { ow = fd_form_preamble->form_preamble->w; @@ -655,7 +652,7 @@ LyXFont const UserFreeFont(BufferParams const & params) LyXFont font(LyXFont::ALL_IGNORE); int pos = fl_get_choice(fd_form_character->choice_family); - switch(pos) { + switch (pos) { case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break; case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break; case 3: font.setFamily(LyXFont::SANS_FAMILY); break; @@ -664,7 +661,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_series); - switch(pos) { + switch (pos) { case 1: font.setSeries(LyXFont::IGNORE_SERIES); break; case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break; case 3: font.setSeries(LyXFont::BOLD_SERIES); break; @@ -672,7 +669,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_shape); - switch(pos) { + switch (pos) { case 1: font.setShape(LyXFont::IGNORE_SHAPE); break; case 2: font.setShape(LyXFont::UP_SHAPE); break; case 3: font.setShape(LyXFont::ITALIC_SHAPE); break; @@ -682,7 +679,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_size); - switch(pos) { + switch (pos) { case 1: font.setSize(LyXFont::IGNORE_SIZE); break; case 2: font.setSize(LyXFont::SIZE_TINY); break; case 3: font.setSize(LyXFont::SIZE_SCRIPT); break; @@ -700,7 +697,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_bar); - switch(pos) { + switch (pos) { case 1: font.setEmph(LyXFont::IGNORE); font.setUnderbar(LyXFont::IGNORE); font.setNoun(LyXFont::IGNORE); @@ -718,7 +715,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_color); - switch(pos) { + switch (pos) { case 1: font.setColor(LColor::ignore); break; case 2: font.setColor(LColor::none); break; case 3: font.setColor(LColor::black); break; @@ -732,7 +729,7 @@ LyXFont const UserFreeFont(BufferParams const & params) case 11: font.setColor(LColor::inherit); break; } - int choice = combo_language2->get(); + int const choice = combo_language2->get(); if (choice == 1) font.setLanguage(ignore_language); else if (choice == 2) @@ -748,7 +745,9 @@ LyXFont const UserFreeFont(BufferParams const & params) extern "C" void TimerCB(FL_OBJECT *, long) { // only if the form still exists - if (lyxrc.show_banner && fd_form_title->form_title != 0) { + if (lyxrc.show_banner + && fd_form_title + && fd_form_title->form_title) { if (fd_form_title->form_title->visible) { fl_hide_form(fd_form_title->form_title); } @@ -817,7 +816,7 @@ void Figure() fl_raise_form(fd_form_figure->form_figure); } else { fl_show_form(fd_form_figure->form_figure, - FL_PLACE_MOUSE, FL_FULLBORDER, + FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, _("Insert Figure")); } } @@ -831,7 +830,7 @@ void FigureApplyCB(FL_OBJECT *, long) return; Buffer * buffer = current_view->buffer(); - if(buffer->isReadonly()) // paranoia + if (buffer->isReadonly()) // paranoia return; current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));