From 6a6bb5a017e041e5fe3a1fbf7053a2d0d4357ae3 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Mon, 12 Mar 2001 11:22:26 +0000 Subject: [PATCH] John's FormExternal patch, Edwin's Qt2 patch and Baruch's gnome patch. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1739 a592a061-630c-0410-9148-cb99ea01b6c8 --- forms/ChangeLog | 4 + forms/lyx.fd | 206 +----------- po/POTFILES.in | 48 +-- src/ChangeLog | 5 + src/frontends/ChangeLog | 4 + src/frontends/Dialogs.h | 3 + src/frontends/gnome/ChangeLog | 4 + src/frontends/gnome/Dialogs.C | 4 +- src/frontends/gnome/Makefile.am | 5 + src/frontends/gnome/Menubar_pimpl.C | 4 +- src/frontends/qt2/ChangeLog | 10 + src/frontends/qt2/Dialogs.C | 8 +- src/frontends/qt2/FormParagraph.C | 41 +-- src/frontends/qt2/Makefile.am | 10 +- src/frontends/qt2/paragraphdlg.C | 6 +- src/frontends/qt2/paragraphdlg.h | 2 +- src/frontends/qt2/paragraphdlg.ui | 4 +- src/frontends/qt2/paragraphdlgimpl.C | 2 +- src/frontends/xforms/ChangeLog | 11 + src/frontends/xforms/Dialogs.C | 2 + src/frontends/xforms/FormGraphics.C | 5 +- src/frontends/xforms/Makefile.am | 4 + src/frontends/xforms/forms/makefile | 1 + src/insets/ChangeLog | 12 + src/insets/ExternalTemplate.C | 6 + src/insets/ExternalTemplate.h | 5 +- src/insets/insetexternal.C | 474 +++++---------------------- src/insets/insetexternal.h | 128 +++----- src/lyx.C | 59 ---- src/lyx.h | 27 -- 30 files changed, 277 insertions(+), 827 deletions(-) diff --git a/forms/ChangeLog b/forms/ChangeLog index c73dd50cff..a39114a126 100644 --- a/forms/ChangeLog +++ b/forms/ChangeLog @@ -1,3 +1,7 @@ +2001-03-09 John Levon + + * lyx.fd: strip external form + 2001-03-05 Edwin Leuven * form1.fd: search_form deleted diff --git a/forms/lyx.fd b/forms/lyx.fd index 6756b5d736..b3238efc1f 100644 --- a/forms/lyx.fd +++ b/forms/lyx.fd @@ -3,7 +3,7 @@ Magic: 13000 Internal Form Definition File (do not change) -Number of forms: 2 +Number of forms: 1 Unit of measure: FL_COORD_PIXEL =============== FORM =============== @@ -192,209 +192,5 @@ name: callback: argument: -=============== FORM =============== -Name: form_external -Width: 560 -Height: 310 -Number of Objects: 11 - --------------------- -class: FL_BOX -type: UP_BOX -box: 0 0 560 310 -boxtype: FL_UP_BOX -colors: FL_COL1 FL_COL1 -alignment: FL_ALIGN_CENTER -style: FL_NORMAL_STYLE -size: FL_DEFAULT_SIZE -lcol: FL_BLACK -label: -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: -callback: -argument: - --------------------- -class: FL_CHOICE -type: NORMAL_CHOICE -box: 130 10 300 30 -boxtype: FL_FRAME_BOX -colors: FL_COL1 FL_BLACK -alignment: FL_ALIGN_LEFT -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: Template|#t -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NorthWest FL_NorthEast -name: templatechoice -callback: ExternalTemplateCB -argument: 0 - --------------------- -class: FL_INPUT -type: NORMAL_INPUT -box: 130 190 190 30 -boxtype: FL_DOWN_BOX -colors: FL_COL1 FL_MCOL -alignment: FL_ALIGN_LEFT -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: File|#F -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_SouthWest FL_SouthEast -name: filename -callback: -argument: - --------------------- -class: FL_BUTTON -type: NORMAL_BUTTON -box: 330 190 100 30 -boxtype: FL_UP_BOX -colors: FL_COL1 FL_COL1 -alignment: FL_ALIGN_CENTER -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: Browse...|#B -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_SouthEast FL_SouthEast -name: filenamebrowse -callback: ExternalBrowseCB -argument: 0 - --------------------- -class: FL_INPUT -type: NORMAL_INPUT -box: 130 230 300 30 -boxtype: FL_DOWN_BOX -colors: FL_COL1 FL_MCOL -alignment: FL_ALIGN_LEFT -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: Parameters|#P -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_SouthWest FL_SouthEast -name: parameters -callback: -argument: - --------------------- -class: FL_BUTTON -type: NORMAL_BUTTON -box: 435 50 110 30 -boxtype: FL_UP_BOX -colors: FL_COL1 FL_BLACK -alignment: FL_ALIGN_CENTER -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: Edit file|#E -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NorthEast FL_NorthEast -name: edit -callback: ExternalEditCB -argument: 0 - --------------------- -class: FL_BUTTON -type: NORMAL_BUTTON -box: 435 90 110 30 -boxtype: FL_UP_BOX -colors: FL_COL1 FL_BLACK -alignment: FL_ALIGN_CENTER -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: View result|#V -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NorthEast FL_NorthEast -name: view -callback: ExternalViewCB -argument: 0 - --------------------- -class: FL_BUTTON -type: NORMAL_BUTTON -box: 435 130 110 30 -boxtype: FL_UP_BOX -colors: FL_COL1 FL_BLACK -alignment: FL_ALIGN_CENTER -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: Update result|#U -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NorthEast FL_NorthEast -name: update -callback: ExternalUpdateCB -argument: 0 - --------------------- -class: FL_BUTTON -type: RETURN_BUTTON -box: 315 270 110 30 -boxtype: FL_UP_BOX -colors: FL_COL1 FL_BLACK -alignment: FL_ALIGN_CENTER -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: OK -shortcut: ^M -resize: FL_RESIZE_ALL -gravity: FL_SouthEast FL_SouthEast -name: ok -callback: ExternalOKCB -argument: 0 - --------------------- -class: FL_BUTTON -type: NORMAL_BUTTON -box: 435 270 110 30 -boxtype: FL_UP_BOX -colors: FL_COL1 FL_COL1 -alignment: FL_ALIGN_CENTER -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: Cancel|#C^[ -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_SouthEast FL_SouthEast -name: cancel -callback: ExternalCancelCB -argument: 0 - --------------------- -class: FL_BROWSER -type: NORMAL_BROWSER -box: 130 50 300 130 -boxtype: FL_DOWN_BOX -colors: FL_COL1 FL_YELLOW -alignment: FL_ALIGN_TOP -style: FL_NORMAL_STYLE -size: FL_DEFAULT_SIZE -lcol: FL_BLACK -label: -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NorthWest FL_SouthEast -name: helptext -callback: -argument: - ============================== create_the_forms diff --git a/po/POTFILES.in b/po/POTFILES.in index 0c414a861f..6a9e2f179d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -62,6 +62,7 @@ src/frontends/kde/refdlg.C src/frontends/kde/tabcreatedlg.C src/frontends/kde/tocdlg.C src/frontends/kde/urldlg.C +src/frontends/qt2/FileDialog.C src/frontends/qt2/FormCharacter.C src/frontends/qt2/FormCopyright.C src/frontends/qt2/FormParagraph.C @@ -72,54 +73,56 @@ src/frontends/qt2/paragraphdlgimpl.C src/frontends/qt2/tabularcreatedlgimpl.C src/frontends/xforms/FileDialog.C src/frontends/xforms/FormBase.h -src/frontends/xforms/form_bibitem.C src/frontends/xforms/FormBibitem.C -src/frontends/xforms/form_bibtex.C +src/frontends/xforms/form_bibitem.C src/frontends/xforms/FormBibtex.C +src/frontends/xforms/form_bibtex.C src/frontends/xforms/form_browser.C -src/frontends/xforms/form_character.C src/frontends/xforms/FormCharacter.C -src/frontends/xforms/form_citation.C +src/frontends/xforms/form_character.C src/frontends/xforms/FormCitation.C -src/frontends/xforms/form_copyright.C +src/frontends/xforms/form_citation.C src/frontends/xforms/FormCopyright.C -src/frontends/xforms/form_credits.C +src/frontends/xforms/form_copyright.C src/frontends/xforms/FormCredits.C -src/frontends/xforms/form_document.C +src/frontends/xforms/form_credits.C src/frontends/xforms/FormDocument.C -src/frontends/xforms/form_error.C +src/frontends/xforms/form_document.C src/frontends/xforms/FormError.C -src/frontends/xforms/form_filedialog.C +src/frontends/xforms/form_error.C +src/frontends/xforms/FormExternal.C +src/frontends/xforms/form_external.C src/frontends/xforms/FormFiledialog.C -src/frontends/xforms/form_graphics.C +src/frontends/xforms/form_filedialog.C src/frontends/xforms/FormGraphics.C -src/frontends/xforms/form_include.C +src/frontends/xforms/form_graphics.C src/frontends/xforms/FormInclude.C -src/frontends/xforms/form_index.C +src/frontends/xforms/form_include.C src/frontends/xforms/FormIndex.C +src/frontends/xforms/form_index.C src/frontends/xforms/FormInset.h src/frontends/xforms/FormLog.C -src/frontends/xforms/form_paragraph.C src/frontends/xforms/FormParagraph.C -src/frontends/xforms/form_preamble.C +src/frontends/xforms/form_paragraph.C src/frontends/xforms/FormPreamble.C -src/frontends/xforms/form_preferences.C +src/frontends/xforms/form_preamble.C src/frontends/xforms/FormPreferences.C -src/frontends/xforms/form_print.C +src/frontends/xforms/form_preferences.C src/frontends/xforms/FormPrint.C -src/frontends/xforms/form_ref.C +src/frontends/xforms/form_print.C src/frontends/xforms/FormRef.C -src/frontends/xforms/form_search.C +src/frontends/xforms/form_ref.C src/frontends/xforms/FormSearch.C +src/frontends/xforms/form_search.C src/frontends/xforms/FormSplash.C -src/frontends/xforms/form_tabular.C src/frontends/xforms/FormTabular.C -src/frontends/xforms/form_tabular_create.C +src/frontends/xforms/form_tabular.C src/frontends/xforms/FormTabularCreate.C -src/frontends/xforms/form_toc.C +src/frontends/xforms/form_tabular_create.C src/frontends/xforms/FormToc.C -src/frontends/xforms/form_url.C +src/frontends/xforms/form_toc.C src/frontends/xforms/FormUrl.C +src/frontends/xforms/form_url.C src/frontends/xforms/FormVCLog.C src/frontends/xforms/input_validators.C src/frontends/xforms/Menubar_pimpl.C @@ -129,6 +132,7 @@ src/importer.C src/insets/figinset.C src/insets/insetbib.C src/insets/inset.C +src/insets/insetcaption.C src/insets/inseterror.C src/insets/insetert.C src/insets/insetexternal.C diff --git a/src/ChangeLog b/src/ChangeLog index 875ebce4bf..a91ace0bbf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-03-09 John Levon + + * lyx.C: + * lyx.h: strip external form + 2001-03-12 Lars Gullik Bjønnes * buffer.C: add using std::stringstream. diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index b5d61f7184..f7420413f5 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,7 @@ +2001-03-09 John Levon + + * Dialogs.h: add showExternal signal + 2001-02-26 John Levon * Makefile.am diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index 734976425b..dec8d1e207 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -33,6 +33,7 @@ class InsetGraphics; class InsetBibKey; class InsetBibtex; class InsetError; +class InsetExternal; class InsetInclude; class InsetInfo; class InsetTabular; @@ -98,6 +99,8 @@ public: Signal0 showCredits; /// Signal1 showError; + /// show the external inset dialog + Signal1 showExternal; /// Signal1 showGraphics; /// show the details of a LyX file include inset diff --git a/src/frontends/gnome/ChangeLog b/src/frontends/gnome/ChangeLog index 72378e4596..bd42dbf9fc 100644 --- a/src/frontends/gnome/ChangeLog +++ b/src/frontends/gnome/ChangeLog @@ -1,3 +1,7 @@ +2001-03-11 Baruch Even + + * Various files: More fixes to get it compiled again. + 2001-03-06 Baruch Even * Various files: Small fixes to get the gnome frontend to compile again. diff --git a/src/frontends/gnome/Dialogs.C b/src/frontends/gnome/Dialogs.C index aff72684e1..7247dcb39c 100644 --- a/src/frontends/gnome/Dialogs.C +++ b/src/frontends/gnome/Dialogs.C @@ -12,6 +12,7 @@ #include "FormPreferences.h" #include "FormPrint.h" #include "FormRef.h" +#include "FormSplash.h" #include "FormTabular.h" #include "FormToc.h" #include "FormUrl.h" @@ -39,12 +40,11 @@ Dialogs::Dialogs(LyXView * lv) dialogs_.push_back(new FormParagraph(lv, this)); dialogs_.push_back(new FormPrint(lv, this)); dialogs_.push_back(new FormRef(lv, this)); + dialogs_.push_back(new FormSplash(lv, this)); dialogs_.push_back(new FormTabular(lv, this)); dialogs_.push_back(new FormToc(lv, this)); dialogs_.push_back(new FormUrl(lv, this)); - showCredits.connect(slot(ShowCredits)); - // reduce the number of connections needed in // dialogs by a simple connection here. hideAll.connect(hideBufferDependent.slot()); diff --git a/src/frontends/gnome/Makefile.am b/src/frontends/gnome/Makefile.am index 16104ef45e..5789ec5751 100644 --- a/src/frontends/gnome/Makefile.am +++ b/src/frontends/gnome/Makefile.am @@ -9,6 +9,9 @@ INCLUDES = ${FRONTEND_INCLUDES} -I${top_srcdir}/src/ \ libgnome_la_OBJADD = \ ../xforms/ButtonController.lo \ ../xforms/Color.lo \ + ../xforms/FileDialog.lo \ + ../xforms/FormFiledialog.lo \ + ../xforms/form_filedialog.lo \ ../xforms/FormBase.lo \ ../xforms/FormCitation.lo \ ../xforms/form_citation.lo \ @@ -31,6 +34,8 @@ libgnome_la_OBJADD = \ ../xforms/form_print.lo \ ../xforms/FormRef.lo \ ../xforms/form_ref.lo \ + ../xforms/FormSplash.lo \ + ../xforms/form_splash.lo \ ../xforms/FormTabular.lo \ ../xforms/form_tabular.lo \ ../xforms/FormTabularCreate.lo \ diff --git a/src/frontends/gnome/Menubar_pimpl.C b/src/frontends/gnome/Menubar_pimpl.C index 2a0201cb4c..b0a2ee1fa7 100644 --- a/src/frontends/gnome/Menubar_pimpl.C +++ b/src/frontends/gnome/Menubar_pimpl.C @@ -246,7 +246,7 @@ void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector(ac); switch(action) { - case LFUN_MENUOPEN: + case LFUN_FILE_OPEN: gitem = Open(cback); break; case LFUN_QUIT: @@ -258,7 +258,7 @@ void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector + + * Makefile.am: updated + * paragraphdlg.ui: manually enabled items in minipage settings + * paragraphdlgimpl.C: tweak enable code on extra page + * Stuff sent in by Denis Perchine to compile again: + * FileDialog_private.[Ch]: added + * FileDialog.C: added + * FormParagraph.C: params settings updated + 2001-03-06 Edwin Leuven * Search dialog added: diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index b4ba40154c..562bb2f3d4 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -14,6 +14,7 @@ #include "Dialogs.h" #include "FormCharacter.h" #include "FormCitation.h" +#include "FormCredits.h" #include "FormCopyright.h" #include "FormDocument.h" #include "FormError.h" @@ -35,10 +36,6 @@ using std::endl; -// temporary till ported -extern void ShowCredits(); - - // Signal enabling all visible popups to be redrawn if so desired. // E.g., when the GUI colours have been remapped. Signal0 Dialogs::redrawGUI; @@ -49,6 +46,7 @@ Dialogs::Dialogs(LyXView * lv) dialogs_.push_back(new FormCharacter(lv, this)); dialogs_.push_back(new FormCitation(lv, this)); dialogs_.push_back(new FormCopyright(lv, this)); + dialogs_.push_back(new FormCredits(lv, this)); dialogs_.push_back(new FormDocument(lv, this)); dialogs_.push_back(new FormError(lv, this)); dialogs_.push_back(new FormGraphics(lv, this)); @@ -63,8 +61,6 @@ Dialogs::Dialogs(LyXView * lv) dialogs_.push_back(new FormToc(lv, this)); dialogs_.push_back(new FormUrl(lv, this)); - showCredits.connect(slot(ShowCredits)); - // reduce the number of connections needed in // dialogs by a simple connection here. hideAll.connect(hideBufferDependent.slot()); diff --git a/src/frontends/qt2/FormParagraph.C b/src/frontends/qt2/FormParagraph.C index 6fd2c80864..e42633d4f8 100644 --- a/src/frontends/qt2/FormParagraph.C +++ b/src/frontends/qt2/FormParagraph.C @@ -72,22 +72,22 @@ void FormParagraph::update(bool switched) align = textclasslist.Style(buf->params.textclass, par->GetLayout()).align; #ifndef NEW_INSETS - LyXParagraph *physpar = par->FirstPhysicalPar(); + ParagraphParameters *params = &(par->FirstPhysicalPar()->params); #else - LyXParagraph *physpar = par; + ParagraphParameters *params = &(par->params); #endif - - if (physpar->added_space_top.kind()==VSpace::LENGTH) { - LyXGlueLength above = physpar->added_space_top.length(); - lyxerr[Debug::GUI] << "Reading above space : \"" << physpar->added_space_top.length().asString() << "\"" << endl; + + if (params->spaceTop().kind() == VSpace::LENGTH) { + LyXGlueLength above = params->spaceTop().length(); + lyxerr[Debug::GUI] << "Reading above space : \"" << params->spaceTop().length().asString() << "\"" << endl; dialog_->setAboveLength(above.value(), above.plusValue(), above.minusValue(), above.unit(), above.plusUnit(), above.minusUnit()); } else dialog_->setAboveLength(0.0, 0.0, 0.0, LyXLength::UNIT_NONE, LyXLength::UNIT_NONE, LyXLength::UNIT_NONE); - if (physpar->added_space_bottom.kind()==VSpace::LENGTH) { - LyXGlueLength below = physpar->added_space_bottom.length(); - lyxerr[Debug::GUI] << "Reading below space : \"" << physpar->added_space_bottom.length().asString() << "\"" << endl; + if (params->spaceBottom().kind() == VSpace::LENGTH) { + LyXGlueLength below = params->spaceBottom().length(); + lyxerr[Debug::GUI] << "Reading below space : \"" << params->spaceBottom().length().asString() << "\"" << endl; dialog_->setBelowLength(below.value(), below.plusValue(), below.minusValue(), below.unit(), below.plusUnit(), below.minusUnit()); } else @@ -95,30 +95,31 @@ void FormParagraph::update(bool switched) dialog_->setLabelWidth(text->cursor.par()->GetLabelWidthString().c_str()); dialog_->setAlign(align); - dialog_->setChecks(physpar->line_top, physpar->line_bottom, - physpar->pagebreak_top, physpar->pagebreak_bottom, physpar->noindent); - dialog_->setSpace(physpar->added_space_top.kind(), physpar->added_space_bottom.kind(), - physpar->added_space_top.keep(), physpar->added_space_bottom.keep()); + dialog_->setChecks(params->lineTop(), params->lineBottom(), + params->pagebreakTop(), params->pagebreakBottom(), params->noindent()); + dialog_->setSpace(params->spaceTop().kind(), params->spaceBottom().kind(), + params->spaceTop().keep(), params->spaceBottom().keep()); // now the extras page LyXLength extrawidth; float val = 0.0; LyXLength::UNIT unit = LyXLength::CM; + params = &(par->params); - if (isValidLength(par->pextra_width, &extrawidth)) { + if (isValidLength(params->pextraWidth(), &extrawidth)) { lyxerr[Debug::GUI] << "Reading extra width \"" << extrawidth.asString() << "\"" << endl; val = extrawidth.value(); unit = extrawidth.unit(); } - lyxerr[Debug::GUI] << "Reading widthp \"" << par->pextra_widthp << "\"" << endl; + lyxerr[Debug::GUI] << "Reading widthp \"" << params->pextraWidthp() << "\"" << endl; - dialog_->setExtra(val, unit, par->pextra_widthp, - par->pextra_alignment, - par->pextra_hfill, - par->pextra_start_minipage, - static_cast(par->pextra_type)); + dialog_->setExtra(val, unit, params->pextraWidthp(), + params->pextraAlignment(), + params->pextraHfill(), + params->pextraStartMinipage(), + static_cast(params->pextraType())); } void FormParagraph::apply() diff --git a/src/frontends/qt2/Makefile.am b/src/frontends/qt2/Makefile.am index f029fbf535..111510068b 100644 --- a/src/frontends/qt2/Makefile.am +++ b/src/frontends/qt2/Makefile.am @@ -9,7 +9,9 @@ DEFINES = -DQT_CLEAN_NAMESPACE CXXFLAGS= $(DEFINES) # moc generated files -BUILTSOURCES = moc_FormCopyrightDialogBase.C \ +BUILTSOURCES = \ + moc_FileDialog_private.C \ + moc_FormCopyrightDialogBase.C \ moc_FormCopyrightDialog.C \ moc_chardlg.C \ moc_chardlgimpl.C \ @@ -32,6 +34,7 @@ libqt2_la_OBJADD = \ ../xforms/Color.lo \ ../xforms/FormBase.lo \ ../xforms/FormCitation.lo \ + ../xforms/FormCredits.lo \ ../xforms/FormDocument.lo \ ../xforms/FormError.lo \ ../xforms/FormGraphics.lo \ @@ -48,6 +51,7 @@ libqt2_la_OBJADD = \ ../xforms/Toolbar_pimpl.lo \ ../xforms/Timeout_pimpl.lo \ ../xforms/form_citation.lo \ + ../xforms/form_credits.lo \ ../xforms/form_copyright.lo \ ../xforms/form_document.lo \ ../xforms/form_error.lo \ @@ -76,6 +80,8 @@ libqt2_la_SOURCES = \ chardlg.h \ chardlgimpl.C \ chardlgimpl.h \ + FileDialog.C \ + FileDialog_private.C \ FormCopyright.C \ FormCopyright.h \ FormCopyrightDialog.C \ @@ -128,6 +134,8 @@ FormCopyrightDialogBase.h: FormCopyrightDialogBase.ui $(UIC) -o $@ $< FormCopyrightDialogBase.C: FormCopyrightDialogBase.ui $(UIC) -impl FormCopyrightDialogBase.h -o $@ $< +moc_FileDialog_private.C: FileDialog_private.h + $(MOC) -o $@ $< moc_FormCopyrightDialogBase.C: FormCopyrightDialogBase.h $(MOC) -o $@ $< moc_FormCopyrightDialog.C: FormCopyrightDialog.h diff --git a/src/frontends/qt2/paragraphdlg.C b/src/frontends/qt2/paragraphdlg.C index 31791b9618..2a57051cb6 100644 --- a/src/frontends/qt2/paragraphdlg.C +++ b/src/frontends/qt2/paragraphdlg.C @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'paragraphdlg.ui' ** -** Created: Sat Feb 10 14:22:28 2001 +** Created: Fri Mar 9 13:08:59 2001 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -465,12 +465,12 @@ ParagraphDlg::ParagraphDlg( QWidget* parent, const char* name, bool modal, WFla minipageStart = new QCheckBox( minipageOptions, "minipageStart" ); minipageStart->setText( tr( "Start new minipage" ) ); - minipageStart->setEnabled( FALSE ); + minipageStart->setEnabled( TRUE ); minipageOptionsLayout->addWidget( minipageStart ); minipageHfill = new QCheckBox( minipageOptions, "minipageHfill" ); minipageHfill->setText( tr( "HFill between minipage paragraphs" ) ); - minipageHfill->setEnabled( FALSE ); + minipageHfill->setEnabled( TRUE ); minipageOptionsLayout->addWidget( minipageHfill ); Layout15 = new QHBoxLayout; diff --git a/src/frontends/qt2/paragraphdlg.h b/src/frontends/qt2/paragraphdlg.h index 39c08770e5..a155220698 100644 --- a/src/frontends/qt2/paragraphdlg.h +++ b/src/frontends/qt2/paragraphdlg.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'paragraphdlg.ui' ** -** Created: Sat Feb 10 14:22:05 2001 +** Created: Fri Mar 9 13:08:44 2001 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! diff --git a/src/frontends/qt2/paragraphdlg.ui b/src/frontends/qt2/paragraphdlg.ui index 777e2c8a57..6de2b8596b 100644 --- a/src/frontends/qt2/paragraphdlg.ui +++ b/src/frontends/qt2/paragraphdlg.ui @@ -1667,7 +1667,7 @@ enabled - false + true @@ -1682,7 +1682,7 @@ enabled - false + true diff --git a/src/frontends/qt2/paragraphdlgimpl.C b/src/frontends/qt2/paragraphdlgimpl.C index afbfbbeac1..590069ac80 100644 --- a/src/frontends/qt2/paragraphdlgimpl.C +++ b/src/frontends/qt2/paragraphdlgimpl.C @@ -395,7 +395,7 @@ int ParagraphDlgImpl::getItem(LyXLength::UNIT unit) const { void ParagraphDlgImpl::enable_extraOptions(int item) { - bool enable = (item==0); + bool enable = (item!=0); extraWidth->setEnabled(enable); extraWidthL->setEnabled(enable); extraUnit->setEnabled(enable); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 9808217b9f..c3d6c8c39d 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,14 @@ +2001-03-09 John Levon + + * Makefile.am: + * Dialogs.C: + * FormExternal.C: + * FormExternal.h: + * form_external.C: + * form_external.h: + * xforms/forms/makefile: + * forms/form_external.fd: add FormExternal + 2001-03-12 Lars Gullik Bjønnes * FormToc.h: use Buffer::typedef diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index 1a17729329..7aa1eb1197 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -20,6 +20,7 @@ #include "FormCredits.h" #include "FormDocument.h" #include "FormError.h" +#include "FormExternal.h" #include "FormGraphics.h" #include "FormInclude.h" #include "FormIndex.h" @@ -58,6 +59,7 @@ Dialogs::Dialogs(LyXView * lv) dialogs_.push_back(new FormCredits(lv, this)); dialogs_.push_back(new FormDocument(lv, this)); dialogs_.push_back(new FormError(lv, this)); + dialogs_.push_back(new FormExternal(lv, this)); dialogs_.push_back(new FormGraphics(lv, this)); dialogs_.push_back(new FormInclude(lv, this)); dialogs_.push_back(new FormIndex(lv, this)); diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index 3d781b1b59..b64ce5da37 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -357,8 +357,9 @@ void FormGraphics::browse() string const filename = fl_get_input(dialog_->input_filename); string const title = N_("Graphics"); - // we need the second '|' to prevent mis-interpretation - string const pattern = "*.(ps|png)|"; + // FIXME: currently we need the second '|' to prevent mis-interpretation + // FIXME: rfind() in split() seems to be broken hence the second space + string const pattern = "*.(ps|png)| "; // Does user clipart directory exist? string clipdir = AddName (user_lyxdir, "clipart"); diff --git a/src/frontends/xforms/Makefile.am b/src/frontends/xforms/Makefile.am index 4a18c94623..a5a2e9bdff 100644 --- a/src/frontends/xforms/Makefile.am +++ b/src/frontends/xforms/Makefile.am @@ -61,6 +61,10 @@ libxforms_la_SOURCES = \ FormError.h \ form_error.C \ form_error.h \ + FormExternal.C \ + FormExternal.h \ + form_external.C \ + form_external.h \ FormGraphics.C \ FormGraphics.h \ form_graphics.C \ diff --git a/src/frontends/xforms/forms/makefile b/src/frontends/xforms/forms/makefile index 4987348d4d..37b7f297ec 100644 --- a/src/frontends/xforms/forms/makefile +++ b/src/frontends/xforms/forms/makefile @@ -25,6 +25,7 @@ SRCS := form_bibitem.fd \ form_credits.fd \ form_document.fd \ form_error.fd \ + form_external.fd \ form_filedialog.fd \ form_graphics.fd \ form_include.fd \ diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 1523dcfffa..11d84bbd92 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,15 @@ +2001-03-12 Angus Leeming + + * ExternalTemplate.C (read): the reading of external insets now checks + for \end_inset and removes it form the input stream. + +2001-03-09 John Levon + + * ExternalTemplate.h: + * ExternalTemplate.C: + * insetexternal.h: + * insetexternal.C: move form to GUII + 2001-03-12 Lars Gullik Bjønnes * insettoc.C (Ascii): use the Buffer typedefs diff --git a/src/insets/ExternalTemplate.C b/src/insets/ExternalTemplate.C index 15b8fecc11..960a829260 100644 --- a/src/insets/ExternalTemplate.C +++ b/src/insets/ExternalTemplate.C @@ -129,6 +129,12 @@ ExternalTemplateManager::getTemplates() const } +ExternalTemplate const & ExternalTemplateManager::getTemplateByName(string const & name) +{ + return templates[name]; +} + + void ExternalTemplateManager::readTemplates(string const & path) { Path p(path); diff --git a/src/insets/ExternalTemplate.h b/src/insets/ExternalTemplate.h index d643f5d483..c02cd865a1 100644 --- a/src/insets/ExternalTemplate.h +++ b/src/insets/ExternalTemplate.h @@ -76,10 +76,12 @@ class ExternalTemplateManager : public noncopyable { public: /// Map from the LyX name of the template to the template structure typedef std::map Templates; - + static ExternalTemplateManager & get(); Templates & getTemplates(); Templates const & getTemplates() const; + /// return the template by LyX name + ExternalTemplate const & getTemplateByName(const string & name); private: ExternalTemplateManager(); void readTemplates(string const & path); @@ -88,4 +90,3 @@ private: }; #endif - diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 8bddd24839..1d22fd9931 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -1,8 +1,8 @@ /* This file is part of * ====================================================== - * + * * LyX, The Document Processor - * + * * Copyright 1995 Matthias Ettrich * Copyright 1995-2000 The LyX Team. * @@ -14,344 +14,122 @@ #pragma implementation #endif -#include FORMS_H_LOCATION #include -#include +#include #include "insetexternal.h" #include "ExternalTemplate.h" -#include "lyx_gui_misc.h" // CancelCloseBoxCB #include "BufferView.h" #include "buffer.h" -#include "frontends/FileDialog.h" +#include "LyXView.h" +#include "frontends/Dialogs.h" #include "lyx_main.h" #include "LaTeXFeatures.h" #include "support/filetools.h" #include "support/lstrings.h" #include "support/path.h" #include "support/syscall.h" -#include "frontends/Dialogs.h" // redrawGUI #ifdef SIGC_CXX_NAMESPACES using SigC::slot; #endif using std::endl; -using std::pair; -using std::make_pair; InsetExternal::InsetExternal() - : form_external(0) + : view(0) { tempname = lyx::tempName(string(), "lyxext"); - r_ = Dialogs::redrawGUI.connect(slot(this, &InsetExternal::redraw)); + ExternalTemplateManager::Templates::const_iterator i1; + params_.templ = ExternalTemplateManager::get().getTemplates().begin()->second; } InsetExternal::~InsetExternal() { lyx::unlink(tempname); - r_.disconnect(); -} - - -void InsetExternal::redraw() -{ - if (form_external && form_external->form_external->visible) - fl_redraw_form(form_external->form_external); -} - - -extern "C" -void ExternalTemplateCB(FL_OBJECT * ob, long data) -{ - InsetExternal::templateCB(ob, data); -} - - -extern "C" -void ExternalBrowseCB(FL_OBJECT * ob, long data) -{ - InsetExternal::browseCB(ob, data); -} - - -extern "C" -void ExternalEditCB(FL_OBJECT * ob, long data) -{ - InsetExternal::editCB(ob, data); + hideDialog(); } -extern "C" -void ExternalViewCB(FL_OBJECT * ob, long data) +InsetExternal::InsetExternalParams InsetExternal::params() const { - InsetExternal::viewCB(ob, data); -} - - -extern "C" -void ExternalUpdateCB(FL_OBJECT * ob, long data) -{ - InsetExternal::updateCB(ob, data); -} - - -extern "C" -void ExternalOKCB(FL_OBJECT * ob, long data) -{ - InsetExternal::okCB(ob, data); -} - - -extern "C" -void ExternalCancelCB(FL_OBJECT * ob, long data) -{ - InsetExternal::cancelCB(ob, data); -} - - -void InsetExternal::templateCB(FL_OBJECT * ob, long) -{ - Holder * holder = static_cast(ob->form->u_vdata); - InsetExternal * inset = holder->inset; - ExternalTemplate et = inset->getTemplate(inset->getCurrentTemplate()); - // Update the help text - fl_clear_browser(inset->form_external->helptext); - fl_addto_browser(inset->form_external->helptext, et.helpText.c_str()); - fl_set_browser_topline(inset->form_external->helptext, 0); -} - - -void InsetExternal::browseCB(FL_OBJECT * ob, long) -{ - Holder * holder = static_cast(ob->form->u_vdata); - InsetExternal * inset = holder->inset; - - static string current_path; - static int once = 0; - - string p = inset->filename; - string buf = MakeAbsPath(holder->view->buffer()->fileName()); - string buf2 = OnlyPath(buf); - if (!p.empty()) { - buf = MakeAbsPath(p, buf2); - buf = OnlyPath(buf); - } else { - buf = OnlyPath(holder->view->buffer()->fileName()); - } - - FileDialog fileDlg(holder->view->owner(), _("Select external file"), - LFUN_SELECT_FILE_SYNC, - make_pair(string(_("Document")), string(buf))); - - // FIXME: should have "nice name" for file type e.g. "Xfig files" - - /// Determine the template file extension - ExternalTemplate et = inset->getTemplate(inset->getCurrentTemplate()); - string regexp = et.fileRegExp; - if (regexp.empty()) { - regexp = "*"; - } - - regexp += "|"; - - bool error = false; - do { - string const path = (once) ? current_path : buf; - FileDialog::Result result = fileDlg.Select(path, regexp); - - if (result.second.empty()) - return; - - string p = result.second; - - buf = MakeRelPath(p, buf2); - current_path = OnlyPath(p); - once = 1; - - if (contains(p, "#") || contains(p, "~") || contains(p, "$") - || contains(p, "%")) { - WriteAlert(_("Filename can't contain any " - "of these characters:"), - // xgettext:no-c-format - _("'#', '~', '$' or '%'.")); - error = true; - } - } while (error); - - if (inset->form_external) - fl_set_input(inset->form_external->filename, buf.c_str()); - -} - - -void InsetExternal::editCB(FL_OBJECT * ob, long) -{ - Holder * holder = static_cast(ob->form->u_vdata); - InsetExternal * inset = holder->inset; - inset->doApply(holder->view); - inset->doEdit(holder->view); -} - - -void InsetExternal::viewCB(FL_OBJECT * ob, long) -{ - Holder * holder = static_cast(ob->form->u_vdata); - InsetExternal * inset = holder->inset; - inset->doApply(holder->view); - inset->doView(holder->view); -} - - -void InsetExternal::updateCB(FL_OBJECT * ob, long) -{ - Holder * holder = static_cast(ob->form->u_vdata); - InsetExternal * inset = holder->inset; - inset->doApply(holder->view); - inset->doUpdate(holder->view); -} - - -void InsetExternal::okCB(FL_OBJECT * ob, long data) -{ - Holder * holder = static_cast(ob->form->u_vdata); - InsetExternal * inset = holder->inset; - inset->doApply(holder->view); - cancelCB(ob,data); -} - - -void InsetExternal::doApply(BufferView * bufview) -{ - bool update = false; - if (templatename != getCurrentTemplate()) { - templatename = getCurrentTemplate(); - update = true; - } - if (filename != fl_get_input(form_external->filename)) { - filename = fl_get_input(form_external->filename); - update = true; - } - if (parameters != fl_get_input(form_external->parameters)) { - parameters = fl_get_input(form_external->parameters); - update = true; - } - - if (update) { - // The text might have change, - // so we should update the button look - bufview->updateInset(this, true); - } + return params_; } - - -void InsetExternal::cancelCB(FL_OBJECT * ob, long) + + +void InsetExternal::setFromParams(InsetExternalParams const & p) { - Holder * holder = static_cast(ob->form->u_vdata); - - InsetExternal * inset = holder->inset; - // BufferView * bv = holder->view; - - if (inset->form_external) { - fl_hide_form(inset->form_external->form_external); - fl_free_form(inset->form_external->form_external); - inset->form_external = 0; - } -} + params_.filename = p.filename; + params_.parameters = p.parameters; + params_.templ = p.templ; +} string const InsetExternal::EditMessage() const { - ExternalTemplate const & et = getTemplate(templatename); - return doSubstitution(0, et.guiName); + return doSubstitution(0, params_.templ.guiName); } void InsetExternal::Edit(BufferView * bv, int /*x*/, int /*y*/, unsigned int /*button*/) { - static int ow = -1, oh; - - if (bv->buffer()->isReadonly()) - WarnReadonly(bv->buffer()->fileName()); - - if (!form_external) { - form_external = create_form_form_external(); - holder.inset = this; - // form_external->ok->u_vdata = &holder; - form_external->form_external->u_vdata = &holder; - fl_set_form_atclose(form_external->form_external, - CancelCloseBoxCB, 0); - } - holder.view = bv; - fl_addto_choice(form_external->templatechoice, - getTemplateString().c_str()); - fl_set_input(form_external->filename, filename.c_str()); - fl_set_input(form_external->parameters, parameters.c_str()); - if (!templatename.empty()) { - fl_set_choice(form_external->templatechoice, - getTemplateNumber(templatename)); - } - // Update the help text - templateCB(form_external->templatechoice, 0); - - ExternalTemplate const & et = getTemplate(templatename); - if (et.automaticProduction) { - fl_deactivate_object(form_external->update); - fl_set_object_lcol(form_external->update, FL_INACTIVE); - } else { - fl_activate_object(form_external->update); - fl_set_object_lcol(form_external->update, FL_BLACK); - } - - if (form_external->form_external->visible) { - fl_raise_form(form_external->form_external); - } else { - fl_show_form(form_external->form_external, - FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, - _("Insert external inset")); - if (ow < 0) { - ow = form_external->form_external->w; - oh = form_external->form_external->h; - } - fl_set_form_minsize(form_external->form_external, ow, oh); - } + view = bv; + view->owner()->getDialogs()->showExternal(this); } void InsetExternal::Write(Buffer const *, std::ostream & os) const { - os << "External " << templatename << ",\"" << filename - << "\",\"" << parameters << "\"\n"; + os << "External " << params_.templ.lyxName << ",\"" << params_.filename + << "\",\"" << params_.parameters << "\"\n"; } void InsetExternal::Read(Buffer const *, LyXLex & lex) { - lex.EatLine(); - string const format = lex.GetString(); + string format; + string token; + + // Read inset data from lex and store in format + if (lex.EatLine()) { + format = lex.GetString(); + } else + lex.printError("InsetExternal: Parse error: `$$Token'"); + while (lex.IsOK()) { + lex.nextToken(); + token = lex.GetString(); + if (token == "\\end_inset") + break; + } + if (token != "\\end_inset") { + lex.printError("Missing \\end_inset at this point. " + "Read: `$$Token'"); + } + + // Parse string format... string::size_type const pos1 = format.find(","); - templatename = format.substr(0, pos1); + params_.templ = ExternalTemplateManager::get().getTemplateByName(format.substr(0, pos1)); string::size_type const pos2 = format.find("\",\"", pos1); - filename = format.substr(pos1 + 2, pos2 - (pos1 + 2)); - parameters = format.substr(pos2 + 3, format.length() - (pos2 + 4)); + params_.filename = format.substr(pos1 + 2, pos2 - (pos1 + 2)); + params_.parameters = format.substr(pos2 + 3, format.length() - (pos2 + 4)); - lyxerr[Debug::INFO] << "InsetExternal::Read: " << templatename - << " " << filename - << " " << parameters << endl; + lyxerr[Debug::INFO] << "InsetExternal::Read: " << params_.templ.lyxName + << " " << params_.filename + << " " << params_.parameters << endl; } int InsetExternal::write(string const & format, Buffer const * buf, std::ostream & os) const { - ExternalTemplate const & et = getTemplate(templatename); + ExternalTemplate const & et = params_.templ; ExternalTemplate::Formats::const_iterator cit = et.formats.find(format); if (cit == et.formats.end()) { lyxerr << "External template format '" << format - << "' not specified in template " << templatename + << "' not specified in template " << params_.templ.lyxName << endl; return 0; } @@ -363,7 +141,7 @@ int InsetExternal::write(string const & format, } os << doSubstitution(buf, (*cit).second.product); - return 0; // CHECK + return 0; // CHECK (FIXME check what ? - jbl) } @@ -394,12 +172,12 @@ int InsetExternal::DocBook(Buffer const * buf, std::ostream & os) const void InsetExternal::Validate(LaTeXFeatures & features) const { - ExternalTemplate const & et = getTemplate(templatename); + ExternalTemplate const & et = params_.templ; ExternalTemplate::Formats::const_iterator cit = et.formats.find("LaTeX"); - if (cit == et.formats.end()) { + + if (cit == et.formats.end()) return; - } if (!(*cit).second.requirement.empty()) { features.require((*cit).second.requirement); @@ -413,56 +191,18 @@ void InsetExternal::Validate(LaTeXFeatures & features) const Inset * InsetExternal::Clone(Buffer const &) const { InsetExternal * inset = new InsetExternal(); - inset->templatename = templatename; - inset->filename = filename; - inset->parameters = parameters; + inset->params_ = params_; return inset; } string const InsetExternal::getScreenLabel() const { - if (templatename.empty()) { + ExternalTemplate const & et = params_.templ; + if (et.guiName.empty()) return _("External"); - } else { - ExternalTemplate const & et = getTemplate(templatename); - if (et.guiName.empty()) - return "ext: ???"; - else - return doSubstitution(0, et.guiName); - } -} - - -void InsetExternal::doUpdate(BufferView const * bv) const -{ - ExternalTemplate const & et = getTemplate(getCurrentTemplate()); - ExternalTemplate::Formats::const_iterator cit = - et.formats.find("LaTeX"); - if (cit == et.formats.end()) - return; - - executeCommand(doSubstitution(bv->buffer(), - (*cit).second.updateCommand), - bv->buffer()); -} - - -void InsetExternal::doView(BufferView const * bv) const -{ - automaticUpdate(bv); - ExternalTemplate const & et = getTemplate(getCurrentTemplate()); - executeCommand(doSubstitution(bv->buffer(), et.viewCommand), - bv->buffer()); -} - - -void InsetExternal::doEdit(BufferView const * bv) const -{ - automaticUpdate(bv); - ExternalTemplate const & et = getTemplate(getCurrentTemplate()); - executeCommand(doSubstitution(bv->buffer(), et.editCommand), - bv->buffer()); + else + return doSubstitution(0, et.guiName); } @@ -481,23 +221,14 @@ void InsetExternal::executeCommand(string const & s, } -void InsetExternal::automaticUpdate(BufferView const * bv) const -{ - ExternalTemplate const & et = getTemplate(templatename); - if (et.automaticProduction) { - doUpdate(bv); - } -} - - string const InsetExternal::doSubstitution(Buffer const * buffer, string const & s) const { string result; - string const basename = ChangeExtension(filename, string()); - result = subst(s, "$$FName", filename); + string const basename = ChangeExtension(params_.filename, string()); + result = subst(s, "$$FName", params_.filename); result = subst(result, "$$Basename", basename); - result = subst(result, "$$Parameters", parameters); + result = subst(result, "$$Parameters", params_.parameters); result = ReplaceEnvironmentPath(result); result = subst(result, "$$Tempname", tempname); result = subst(result, "$$Sysdir", system_lyxdir); @@ -527,70 +258,39 @@ string const InsetExternal::doSubstitution(Buffer const * buffer, } -string const InsetExternal::getCurrentTemplate() const +void InsetExternal::updateExternal() const { - return getTemplateName(fl_get_choice(form_external->templatechoice)); + ExternalTemplate const & et = params_.templ; + ExternalTemplate::Formats::const_iterator cit = + et.formats.find("LaTeX"); + if (cit == et.formats.end()) + return; + + executeCommand(doSubstitution(view->buffer(), + (*cit).second.updateCommand), + view->buffer()); } -ExternalTemplate const InsetExternal::getTemplate(string const & name) const +void InsetExternal::viewExternal() const { - ExternalTemplateManager::Templates::iterator i = - ExternalTemplateManager::get().getTemplates().find(name); - // Make sure that the template exists in the map - if (i == ExternalTemplateManager::get().getTemplates().end()) { - lyxerr << "Unknown external material template: " - << name << endl; - return ExternalTemplate(); - } - return (*i).second; -} - + ExternalTemplate const & et = params_.templ; + if (et.automaticProduction) + updateExternal(); -int InsetExternal::getTemplateNumber(string const & name) const -{ - int i = 1; - ExternalTemplateManager::Templates::const_iterator i1, i2; - i1 = ExternalTemplateManager::get().getTemplates().begin(); - i2 = ExternalTemplateManager::get().getTemplates().end(); - for (; i1 != i2; ++i1) { - if ((*i1).second.lyxName == name) - return i; - ++i; - } - // This should never happen - /// This can happen if someone sends you a lyx file that uses - /// external templates that are defined only on his machine - //Assert(false); - return 0; + executeCommand(doSubstitution(view->buffer(), + et.viewCommand), + view->buffer()); } -string const InsetExternal::getTemplateName(int i) const +void InsetExternal::editExternal() const { - ExternalTemplateManager::Templates::const_iterator i1; - i1 = ExternalTemplateManager::get().getTemplates().begin(); - for (int n = 1; n < i; ++n) { - ++i1; - } - return (*i1).second.lyxName; -} - + ExternalTemplate const & et = params_.templ; + if (et.automaticProduction) + updateExternal(); -string const InsetExternal::getTemplateString() const -{ - string result; - bool first = true; - ExternalTemplateManager::Templates::const_iterator i1, i2; - i1 = ExternalTemplateManager::get().getTemplates().begin(); - i2 = ExternalTemplateManager::get().getTemplates().end(); - for (; i1 != i2; ++i1) { - if (!first) { - result += "|"; - } else { - first = false; - } - result += (*i1).second.lyxName; - } - return result; + executeCommand(doSubstitution(view->buffer(), + et.editCommand), + view->buffer()); } diff --git a/src/insets/insetexternal.h b/src/insets/insetexternal.h index 565316d2f2..278ad8a827 100644 --- a/src/insets/insetexternal.h +++ b/src/insets/insetexternal.h @@ -1,9 +1,9 @@ // -*- C++ -*- /* This file is part of* - * ====================================================== + * ====================================================== * * LyX, The Document Processor - * + * * Copyright 1995 Matthias Ettrich * Copyright 1995-2000 The LyX Team. * @@ -17,20 +17,31 @@ #endif #include "insetbutton.h" +#include "ExternalTemplate.h" #include "LString.h" -#include "../lyx.h" #include -struct ExternalTemplate; - #ifdef SIGC_CXX_NAMESPACES -using SigC::Object; -using SigC::Connection; +using SigC::Signal0; #endif /// -class InsetExternal : public InsetButton, public Object { +class InsetExternal : public InsetButton { public: + /// hold parameters settable from the GUI + struct InsetExternalParams { + InsetExternalParams(string const & f = string(), + string const & p = string(), + ExternalTemplate const & t = ExternalTemplate()) + : filename(f), parameters(p), templ(t) {} + /// the filename + string filename; + /// the parameters of the current choice + string parameters; + /// the current template used + ExternalTemplate templ; + }; + InsetExternal(); /// virtual ~InsetExternal(); @@ -44,6 +55,7 @@ public: virtual void Write(Buffer const *, std::ostream &) const; /// virtual void Read(Buffer const *, LyXLex & lex); + /** returns the number of rows (\n's) of generated tex code. fragile == true means, that the inset should take care about fragile commands by adding a \protect before. @@ -52,118 +64,64 @@ public: */ virtual int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const; - /// + /// write ASCII output to the ostream virtual int Ascii(Buffer const *, std::ostream &, int linelen) const; - /// + /// write LinuxDoc output to the ostream virtual int Linuxdoc(Buffer const *, std::ostream &) const; - /// + /// write DocBook output to the ostream virtual int DocBook(Buffer const *, std::ostream &) const; + /// Updates needed features for this inset. virtual void Validate(LaTeXFeatures & features) const; /// returns LyX code associated with the inset. Used for TOC, ...) virtual Inset::Code LyxCode() const { return EXTERNAL_CODE; } - + /// virtual Inset * Clone(Buffer const &) const; /// returns the text of the button virtual string const getScreenLabel() const; - /// Callback function for the template drop-down - static void templateCB(FL_OBJECT *, long); + // The following public members are used from the frontends code - /// Callback function for the browse button - static void browseCB(FL_OBJECT *, long); + /// set the parameters from a Params structure + virtual void setFromParams(InsetExternalParams const &); - /// Callback function for the edit button - static void editCB(FL_OBJECT *, long); + /// update the file represented by the template + void updateExternal() const; - /// Callback function for the view button - static void viewCB(FL_OBJECT *, long); + /// edit file of this template + void editExternal() const; - /// Callback function for the update production button - static void updateCB(FL_OBJECT *, long); + /// view file of this template + void viewExternal() const; - /// Callback function for the ok button - static void okCB(FL_OBJECT *, long); + /// return a copy of our current params + InsetExternalParams params() const; - /// Callback function for the cancel button - static void cancelCB(FL_OBJECT *, long); -private: - /** Redraw the form (on receipt of a Signal indicating, for example, - that the xform colors have been re-mapped). - */ - void redraw(); + /// hide connection + Signal0 hideDialog; +private: /// Write the output for a specific file format int write(string const & format, Buffer const *, std::ostream &) const; - /// Apply the changes - void doApply(BufferView * bv); - /// Execute this command in the directory of this document void executeCommand(string const & s, Buffer const * buf) const; - /// Update if automatic - void automaticUpdate(BufferView const *) const; - - /// Do update - void doUpdate(BufferView const *) const; - /// Do edit - void doEdit(BufferView const *) const; - /// Do view - void doView(BufferView const *) const; - /// Substitute meta-variables in this string string const doSubstitution(Buffer const *, string const & s) const; - /** Get the LyX name of the currently selected - template in the choice list - */ - string const getCurrentTemplate() const; - - /// Get a certain template from a LyX name - ExternalTemplate const getTemplate(string const & lyxname) const; + /// our owning view + BufferView * view; - /** - Get the number starting from 1 of a template with a - specific LyX name for the choice list - */ - int getTemplateNumber(string const & guiname) const; - - /// Get the LyX name of a template with a given number starting from 1 - string const getTemplateName(int n) const; - - /// Get a string with all the GUI template names separated by | - string const getTemplateString() const; - - /// - struct Holder { - InsetExternal * inset; - BufferView * view; - }; - /// - Holder holder; - - /// The external inset form - FD_form_external * form_external; - - /// - string templatename; - - /// - string filename; - - /// - string parameters; + /// the current params + InsetExternalParams params_; /// A temp filename string tempname; - - /// Redraw connection. - Connection r_; }; #endif diff --git a/src/lyx.C b/src/lyx.C index 2e79c1fc94..5253dd96e1 100644 --- a/src/lyx.C +++ b/src/lyx.C @@ -45,62 +45,3 @@ FD_form_figure *create_form_form_figure(void) return fdui; } -/*---------------------------------------*/ - -FD_form_external *create_form_form_external(void) -{ - FL_OBJECT *obj; - FD_form_external *fdui = (FD_form_external *) fl_calloc(1, sizeof(FD_form_external)); - - fdui->form_external = fl_bgn_form(FL_NO_BOX, 560, 310); - obj = fl_add_box(FL_UP_BOX, 0, 0, 560, 310, ""); - fdui->templatechoice = obj = fl_add_choice(FL_NORMAL_CHOICE, 130, 10, 300, 30, idex(_("Template|#t")));fl_set_button_shortcut(obj, scex(_("Template|#t")), 1); - fl_set_object_boxtype(obj, FL_FRAME_BOX); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast); - fl_set_object_callback(obj, ExternalTemplateCB, 0); - fdui->filename = obj = fl_add_input(FL_NORMAL_INPUT, 130, 190, 190, 30, idex(_("File|#F")));fl_set_button_shortcut(obj, scex(_("File|#F")), 1); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast); - fdui->filenamebrowse = obj = fl_add_button(FL_NORMAL_BUTTON, 330, 190, 100, 30, idex(_("Browse...|#B")));fl_set_button_shortcut(obj, scex(_("Browse...|#B")), 1); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); - fl_set_object_callback(obj, ExternalBrowseCB, 0); - fdui->parameters = obj = fl_add_input(FL_NORMAL_INPUT, 130, 230, 300, 30, idex(_("Parameters|#P")));fl_set_button_shortcut(obj, scex(_("Parameters|#P")), 1); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast); - fdui->edit = obj = fl_add_button(FL_NORMAL_BUTTON, 435, 50, 110, 30, idex(_("Edit file|#E")));fl_set_button_shortcut(obj, scex(_("Edit file|#E")), 1); - fl_set_object_color(obj, FL_COL1, FL_BLACK); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast); - fl_set_object_callback(obj, ExternalEditCB, 0); - fdui->view = obj = fl_add_button(FL_NORMAL_BUTTON, 435, 90, 110, 30, idex(_("View result|#V")));fl_set_button_shortcut(obj, scex(_("View result|#V")), 1); - fl_set_object_color(obj, FL_COL1, FL_BLACK); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast); - fl_set_object_callback(obj, ExternalViewCB, 0); - fdui->update = obj = fl_add_button(FL_NORMAL_BUTTON, 435, 130, 110, 30, idex(_("Update result|#U")));fl_set_button_shortcut(obj, scex(_("Update result|#U")), 1); - fl_set_object_color(obj, FL_COL1, FL_BLACK); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast); - fl_set_object_callback(obj, ExternalUpdateCB, 0); - fdui->ok = obj = fl_add_button(FL_RETURN_BUTTON, 315, 270, 110, 30, _("OK")); - fl_set_object_color(obj, FL_COL1, FL_BLACK); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); - fl_set_object_callback(obj, ExternalOKCB, 0); - fdui->cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 435, 270, 110, 30, idex(_("Cancel|#C^[")));fl_set_button_shortcut(obj, scex(_("Cancel|#C^[")), 1); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); - fl_set_object_callback(obj, ExternalCancelCB, 0); - fdui->helptext = obj = fl_add_browser(FL_NORMAL_BROWSER, 130, 50, 300, 130, ""); - fl_set_object_lalign(obj, FL_ALIGN_TOP); - fl_set_object_gravity(obj, FL_NorthWest, FL_SouthEast); - fl_end_form(); - - fdui->form_external->fdui = fdui; - - return fdui; -} -/*---------------------------------------*/ - diff --git a/src/lyx.h b/src/lyx.h index 9172685e08..534f9c927a 100644 --- a/src/lyx.h +++ b/src/lyx.h @@ -8,15 +8,6 @@ extern "C" void FigureOKCB(FL_OBJECT *, long); extern "C" void FigureApplyCB(FL_OBJECT *, long); extern "C" void FigureCancelCB(FL_OBJECT *, long); -extern "C" void ExternalTemplateCB(FL_OBJECT *, long); -extern "C" void ExternalBrowseCB(FL_OBJECT *, long); -extern "C" void ExternalEditCB(FL_OBJECT *, long); -extern "C" void ExternalViewCB(FL_OBJECT *, long); -extern "C" void ExternalUpdateCB(FL_OBJECT *, long); -extern "C" void ExternalOKCB(FL_OBJECT *, long); -extern "C" void ExternalCancelCB(FL_OBJECT *, long); - - /**** Forms and Objects ****/ typedef struct { FL_FORM *form_figure; @@ -29,23 +20,5 @@ typedef struct { } FD_form_figure; extern FD_form_figure * create_form_form_figure(void); -typedef struct { - FL_FORM *form_external; - void *vdata; - char *cdata; - long ldata; - FL_OBJECT *templatechoice; - FL_OBJECT *filename; - FL_OBJECT *filenamebrowse; - FL_OBJECT *parameters; - FL_OBJECT *edit; - FL_OBJECT *view; - FL_OBJECT *update; - FL_OBJECT *ok; - FL_OBJECT *cancel; - FL_OBJECT *helptext; -} FD_form_external; - -extern FD_form_external * create_form_form_external(void); #endif /* FD_form_title_h_ */ -- 2.39.2