]> git.lyx.org Git - lyx.git/commitdiff
patch from Angus and patch from Kayvan
authorLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 27 Jul 2000 08:55:59 +0000 (08:55 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 27 Jul 2000 08:55:59 +0000 (08:55 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@930 a592a061-630c-0410-9148-cb99ea01b6c8

29 files changed:
ChangeLog
Makefile.am
development/lyx.spec.in
forms/cite.fd [deleted file]
forms/form_url.fd [deleted file]
po/POTFILES.in
src/buffer.C
src/commandtags.h
src/ext_l10n.h
src/frontends/Dialogs.h
src/frontends/xforms/Dialogs.C
src/frontends/xforms/FormCitation.C
src/frontends/xforms/FormCitation.h
src/frontends/xforms/FormUrl.C [new file with mode: 0644]
src/frontends/xforms/FormUrl.h [new file with mode: 0644]
src/frontends/xforms/forms/form_url.fd [new file with mode: 0644]
src/frontends/xforms/forms/makefile
src/insets/Makefile.am
src/insets/insetbib.C
src/insets/insetcite.C
src/insets/insetcite.h
src/insets/insetcommand.C
src/insets/insetcommand.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/inseturl.C
src/insets/inseturl.h
src/lyxfunc.C
src/paragraph.C

index 1bd8c39b7942bca5626266889f6c443f54c7e933..a93449706d83ca54ecd58a56c3386a0e3e9b6047 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,45 @@
+2000-07-26  Kayvan A. Sylvan <kayvan@sylvan.com>
+
+       * development/lyx.spec.in
+       * Makefile.am: Fix buglet for LyX RPM generation resulting from
+       file/directory re-organization.
+                
+2000-07-26  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * src/insets/insetcommand.[Ch]: moved the string data and
+       associated manipulation methods into a new stand-alone class
+       InsetCommandParams. This class has two additional methods
+       getAsString() and setFromString() allowing the contents to be
+       moved around as a single string.
+       (addContents) method removed.
+       (setContents) method no longer virtual.
+
+       * src/buffer.C (readInset): made use of new InsetCitation,
+       InsetUrl constructors based on InsetCommandParams.
+
+       * src/commandtags.h: add LFUN_INSERT_URL
+
+       * src/lyxfunc.C (Dispatch): changed to accomadate GUI-
+       independent InsetUrl and use InsetCommandParams to extract
+       string info and create new Insets.
+
+       * src/frontends/Dialogs.h: add signals showUrl, createUrl.
+
+       * src/frontends/xforms/FormCitation.C (apply): uses 
+       InsetCommandParams.
+
+       * src/frontends/xforms/form_url.C
+       * src/frontends/xforms/form_url.h
+       * src/frontends/xforms/FormUrl.h
+       * src/frontends/xforms/FormUrl.C
+       * src/frontends/xforms/forms/form_url.fd: new files
+
+       * src/insets/insetcite.[Ch]: removed unused constructors.
+
+       * src/insets/insetinclude.[Ch]: no longer store filename
+
+       * src/insets/inseturl.[Ch]: GUI-independent.
+
 2000-07-26  Juergen Vigna  <jug@sad.it>
        * renamed frontend from gtk to gnome as it is that what is realized
        and did the necessary changes in the files.
index 125588285c6c96cd41a5df6ed1638e6fbfe8e3b3..011aa4e7834413799aed831396776e1701be0714 100644 (file)
@@ -25,7 +25,7 @@ dist-hook:
        rm -rf `find images -name \*CVS\*`
 
 rpmdist: dist
-       ln -s images/lyx.xpm . ; \
+       ln -s lib/images/lyx.xpm . ; \
        rpm -ta ${PACKAGE}-${VERSION}.tar.gz ; \
        rm lyx.xpm
 
index 1fb6d09d2c6ea2f8802d7257916477c051015382..aede6edc0211d70fec7e7c1a6c0657470e8c8336 100644 (file)
@@ -38,8 +38,17 @@ place that the Redhat tetex package is installed and would see it.
 %build
 unset LINGUAS || true
 CXXFLAGS="$RPM_OPT_FLAGS" CFLAGS="$RPM_OPT_FLAGS" \
-./configure --prefix=/usr --without-warnings
-make
+./configure --prefix=/usr --without-warnings --with-included-string
+# The following check is to ensure that lyx RPMs generated on RH 6.X machines
+# with gcc-2.95 still run against older Redhat OS/compiler combinations.
+# It will eventually be ripped out.
+if [ -r /usr/lib/libstdc++-libc6.1-1.so.2 ]
+then
+       make CXX=gcc LYX_LIBS='/usr/lib/libstdc++-libc6.1-1.so.2 -lforms -lXpm'
+else
+       make
+fi
+
 
 %install
 unset LINGUAS || true
@@ -59,7 +68,7 @@ cp -r ${RPM_BUILD_ROOT}/usr/share/lyx/tex \
 #
 # Miscellaneous files
 #
-cp -a images/lyx.xpm ${RPM_BUILD_ROOT}/usr/share/lyx/images/
+cp -a lib/images/lyx.xpm ${RPM_BUILD_ROOT}/usr/share/lyx/images/
 cp lib/reLyX/README README.reLyX
 
 %clean
diff --git a/forms/cite.fd b/forms/cite.fd
deleted file mode 100644 (file)
index a5543f2..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-Magic: 13000
-
-Internal Form Definition File
-    (do not change)
-
-Number of forms: 1
-Unit of measure: FL_COORD_PIXEL
-
-=============== FORM ===============
-Name: citation_form
-Width: 440
-Height: 790
-Number of Objects: 13
-
---------------------
-class: FL_BOX
-type: UP_BOX
-box: 0 0 440 790
-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_X
-gravity: FL_NoGravity FL_NoGravity
-name: box
-callback: 
-argument: 
-
---------------------
-class: FL_BROWSER
-type: HOLD_BROWSER
-box: 20 40 170 370
-boxtype: FL_DOWN_BOX
-colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_TOP_LEFT
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Inset keys
-shortcut: 
-resize: FL_RESIZE_X
-gravity: FL_NoGravity FL_NoGravity
-name: citeBrsr
-callback: citation_cb
-argument: InsetCitation::CITEBRSR
-
---------------------
-class: FL_BROWSER
-type: HOLD_BROWSER
-box: 250 40 170 370
-boxtype: FL_DOWN_BOX
-colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_TOP_LEFT
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Bibliography keys
-shortcut: 
-resize: FL_RESIZE_X
-gravity: FL_NoGravity FL_NoGravity
-name: bibBrsr
-callback: citation_cb
-argument: InsetCitation::BIBBRSR
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 200 40 40 40
-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: @4->
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name: bibBrsr
-callback: citation_cb
-argument: InsetCitation::BIBBRSR
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 200 40 40 40
-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: Button
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_South FL_South
-name: bibBrsr
-callback: citation_cb
-argument: InsetCitation::BIBBRSR
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 200 90 40 40
-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: @9+
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name: bibBrsr
-callback: citation_cb
-argument: InsetCitation::BIBBRSR
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 200 90 40 40
-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: Button
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_South FL_South
-name: bibBrsr
-callback: citation_cb
-argument: InsetCitation::BIBBRSR
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 200 140 40 40
-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: @8->
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name: bibBrsr
-callback: citation_cb
-argument: InsetCitation::BIBBRSR
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 200 140 40 40
-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: Button
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_South FL_South
-name: bibBrsr
-callback: citation_cb
-argument: InsetCitation::BIBBRSR
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 200 190 40 40
-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: @2->
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name: bibBrsr
-callback: citation_cb
-argument: InsetCitation::BIBBRSR
-
---------------------
-class: FL_BUTTON
-type: NORMAL_BUTTON
-box: 200 190 40 40
-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: Button
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_South FL_South
-name: bibBrsr
-callback: citation_cb
-argument: InsetCitation::BIBBRSR
-
---------------------
-class: FL_BROWSER
-type: NORMAL_BROWSER
-box: 20 440 400 110
-boxtype: FL_DOWN_BOX
-colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_TOP_LEFT
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Info
-shortcut: 
-resize: FL_RESIZE_X
-gravity: FL_NoGravity FL_NoGravity
-name: infoBrsr
-callback: 
-argument: 
-
---------------------
-class: FL_CHOICE
-type: NORMAL_CHOICE
-box: 160 570 130 30
-boxtype: FL_DOWN_BOX
-colors: FL_COL1 FL_BLACK
-alignment: FL_ALIGN_LEFT
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Citation style
-shortcut: 
-resize: FL_RESIZE_X
-gravity: FL_NoGravity FL_NoGravity
-name: style
-callback: 
-argument: 
-
-==============================
---------------------
diff --git a/forms/form_url.fd b/forms/form_url.fd
deleted file mode 100644 (file)
index 916d90e..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-Magic: 13000
-
-Internal Form Definition File
-    (do not change)
-
-Number of forms: 1
-Unit of measure: FL_COORD_PIXEL
-
-=============== FORM ===============
-Name: form_url
-Width: 520
-Height: 140
-Number of Objects: 5
-
---------------------
-class: FL_BOX
-type: UP_BOX
-box: 0 0 520 140
-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_INPUT
-type: NORMAL_INPUT
-box: 70 20 440 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: URL
-shortcut: Url|#U
-resize: FL_RESIZE_X
-gravity: FL_NorthWest FL_NorthEast
-name: url_name
-callback: 
-argument: 
-
---------------------
-class: FL_INPUT
-type: NORMAL_INPUT
-box: 70 60 440 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: Name
-shortcut: Name|#N
-resize: FL_RESIZE_X
-gravity: FL_NorthWest FL_NorthEast
-name: name_name
-callback: 
-argument: 
-
---------------------
-class: FL_CHECKBUTTON
-type: PUSH_BUTTON
-box: 70 100 230 30
-boxtype: FL_NO_BOX
-colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: HTML type
-shortcut: HTML type|#H
-resize: FL_RESIZE_X
-gravity: FL_NorthWest FL_NorthEast
-name: radio_html
-callback: 
-argument: 
-
---------------------
-class: FL_BUTTON
-type: RETURN_BUTTON
-box: 410 100 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: Close|#C^[
-shortcut: ^M
-resize: FL_RESIZE_NONE
-gravity: FL_SouthEast FL_SouthEast
-name: button_close
-callback: C_InsetUrl_CloseUrlCB
-argument: 0
-
-==============================
-create_the_forms
index a2d1598dd73482513118d1f4e5b946f9e9121862..db7f810105bc157c97643b29ec8f393aae593910 100644 (file)
@@ -34,13 +34,9 @@ src/frontends/xforms/FormPreferences.C
 src/frontends/xforms/form_preferences.C
 src/frontends/xforms/FormPrint.C
 src/frontends/xforms/form_print.C
-src/frontends/xforms/forms/form_citation.C
-src/frontends/xforms/forms/form_copyright.C
-src/frontends/xforms/forms/form_preferences.C
-src/frontends/xforms/forms/form_print.C
-src/frontends/xforms/forms/form_tabular.C
 src/frontends/xforms/FormTabular.C
 src/frontends/xforms/form_tabular.C
+src/frontends/xforms/FormUrl.C
 src/frontends/xforms/Menubar_pimpl.C
 src/gettext.h
 src/insets/figinset.C
index 3cfdc03ece4ccdd76b829f33d582063361770ba7..cb9efd90d5c4ce1ae2adc75c2650dd207a0548e9 100644 (file)
@@ -957,7 +957,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                        inscmd.Read(this, lex);
                        Inset * inset = 0;
                        if (inscmd.getCmdName() == "cite") {
-                               inset = new InsetCitation(inscmd.getContents(), inscmd.getOptions());
+                               inset = new InsetCitation(inscmd.params());
                        } else if (inscmd.getCmdName() == "bibitem") {
                                lex.printError("Wrong place for bibitem");
                                inset = inscmd.Clone();
@@ -971,7 +971,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
                                inset = new InsetLabel(inscmd.getCommand());
                        } else if (inscmd.getCmdName() == "url"
                                   || inscmd.getCmdName() == "htmlurl") {
-                               inset = new InsetUrl(inscmd.getCommand());
+                               inset = new InsetUrl(inscmd.params());
                        } else if (inscmd.getCmdName() == "ref"
                                   || inscmd.getCmdName() == "pageref"
                                   || inscmd.getCmdName() == "vref"
@@ -1190,8 +1190,7 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par,
                inscmd.Read(this, lex);
                Inset * inset = 0;
                if (inscmd.getCmdName() == "cite") {
-                       inset = new InsetCitation(inscmd.getContents(),
-                                                 inscmd.getOptions());
+                       inset = new InsetCitation(inscmd.params());
                } else if (inscmd.getCmdName() == "bibitem") {
                        lex.printError("Wrong place for bibitem");
                        inset = inscmd.Clone();
@@ -1206,7 +1205,7 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par,
                        inset = new InsetLabel(inscmd.getCommand());
                } else if (inscmd.getCmdName() == "url"
                           || inscmd.getCmdName() == "htmlurl") {
-                       inset = new InsetUrl(inscmd.getCommand());
+                       inset = new InsetUrl(inscmd.params());
                } else if (inscmd.getCmdName() == "ref"
                           || inscmd.getCmdName() == "pageref"
                           || inscmd.getCmdName() == "vref"
index a49f13fdfca7f49be1c9edc83b552a8852da65e7..51fdc26a98d1199a9c77bd965bbc057390ca5962 100644 (file)
@@ -267,15 +267,11 @@ enum kb_action {
        LFUN_INSET_LIST,                // Lgb 20000627
        LFUN_INSET_THEOREM,             // Lgb 20000630
        LFUN_CREATE_CITATION,           // Angus 20000705
-       LFUN_INSET_CAPTION,            // Lgb 20000718
+       LFUN_INSET_CAPTION,             // Lgb 20000718
        LFUN_SWITCHBUFFER,  // and where is this comming from?
+       LFUN_INSERT_URL,                // Angus 20000726
        LFUN_LASTACTION  /* this marks the end of the table */
 };
 
 std::ostream & operator<<(std::ostream &, kb_action);
 #endif
-
-
-
-
-
index dfc27b8025554d631106eccc3f9d28a7cbec048d..0307595dc0462f7be3023f65ba3ee265b5e5a997 100644 (file)
@@ -7,7 +7,6 @@ _("Options|O");
 _("Documents|D");
 _("Help|H");
 _("File|F");
-_("File|F");
 _("Options|O");
 _("Help|H");
 _("New...|N");
index 07bd1b480ca78acc8c4629991694898ef4693d39..51885577004ac291c2b6c1aabbe1fbfd176d438f 100644 (file)
@@ -35,13 +35,14 @@ class DialogBase;
 // Maybe this should be a UIFunc modelled on LyXFunc
 class LyXView;
 
-class InsetInclude;
-class InsetIndex;
 class InsetBibKey;
-class InsetCitation;
 class InsetBibtex;
+class InsetCitation;
+class InsetInclude;
+class InsetIndex;
 class InsetInfo;
 class InsetTabular;
+class InsetUrl;
 
 /** Container of all dialogs and signals a LyXView needs or uses to access them
     The list of dialog signals isn't comprehensive but should be a good guide
@@ -113,6 +114,10 @@ public:
        ///
        Signal1<void, string const &> createCitation;
        ///
+       Signal1<void, InsetUrl *> showUrl;
+       ///
+       Signal1<void, string const &> createUrl;
+       ///
        Signal1<void, InsetBibtex *> showBibtex;
        ///
        Signal1<void, InsetInfo *> showInfo;
index c13f97bf9ffc15719276eb37a5f725b1330255a8..26b63a400873a57e8f05c00cc8080f1e37f0f2a5 100644 (file)
@@ -7,6 +7,7 @@
 #include "FormPreferences.h"
 #include "FormPrint.h"
 #include "FormTabular.h"
+#include "FormUrl.h"
 
 #ifdef __GNUG__
 #pragma implementation
@@ -20,6 +21,7 @@ Dialogs::Dialogs(LyXView * lv)
        dialogs_.push_back(new FormPreferences(lv, this));
        dialogs_.push_back(new FormPrint(lv, this));
        dialogs_.push_back(new FormTabular(lv, this));
+       dialogs_.push_back(new FormUrl(lv, this));
 
        // reduce the number of connections needed in
        // dialogs by a simple connection here.
index 941d5b4d5d0ca5485fb5c140853c387f17415b95..bd77914b85dbbfb2c10be9bcf3a58b6011e24740 100644 (file)
  */
 
 #include <config.h>
-#include <algorithm>
-
 #include "gettext.h"
 #include FORMS_H_LOCATION
-#include "xform_macros.h"
-#include "FormCitation.h"
+#include "BufferView.h"
 #include "Dialogs.h"
+#include "FormCitation.h"
 #include "LyXView.h"
+#include "buffer.h"
+#include "form_citation.h"
 #include "lyxfunc.h"
+#include "xform_macros.h"
 #include "insets/insetcite.h"
-#include "form_citation.h"
-#include "buffer.h"
-#include "BufferView.h"
 #include "support/filetools.h"
 
 #ifdef __GNUG__
@@ -41,7 +39,8 @@ C_GENERICCB(FormCitation, CancelCB)
 C_GENERICCB(FormCitation, InputCB)
 
 FormCitation::FormCitation(LyXView * lv, Dialogs * d)
-       : dialog_(0), lv_(lv), d_(d), h_(0), inset_(0), dialogIsOpen(false)
+       : dialog_(0), lv_(lv), d_(d), u_(0), h_(0), ih_(0),
+         inset_(0), dialogIsOpen(false)
 {
        // let the dialog be shown
        // These are permanent connections so we won't bother
@@ -59,7 +58,7 @@ FormCitation::~FormCitation()
 
 void FormCitation::build()
 {
-  dialog_ = build_citation();
+       dialog_ = build_citation();
 }
 
 
@@ -449,22 +448,23 @@ void FormCitation::apply()
 {
        if( lv_->buffer()->isReadonly() ) return;
 
-       string tmp;
+       string contents;
        for( unsigned int i = 0; i < citekeys.size(); ++i ) {
-               if (i > 0) tmp += ", ";
-               tmp += citekeys[i];
+               if (i > 0) contents += ", ";
+               contents += citekeys[i];
        }
 
        textAfter = fl_get_input(dialog_->textAftr);
 
        if( inset_ != 0 )
        {
-               inset_->setContents( tmp );
+               inset_->setContents( contents );
                inset_->setOptions( textAfter );
                lv_->view()->updateInset( inset_, true );
        } else {
-               string arg = tmp + '|' + textAfter;
-               lv_->getLyXFunc()->Dispatch( LFUN_INSERT_CITATION, arg.c_str() );
+               InsetCommandParams p( "cite", contents, textAfter );
+               lv_->getLyXFunc()->Dispatch( LFUN_INSERT_CITATION,
+                                            p.getAsString().c_str() );
        }
 }
 
index f230d20febcdc7244561b7b6e0c61c672865d200..3047dca4d31386356b9850b2945283966760c230 100644 (file)
@@ -67,7 +67,7 @@ private:
        void show();
        /// Hide the dialog.
        void hide();
-       /// Not used but we've got to implement it.
+       ///
        void update();
        //@}
 
diff --git a/src/frontends/xforms/FormUrl.C b/src/frontends/xforms/FormUrl.C
new file mode 100644 (file)
index 0000000..bceee12
--- /dev/null
@@ -0,0 +1,208 @@
+// -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2000 The LyX Team.
+ *
+ * ======================================================
+ */
+
+#include <config.h>
+#include "gettext.h"
+#include FORMS_H_LOCATION
+#include "BufferView.h"
+#include "Dialogs.h"
+#include "FormUrl.h"
+#include "LyXView.h"
+#include "buffer.h"
+#include "form_url.h"
+#include "lyxfunc.h"
+#include "xform_macros.h"
+#include "insets/insetcommand.h"
+#include "insets/inseturl.h"
+#include "support/filetools.h"
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+C_RETURNCB(FormUrl, WMHideCB)
+C_GENERICCB(FormUrl, OKCB)
+C_GENERICCB(FormUrl, CancelCB)
+
+FormUrl::FormUrl(LyXView * lv, Dialogs * d)
+       : dialog_(0), lv_(lv), d_(d), u_(0), h_(0), ih_(0),
+         inset_(0), dialogIsOpen(false)
+{
+       // let the dialog be shown
+       // These are permanent connections so we won't bother
+       // storing a copy because we won't be disconnecting.
+       d->showUrl.connect(slot(this, &FormUrl::showInset));
+       d->createUrl.connect(slot(this, &FormUrl::createInset));
+       params = new InsetCommandParams();
+}
+
+
+FormUrl::~FormUrl()
+{
+       free();
+       delete params;
+}
+
+
+void FormUrl::build()
+{
+       dialog_ = build_url();
+}
+
+
+void FormUrl::showInset( InsetUrl * inset )
+{
+       if( dialogIsOpen || inset == 0 ) return;
+
+       inset_ = inset;
+       ih_ = inset_->hide.connect(slot(this, &FormUrl::hide));
+
+       (*params) = inset->params();
+       show();
+}
+
+
+void FormUrl::createInset( string const & arg )
+{
+       if( dialogIsOpen ) return;
+
+       params->setFromString( arg );
+       show();
+}
+
+
+void FormUrl::show()
+{
+       if (!dialog_) {
+               build();
+               fl_set_form_atclose(dialog_->form_url,
+                                   C_FormUrlWMHideCB, 0);
+       }
+
+       update();  // make sure its up-to-date
+
+       dialogIsOpen = true;
+       if (dialog_->form_url->visible) {
+               fl_raise_form(dialog_->form_url);
+       } else {
+               fl_show_form(dialog_->form_url,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE,
+                            FL_TRANSIENT,
+                            _("Url"));
+               u_ = d_->updateBufferDependent.
+                        connect(slot(this, &FormUrl::update));
+               h_ = d_->hideBufferDependent.
+                        connect(slot(this, &FormUrl::hide));
+       }
+}
+
+
+void FormUrl::update()
+{
+       fl_set_input(dialog_->url,  params->getContents().c_str());
+       fl_set_input(dialog_->name, params->getOptions().c_str());
+
+       if ( params->getCmdName() == "url" )
+               fl_set_button(dialog_->radio_html, 0);
+       else
+               fl_set_button(dialog_->radio_html, 1);
+
+       static int ow = -1, oh;
+
+       if (ow < 0) {
+               ow = dialog_->form_url->w;
+               oh = dialog_->form_url->h;
+       }
+
+       fl_set_form_minsize(dialog_->form_url, ow, oh);
+       fl_set_form_maxsize(dialog_->form_url, 2*ow, oh);
+}
+
+
+void FormUrl::apply()
+{
+       if( lv_->buffer()->isReadonly() ) return;
+
+       params->setContents( fl_get_input(dialog_->url) );
+       params->setOptions( fl_get_input(dialog_->name) );
+
+       if (fl_get_button(dialog_->radio_html))
+               params->setCmdName("htmlurl");
+       else
+               params->setCmdName("url");
+
+       if( inset_ != 0 )
+       {
+               inset_->setParams( *params );
+               lv_->view()->updateInset( inset_, true );
+       } else {
+               lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL,
+                                            params->getAsString().c_str() );
+       }
+}
+
+
+void FormUrl::hide()
+{
+       if (dialog_
+           && dialog_->form_url
+           && dialog_->form_url->visible) {
+               fl_hide_form(dialog_->form_url);
+               u_.disconnect();
+               h_.disconnect();
+       }
+
+       // free up the dialog for another inset
+       inset_ = 0;
+       ih_.disconnect();
+       dialogIsOpen = false;
+}
+
+
+void FormUrl::free()
+{
+       // we don't need to delete u and h here because
+       // hide() does that after disconnecting.
+       if (dialog_) {
+               if (dialog_->form_url
+                   && dialog_->form_url->visible) {
+                       hide();
+               }
+               fl_free_form(dialog_->form_url);
+               delete dialog_;
+               dialog_ = 0;
+       }
+}
+
+
+int FormUrl::WMHideCB(FL_FORM * form, void *)
+{
+       // Ensure that the signals (u and h) are disconnected even if the
+       // window manager is used to close the dialog.
+       FormUrl * pre = static_cast<FormUrl*>(form->u_vdata);
+       pre->hide();
+       return FL_CANCEL;
+}
+
+
+void FormUrl::OKCB(FL_OBJECT * ob, long)
+{
+       FormUrl * pre = static_cast<FormUrl*>(ob->form->u_vdata);
+       pre->apply();
+       pre->hide();
+}
+
+
+void FormUrl::CancelCB(FL_OBJECT * ob, long)
+{
+       FormUrl * pre = static_cast<FormUrl*>(ob->form->u_vdata);
+       pre->hide();
+}
diff --git a/src/frontends/xforms/FormUrl.h b/src/frontends/xforms/FormUrl.h
new file mode 100644 (file)
index 0000000..b4a804d
--- /dev/null
@@ -0,0 +1,101 @@
+// -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2000 The LyX Team.
+ *
+ * ======================================================
+ */
+
+#ifndef FORMURL_H
+#define FORMURL_H
+
+#include "DialogBase.h"
+#include "LString.h"
+
+class Dialogs;
+class LyXView;
+class InsetCommandParams;
+class InsetUrl;
+struct FD_form_url;
+
+/** This class provides an XForms implementation of the FormUrl Dialog.
+ */
+class FormUrl : public DialogBase {
+public:
+       /**@name Constructors and Destructors */
+       //@{
+       ///
+       FormUrl(LyXView *, Dialogs *);
+       ///
+       ~FormUrl();
+       //@}
+
+       /**@name Real per-instance Callback Methods */
+       //@{
+       static  int WMHideCB(FL_FORM *, void *);
+       static void OKCB(FL_OBJECT *, long);
+       static void CancelCB(FL_OBJECT *, long);
+       //@}
+
+private:
+       FormUrl() {}
+       FormUrl(FormUrl &) : DialogBase() {}
+       
+       /**@name Slot Methods */
+       //@{
+       /// Create the dialog if necessary, update it and display it.
+       void createInset( string const & );
+       /// 
+       void showInset( InsetUrl * );
+       /// 
+       void show();
+       /// Hide the dialog.
+       void hide();
+       ///
+       void update();
+       //@}
+
+       /**@name Dialog internal methods */
+       //@{
+       /// Apply from dialog
+       void apply();
+       /// Build the dialog
+       void build();
+       ///
+       FD_form_url * build_url();
+       /// Explicitly free the dialog.
+       void free();
+       //@}
+
+       /**@name Private Data */
+       //@{
+       /// Real GUI implementation.
+       FD_form_url * dialog_;
+       /** Which LyXFunc do we use?
+           We could modify Dialogs to have a visible LyXFunc* instead and
+           save a couple of bytes per dialog.
+       */
+       LyXView * lv_;
+       /** Which Dialogs do we belong to?
+           Used so we can get at the signals we have to connect to.
+       */
+       Dialogs * d_;
+       /// Update connection.
+       Connection u_;
+       /// Hide connection.
+       Connection h_;
+       /// inset::hide connection.
+       Connection ih_;
+       ///
+       InsetUrl * inset_;
+       ///
+       bool dialogIsOpen;
+       ///
+       InsetCommandParams * params;
+       //@}
+};
+
+#endif
diff --git a/src/frontends/xforms/forms/form_url.fd b/src/frontends/xforms/forms/form_url.fd
new file mode 100644 (file)
index 0000000..bf8384b
--- /dev/null
@@ -0,0 +1,124 @@
+Magic: 13000
+
+Internal Form Definition File
+    (do not change)
+
+Number of forms: 1
+Unit of measure: FL_COORD_PIXEL
+
+=============== FORM ===============
+Name: form_url
+Width: 520
+Height: 140
+Number of Objects: 6
+
+--------------------
+class: FL_BOX
+type: UP_BOX
+box: 0 0 520 140
+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_INPUT
+type: NORMAL_INPUT
+box: 70 20 440 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: URL
+shortcut: Url|#U
+resize: FL_RESIZE_X
+gravity: FL_NorthWest FL_NorthEast
+name: url
+callback: 
+argument: 
+
+--------------------
+class: FL_INPUT
+type: NORMAL_INPUT
+box: 70 60 440 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: Name
+shortcut: Name|#N
+resize: FL_RESIZE_X
+gravity: FL_NorthWest FL_NorthEast
+name: name
+callback: 
+argument: 
+
+--------------------
+class: FL_CHECKBUTTON
+type: PUSH_BUTTON
+box: 70 100 230 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: HTML type
+shortcut: HTML type|#H
+resize: FL_RESIZE_X
+gravity: FL_NorthWest FL_NorthEast
+name: radio_html
+callback: 
+argument: 
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 410 100 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: Cancel
+shortcut: ^[
+resize: FL_RESIZE_NONE
+gravity: FL_SouthEast FL_SouthEast
+name: cancel
+callback: C_FormUrlCancelCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: RETURN_BUTTON
+box: 300 100 100 30
+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: OK
+shortcut: ^M
+resize: FL_RESIZE_ALL
+gravity: FL_SouthEast FL_SouthEast
+name: ok
+callback: C_FormUrlOKCB
+argument: 0
+
+==============================
+create_the_forms
index fc50cf26dda1c8ac227b97d4d258636057dcaeff..5fdde9b160ef4354611b0ee512cc997fc7a202aa 100644 (file)
@@ -23,7 +23,8 @@ SRCS := form_citation.fd \
        form_copyright.fd \
        form_preferences.fd \
        form_print.fd \
-       form_tabular.fd
+       form_tabular.fd \
+       form_url.fd
 
 
 OBJS := $(SRCS:.fd=.c)
index 0449bcb4d746c045ed305adf212786e166b96456..6eb6dc2ff4352170a4f65359b1602b80d9eed754 100644 (file)
@@ -14,8 +14,6 @@ libinsets_la_SOURCES = \
        figinset.h \
        form_graphics.C \
        form_graphics.h \
-       form_url.C \
-       form_url.h \
        inset.C \
        insetbib.C \
        insetbib.h \
index 7a72aeb96a2f383b98119901ad457602b77478e0..a2647612a27ff18bc74af909162b5487fe15e5d2 100644 (file)
@@ -350,10 +350,11 @@ void InsetBibtex::Edit(BufferView * bv, int, int, unsigned int)
 
 bool InsetBibtex::addDatabase(string const & db)
 {
-       if (!contains(getContents(), db.c_str())) {
-               if (!getContents().empty()) 
-                       addContents(",");
-               addContents(db);
+       string contents(getContents());
+       if (!contains(contents, db.c_str())) {
+               if (!contents.empty()) 
+                       contents += ",";
+               setContents(contents + db);
                return true;
        }
        return false;
index 9433e9764c7f342fe0f58ff22b711c3d6ab07b19..3b6304e41f7162f79e6b063cc6569a87affe5e6c 100644 (file)
@@ -20,8 +20,8 @@
 #include "frontends/Dialogs.h"
 #include "support/lstrings.h"
 
-InsetCitation::InsetCitation(string const & key, string const & note)
-               : InsetCommand("cite", key, note)
+InsetCitation::InsetCitation(InsetCommandParams const & p)
+               : InsetCommand(p)
 {}
 
 InsetCitation::~InsetCitation()
index bf2cd559b363f5595c4935d16584f5157d9d65c5..63789cf51e316303aa078938e44ccefa54d9b56d 100644 (file)
 #include "insetcommand.h"
 #include <sigc++/signal_system.h>
 
-class Dialogs;
-
 #ifdef SIGC_CXX_NAMESPACES
 using SigC::Signal0;
 #endif
 
-
 /** Used to insert citations  
  */
 class InsetCitation : public InsetCommand {
 public:
        ///
        explicit
-       InsetCitation(string const & key, string const & note = string());
+       InsetCitation(InsetCommandParams const &);
        ///
        ~InsetCitation();
        ///
-       Inset * Clone() const {
-               return new InsetCitation(getContents(), getOptions());
-       }
+       Inset * Clone() const { return new InsetCitation(params()); }
        ///
        string getScreenLabel() const;
        ///
index b5758e107c3cb8aee24f592f3abe4bed48ee511c..4beaec279c5a8948413e279660cdd4a374b1748f 100644 (file)
@@ -22,16 +22,67 @@ using std::ostream;
 using std::endl;
 
 
+InsetCommandParams::InsetCommandParams()
+{}
+
+
+InsetCommandParams::InsetCommandParams( string const & n,
+                                       string const & c,
+                                       string const & o )
+       : cmdname(n), contents(c), options(o)
+{}
+
+
+string InsetCommandParams::getAsString() const
+{
+       string b(cmdname);
+       b += "|++|" + options + "|++|" + contents;
+       return b;
+}
+
+
+void InsetCommandParams::setFromString( string const & b )
+{
+       string::size_type idx = b.find("|++|");
+       if( idx == string::npos ) return;
+
+       cmdname = b.substr(0, idx);
+       string tmp = b.substr(idx+4);
+
+       idx = tmp.find("|++|");
+       if( idx == string::npos ) {
+               options = tmp;
+       } else {
+               options  = tmp.substr(0, idx);
+               contents = tmp.substr(idx+4);
+       }
+}
+
+
 InsetCommand::InsetCommand()
 {}
 
 
-InsetCommand::InsetCommand(string const & cmd, string const & arg, 
-                          string const & opt)
-       : cmdname(cmd), options(opt), contents(arg)
+InsetCommand::InsetCommand( string const & n,
+                           string const & c, 
+                           string const & o )
+       : p_(n, c, o)
 {}
 
 
+InsetCommand::InsetCommand( InsetCommandParams const & p )
+       : p_( p.getCmdName(), p.getContents(), p.getOptions() )
+{}
+
+
+void InsetCommand::setParams(InsetCommandParams const & p )
+{
+       p_.setCmdName( p.getCmdName() );
+       p_.setContents( p.getContents() );
+       p_.setOptions( p.getOptions() );
+}
+
+
 // In lyxf3 this will be just LaTeX
 void InsetCommand::Write(Buffer const *, ostream & os) const
 {
@@ -88,10 +139,9 @@ void InsetCommand::scanCommand(string const & cmd)
        }
 
        // Don't mess with this.
-       if (!tcmdname.empty()) cmdname = tcmdname;
-       if (!toptions.empty()) options = toptions;
-       if (!tcontents.empty()) setContents(tcontents); 
-                       // setContents is overloaded in InsetInclude
+       if (!tcmdname.empty())  setCmdName( tcmdname );
+       if (!toptions.empty())  setOptions( toptions );
+       if (!tcontents.empty()) setContents( tcontents ); 
 
        if (lyxerr.debugging(Debug::PARSER))
                lyxerr << "Command <" <<  cmd
@@ -153,15 +203,15 @@ int InsetCommand::DocBook(Buffer const *, ostream &) const
 
 Inset * InsetCommand::Clone() const
 {
-       return new InsetCommand(cmdname, contents, options);
+       return new InsetCommand(getCmdName(), getContents(), getOptions());
 }
 
 
 string InsetCommand::getCommand() const
 {      
        string s;
-       if (!cmdname.empty()) s += "\\"+cmdname;
-       if (!options.empty()) s += "["+options+']';
-       s += "{"+contents+'}';
+       if (!getCmdName().empty()) s += "\\"+getCmdName();
+       if (!getOptions().empty()) s += "["+getOptions()+']';
+       s += "{"+getContents()+'}';
        return s;
 }
index 68c82a945eca708174b4cfc9f0a0132804757da1..e287d7929ffe1839e6fe58db4c97c7c3e69c0a11 100644 (file)
  * Similar to InsetLaTeX but having control of the basic structure of a
  *   LaTeX command: \name[options]{contents}. 
  */
+class InsetCommandParams {
+public:
+       ///
+       InsetCommandParams();
+       ///
+       explicit
+       InsetCommandParams( string const & n,
+                           string const & c = string(),
+                           string const & o = string());
+       ///
+       string const & getCmdName() const { return cmdname; }
+       ///
+       string const & getOptions() const { return options; }
+       ///
+       string const & getContents() const { return contents; }
+       ///
+       void setCmdName( string const & n ) { cmdname = n; }
+       ///
+       void setOptions(string const & o) { options = o; }
+       ///
+       void setContents(string const & c) { contents = c; }
+       ///
+       string getAsString() const;
+       ///
+       void setFromString( string const & );
+
+private:
+       ///    
+       string cmdname;
+       ///    
+       string contents;
+       ///    
+       string options;
+};
+
+
 class InsetCommand : public InsetButton {
 public:
        ///
        InsetCommand();
        ///
        explicit
-       InsetCommand(string const & name, string const & arg = string(), 
-                    string const & opt = string());
+       InsetCommand(string const & n,
+                    string const & c = string(), 
+                    string const & o = string());
+       ///
+       explicit
+       InsetCommand(InsetCommandParams const &);
        ///
        void Write(Buffer const *, std::ostream &) const;
 
@@ -62,48 +102,28 @@ public:
          confusion with lyxinset::getLabel(int), but I've seen that
          it wasn't. I hope you never confuse again both methods.  (ale)
         */
-       virtual string getScreenLabel() const
-       {
-               return getCommand();
-       }
-
+       virtual string getScreenLabel() const { return getCommand(); }
        /// Build the complete LaTeX command
        string getCommand() const;
        ///
-       string const & getCmdName() const {
-               return cmdname;
-       }
+       string const & getCmdName() const { return p_.getCmdName(); }
        ///
-       string const & getOptions() const {
-               return options;
-       }
+       string const & getOptions() const { return p_.getOptions(); }
        ///
-       string const & getContents() const {
-               return contents;
-       }
+       string const & getContents() const { return p_.getContents(); }
        ///
-       void setCmdName(string const & n) {
-               cmdname = n;
-       }
+       void setCmdName(string const & n) { p_.setCmdName(n); }
        ///
-       void setOptions(string const & o) {
-               options = o;
-       }
+       void setOptions(string const & o) { p_.setOptions(o); }
        ///
-       virtual void setContents(string const & c) {
-               contents = c;
-       }
+       void setContents(string const & c) { p_.setContents(c); }
        ///
-       void addContents(string const & c) {
-               contents += c;
-       }
+       InsetCommandParams const & params() const { return p_; }
+       ///
+       void setParams(InsetCommandParams const &);
 private:
-       ///    
-       string cmdname;
-       ///    
-       string options;
-       ///    
-       string contents;
+       ///
+       InsetCommandParams p_;
 };
 
 #endif
index 5d71ca7f455ab2706dc99bc8f249888bd1f0322c..1bd61134803d0a5331fa1b92e3c8972d57f8c2bd 100644 (file)
@@ -1,3 +1,4 @@
+
 #include <config.h>
 
 #include <cstdlib>
@@ -334,11 +335,16 @@ string InsetInclude::getScreenLabel() const
 }
 
 
-void InsetInclude::setContents(string const & c)
+string InsetInclude::getFileName() const
+{
+       return MakeAbsPath(getContents(), 
+                          OnlyPath(getMasterFilename()));
+}
+
+
+string InsetInclude::getMasterFilename() const
 {
-       InsetCommand::setContents(c);
-       filename = MakeAbsPath(getContents(), 
-                              OnlyPath(getMasterFilename())); 
+       return master->fileName();
 }
 
 
index 0adf74ca740fa4713bd87e772abb5d70fe51afa1..041e923cfef466c342a2df047f2068073d5748d5 100644 (file)
@@ -16,9 +16,8 @@
 #endif
 
 #include "insetcommand.h"
-#include "buffer.h"
-#include "support/filetools.h"
 
+class Buffer;
 struct LaTeXFeatures;
 
 // Created by AAS 970521
@@ -72,16 +71,11 @@ public:
        bool display() const;
        ///
        string getScreenLabel() const;
-       ///
-       void setContents(string const & c);
-        ///
-        void setFilename(string const & n) { setContents(n); }
         ///
-        string getMasterFilename() const { return master->fileName(); }
+        string getMasterFilename() const;
         ///
-        string getFileName() const { 
-               return filename;
-       }
+        string getFileName() const;
+
         ///  In "input" mode uses \input instead of \include.
        bool isInput() const { return flag == InsetInclude::INPUT; }
         ///  If this is true, the child file shouldn't be loaded by lyx
@@ -129,8 +123,6 @@ private:
         ///
        Buffer * master;
        ///
-       string filename;
-       ///
        mutable string include_label;
 };
 
index bb188b9075aed4fdabc99a40ac536cbdd362e39c..eb4b4cf250d69e4672a273f77d600e549a14ef0d 100644 (file)
 #include <config.h>
 
-#include <cstdlib>
-
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-#include FORMS_H_LOCATION 
 #include "inseturl.h"
-#include "LString.h"
-#include "commandtags.h"
-#include "debug.h"
-#include "gettext.h"
+#include "BufferView.h"
 #include "LaTeXFeatures.h"
-#include "lyx_gui_misc.h" // CancelCloseBoxCB
+#include "LyXView.h"
+#include "debug.h"
+#include "frontends/Dialogs.h"
 
 using std::ostream;
 
 
-InsetUrl::InsetUrl(string const & cmd)
-       : fd_form_url(0)
-{
-       scanCommand(cmd);
-       if (getCmdName() == "url")
-               flag = InsetUrl::URL;
-       else
-               flag = InsetUrl::HTML_URL;
-}
-
-
-InsetUrl::InsetUrl(InsetCommand const & inscmd)
-       : fd_form_url(0)
-{
-       setCmdName(inscmd.getCmdName());
-       setContents(inscmd.getContents());
-       setOptions(inscmd.getOptions());
-       if (getCmdName() == "url")
-               flag = InsetUrl::URL;
-       else
-               flag = InsetUrl::HTML_URL;
-}
-
-
-InsetUrl::InsetUrl(string const & ins_name, string const & ins_cont,
-                  string const & ins_opt)
-       : fd_form_url(0)
-{
-       setCmdName(ins_name);
-       setContents(ins_cont);
-       setOptions(ins_opt);
-       if (ins_name == "url")
-               flag = InsetUrl::URL;
-       else
-               flag = InsetUrl::HTML_URL;
-}
+InsetUrl::InsetUrl(InsetCommandParams const & p)
+               : InsetCommand(p)
+{}
 
 
 InsetUrl::~InsetUrl()
 {
-       if (fd_form_url) {
-               fl_hide_form(fd_form_url->form_url);
-               fl_free_form(fd_form_url->form_url);
-               fd_form_url = 0;
-       }
-}
-
-
-void InsetUrl::CloseUrlCB(FL_OBJECT * ob, long)
-{
-       Holder * holder = static_cast<Holder*>(ob->u_vdata);
-       
-       InsetUrl * inset = holder->inset;
-       BufferView * bv = holder->view;
-       
-       string url = fl_get_input(inset->fd_form_url->url_name);
-       string name = fl_get_input(inset->fd_form_url->name_name);
-       string cmdname;
-       if (fl_get_button(inset->fd_form_url->radio_html))
-               cmdname = "htmlurl";
-       else
-               cmdname = "url";
-       
-       Buffer * buffer = bv->buffer();
-       
-       if ((url != inset->getContents() ||
-            name != inset->getOptions() ||
-            cmdname != inset->getCmdName())
-           && !(buffer->isReadonly()) ) {
-               buffer->markDirty();
-               inset->setContents(url);
-               inset->setOptions(name);
-               inset->setCmdName(cmdname);
-               if (cmdname == "url")
-                       inset->flag = InsetUrl::URL;
-               else
-                       inset->flag = InsetUrl::HTML_URL;
-               bv->updateInset(inset, true);
-       }
-       
-       if (inset->fd_form_url) {
-               fl_hide_form(inset->fd_form_url->form_url);
-               fl_free_form(inset->fd_form_url->form_url);
-               inset->fd_form_url = 0;
-       }
-}
-
-
-extern "C"
-void C_InsetUrl_CloseUrlCB(FL_OBJECT * ob, long data)
-{
-       InsetUrl::CloseUrlCB(ob, data);
+       hide();
 }
 
 
@@ -121,57 +33,23 @@ char const * InsetUrl::EditMessage() const
 
 void InsetUrl::Edit(BufferView * bv, int, int, unsigned int)
 {
-       static int ow = -1, oh;
-
-       if(bv->buffer()->isReadonly())
-               WarnReadonly(bv->buffer()->fileName());
-
-       if (!fd_form_url) {
-               fd_form_url = create_form_form_url();
-               holder.inset = this;
-               fd_form_url->button_close->u_vdata = &holder;
-               fl_set_form_atclose(fd_form_url->form_url,
-                                   CancelCloseBoxCB, 0);
-       }
-       holder.view = bv;
-       fl_set_input(fd_form_url->url_name, getContents().c_str());
-       fl_set_input(fd_form_url->name_name, getOptions().c_str());
-       switch(flag) {
-       case InsetUrl::URL:
-               fl_set_button(fd_form_url->radio_html, 0);
-               break;
-       case InsetUrl::HTML_URL:
-               fl_set_button(fd_form_url->radio_html, 1);
-               break;
-       }
-       
-       if (fd_form_url->form_url->visible) {
-               fl_raise_form(fd_form_url->form_url);
-       } else {
-               fl_show_form(fd_form_url->form_url,
-                            FL_PLACE_MOUSE | FL_FREE_SIZE,
-                            FL_FULLBORDER, _("Insert Url"));
-               if (ow < 0) {
-                       ow = fd_form_url->form_url->w;
-                       oh = fd_form_url->form_url->h;
-               }
-               fl_set_form_minsize(fd_form_url->form_url, ow, oh);
-       }
+       bv->owner()->getDialogs()->showUrl( this );
 }
 
 
 string InsetUrl::getScreenLabel() const
 {
        string temp;
-       if (flag == InsetUrl::HTML_URL)
-               temp += _("HtmlUrl: ");
+       if( getCmdName() == "url" )
+               temp = _("Url: ");
        else 
-               temp += _("Url: ");
-       if(!getOptions().empty()) {
+               temp = _("HtmlUrl: ");
+
+       if(!getOptions().empty())
                temp += getOptions();
-       } else {
-         temp += getContents();
-       }
+       else
+               temp += getContents();
+
        return temp;
 }
 
index 3b4f1e8ade96c1159f2fadb66f213b75c00f223d..e76161e78057e5e8e9222b186301574e74eae5c2 100644 (file)
 #endif
 
 #include "insetcommand.h"
-#include "buffer.h"
-#include "form_url.h"
+#include <sigc++/signal_system.h>
 
 struct LaTeXFeatures;
 
+#ifdef SIGC_CXX_NAMESPACES
+using SigC::Signal0;
+#endif
+
 /** The url inset  
  */
 class InsetUrl : public InsetCommand {
 public:
-        ///
-        enum Url_Flags {
-               ///
-               URL,
-               ///
-               HTML_URL
-       };
-       
-       ///
-       InsetUrl() : InsetCommand("url"), fd_form_url(0) {
-               flag = InsetUrl::URL;
-       }
-       ///
-       explicit
-       InsetUrl(string const &);
        ///
        explicit
-       InsetUrl(InsetCommand const &);
-       ///
-       InsetUrl(string const &, string const &, string const &);
+       InsetUrl(InsetCommandParams const &);
        ///
        ~InsetUrl();
         ///
-        Inset * Clone() const { return new InsetUrl(getCommand()); }
+       Inset * Clone() const { return new InsetUrl(params()); }
        ///
        Inset::Code LyxCode() const { return Inset::URL_CODE; }
        ///
        void Validate(LaTeXFeatures &) const;
        ///
-       void Edit(BufferView *, int, int, unsigned int);
+       string getScreenLabel() const;
        ///
-       EDITABLE Editable() const {
-               return IS_EDITABLE;
-       }
+       EDITABLE Editable() const { return IS_EDITABLE; }
        ///
        char const * EditMessage() const;
-        ///
-       bool display() const { return false; }
-       ///
-       string getScreenLabel() const;
        ///
-       InsetUrl::Url_Flags getFlag() const { return flag; }
-       ///
-       void setFlag(InsetUrl::Url_Flags f) { flag = f; }
+       void Edit(BufferView *, int, int, unsigned int);
         ///
-        void gotoLabel();
+       bool display() const { return false; }
        ///
        int Latex(Buffer const *, std::ostream &,
                  bool fragile, bool free_spc) const;
@@ -81,20 +59,7 @@ public:
        ///
        int DocBook(Buffer const *, std::ostream &) const;
        ///
-       static void CloseUrlCB(FL_OBJECT *, long data);
-private:
-       ///
-       struct Holder {
-               InsetUrl * inset;
-               BufferView * view;
-       };
-       ///
-       Holder holder;
-       
-       ///
-        Url_Flags flag;
-       ///
-        FD_form_url * fd_form_url;
+       Signal0<void> hide;
 };
 
 #endif
index 9e184257cb159e3ae977625027f5500e07f4fdb9..c7121450d88b78100481bbffb3421c8a749d1eed 100644 (file)
@@ -2071,18 +2071,28 @@ string LyXFunc::Dispatch(int ac,
        case LFUN_HTMLURL:
        case LFUN_URL:
        {
-               InsetCommand * new_inset;
+               InsetCommandParams p;
                if (action == LFUN_HTMLURL)
-                       new_inset = new InsetUrl("htmlurl", "", "");
+                       p.setCmdName("htmlurl");
                else
-                       new_inset = new InsetUrl("url", "", "");
-               if (owner->view()->insertInset(new_inset))
-                       new_inset->Edit(owner->view(), 0, 0, 0);
+                       p.setCmdName("url");
+               owner->getDialogs()->createUrl( p.getAsString() );
+       }
+       break;
+                   
+       case LFUN_INSERT_URL:
+       {
+               InsetCommandParams p;
+               p.setFromString( argument );
+
+               InsetUrl * inset = new InsetUrl( p );
+               if (!owner->view()->insertInset(inset))
+                       delete inset;
                else
-                       delete new_inset;
+                       owner->view()->updateInset( inset, true );
        }
        break;
-       
+                   
        case LFUN_INSET_TEXT:
        {
                InsetText * new_inset = new InsetText;
@@ -2493,10 +2503,10 @@ string LyXFunc::Dispatch(int ac,
                    
        case LFUN_INSERT_CITATION:
        {
-               string keys = token(argument, '|', 0);
-               string text = token(argument, '|', 1);
+               InsetCommandParams p;
+               p.setFromString( argument );
 
-               InsetCitation * inset = new InsetCitation( keys, text );
+               InsetCitation * inset = new InsetCitation( p );
                if (!owner->view()->insertInset(inset))
                        delete inset;
                else
index 3f94aeb4fa73f17dc0936e0fbe95b5561e79fb07..a64c5d1f873adedbf471f7f9ec7e55991487d4ad 100644 (file)
@@ -23,6 +23,7 @@
 #include "lyxrc.h"
 #include "layout.h"
 #include "tex-strings.h"
+#include "buffer.h"
 #include "bufferparams.h"
 #include "support/FileInfo.h"
 #include "support/LAssert.h"