]> git.lyx.org Git - lyx.git/commitdiff
changes read the dirr and changelog, something should be remvoed/changed
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 8 Nov 2000 09:39:46 +0000 (09:39 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 8 Nov 2000 09:39:46 +0000 (09:39 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1205 a592a061-630c-0410-9148-cb99ea01b6c8

54 files changed:
ChangeLog
configure.in
po/POTFILES.in
src/LaTeX.C
src/LaTeXLog.C
src/LyXSendto.C
src/buffer.C
src/converter.C
src/converter.h
src/credits.C
src/filedlg.C
src/frontends/ButtonPolicies.C
src/frontends/ButtonPolicies.h
src/frontends/xforms/ButtonController.C [new file with mode: 0644]
src/frontends/xforms/ButtonController.h
src/frontends/xforms/Dialogs.C
src/frontends/xforms/FormBase.C
src/frontends/xforms/FormBase.h
src/frontends/xforms/FormDocument.C
src/frontends/xforms/FormError.C
src/frontends/xforms/FormError.h
src/frontends/xforms/FormGraphics.C
src/frontends/xforms/FormGraphics.h
src/frontends/xforms/FormPreferences.C
src/frontends/xforms/FormPreferences.h
src/frontends/xforms/Makefile.am
src/frontends/xforms/form_preferences.C
src/frontends/xforms/form_preferences.h
src/frontends/xforms/input_validators.c
src/graphics/GraphicsCacheItem_pimpl.C
src/insets/ExternalTemplate.C
src/insets/figinset.C
src/insets/insetbib.C
src/insets/insetexternal.C
src/insets/insetinclude.C
src/insets/insetinfo.C
src/intl.C
src/lyx_cb.C
src/lyx_gui_misc.C
src/lyx_gui_misc.h
src/lyx_sendfax_main.C
src/lyxfr0.C
src/lyxvc.C
src/mathed/math_panel.C
src/os2_defines.h
src/spellchecker.C
src/support/Makefile.am
src/support/filetools.C
src/support/filetools.h
src/support/getcwd.C
src/support/lyxlib.h
src/support/path.h
src/support/tempname.C [new file with mode: 0644]
src/vc-backend.C

index d9348d306517987b4d709ce3b69ebbc1381633e2..31aa95c7c51711c6581794a3db9e234ba9cbdde0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,134 @@
+2000-11-08  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * src/support/filetools.C (DirList): implement using system functions
+
+       * src/support/tempname.C: new file
+
+       * src/support/Makefile.am (libsupport_la_SOURCES): add tempname.C
+
+       * src/insets/insetexternal.C (InsetExternal): use lyx::tempName
+
+       * src/graphics/GraphicsCacheItem_pimpl.C (renderXPM): use
+       lyx::tempName 
+
+       * src/frontends/xforms/ButtonController.C: new file
+
+       * src/os2_defines.h: remove getcwd define
+
+       * src/lyxvc.C: include support/lyxlib.h
+       (showLog): use lyx::tempName
+
+       * src/lyx_cb.C: comment out includes that we don't need
+       (AutoSave): use lyx::tempName
+
+       * src/filedlg.C: include support/lyxlib.h
+       (Reread): use lyx::getcwd
+
+       * src/converter.C: include support/filetools.h
+       (add_options): change to static inline, make tail const
+       (Add): make old_viewer const
+       (GetAllFormats): make it a const method, use const_iterator
+       (enable): make static inline
+       (SplitFormat): make using_format const
+
+       * src/LaTeX.C (run): use lyx::getcwd
+
+       * configure.in: check for mkstemp as well 
+
+2000-11-07  Angus Leeming <a.leeming@ic.ac.uk>
+
+       * src/converter.[Ch] (GetAllCommands): new method.
+
+       * src/support/filetools.[Ch] (DirList): new method.
+
+       * src/frontends/xforms/FormPreferences.C: started (just!) adding
+       functionality to the converters tab.
+       The formats tab is now nearly complete.
+       The kbmap choices in Languages tab now display the contents of
+       system_lyxdir/kbd/*.kmap in readable form.
+
+       * src/frontends/xforms/FormPreferences.h: made struct RGB private.
+       Moved some variables into the class.
+
+       * src/frontends/xforms/forms/form_preferences.fd: Revert colour of
+       inactive tab folder to FL_COL1. Haven't yet worked out how to change
+       colour of active folder to lighter grey instead. Any takers?
+       (form_colours): added an "Apply" button.
+       (form_converters): added a "Flags" input field.
+       (form_formats): added a "Shortcut" input field. Note that we can't use
+       names such as "input_shortcut" as this buggers up the sed script stuff.
+
+       * src/frontends/xforms/FormPreferences.C
+                                     
+2000-11-07  Angus Leeming <a.leeming@ic.ac.uk>
+
+       * src/LaTeXLog.C:
+       * src/LyXSendto.C:
+       * src/credits.C:
+       * src/filedlg.C:
+       * src/intl.C:
+       * src/lyx_cb.C:
+       * src/lyx_sendfax_main.C:
+       * src/lyxfr0.C:
+       * src/lyxvc.C:
+       * src/spellchecker.C:
+       * src/insets/figinset.C:
+       * src/insets/insetbib.C:
+       * src/insets/insetexternal.C:
+       * src/insets/insetinclude.C:
+       * src/insets/insetinfo.C:
+       * src/mathed/math_panel.C:
+       use FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT in fl_show_form(), so
+       all "daughter" dialogs now have identical "feel".
+                                
+2000-11-07  Angus Leeming <a.leeming@ic.ac.uk>
+
+       * src/lyx_gui_misc.[Ch] (IgnoreCloseBoxCB): removed as it's no longer
+       used (and was only used in one place prior to this patch. Incorrectly!)
+
+       * src/frontends/xforms/FormDocument.C: changed some instances of
+       FL_RETURN_ALWAYS to FL_RETURN_CHANGED as I think that this makes more
+       sense. Also added fl_set_input_return() for class_->input_doc_extra and
+       for options_->input_float_placement. This fixes a bug reported by
+       Rob Lahaye.
+
+       * src/frontends/xforms/FormGraphics.[Ch] (free): removed. Placed
+       functionality into d-tor.
+
+       * src/frontends/xforms/input_validators.c (fl_lowercase_filter): allow
+       input of numerals also.
+
+       * src/insets/insetinclude.C (Edit): use CancelCloseBoxCB in
+       fl_set_form_atclose(). Can now close dialog from window manager,
+       fixing a bug reported by Rob Lahaye.
+
+2000-11-06  Angus Leeming <a.leeming@ic.ac.uk>
+
+       * src/frontends/xforms/forms/form_preferences.fd: Inactive tab folders
+       are no longer dark. Haven't yet worked out how to lighten the colour of
+       the active tabfolder. Any ideas anybody?
+       Adjusted Colours tab a little.
+       Added Shortcut field to converters tab. Note that we can't create an
+       fdesign label like "input_shortcut" as this buggers up the sed-script
+       stuff.
+
+       * src/frontends/xforms/FormPreferences.[Ch]:
+       (feedback): fixed crash due to to ob=0.
+       (LanguagesXXX): the kbmap choices now contain the files
+       sytem_lyxdir/kbd/*.kmap. I think that these choices should eventually
+       be replaced by an input with a file browse button, but since the browse
+       buttons don'y yet work, this'll do for the moment.
+       (FormatsXXX): think that this is now nearly fully functional.
+       Some points/questions though:
+       1. Does "Apply" remove formats if no longer present?
+       2. I think that the browser should list the GUI names rather than the
+          format names.
+       3. Must ensure that we can't delete Formats used by an existing
+          Converter.
+
+       * src/support/filetools.[Ch] (DirList): new function. Not at all sure
+       if this is the best way to do this.
+                                                       
 2000-11-07  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * lib/reLyX/acinclude.m4 (RELYX_CHECK_ERRORS): remove useless message.
index c525a93a931b1449b4e581acd42ee5cecac23677..10410de357393b7f5c59150330aadb3c9581fe95 100644 (file)
@@ -252,6 +252,7 @@ if test "x$lyx_broken_headers" = "xyes"; then
     [Define on SunOS 4 and SCO, were some functions are missing from the headers])
 fi
 AC_CHECK_FUNCS(memmove memset strchr putenv setenv mkfifo snprintf vsnprintf)
+AC_CHECK_FUNCS(mkstemp)
 
 dnl Until this is fixed in autoconf we provide our own version
 LYX_FUNC_SELECT_ARGTYPES
index cfcf30161702ce831e6a246162c5ebeb468f4f14..d18943019e80b3f29bea47097260ae46c3037269 100644 (file)
@@ -47,35 +47,35 @@ src/frontends/kde/refdlg.C
 src/frontends/kde/tocdlg.C
 src/frontends/kde/urldlg.C
 src/frontends/xforms/FormBase.h
-src/frontends/xforms/FormCitation.C
 src/frontends/xforms/form_citation.C
-src/frontends/xforms/FormCopyright.C
+src/frontends/xforms/FormCitation.C
 src/frontends/xforms/form_copyright.C
-src/frontends/xforms/FormDocument.C
+src/frontends/xforms/FormCopyright.C
 src/frontends/xforms/form_document.C
-src/frontends/xforms/FormError.C
+src/frontends/xforms/FormDocument.C
 src/frontends/xforms/form_error.C
-src/frontends/xforms/FormGraphics.C
+src/frontends/xforms/FormError.C
 src/frontends/xforms/form_graphics.C
-src/frontends/xforms/FormIndex.C
+src/frontends/xforms/FormGraphics.C
 src/frontends/xforms/form_index.C
+src/frontends/xforms/FormIndex.C
 src/frontends/xforms/FormInset.h
-src/frontends/xforms/FormParagraph.C
 src/frontends/xforms/form_paragraph.C
-src/frontends/xforms/FormPreferences.C
+src/frontends/xforms/FormParagraph.C
 src/frontends/xforms/form_preferences.C
-src/frontends/xforms/FormPrint.C
+src/frontends/xforms/FormPreferences.C
 src/frontends/xforms/form_print.C
-src/frontends/xforms/FormRef.C
+src/frontends/xforms/FormPrint.C
 src/frontends/xforms/form_ref.C
-src/frontends/xforms/FormTabular.C
+src/frontends/xforms/FormRef.C
 src/frontends/xforms/form_tabular.C
-src/frontends/xforms/FormTabularCreate.C
+src/frontends/xforms/FormTabular.C
 src/frontends/xforms/form_tabular_create.C
-src/frontends/xforms/FormToc.C
+src/frontends/xforms/FormTabularCreate.C
 src/frontends/xforms/form_toc.C
-src/frontends/xforms/FormUrl.C
+src/frontends/xforms/FormToc.C
 src/frontends/xforms/form_url.C
+src/frontends/xforms/FormUrl.C
 src/frontends/xforms/Menubar_pimpl.C
 src/gettext.h
 src/importer.C
index 0db816277c23a06a85ef02e66c76abf9da97c6f0..deaffae9ce38a8d3797dc60db20e55966f1d7e65 100644 (file)
@@ -119,7 +119,7 @@ int LaTeX::run(TeXErrors & terr, MiniBuffer * minib)
        bool rerun = false; // rerun requested
        
        // The class LaTeX does not know the temp path.
-       bufferlist.updateIncludedTeXfiles(GetCWD());
+       bufferlist.updateIncludedTeXfiles(lyx::getcwd()); //GetCWD());
        
        // Never write the depfile if an error was encountered.
        
index a791546c5a02e039c6c59314d8c8e5cf07421b8a..f53b6719a51f62bb7bfbe6eb26fdf1a44627031b 100644 (file)
@@ -50,7 +50,7 @@ void ShowLatexLog()
                fl_raise_form(fd_latex_log->LaTeXLog);
        } else {
                fl_show_form(fd_latex_log->LaTeXLog,
-                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             use_build ? _("Build Program Log") : _("LaTeX Log"));
                if (ow < 0) {
                        ow = fd_latex_log->LaTeXLog->w;
index 5e7587c35da3595b418a5b483e8e81598260c243..881ad276eb148cc2b4a2f4fe37e04e4937652702 100644 (file)
@@ -36,7 +36,7 @@ void MenuSendto()
         fl_raise_form(fd_form_sendto->form_sendto);
     } else {  
         fl_show_form(fd_form_sendto->form_sendto,
-                     FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+                    FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                      _("Send Document to Command"));
        if (ow < 0) {
                ow = fd_form_sendto->form_sendto->w;
index 74c7d6eb5842e4bd6ba3726bd62cb4c4bbda1fcf..62750128c60941c70bda4896eb53bf3539415296 100644 (file)
@@ -1289,7 +1289,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
                return;
        }
 
-       string const fname1 = TmpFileName();
+       string const fname1 = lyx::tempName(); //TmpFileName();
        LyXParagraph * par = paragraph;
        while (par) {
                int noparbreak = 0;
index ac91f7cf7f3039ad8e0469ad8c557481d4af00c3..75d1808f4c00be036d9c7ed59a990a06133088fd 100644 (file)
@@ -20,6 +20,7 @@
 #include "lyxrc.h"
 #include "support/syscall.h"
 #include "support/path.h"
+#include "support/filetools.h"
 #include "buffer.h"
 #include "bufferview_funcs.h"
 #include "LaTeX.h"
@@ -41,11 +42,11 @@ using std::find_if;
 vector<Command> Converter::commands;
 string Converter::latex_command;
 
-inline
+static inline
 string const add_options(string const & command, string const & options)
 {
        string head;
-       string tail = split(command, head, ' ');
+       string const tail = split(command, head, ' ');
        return head + ' ' + options + ' ' + tail;
 }
 
@@ -76,7 +77,7 @@ void Formats::Add(string const & name, string const & extension,
                return;
        }
 
-       string old_viewer = formats[name].viewer;
+       string const old_viewer = formats[name].viewer;
        formats[name] = Format(name, extension, prettyname, shortcut,
                               old_viewer);
 }
@@ -137,6 +138,8 @@ bool Formats::View(Buffer const * buffer, string const & filename,
 }
 
 
+// This method should return a reference, and throw an exception
+// if the format named name cannot be found (Lgb)
 Format * Formats::GetFormat(string const & name)
 {
        FormatList::iterator it = formats.find(name);
@@ -168,18 +171,20 @@ string const Formats::Extension(string const & name)
 
 
 vector<Format> 
-const Formats::GetAllFormats()
+const Formats::GetAllFormats() const
 {
        vector<Format> result;
-       for (FormatList::iterator it = formats.begin(); 
-            it != formats.end(); ++it)
-               result.push_back(it->second);
+       for (FormatList::const_iterator cit = formats.begin(); 
+            cit != formats.end(); ++cit)
+               result.push_back(cit->second);
        return result;
 }
 
 
 //////////////////////////////////////////////////////////////////////////////
 
+// Instead of storing an object we could just store an const reference.
+// _but_ that is not guaranteed to work in all cases. (Lgb)
 class compare_Command {
 public:
        compare_Command(Command const & c) : com(c) {}
@@ -262,7 +267,7 @@ void Converter::Add(string const & from, string const & to,
 }
 
 
-inline
+static inline
 bool enable(vector<Command>::iterator it, string const & from)
 {
        return find(it->disable.begin(), it->disable.end(), from)
@@ -575,7 +580,7 @@ bool Converter::Convert(Buffer const * buffer,
 
 string const Converter::SplitFormat(string const & str, string & format)
 {
-       string using_format = split(str, format, ':');
+       string const using_format = split(str, format, ':');
        if (format.empty())
                format = "dvi";
        return using_format;
@@ -778,6 +783,16 @@ void Converter::init()
 {
 }
 
+vector<Command> const Converter::GetAllCommands()
+{
+       vector<Command> result;
+       for (vector<Command>::iterator it = commands.begin(); 
+            it != commands.end(); ++it)
+               result.push_back(*it);
+       return result;
+}
+
+
 /// The global instance
 Formats formats;
 
index 37ac7d5ca56965916720960c161b503696783527..fc84a7550d4af08f3ded1d9fbab8d6209a321935 100644 (file)
@@ -122,7 +122,7 @@ public:
        ///
        string const Extension(string const & name);
        ///
-       std::vector<Format> const GetAllFormats();
+       std::vector<Format> const GetAllFormats() const;
 private:
        ///
        FormatList formats;
@@ -169,6 +169,9 @@ public:
        ///
        static
        void init();
+       ///
+       static
+       std::vector<Command> const GetAllCommands();
 private:
        ///
        static
index 430e56c580ecec7ee4f2ad0541f316215fdca568..0bbb361a9588a083e39bfa932af72487f7b01133 100644 (file)
@@ -67,7 +67,7 @@ void ShowCredits()
                fl_raise_form(fd_form_credits->form_credits);
        } else {
                fl_show_form(fd_form_credits->form_credits,
-                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("Credits"));
        }
 }
index 97c78aee49520e0a6f49cbca715c3c5486d8a3d2..4c4d5adc7ae34097564b763011e88f452b4c18f8 100644 (file)
@@ -24,6 +24,7 @@ using std::sort;
 
 #include "lyx_gui_misc.h" // CancelCloseCB
 #include "support/FileInfo.h"
+#include "support/lyxlib.h"
 #include "gettext.h"
 
 #ifdef HAVE_ERRNO_H
@@ -190,7 +191,7 @@ void LyXFileDlg::Reread()
        if (!pDirectory) {
                WriteFSAlert(_("Warning! Couldn't open directory."), 
                             pszDirectory);
-               pszDirectory = GetCWD();
+               pszDirectory = lyx::getcwd(); //GetCWD();
                pDirectory = ::opendir(pszDirectory.c_str());
        }
 
@@ -700,8 +701,9 @@ string const LyXFileDlg::Select(string const & title, string const & path,
        fl_set_button(pFileDlgForm->Ready, 0);
        fl_set_focus_object(pFileDlgForm->FileDlg, pFileDlgForm->Filename);
        fl_deactivate_all_forms();
-       fl_show_form(pFileDlgForm->FileDlg, FL_PLACE_MOUSE | FL_FREE_SIZE,
-                    FL_FULLBORDER, title.c_str());
+       fl_show_form(pFileDlgForm->FileDlg, 
+                    FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+                    title.c_str());
 
        isOk = RunDialog();
        
index fcb15da1bc2d367b1e4d0937258e6f7cddc8a692..23812b42c1cfc1176d1822c8612bd36935e51aba 100644 (file)
@@ -98,6 +98,7 @@ PreferencesPolicy::PreferencesPolicy()
 
 void PreferencesPolicy::input(SMInput input)
 {
+       lyxerr << "PreferencesPolicy::input" << endl;
        // CANCEL and HIDE always take us to INITIAL for all cases.
        // Note that I didn't put that special case in the helper function
        // because it doesn't belong there.  Some other 
@@ -159,6 +160,8 @@ OkCancelPolicy::OkCancelPolicy()
 
 void OkCancelPolicy::input(SMInput input)
 {
+       lyxerr << "OkCancelPolicy::input" << endl;
+       
        // CANCEL and HIDE always take us to INITIAL for all cases
        if (SMI_CANCEL == input
            || SMI_HIDE == input) {
@@ -231,6 +234,8 @@ OkCancelReadOnlyPolicy::OkCancelReadOnlyPolicy()
 
 void OkCancelReadOnlyPolicy::input(SMInput input)
 {
+       lyxerr << "OkCancelReadOnlyPolicy" << endl;
+       
        // CANCEL and HIDE always take us to INITIAL for all cases
        if (SMI_CANCEL == input
            || SMI_HIDE == input) {
@@ -307,6 +312,8 @@ NoRepeatedApplyReadOnlyPolicy::NoRepeatedApplyReadOnlyPolicy()
 
 void NoRepeatedApplyReadOnlyPolicy::input(SMInput input)
 {
+       lyxerr << "NoReapeatedApplyReadOnlyPolicy::input" << endl;
+       
        // CANCEL and HIDE always take us to INITIAL for all cases
        if (SMI_CANCEL == input
            || SMI_HIDE == input) {
@@ -397,6 +404,8 @@ OkApplyCancelReadOnlyPolicy::OkApplyCancelReadOnlyPolicy()
 
 void OkApplyCancelReadOnlyPolicy::input(SMInput input)
 {
+       lyxerr << "OkApplyCancelReadOnlyPolicy::input" << endl;
+       
        // CANCEL and HIDE always take us to INITIAL for all cases
        if (SMI_CANCEL == input
            || SMI_HIDE == input) {
@@ -461,6 +470,8 @@ OkApplyCancelPolicy::OkApplyCancelPolicy()
 
 void OkApplyCancelPolicy::input(SMInput input)
 {
+       lyxerr << "OkApplyCancelPolicy::input" << endl;
+       
        // CANCEL and HIDE always take us to INITIAL for all cases
        if (SMI_CANCEL == input
            || SMI_HIDE == input) {
@@ -517,6 +528,8 @@ NoRepeatedApplyPolicy::NoRepeatedApplyPolicy()
 
 void NoRepeatedApplyPolicy::input(SMInput input)
 {
+       lyxerr << "NoRepeatedApplyPolicy::input" << endl;
+       
        // CANCEL and HIDE always take us to INITIAL for all cases
        if (SMI_CANCEL == input
            || SMI_HIDE == input) {
index 45a12769ae03cdc24397b627be1618f9fe971563..a552917fcef5073cd8104df4a45559fa02598ae4 100644 (file)
@@ -189,7 +189,7 @@ public:
        ///
        OkCancelPolicy();
        ///
-       virtual ~OkCancelPolicy() {}
+       //virtual ~OkCancelPolicy() {}
        
        /// Trigger a transition with this input.
        virtual void input(SMInput);
@@ -231,7 +231,7 @@ public:
        ///
        OkCancelReadOnlyPolicy();
        ///
-       virtual ~OkCancelReadOnlyPolicy() {}
+       //virtual ~OkCancelReadOnlyPolicy() {}
        
        /// Trigger a transition with this input.
        virtual void input(SMInput);
@@ -275,7 +275,7 @@ public:
        ///
        NoRepeatedApplyReadOnlyPolicy();
        ///
-       virtual ~NoRepeatedApplyReadOnlyPolicy() {}
+       //virtual ~NoRepeatedApplyReadOnlyPolicy() {}
        
        /// Trigger a transition with this input.
        virtual void input(SMInput);
@@ -316,7 +316,7 @@ public:
        ///
        OkApplyCancelReadOnlyPolicy();
        ///
-       virtual ~OkApplyCancelReadOnlyPolicy() {}
+       //virtual ~OkApplyCancelReadOnlyPolicy() {}
        
        /// Trigger a transition with this input.
        virtual void input(SMInput);
@@ -351,7 +351,7 @@ public:
        ///
        OkApplyCancelPolicy();
        ///
-       virtual ~OkApplyCancelPolicy() {}
+       //virtual ~OkApplyCancelPolicy() {}
        
        /// Trigger a transition with this input.
        virtual void input(SMInput);
@@ -383,7 +383,7 @@ public:
        ///
        NoRepeatedApplyPolicy();
        ///
-       virtual ~NoRepeatedApplyPolicy() {}
+       //virtual ~NoRepeatedApplyPolicy() {}
        
        /// Trigger a transition with this input.
        virtual void input(SMInput);
@@ -416,7 +416,7 @@ public:
        ///
        PreferencesPolicy();
        ///
-       virtual ~PreferencesPolicy() {}
+       //virtual ~PreferencesPolicy() {}
        
        /// Trigger a transition with this input.
        virtual void input(SMInput);
@@ -446,7 +446,7 @@ private:
  */
 class IgnorantPolicy : public ButtonPolicy {
 public:
-       virtual ~IgnorantPolicy() {}
+       //virtual ~IgnorantPolicy() {}
        
        /// Trigger a transition with this input.
        virtual void input(SMInput) {}
diff --git a/src/frontends/xforms/ButtonController.C b/src/frontends/xforms/ButtonController.C
new file mode 100644 (file)
index 0000000..e79abaa
--- /dev/null
@@ -0,0 +1,157 @@
+#include <config.h>
+
+#include FORMS_H_LOCATION
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "ButtonController.h"
+#include "support/LAssert.h"
+
+
+ButtonController::ButtonController(ButtonPolicy * bp,
+                                  char const * cancel, char const * close)
+       : bp_(bp), okay_(0), apply_(0), cancel_(0), undo_all_(0),
+         read_only_(), cancel_label(cancel), close_label(close)
+{
+       Assert(bp);
+}
+
+
+void ButtonController::refresh()
+{
+       if (okay_) {
+               if (bp_->buttonStatus(ButtonPolicy::OKAY)) {
+                       fl_activate_object(okay_);
+                       fl_set_object_lcol(okay_, FL_BLACK);
+               } else {
+                       fl_deactivate_object(okay_);
+                       fl_set_object_lcol(okay_, FL_INACTIVE);
+               }
+       }
+       if (apply_) {
+               if (bp_->buttonStatus(ButtonPolicy::APPLY)) {
+                       fl_activate_object(apply_);
+                       fl_set_object_lcol(apply_, FL_BLACK);
+               } else {
+                       fl_deactivate_object(apply_);
+                       fl_set_object_lcol(apply_, FL_INACTIVE);
+               }
+       }
+       if (undo_all_) {
+               if (bp_->buttonStatus(ButtonPolicy::UNDO_ALL)) {
+                       fl_activate_object(undo_all_);
+                       fl_set_object_lcol(undo_all_, FL_BLACK);
+               } else {
+                       fl_deactivate_object(undo_all_);
+                       fl_set_object_lcol(undo_all_,
+                                          FL_INACTIVE);
+               }
+       }
+       if (cancel_) {
+               if (bp_->buttonStatus(ButtonPolicy::CANCEL)) {
+                       fl_set_object_label(cancel_,
+                                           cancel_label);
+               } else {
+                       fl_set_object_label(cancel_,
+                                           close_label);
+               }
+       }
+       if (!read_only_.empty()) {
+               if (bp_->isReadOnly()) {
+                       std::list<FL_OBJECT *>::iterator
+                               end = read_only_.end();
+                       for (std::list<FL_OBJECT *>::iterator
+                                    iter = read_only_.begin();
+                            iter != end;
+                            ++iter) {
+                               fl_deactivate_object(*iter);
+                               fl_set_object_lcol(*iter,
+                                                  FL_INACTIVE);
+                       }
+               } else {
+                       std::list<FL_OBJECT *>::iterator
+                               end = read_only_.end();
+                       for (std::list<FL_OBJECT *>::iterator
+                                    iter = read_only_.begin();
+                            iter != end;
+                            ++iter) {
+                               fl_activate_object(*iter);
+                               fl_set_object_lcol(*iter,
+                                                  FL_BLACK);
+                       }
+               }
+       }
+}
+
+
+void ButtonController::input(ButtonPolicy::SMInput in)
+{
+       bp_->input(in);
+       refresh();
+}
+
+
+void ButtonController::ok()
+{
+       input(ButtonPolicy::SMI_OKAY);
+}
+
+
+void ButtonController::apply()
+{
+       input(ButtonPolicy::SMI_APPLY);
+}
+
+
+void ButtonController::cancel()
+{
+       input(ButtonPolicy::SMI_CANCEL);
+}
+
+
+void ButtonController::undoAll()
+{
+       input(ButtonPolicy::SMI_UNDO_ALL);
+}
+
+
+void ButtonController::hide()
+{
+       input(ButtonPolicy::SMI_HIDE);
+}
+
+
+bool ButtonController::readOnly(bool ro)
+{
+       if (ro) {
+               input(ButtonPolicy::SMI_READ_ONLY);
+       } else {
+               input(ButtonPolicy::SMI_READ_WRITE);
+       }
+       return ro;
+}
+
+
+void ButtonController::readWrite()
+{
+       readOnly(false);
+}
+
+
+bool ButtonController::valid(bool v)
+{ 
+       if (v) {
+               input(ButtonPolicy::SMI_VALID);
+       } else {
+               input(ButtonPolicy::SMI_INVALID);
+       }
+       return v;
+}
+
+
+void ButtonController::invalid()
+{
+       valid(false);
+}
index 5f4c6462a6cee6697f7936f8a159a99118453e02..92e29828245460100016210809f83e3a2b39cbe3 100644 (file)
 #include "ButtonPolicies.h"
 #include <list>
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 /** General purpose button controller for up to four buttons.
     Controls the activation of the OK, Apply and Cancel buttons.
     Actually supports 4 buttons in all and it's up to the user to decide on
@@ -44,11 +48,12 @@ public:
            you can just assign "Cancel" to both labels.  Or even reuse this
            class for something completely different.
         */
-       ButtonController(ButtonPolicy * bp, char const * cancel, char const * close)
-               : bp_(bp), okay_(0), apply_(0), cancel_(0), undo_all_(0),
-                 read_only_(), cancel_label(cancel), close_label(close) {}
-       /// Somebody else owns the FL_OBJECTs we just manipulate them.
-       ~ButtonController() {}
+       ButtonController(ButtonPolicy * bp,
+                        char const * cancel, char const * close);
+
+       // Somebody else owns the FL_OBJECTs we just manipulate them.
+       // so? (Lgb)
+       //~ButtonController() {}
 
        /* Initialise Button Functions */
        /// Call refresh() when finished setting the buttons.
@@ -86,121 +91,28 @@ public:
 
        /* Action Functions */
        /// force a refresh of the buttons
-       void refresh() {
-               if (okay_) {
-                       if (bp_->buttonStatus(ButtonPolicy::OKAY)) {
-                               fl_activate_object(okay_);
-                               fl_set_object_lcol(okay_, FL_BLACK);
-                       } else {
-                               fl_deactivate_object(okay_);
-                               fl_set_object_lcol(okay_, FL_INACTIVE);
-                       }
-               }
-               if (apply_) {
-                       if (bp_->buttonStatus(ButtonPolicy::APPLY)) {
-                               fl_activate_object(apply_);
-                               fl_set_object_lcol(apply_, FL_BLACK);
-                       } else {
-                               fl_deactivate_object(apply_);
-                               fl_set_object_lcol(apply_, FL_INACTIVE);
-                       }
-               }
-               if (undo_all_) {
-                       if (bp_->buttonStatus(ButtonPolicy::UNDO_ALL)) {
-                               fl_activate_object(undo_all_);
-                               fl_set_object_lcol(undo_all_, FL_BLACK);
-                       } else {
-                               fl_deactivate_object(undo_all_);
-                               fl_set_object_lcol(undo_all_,
-                                                  FL_INACTIVE);
-                       }
-               }
-               if (cancel_) {
-                       if (bp_->buttonStatus(ButtonPolicy::CANCEL)) {
-                               fl_set_object_label(cancel_,
-                                                   cancel_label);
-                       } else {
-                               fl_set_object_label(cancel_,
-                                                   close_label);
-                       }
-               }
-               if (!read_only_.empty()) {
-                       if (bp_->isReadOnly()) {
-                               std::list<FL_OBJECT *>::iterator
-                                       end = read_only_.end();
-                               for (std::list<FL_OBJECT *>::iterator
-                                    iter = read_only_.begin();
-                                    iter != end;
-                                    ++iter) {
-                                       fl_deactivate_object(*iter);
-                                       fl_set_object_lcol(*iter,
-                                                          FL_INACTIVE);
-                               }
-                       } else {
-                               std::list<FL_OBJECT *>::iterator
-                                       end = read_only_.end();
-                               for (std::list<FL_OBJECT *>::iterator
-                                    iter = read_only_.begin();
-                                    iter != end;
-                                    ++iter) {
-                                       fl_activate_object(*iter);
-                                       fl_set_object_lcol(*iter,
-                                                          FL_BLACK);
-                               }
-                       }
-               }
-       }
+       void refresh();
+
        ///
-       void input(ButtonPolicy::SMInput in) {
-               bp_->input(in);
-               refresh();
-       }
+       void input(ButtonPolicy::SMInput in);
        ///
-       void ok() {
-               input(ButtonPolicy::SMI_OKAY);
-       }
+       void ok();
        ///
-       void apply() {
-               input(ButtonPolicy::SMI_APPLY);
-       }
+       void apply();
        ///
-       void cancel() {
-               input(ButtonPolicy::SMI_CANCEL);
-       }
+       void cancel();
        ///
-       void undoAll() {
-               input(ButtonPolicy::SMI_UNDO_ALL);
-       }
+       void undoAll();
        ///
-       void hide() {
-               input(ButtonPolicy::SMI_HIDE);
-       }
+       void hide();
        /// Passthrough function -- returns its input value
-       bool readOnly(bool ro = true) {
-               if (ro) {
-                       input(ButtonPolicy::SMI_READ_ONLY);
-               } else {
-                       input(ButtonPolicy::SMI_READ_WRITE);
-               }
-               return ro;
-       }
+       bool readOnly(bool ro = true);
        ///
-       void readWrite() {
-               readOnly(false);
-       }
+       void readWrite();
        /// Passthrough function -- returns its input value
-       bool valid(bool v = true) { 
-               if (v) {
-                       input(ButtonPolicy::SMI_VALID);
-               } else {
-                       input(ButtonPolicy::SMI_INVALID);
-               }
-               return v;
-       }
+       bool valid(bool v = true);
        ///
-       void invalid() {
-               valid(false);
-       }
+       void invalid();
 private:
        ///
        ButtonPolicy * bp_;
index 0892d444b5ce74ae53d0ebd16408151bc0c8c382..f7603e384423a7105f91a3801e5615ea9e0b73b5 100644 (file)
@@ -49,13 +49,23 @@ Dialogs::Dialogs(LyXView * lv)
        hideAll.connect(hideBufferDependent.slot());
 }
 
+
 Dialogs::~Dialogs()
 {
+#if 0
+       // I belive that this is unsafe...
        for (vector<DialogBase *>::iterator iter = dialogs_.begin();
             iter != dialogs_.end();
             ++iter) {
                delete *iter;
        }
+#else
+       // I think this is better...
+       while (!dialogs_.empty()) {
+               delete dialogs_.back();
+               dialogs_.erase(dialogs_.end() - 1);
+       }
+#endif
 }
 
 
index 1583e7f9600c7181ed7ba6747f4fdbcb9d3ca034..2adf40dbac5430b72139b08ed1c1f49965c26400 100644 (file)
 #include "FormBase.h"
 #include "LyXView.h"
 #include "xform_macros.h"
+#include "support/LAssert.h"
+
+// The current scheme muddles debugging.
+// Can we please use some other means to create these functions?
+// I really don't like to use the preprossessor for this.
+// My suggestion: First of all move these functions into their own
+// file (that can be included here if wanted, and use m4 to expand
+// that file. So create a m4 function to do the expansion, a file
+// that contains the calls to to this function and a script to run
+// it and create the C++ file with the expanded functions. (Lgb)
+// Possible startoff point:
+// define([C_RETURNCB],[extern "C" int C_$1$2(FL_FORM * ob, void * d) { return $1::$2(ob, d); }])
 
 C_RETURNCB (FormBase, WMHideCB)
 C_GENERICCB(FormBase, ApplyCB)
@@ -34,7 +46,9 @@ FormBase::FormBase(LyXView * lv, Dialogs * d, string const & t,
                   ButtonPolicy * bp, char const * close, char const * cancel)
        : lv_(lv), bc_(bp, cancel, close), d_(d), h_(0), title(t), bp_(bp),
          minw_(0), minh_(0)
-{}
+{
+       Assert(lv && d && bp);
+}
 
 
 FormBase::~FormBase()
@@ -88,9 +102,11 @@ void FormBase::hide()
 
 int FormBase::WMHideCB(FL_FORM * form, void *)
 {
+       Assert(form);
        // Ensure that the signals (u and h) are disconnected even if the
        // window manager is used to close the dialog.
        FormBase * pre = static_cast<FormBase*>(form->u_vdata);
+       Assert(pre);
        pre->hide();
        pre->bc_.hide();
        return FL_CANCEL;
@@ -99,7 +115,9 @@ int FormBase::WMHideCB(FL_FORM * form, void *)
 
 void FormBase::ApplyCB(FL_OBJECT * ob, long)
 {
+       Assert(ob && ob->form);
        FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
+       Assert(pre);
        pre->apply();
        pre->bc_.apply();
 }
@@ -107,7 +125,9 @@ void FormBase::ApplyCB(FL_OBJECT * ob, long)
 
 void FormBase::OKCB(FL_OBJECT * ob, long)
 {
+       Assert(ob && ob->form);
        FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
+       Assert(pre);
        pre->ok();
        pre->bc_.ok();
 }
@@ -115,7 +135,9 @@ void FormBase::OKCB(FL_OBJECT * ob, long)
 
 void FormBase::CancelCB(FL_OBJECT * ob, long)
 {
+       Assert(ob && ob->form);
        FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
+       Assert(pre);
        pre->cancel();
        pre->bc_.cancel();
 }
@@ -123,14 +145,18 @@ void FormBase::CancelCB(FL_OBJECT * ob, long)
 
 void FormBase::InputCB(FL_OBJECT * ob, long data )
 {
+       Assert(ob && ob->form);
        FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
-       pre->bc_.valid( pre->input( ob, data ) );
+       Assert(ob);
+       pre->bc_.valid(pre->input(ob, data));
 }
 
 
 void FormBase::RestoreCB(FL_OBJECT * ob, long)
 {
+       Assert(ob && ob->form);
        FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
+       Assert(ob);
        pre->restore();
        pre->bc_.undoAll();
 }
@@ -140,7 +166,9 @@ FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
                       ButtonPolicy * bp,
                       char const * close, char const * cancel)
        : FormBase( lv, d, t, bp, close, cancel )
-{}
+{
+       Assert(lv && d && bp);
+}
 
 
 void FormBaseBI::connect()
@@ -161,7 +189,9 @@ FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
                       char const * close, char const * cancel)
        : FormBase( lv, d, t, bp, close, cancel ),
          u_(0)
-{}
+{
+       Assert(lv && d && bp);
+}
 
 
 void FormBaseBD::connect()
index 6ac0321f99d33fb16afcb288ad7abc062f941de4..6819daa863518a7cf4d8c63baad0e4db9f973989 100644 (file)
@@ -28,7 +28,8 @@ class LyXView;
 #endif
 
 /** This class is an XForms GUI base class.
-    It is meant to be used solely as the parent class to FormBaseBI and FormBaseBD
+    It is meant to be used solely as the parent class to FormBaseBI
+    and FormBaseBD.
     @author Angus Leeming
  */
 class FormBase : public DialogBase, public noncopyable {
index e05395849d63eebced5f516d16380eee53a9ab20..dbeb3642163db823e32ada1e1f95decd80753249 100644 (file)
@@ -108,15 +108,15 @@ void FormDocument::build()
                      "| A4 small Margins (only portrait) "
                      "| A4 very small Margins (only portrait) "
                      "| A4 very wide margins (only portrait) "));
-    fl_set_input_return(paper_->input_custom_width, FL_RETURN_ALWAYS);
-    fl_set_input_return(paper_->input_custom_height, FL_RETURN_ALWAYS);
-    fl_set_input_return(paper_->input_top_margin, FL_RETURN_ALWAYS);
-    fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_ALWAYS);
-    fl_set_input_return(paper_->input_left_margin, FL_RETURN_ALWAYS);
-    fl_set_input_return(paper_->input_right_margin, FL_RETURN_ALWAYS);
-    fl_set_input_return(paper_->input_head_height, FL_RETURN_ALWAYS);
-    fl_set_input_return(paper_->input_head_sep, FL_RETURN_ALWAYS);
-    fl_set_input_return(paper_->input_foot_skip, FL_RETURN_ALWAYS);
+    fl_set_input_return(paper_->input_custom_width, FL_RETURN_CHANGED);
+    fl_set_input_return(paper_->input_custom_height, FL_RETURN_CHANGED);
+    fl_set_input_return(paper_->input_top_margin, FL_RETURN_CHANGED);
+    fl_set_input_return(paper_->input_bottom_margin, FL_RETURN_CHANGED);
+    fl_set_input_return(paper_->input_left_margin, FL_RETURN_CHANGED);
+    fl_set_input_return(paper_->input_right_margin, FL_RETURN_CHANGED);
+    fl_set_input_return(paper_->input_head_height, FL_RETURN_CHANGED);
+    fl_set_input_return(paper_->input_head_sep, FL_RETURN_CHANGED);
+    fl_set_input_return(paper_->input_foot_skip, FL_RETURN_CHANGED);
 
     bc_.addReadOnly (paper_->choice_paperpackage);
     bc_.addReadOnly (paper_->greoup_radio_orientation);
@@ -170,8 +170,9 @@ void FormDocument::build()
                    "default|empty|plain|headings|fancy");
     fl_addto_choice(class_->choice_doc_skip,
                    _(" Smallskip | Medskip | Bigskip | Length "));
-    fl_set_input_return(class_->input_doc_skip, FL_RETURN_ALWAYS);
-    fl_set_input_return(class_->input_doc_spacing, FL_RETURN_ALWAYS);
+    fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
+    fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
+    fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
 
     bc_.addReadOnly (class_->radio_doc_indent);
     bc_.addReadOnly (class_->radio_doc_skip);
@@ -223,6 +224,7 @@ void FormDocument::build()
 
     // the document options form
     options_ = build_doc_options();
+    fl_set_input_return(options_->input_float_placement, FL_RETURN_CHANGED);
     fl_set_counter_bounds(options_->slider_secnumdepth,-2,5);
     fl_set_counter_bounds(options_->slider_tocdepth,-1,5);
     fl_set_counter_step(options_->slider_secnumdepth,1,1);
index b481b29d3a37847039998f5c55e10ce720b7e074..96c40cc2f25c64fbb3e86c61cf00c3453a92c808 100644 (file)
 #include "FormError.h"
 #include "form_error.h"
 #include "insets/inseterror.h"
+#include "support/LAssert.h"
 
-FormError::FormError( LyXView * lv, Dialogs * d )
-       : FormInset( lv, d, _("LaTeX Error") ),
+
+FormError::FormError(LyXView * lv, Dialogs * d)
+       : FormInset( lv, d, _("LaTeX Error")),
          dialog_(0), inset_(0)
 {
+       Assert(lv && d);
        // let the dialog be shown
        // This is a permanent connection so we won't bother
        // storing a copy because we won't be disconnecting.
@@ -39,7 +42,7 @@ FormError::~FormError()
 
 FL_FORM * FormError::form() const
 {
-       if (dialog_ ) return dialog_->form;
+       if (dialog_) return dialog_->form;
        return 0;
 }
 
@@ -52,9 +55,9 @@ void FormError::disconnect()
 }
 
 
-void FormError::showInset( InsetError * inset )
+void FormError::showInset(InsetError * inset)
 {
-       if (inset == 0) return;
+       if (inset == 0) return; // Is this _really_ allowed? (Lgb)
 
        // If connected to another inset, disconnect from it.
        if (inset_)
index 4211bc89812e877948eafce0b0e8d7630d7e79ce..b0b62e255bfd8c4e8deb4adc8692d713d0df7f2e 100644 (file)
@@ -34,7 +34,7 @@ private:
        virtual void disconnect();
 
        /// Slot launching dialog to an existing inset
-       void showInset( InsetError * );
+       void showInset(InsetError *);
        /// Update dialog before showing it
        virtual void update();
        /// Build the dialog
index c5d80831391088a0e0d9401446f0db161b247841..886e309ed6ee4d030ec552e68ce8e90635ffadc2 100644 (file)
@@ -56,7 +56,13 @@ FormGraphics::FormGraphics(LyXView * lv, Dialogs * d)
 
 FormGraphics::~FormGraphics()
 {
-       free();
+       // Remove all associations for the radio buttons
+       widthButtons.reset();
+       heightButtons.reset();
+       displayButtons.reset();
+       
+       // Free the form.
+       delete dialog_;
 }
 
 
@@ -172,20 +178,6 @@ void FormGraphics::showDialog(InsetGraphics * inset)
 }
 
 
-void FormGraphics::free()
-{
-       // Remove all associations for the radio buttons
-       widthButtons.reset();
-       heightButtons.reset();
-       displayButtons.reset();
-
-       
-       // Free the form.
-       delete dialog_;
-       dialog_ = 0;
-}
-
-
 void FormGraphics::apply()
 {
        Assert(inset_ != 0);
index ce3b853ce79551ff7972ed8e5d81b7cf1cf70864..e9aeb9002a38918bfc1a7555595b401bf7949da7 100644 (file)
@@ -86,8 +86,6 @@ private:
 
        /// Save the active inset and show the dialog.
        void showDialog(InsetGraphics *);
-       /// Explicitly free the dialog.
-       void free();
        /// Verify that the input is correct. If not disable ok/apply buttons.
        bool checkInput();
        /// Open the file browse dialog to select an image file.
index 134a6c264ca3587642cf2a526a02e0f6997955a6..0d5f1dc05d6c5a9139348ca0821210e301d12ea9 100644 (file)
@@ -38,20 +38,21 @@ using SigC::slot;
 #endif
 
 using std::find;
+using std::find_if;
 using std::getline;
 using std::istream;
 using std::pair;
+using std::sort;
 using std::vector;
-using std::find_if;
 
 extern string fmt(char const * fmtstr ...);
+extern string system_lyxdir;
 extern Languages languages;
 
-typedef pair<string, FormPreferences::RGB> X11Colour;
-
-static vector<X11Colour> colourDB;
 static string const colourFile("/usr/lib/X11/rgb.txt");
-
+vector<FormPreferences::X11Colour> FormPreferences::colourDB;
+pair<vector<string>, vector<string> > FormPreferences::dirlist;
+    
 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
        : FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
          dialog_(0),
@@ -261,13 +262,7 @@ void FormPreferences::apply()
 
 void FormPreferences::feedback( FL_OBJECT * ob )
 {
-       // Angus, do you really want to allow ob to be 0?
-       // You set this in feedbackPost.  Why?
-       if (!ob) return;  // stop a segfault below.
-       // an alternative to the above is to check feedbackObj in
-       // FeedbackCB and not call this function at all.  But that's a 
-       // matter of deciding who should be checking the parameters for this
-       // function.
+       if( !ob ) return;
 
        string str;
 
@@ -307,6 +302,8 @@ void FormPreferences::feedback( FL_OBJECT * ob )
 
 bool FormPreferences::input(FL_OBJECT * ob, long)
 {
+       Assert(ob);
+       
        // whatever checks you need to ensure the user hasn't entered
        // some totally ridiculous value somewhere.  Change activate to suit.
        // comments before each test describe what is _valid_
@@ -357,8 +354,7 @@ void FormPreferences::buildColours()
 {
        colours_ = build_colours();
 
-       FL_OBJECT *obj;
-       obj = colours_->valslider_red;
+       FL_OBJECT * obj = colours_->valslider_red;
        fl_set_slider_bounds(obj, 0, 255);
        fl_set_slider_precision(obj, 0);
        fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
@@ -389,14 +385,17 @@ void FormPreferences::buildColours()
 }
 
 
-string const FormPreferences::feedbackColours( FL_OBJECT const * const ) const
+string const
+FormPreferences::feedbackColours(FL_OBJECT const * const ob) const
 {
+       Assert(ob);
        return string();
 }
 
 
 bool FormPreferences::inputColours( FL_OBJECT const * const ob )
 {
+       Assert(ob);
        bool activate = true;
        
        if (ob == colours_->browser_x11) {
@@ -458,7 +457,7 @@ bool FormPreferences::ColoursLoadBrowser(string const & filename)
                        // remove redundant entries on the fly
                        bool add = cols.empty();
                        if (!add) {
-                               vector<RGB>::const_iterator it =
+                               vector<RGB>::const_iterator it = 
                                        find( cols.begin(), cols.end(), col );
                                add = (it == cols.end());
                        }
@@ -533,14 +532,14 @@ int FormPreferences::ColoursSearchEntry(RGB const & col) const
 }
 
 
-void FormPreferences::ColoursUpdateBrowser( int i )
+void FormPreferences::ColoursUpdateBrowser(int i)
 {
        fl_freeze_form(colours_->form);
 
        RGB col = colourDB[i].second;
     
-       fl_mapcolor(FL_FREE_COL4+i, col.r, col.g, col.b);
-       fl_mapcolor(FL_FREE_COL4,   col.r, col.g, col.b);
+       fl_mapcolor(FL_FREE_COL4 + i, col.r, col.g, col.b);
+       fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
        fl_set_slider_value(colours_->valslider_red,   col.r);
        fl_set_slider_value(colours_->valslider_green, col.g);
        fl_set_slider_value(colours_->valslider_blue,  col.b);
@@ -562,11 +561,11 @@ void FormPreferences::ColoursUpdateRGB()
        fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
        fl_redraw_object(colours_->button_colour);
 
-       int i = ColoursSearchEntry( col );
+       int const i = ColoursSearchEntry( col );
        // change topline only if necessary
        // int top = fl_get_browser_topline(colours_->browser_x11);
        // if (i < top || i > (top+15))
-       fl_set_browser_topline(colours_->browser_x11, i-5);
+       fl_set_browser_topline(colours_->browser_x11, i - 5);
        fl_select_browser_line(colours_->browser_x11, i + 1);
 
        fl_unfreeze_form(colours_->form);
@@ -584,19 +583,47 @@ void FormPreferences::applyConverters() const
 void FormPreferences::buildConverters()
 {
        converters_ = build_converters();
-
+       
+       fl_set_input_return(converters_->input_converter, FL_RETURN_CHANGED);
+       fl_set_input_return(converters_->input_flags, FL_RETURN_CHANGED);
+       
+       updateConverters();     
 }
 
 
 string const
-FormPreferences::feedbackConverters( FL_OBJECT const * const ) const
+FormPreferences::feedbackConverters( FL_OBJECT const * const ob) const
 {
+       Assert(ob);
        return string();
 }
 
 
 void FormPreferences::updateConverters()
-{}
+{
+       vector<Command> commands = Converter::GetAllCommands();
+       
+       vector<string> names;
+       for(vector<Command>::const_iterator cit = commands.begin();
+            cit != commands.end(); ++cit) {
+               string from = cit->from->prettyname;
+               string to   = cit->to->prettyname;
+               string name = from + " -> " + to;
+               names.push_back(name);
+       }
+       sort(names.begin(), names.end());
+       
+       fl_clear_browser(converters_->browser_converters);
+       for (vector<string>::const_iterator cit = names.begin();
+            cit != names.end(); ++cit)
+               fl_addto_browser(converters_->browser_converters,
+                                cit->c_str());
+       fl_deactivate_object(converters_->button_add);
+       fl_set_object_lcol(converters_->button_add, FL_INACTIVE);
+       
+       fl_deactivate_object(converters_->button_delete);
+       fl_set_object_lcol(converters_->button_delete, FL_INACTIVE);
+}
 
 
 void FormPreferences::applyFormats() const
@@ -625,20 +652,23 @@ void FormPreferences::buildFormats()
 
        fl_set_input_return(formats_->input_format, FL_RETURN_CHANGED);
        fl_set_input_return(formats_->input_viewer, FL_RETURN_CHANGED);
+       fl_set_input_return(formats_->input_shrtcut, FL_RETURN_CHANGED);
        fl_set_input_return(formats_->input_gui_name, FL_RETURN_CHANGED);
        fl_set_input_return(formats_->input_extension, FL_RETURN_CHANGED);
 
        fl_set_input_filter(formats_->input_format, fl_lowercase_filter);
 
-       formats_vec = formats.GetAllFormats();
-       for (vector<Format>::const_iterator it = formats_vec.begin();
-            it != formats_vec.end(); ++it)
-               fl_addto_browser(formats_->browser_formats, it->name.c_str());
+       updateFormats();
 }
 
 
-string const FormPreferences::feedbackFormats( FL_OBJECT const * const ) const
+string const
+FormPreferences::feedbackFormats(FL_OBJECT const * const ob) const
 {
+       Assert(ob);
+       
+       //if( !ob ) return;
+
        string str;
 
        return str;
@@ -647,44 +677,260 @@ string const FormPreferences::feedbackFormats( FL_OBJECT const * const ) const
 
 bool FormPreferences::inputFormats(FL_OBJECT const * const ob)
 {
+       Assert(ob);
+       
+       //if( !ob ) return false;
+
        if (ob == formats_->browser_formats) {
-               int i = fl_get_browser(formats_->browser_formats);
-               if (i > 0) {
-                       Format const & f = formats_vec[i-1];
-                       fl_set_input(formats_->input_format, f.name.c_str());
-                       fl_set_input(formats_->input_gui_name, f.prettyname.c_str());
-                       fl_set_input(formats_->input_extension, f.extension.c_str());
-                       fl_set_input(formats_->input_viewer, f.viewer.c_str());
-               }
+               FormatsInputBrowser();
+
+       } else if (ob == formats_->input_format) {
+               FormatsInputInput();
+
        } else if (ob == formats_->button_add) {
-               string name = fl_get_input(formats_->input_format);
-               string prettyname = fl_get_input(formats_->input_gui_name);
-               string extension = fl_get_input(formats_->input_extension);
-               string viewer =  fl_get_input(formats_->input_viewer);
-               string shortcut;
-               if (prettyname.empty())
-                       return false;
-               Format format(name, extension, prettyname, shortcut, viewer);
-               vector<Format>::iterator it = find_if(formats_vec.begin(),
-                                                     formats_vec.end(),
-                                                     compare_memfun(&Format::getname, name));
-               if (it == formats_vec.end()) {
-                       formats_vec.push_back(format);
-                       fl_add_browser_line(formats_->browser_formats, 
-                                           name.c_str());
-               } else {
-                       //if (*it == format)
-                       //      return false;
-                       *it = format;
-               }
-               return true;
+               FormatsInputAdd();
+
+       } else if (ob == formats_->button_delete) {
+               FormatsInputDelete();
        }
        return true;
 }
 
 
 void FormPreferences::updateFormats()
-{}
+{
+       formats_vec = formats.GetAllFormats();
+
+       vector<string> names;
+       for (vector<Format>::const_iterator it = formats_vec.begin();
+            it != formats_vec.end(); ++it)
+               names.push_back( it->name.c_str() );
+       sort(names.begin(), names.end());
+
+       fl_clear_browser(formats_->browser_formats);
+       for (vector<string>::const_iterator it = names.begin();
+            it != names.end(); ++it)
+               fl_addto_browser(formats_->browser_formats, it->c_str());
+
+       fl_deactivate_object(formats_->button_add);
+       fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
+
+       fl_deactivate_object(formats_->button_delete);
+       fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
+}
+
+
+bool FormPreferences::FormatsInputAdd()
+{
+       string name = fl_get_input(formats_->input_format);
+       string prettyname = fl_get_input(formats_->input_gui_name);
+       string extension = fl_get_input(formats_->input_extension);
+       string viewer =  fl_get_input(formats_->input_viewer);
+       string shortcut =  fl_get_input(formats_->input_shrtcut);
+       if (prettyname.empty())
+               return false;
+
+       Format format(name, extension, prettyname, shortcut, viewer);
+       vector<Format>::iterator it =
+               find_if(formats_vec.begin(), formats_vec.end(),
+                       compare_memfun(&Format::getname, name));
+
+       if (it == formats_vec.end()) {
+               fl_freeze_form(formats_->form);
+
+               formats_vec.push_back(format);
+
+               vector<string> names;
+               for (vector<Format>::const_iterator it = formats_vec.begin();
+                    it != formats_vec.end(); ++it)
+                       names.push_back( it->name.c_str() );
+
+               sort( names.begin(), names.end() );
+
+               fl_clear_browser( formats_->browser_formats );
+               for (vector<string>::const_iterator it = names.begin();
+                    it != names.end(); ++it)
+                       fl_addto_browser(formats_->browser_formats, 
+                                        it->c_str()); 
+
+               fl_set_input(formats_->input_format, "");
+               fl_set_input(formats_->input_gui_name, "");
+               fl_set_input(formats_->input_shrtcut, "");
+               fl_set_input(formats_->input_extension, "");
+               fl_set_input(formats_->input_viewer, "");
+
+               fl_set_object_label( formats_->button_add,
+                                    idex(_("Add|#A")) );
+               fl_set_button_shortcut( formats_->button_add,
+                                       scex(_("Add|#A")), 1);
+
+               fl_deactivate_object(formats_->button_add);
+               fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
+
+               fl_deactivate_object(formats_->button_delete);
+               fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
+                       
+               fl_unfreeze_form(formats_->form);
+
+       } else {
+               //if (*it == format)
+               //      return false;
+               *it = format;
+       }
+       return true;
+}
+
+
+bool FormPreferences::FormatsInputDelete()
+{
+       string name = fl_get_input(formats_->input_format);
+       vector<Format>::iterator it =
+               find_if(formats_vec.begin(), formats_vec.end(),
+                       compare_memfun(&Format::getname, name));
+
+       fl_freeze_form(formats_->form);
+
+       if (it == formats_vec.end()) {
+               fl_deactivate_object(formats_->button_delete);
+               fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
+
+       } else {
+               int sel = 0;
+               for( int i = 0;
+                    i < fl_get_browser_maxline(formats_->browser_formats); 
+                    ++i ) {
+                       string str = fl_get_browser_line( formats_->browser_formats, i+1 );
+                       if( str == name ) {
+                               sel = i+1;
+                               break;
+                       }
+               }
+               
+               if( sel != 0 ) {
+                       fl_delete_browser_line(formats_->browser_formats, sel );
+
+                       fl_set_input(formats_->input_format, "");
+                       fl_set_input(formats_->input_gui_name, "");
+                       fl_set_input(formats_->input_shrtcut, "");
+                       fl_set_input(formats_->input_extension, "");
+                       fl_set_input(formats_->input_viewer, "");
+
+                       fl_set_object_label( formats_->button_add,
+                                            idex(_("Add|#A")) );
+                       fl_set_button_shortcut( formats_->button_add,
+                                               scex(_("Add|#A")), 1);
+
+                       fl_deactivate_object(formats_->button_add);
+                       fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
+
+                       fl_deactivate_object(formats_->button_delete);
+                       fl_set_object_lcol(formats_->button_delete,
+                                          FL_INACTIVE);
+               }
+       }
+       
+       fl_unfreeze_form(formats_->form);
+
+       return true;
+}
+
+
+bool FormPreferences::FormatsInputBrowser() 
+{
+       int const i = fl_get_browser(formats_->browser_formats);
+       if( i <= 0 ) return true;
+
+       string name = fl_get_browser_line(formats_->browser_formats, i);
+       vector<Format>::iterator it =
+               find_if(formats_vec.begin(), formats_vec.end(),
+                       compare_memfun(&Format::getname, name));
+
+       if (it != formats_vec.end()) {
+               fl_freeze_form(formats_->form);
+
+               fl_set_input(formats_->input_format, it->name.c_str());
+               fl_set_input(formats_->input_gui_name, it->prettyname.c_str());
+               fl_set_input(formats_->input_shrtcut, it->shortcut.c_str());
+               fl_set_input(formats_->input_extension, it->extension.c_str());
+               fl_set_input(formats_->input_viewer, it->viewer.c_str());
+
+               fl_set_object_label( formats_->button_add,
+                                    idex(_("Modify|#M")) );
+               fl_set_button_shortcut( formats_->button_add, 
+                                       scex(_("Modify|#M")), 1);
+
+               fl_activate_object(formats_->button_add);
+               fl_set_object_lcol(formats_->button_add, FL_BLACK);
+
+               fl_activate_object(formats_->button_delete);
+               fl_set_object_lcol(formats_->button_delete, FL_BLACK);
+                               
+               fl_unfreeze_form(formats_->form);
+       }
+       return true;
+}
+
+
+bool FormPreferences::FormatsInputInput()
+{
+       string const name = fl_get_input(formats_->input_format);
+       vector<Format>::iterator it =
+               find_if(formats_vec.begin(), formats_vec.end(),
+                       compare_memfun(&Format::getname, name));
+
+       fl_freeze_form(formats_->form);
+
+       if (it == formats_vec.end()) {
+               fl_set_object_label( formats_->button_add,
+                                    idex(_("Add|#A")) );
+               fl_set_button_shortcut( formats_->button_add,
+                                       scex(_("Add|#A")), 1);
+
+               if( name.empty() ) {
+                       fl_deactivate_object(formats_->button_add);
+                       fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
+               } else {
+                       fl_activate_object(formats_->button_add);
+                       fl_set_object_lcol(formats_->button_add, FL_BLACK);
+               }
+
+               fl_deselect_browser(formats_->browser_formats);
+
+               fl_deactivate_object(formats_->button_delete);
+               fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
+
+       } else {
+               fl_set_object_label( formats_->button_add,
+                                    idex(_("Modify|#M")) );
+               fl_set_button_shortcut( formats_->button_add,
+                                       scex(_("Modify|#M")), 1);
+
+               int sel = 0;
+               for( int i = 0;
+                    i < fl_get_browser_maxline(formats_->browser_formats);
+                    ++i ) {
+                       string str = fl_get_browser_line( formats_->browser_formats, i+1 );
+                       if( str == name ) {
+                               sel = i+1;
+                               break;
+                       }
+               }
+
+               int top = sel - 6;
+               if( top < 1 ) top = 0;
+               fl_set_browser_topline(formats_->browser_formats, top);
+               fl_select_browser_line(formats_->browser_formats, sel);
+               
+               fl_activate_object(formats_->button_add);
+               fl_set_object_lcol(formats_->button_add, FL_BLACK);
+
+               fl_activate_object(formats_->button_delete);
+               fl_set_object_lcol(formats_->button_delete, FL_BLACK);
+       }
+
+       fl_unfreeze_form(formats_->form);
+       return true;
+}
 
 
 void FormPreferences::applyInputsMisc() const
@@ -713,6 +959,10 @@ void FormPreferences::buildInputsMisc()
 string const
 FormPreferences::feedbackInputsMisc(FL_OBJECT const * const ob) const
 {
+       Assert(ob);
+       
+       //if( !ob ) return string();
+
        string str;
 
        if (ob == inputs_misc_->input_date_format )
@@ -779,6 +1029,10 @@ void FormPreferences::buildInterface()
 string const
 FormPreferences::feedbackInterface( FL_OBJECT const * const ob ) const
 {
+       Assert(ob);
+       
+       //if( !ob ) return string();
+
        string str;
 
        if (ob == interface_->input_popup_font )
@@ -815,16 +1069,28 @@ void FormPreferences::updateInterface()
 }
 
 
-void FormPreferences::applyLanguage() const
+void FormPreferences::applyLanguage()
 {
        lyxrc.default_language = combo_default_lang->getline();
 
        int button = fl_get_button(language_->check_use_kbmap);
+       string name_1 = combo_kbmap_1->getline();
+       string name_2 = combo_kbmap_2->getline();
+       if( button )
+               button = ( !name_1.empty() && !name_2.empty() );
        lyxrc.use_kbmap = static_cast<bool>(button);
 
        if (button) {
-           lyxrc.primary_kbmap = combo_kbmap_1->getline();
-           lyxrc.secondary_kbmap = combo_kbmap_2->getline();
+               vector<string>::iterator it =
+                       find( dirlist.second.begin(), dirlist.second.end(),
+                             name_1 );
+               vector<string>::size_type sel = it - dirlist.second.begin();
+               lyxrc.primary_kbmap = dirlist.first[sel];
+
+               it = find( dirlist.second.begin(), dirlist.second.end(),
+                          name_2 );
+               sel = it - dirlist.second.begin();
+               lyxrc.secondary_kbmap = dirlist.first[sel];
        }
        
        button = fl_get_button(language_->check_rtl_support);
@@ -842,6 +1108,9 @@ void FormPreferences::applyLanguage() const
        lyxrc.language_package = fl_get_input(language_->input_package);
        lyxrc.language_command_begin = fl_get_input(language_->input_command_begin);
        lyxrc.language_command_end = fl_get_input(language_->input_command_end);
+
+       // Ensure that all is self-consistent.
+       updateLanguage();
 }
 
 
@@ -863,17 +1132,28 @@ void FormPreferences::buildLanguage()
        combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
        combo_default_lang->shortcut("#L",1);
        combo_default_lang->setcallback(ComboLanguageCB, this);
-       LanguagesAdd( *combo_default_lang );
-       
+
+       for (Languages::const_iterator cit = languages.begin();
+           cit != languages.end(); cit++) {
+               combo_default_lang->addto((*cit).second.lang());
+       }
+
        // ditto kbmap_1
+       string dir = AddPath(system_lyxdir, "kbd");
+       vector<string> dirlist = DirList(dir , "kmap");
+
        obj = language_->choice_kbmap_1;
        fl_deactivate_object(language_->choice_kbmap_1);
        combo_kbmap_1 = new Combox(FL_COMBOX_DROPLIST);
        combo_kbmap_1->add(obj->x, obj->y, obj->w, obj->h, 400);
        combo_kbmap_1->shortcut("#1",1);
        combo_kbmap_1->setcallback(ComboLanguageCB, this);
-       LanguagesAdd( *combo_kbmap_1 );
-       
+
+       for (vector<string>::const_iterator cit = dirlist.begin();
+           cit != dirlist.end(); cit++) {
+               combo_kbmap_1->addto(*cit);
+       }
+
        // ditto kbmap_2
        obj = language_->choice_kbmap_2;
        fl_deactivate_object(language_->choice_kbmap_2);
@@ -881,7 +1161,11 @@ void FormPreferences::buildLanguage()
        combo_kbmap_2->add(obj->x, obj->y, obj->w, obj->h, 400);
        combo_kbmap_2->shortcut("#2",1);
        combo_kbmap_2->setcallback(ComboLanguageCB, this);
-       LanguagesAdd( *combo_kbmap_2 );
+
+       for (vector<string>::const_iterator cit = dirlist.begin();
+           cit != dirlist.end(); cit++) {
+               combo_kbmap_2->addto(*cit);
+       }
 
        fl_end_form();
        fl_unfreeze_form(language_->form);
@@ -906,12 +1190,20 @@ void FormPreferences::buildLanguage()
        setPostHandler( language_->input_command_end );
 
        fl_end_form();
+
+       // Activate/Deactivate the input fields dependent on the state of the
+       // buttons.
+       inputLanguage( 0 );
 }
 
 
 string const
 FormPreferences::feedbackLanguage(FL_OBJECT const * const ob) const
 {
+       Assert(ob);
+       
+       //if( !ob ) return string();
+
        string str;
 
        if (reinterpret_cast<Combox const *>(ob) == combo_default_lang )
@@ -967,11 +1259,21 @@ void FormPreferences::updateLanguage()
        combo_default_lang->select_text( lyxrc.default_language );
 
        if (lyxrc.use_kbmap) {
-               combo_kbmap_1->select_text( lyxrc.primary_kbmap );
-               combo_kbmap_2->select_text( lyxrc.secondary_kbmap );
+               string fullpath = lyxrc.primary_kbmap;
+               vector<string>::iterator it =
+                       find( dirlist.first.begin(), dirlist.first.end(),
+                             fullpath );
+               vector<string>::size_type sel = it - dirlist.first.begin();
+               combo_kbmap_1->select_text( dirlist.second[sel] );
+
+               fullpath = lyxrc.secondary_kbmap;
+               it = find( dirlist.first.begin(), dirlist.first.end(),
+                          fullpath );
+               sel = it - dirlist.first.begin();
+               combo_kbmap_2->select_text( dirlist.second[sel] );
        } else {
-               combo_kbmap_1->select_text( lyxrc.default_language );
-               combo_kbmap_2->select_text( lyxrc.default_language );
+               combo_kbmap_1->select_text( "" );
+               combo_kbmap_2->select_text( "" );
        }
        
        fl_set_button(language_->check_rtl_support, lyxrc.rtl_support);
@@ -993,15 +1295,6 @@ void FormPreferences::updateLanguage()
 }
 
 
-void FormPreferences::LanguagesAdd( Combox & combo ) const
-{
-       for (Languages::const_iterator cit = languages.begin();
-           cit != languages.end(); cit++) {
-               combo.addto((*cit).second.lang());
-       }
-}
-
-
 void FormPreferences::applyLnFmisc() const
 {
        lyxrc.show_banner = fl_get_button(lnf_misc_->check_banner);
@@ -1009,7 +1302,7 @@ void FormPreferences::applyLnFmisc() const
                                                 check_auto_region_delete);
        lyxrc.exit_confirmation = fl_get_button(lnf_misc_->check_exit_confirm);
        lyxrc.display_shortcuts =
-               fl_get_button(lnf_misc_->check_display_shortcuts);
+               fl_get_button(lnf_misc_->check_display_shrtcuts);
        lyxrc.new_ask_filename = fl_get_button(lnf_misc_->check_ask_new_file);
        lyxrc.cursor_follows_scrollbar =
                fl_get_button(lnf_misc_->check_cursor_follows_scrollbar);
@@ -1035,7 +1328,7 @@ void FormPreferences::buildLnFmisc()
        setPostHandler( lnf_misc_->check_banner );
        setPostHandler( lnf_misc_->check_auto_region_delete );
        setPostHandler( lnf_misc_->check_exit_confirm );
-       setPostHandler( lnf_misc_->check_display_shortcuts );
+       setPostHandler( lnf_misc_->check_display_shrtcuts );
        setPostHandler( lnf_misc_->counter_autosave );
        setPostHandler( lnf_misc_->check_ask_new_file );
        setPostHandler( lnf_misc_->check_cursor_follows_scrollbar );
@@ -1047,6 +1340,10 @@ void FormPreferences::buildLnFmisc()
 
 string const FormPreferences::feedbackLnFmisc(FL_OBJECT const * const ob) const
 {
+       Assert(ob);
+       
+       //if( !ob ) return string();
+
        string str;
 
        if (ob == lnf_misc_->check_banner )
@@ -1055,7 +1352,7 @@ string const FormPreferences::feedbackLnFmisc(FL_OBJECT const * const ob) const
                str = lyxrc.getDescription( LyXRC::RC_AUTOREGIONDELETE );
        else if (ob == lnf_misc_->check_exit_confirm )
                str = lyxrc.getDescription( LyXRC::RC_EXIT_CONFIRMATION );
-       else if (ob == lnf_misc_->check_display_shortcuts )
+       else if (ob == lnf_misc_->check_display_shrtcuts )
                str = lyxrc.getDescription( LyXRC::RC_DISPLAY_SHORTCUTS );
        else if (ob == lnf_misc_->check_ask_new_file )
                str = lyxrc.getDescription( LyXRC::RC_NEW_ASK_FILENAME );
@@ -1078,7 +1375,7 @@ void FormPreferences::updateLnFmisc()
                      lyxrc.auto_region_delete);
        fl_set_button(lnf_misc_->check_exit_confirm,
                      lyxrc.exit_confirmation);
-       fl_set_button(lnf_misc_->check_display_shortcuts,
+       fl_set_button(lnf_misc_->check_display_shrtcuts,
                      lyxrc.display_shortcuts);
        fl_set_button(lnf_misc_->check_ask_new_file,
                      lyxrc.new_ask_filename);
@@ -1137,6 +1434,10 @@ void FormPreferences::buildOutputsMisc()
 string const
 FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob) const
 {
+       Assert(ob);
+       
+       //if( !ob ) return string();
+
        string str;
 
        if (ob == outputs_misc_->counter_line_len )
@@ -1256,6 +1557,10 @@ void FormPreferences::buildPaths()
 
 string const FormPreferences::feedbackPaths( FL_OBJECT const * const ob ) const
 {
+       Assert(ob);
+       
+       //if( !ob ) return string();
+
        string str;
 
        if (ob == paths_->input_default_path )
@@ -1285,6 +1590,10 @@ string const FormPreferences::feedbackPaths( FL_OBJECT const * const ob ) const
 
 bool FormPreferences::inputPaths( FL_OBJECT const * const ob )
 {
+       // what kind of coding is this? Do you plan for a ob == NULL?
+       // When is that allowed? (Lgb)
+       //Assert(ob);
+       
        bool activate = true;
        
        if (!ob || ob == paths_->check_use_temp_dir) {
@@ -1439,8 +1748,13 @@ void FormPreferences::applyPrinter() const
 }
 
 
-string const FormPreferences::feedbackPrinter(FL_OBJECT const * const ob) const
+string const
+FormPreferences::feedbackPrinter(FL_OBJECT const * const ob) const
 {
+       Assert(ob);
+       
+       //if( !ob ) return string();
+
        string str;
 
        if (ob == printer_->input_command )
@@ -1761,6 +2075,10 @@ void FormPreferences::buildScreenFonts()
 string const
 FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob ) const
 {
+       Assert(ob);
+       
+       //if( !ob ) return string();
+
        string str;
 
        if (ob == screen_fonts_->input_roman )
@@ -1992,6 +2310,10 @@ void FormPreferences::buildSpellchecker()
 string const
 FormPreferences::feedbackSpellChecker(FL_OBJECT const * const ob) const
 {
+       Assert(ob);
+       
+       //if( !ob ) return string();
+
        string str;
 
        if (ob == spellchecker_->choice_spell_command )
@@ -2019,6 +2341,8 @@ FormPreferences::feedbackSpellChecker(FL_OBJECT const * const ob) const
 
 bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob )
 {
+       // ditto ob! (Lgb)
+       
        // Allow/dissallow input
 
        // If spell checker == "none", disable all input.
@@ -2093,7 +2417,7 @@ void FormPreferences::updateSpellChecker()
                choice = 3;
        fl_set_choice(spellchecker_->choice_spell_command, choice);
        
-       string str = string();
+       string str;
        if (lyxrc.isp_use_alt_lang ) str = lyxrc.isp_alt_lang;
 
        fl_set_button(spellchecker_->check_alt_lang,
@@ -2125,7 +2449,7 @@ void FormPreferences::updateSpellChecker()
 }
 
 
-bool FormPreferences::WriteableDir( string const & name ) const
+bool FormPreferences::WriteableDir(string const & name) const
 {
        bool success = true;
        string str;
@@ -2155,7 +2479,7 @@ bool FormPreferences::WriteableDir( string const & name ) const
 }
 
 
-bool FormPreferences::ReadableDir( string const & name ) const
+bool FormPreferences::ReadableDir(string const & name) const
 {
        bool success = true;
        string str;
@@ -2207,8 +2531,8 @@ bool FormPreferences::WriteableFile(string const & name,
                str = N_("WARNING! The absolute path is required.");
        }
 
-       // This is not a nice way to use FileInfo (Lgb)
 #if 0
+       // This is not a nice way to use FileInfo (Lgb)
        FileInfo d;
        
        {
@@ -2258,10 +2582,11 @@ bool FormPreferences::WriteableFile(string const & name,
 
 void FormPreferences::ComboLanguageCB(int, void * v, Combox * combox)
 {
-    FormPreferences * pre = static_cast<FormPreferences*>(v);
-    // This is safe, as nothing is done to the pointer, other than
-    // to use its address in a block-if statement.
-    pre->bc_.valid( pre->input( reinterpret_cast<FL_OBJECT *>(combox), 0 ));
+       Assert(v && combox);
+       FormPreferences * pre = static_cast<FormPreferences*>(v);
+       // This is safe, as nothing is done to the pointer, other than
+       // to use its address in a block-if statement.
+       pre->bc_.valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
 }
 
 
@@ -2271,8 +2596,14 @@ C_GENERICCB(FormPreferences, FeedbackCB)
        
 void FormPreferences::FeedbackCB(FL_OBJECT * ob, long)
 {
+       Assert(ob);
+       
+       //if( !ob ) return;
+
        FormPreferences * pre =
                static_cast<FormPreferences*>(ob->form->u_vdata);
+       Assert(pre);
+       
        pre->feedback( pre->feedbackObj );
 }
 
@@ -2284,6 +2615,7 @@ int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event,
        // can occur when form is being deleted. This seems an easier fix than
        // a call "fl_set_object_posthandler(ob, 0)" for each and every object
        // in the destructor.
+       if (!ob ) return 0;
        if (!ob->form ) return 0;
 
        FormPreferences * pre =
@@ -2296,8 +2628,12 @@ int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event,
 // post_handler for feedback messages
 void FormPreferences::feedbackPost(FL_OBJECT * ob, int event)
 {
+       Assert(ob);
+       
+       //if( !ob ) return;
+       
        // We do not test for empty help here, since this can never happen
-       if (event == FL_ENTER){
+       if (event == FL_ENTER) {
                // Used as a placeholder for ob, so that we don't have to
                // a horrible reinterpret_cast to long and pass it as an
                // argument in fl_set_object_callback.
@@ -2306,8 +2642,7 @@ void FormPreferences::feedbackPost(FL_OBJECT * ob, int event)
                                       C_FormPreferencesFeedbackCB,
                                       0);
                fl_set_timer(dialog_->timer_feedback, 0.5);
-       }
-       else if (event != FL_MOTION){
+       } else if (event != FL_MOTION) {
                fl_set_timer(dialog_->timer_feedback, 0);
                feedbackObj = 0;
                fl_set_object_label(dialog_->text_warning, "");
@@ -2317,5 +2652,9 @@ void FormPreferences::feedbackPost(FL_OBJECT * ob, int event)
 
 void FormPreferences::setPostHandler(FL_OBJECT * ob) const
 {
+       Assert(ob);
+       
+       //if( !ob ) return;
+
        fl_set_object_posthandler(ob, C_FormPreferencesFeedbackPost);
 }
index 538946d36323f17971b1532ab2e10ab75632b00a..f855cf0d80802a3a16247414ee404a97f133bb0e 100644 (file)
@@ -58,6 +58,7 @@ public:
        ///
        void feedbackPost(FL_OBJECT *, int);
 
+private:
        /// helper struct for Colours
        struct RGB {
                int r;
@@ -66,8 +67,13 @@ public:
                RGB() : r(0), g(0), b(0) {}
                RGB(int red, int green, int blue) : r(red), g(green), b(blue) {}
        };
+       ///
+       friend bool operator==(RGB const &, RGB const &);
+       ///
+       friend bool operator!=(RGB const &, RGB const &);
+       ///
+       typedef std::pair<string, RGB> X11Colour;
 
-private:
        /// Update the dialog.
        virtual void update();
        ///
@@ -99,7 +105,7 @@ private:
        ///
        void applyInterface() const;
        ///
-       void applyLanguage() const;
+       void applyLanguage(); // not const because calls updateLanguage!
        ///
        void applyLnFmisc() const;
        ///
@@ -216,8 +222,6 @@ private:
        /** Some helper functions for specific folders.
         */
        
-       ///
-       void LanguagesAdd( Combox & ) const;
        ///
        bool ColoursLoadBrowser( string const & );
        ///
@@ -226,6 +230,14 @@ private:
        void ColoursUpdateBrowser( int );
        ///
        void ColoursUpdateRGB();
+       ///
+       bool FormatsInputAdd();
+       ///
+       bool FormatsInputBrowser();
+       ///
+       bool FormatsInputDelete();
+       ///
+       bool FormatsInputInput();
 
        ///
        bool WriteableDir( string const & ) const;
@@ -308,14 +320,21 @@ private:
        Combox * combo_kbmap_1;
        ///
        Combox * combo_kbmap_2;
-       ///
+       /// 
        FL_OBJECT * feedbackObj;
-       ///
-       std::vector<Format> formats_vec;
 
+       /// A vector of Formats, to be manipulated in the Format browser.
+       std::vector<Format> formats_vec;
+       /// A vector of RGB colours and associated name.
+       static std::vector<X11Colour> colourDB;
+       /** A collection of kmap files.
+           First entry is the file name, full path.
+           Second entry is the shorthand, as appears in the fl_choice.
+           Eg, system_lyxdir/kbd/american2.kmap, american2
+       */
+       static std::pair<std::vector<string>, std::vector<string> > dirlist;
 };
 
-
 inline
 bool operator==(FormPreferences::RGB const & c1,
                FormPreferences::RGB const & c2)
index cb0f918656319a6c85be05cdff34678d77af397d..55519e774f82bdd71397b2f97e0e2c7044ea117b 100644 (file)
@@ -12,6 +12,7 @@ LYXDATADIRS = forms
 ETAGS_ARGS = --lang=c++
 # Alphabetical order please.  It makes it easier to figure out what's missing. 
 libxforms_la_SOURCES = \
+       ButtonController.C \
        ButtonController.h \
        Dialogs.C \
        GUIRunTime.C \
index a54d23642c1e4b56ba567b4c353a42cfc34aea42..edb737a1e31070fec2937b9cb49e77c449e52ed1 100644 (file)
@@ -27,7 +27,6 @@ FD_form_preferences * FormPreferences::build_preferences()
   obj = fl_add_box(FL_UP_BOX, 0, 0, 470, 500, "");
   fdui->tabfolder_prefs = obj = fl_add_tabfolder(FL_TOP_TABFOLDER, 5, 10, 455, 375, "");
     fl_set_object_boxtype(obj, FL_FLAT_BOX);
-    fl_set_object_color(obj, FL_BOTTOM_BCOL, FL_COL1);
   fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 270, 390, 90, 30, idex(_("Apply|#A")));
     fl_set_button_shortcut(obj, scex(_("Apply|#A")), 1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
@@ -72,7 +71,6 @@ FD_form_outer_tab * FormPreferences::build_outer_tab()
   obj = fl_add_box(FL_FLAT_BOX, 0, 0, 455, 375, "");
   fdui->tabfolder_outer = obj = fl_add_tabfolder(FL_TOP_TABFOLDER, 0, 0, 455, 375, "");
     fl_set_object_boxtype(obj, FL_FLAT_BOX);
-    fl_set_object_color(obj, FL_BOTTOM_BCOL, FL_COL1);
   fl_end_form();
 
   fdui->form->fdui = fdui;
@@ -413,22 +411,22 @@ FD_form_colours * FormPreferences::build_colours()
     fl_set_button_shortcut(obj, scex(_("Browse|#B")), 1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
-  fdui->button_colour = obj = fl_add_button(FL_NORMAL_BUTTON, 290, 230, 150, 30, "");
+  fdui->button_colour = obj = fl_add_button(FL_NORMAL_BUTTON, 180, 230, 90, 30, "");
     fl_set_object_boxtype(obj, FL_BORDER_BOX);
     fl_set_object_color(obj, FL_WHITE, FL_COL1);
-  fdui->valslider_red = obj = fl_add_valslider(FL_VERT_FILL_SLIDER, 180, 25, 30, 235, idex(_("R|#R")));
+  fdui->valslider_red = obj = fl_add_valslider(FL_VERT_FILL_SLIDER, 180, 25, 30, 200, idex(_("R|#R")));
     fl_set_button_shortcut(obj, scex(_("R|#R")), 1);
     fl_set_object_color(obj, FL_COL1, FL_RED);
     fl_set_object_lalign(obj, FL_ALIGN_TOP);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
     fl_set_slider_size(obj, 0.15);
-  fdui->valslider_green = obj = fl_add_valslider(FL_VERT_FILL_SLIDER, 210, 25, 30, 235, idex(_("G|#G")));
+  fdui->valslider_green = obj = fl_add_valslider(FL_VERT_FILL_SLIDER, 210, 25, 30, 200, idex(_("G|#G")));
     fl_set_button_shortcut(obj, scex(_("G|#G")), 1);
     fl_set_object_color(obj, FL_COL1, FL_GREEN);
     fl_set_object_lalign(obj, FL_ALIGN_TOP);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
     fl_set_slider_size(obj, 0.15);
-  fdui->valslider_blue = obj = fl_add_valslider(FL_VERT_FILL_SLIDER, 240, 25, 30, 235, idex(_("B|#B")));
+  fdui->valslider_blue = obj = fl_add_valslider(FL_VERT_FILL_SLIDER, 240, 25, 30, 200, idex(_("B|#B")));
     fl_set_button_shortcut(obj, scex(_("B|#B")), 1);
     fl_set_object_color(obj, FL_COL1, FL_BLUE);
     fl_set_object_lalign(obj, FL_ALIGN_TOP);
@@ -439,6 +437,10 @@ FD_form_colours * FormPreferences::build_colours()
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lalign(obj, FL_ALIGN_TOP);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  fdui->button_modify = obj = fl_add_button(FL_NORMAL_BUTTON, 350, 230, 90, 30, idex(_("Modify|#M")));
+    fl_set_button_shortcut(obj, scex(_("Modify|#M")), 1);
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   fl_end_form();
 
   fdui->form->fdui = fdui;
@@ -487,6 +489,10 @@ FD_form_converters * FormPreferences::build_converters()
     fl_set_button_shortcut(obj, scex(_("To|#T")), 1);
     fl_set_object_boxtype(obj, FL_FRAME_BOX);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  fdui->input_flags = obj = fl_add_input(FL_NORMAL_INPUT, 280, 150, 150, 30, idex(_("Flags|#F")));
+    fl_set_button_shortcut(obj, scex(_("Flags|#F")), 1);
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   fl_end_form();
 
   fdui->form->fdui = fdui;
@@ -531,14 +537,18 @@ FD_form_formats * FormPreferences::build_formats()
     fl_set_button_shortcut(obj, scex(_("Add|#A")), 1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
-  fdui->input_extension = obj = fl_add_input(FL_NORMAL_INPUT, 280, 110, 150, 30, idex(_("Extension|#E")));
+  fdui->input_extension = obj = fl_add_input(FL_NORMAL_INPUT, 280, 150, 150, 30, idex(_("Extension|#E")));
     fl_set_button_shortcut(obj, scex(_("Extension|#E")), 1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
-  fdui->input_viewer = obj = fl_add_input(FL_NORMAL_INPUT, 280, 150, 150, 30, idex(_("Viewer|#V")));
+  fdui->input_viewer = obj = fl_add_input(FL_NORMAL_INPUT, 280, 190, 150, 30, idex(_("Viewer|#V")));
     fl_set_button_shortcut(obj, scex(_("Viewer|#V")), 1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  fdui->input_shrtcut = obj = fl_add_input(FL_NORMAL_INPUT, 280, 110, 150, 30, idex(_("Shortcut|#S")));
+    fl_set_button_shortcut(obj, scex(_("Shortcut|#S")), 1);
+    fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   fl_end_form();
 
   fdui->form->fdui = fdui;
@@ -577,7 +587,7 @@ FD_form_lnf_misc * FormPreferences::build_lnf_misc()
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
     fl_set_button(obj, 1);
-  fdui->check_display_shortcuts = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 15, 105, 310, 30, _("Display keyboard shortcuts"));
+  fdui->check_display_shrtcuts = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 15, 105, 310, 30, _("Display keyboard shortcuts"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
     fl_set_button(obj, 1);
index 38a8d08af7d2d9941cc4283eec0ef297516c1c1a..83ae9de5097a36857aed79079ad632cb270188d6 100644 (file)
@@ -136,6 +136,7 @@ struct FD_form_colours {
        FL_OBJECT *valslider_green;
        FL_OBJECT *valslider_blue;
        FL_OBJECT *browser_lyx_objs;
+       FL_OBJECT *button_modify;
 };
 struct FD_form_converters {
        ~FD_form_converters();
@@ -147,6 +148,7 @@ struct FD_form_converters {
        FL_OBJECT *input_converter;
        FL_OBJECT *choice_from;
        FL_OBJECT *choice_to;
+       FL_OBJECT *input_flags;
 };
 struct FD_form_formats {
        ~FD_form_formats();
@@ -159,6 +161,7 @@ struct FD_form_formats {
        FL_OBJECT *button_add;
        FL_OBJECT *input_extension;
        FL_OBJECT *input_viewer;
+       FL_OBJECT *input_shrtcut;
 };
 struct FD_form_lnf_misc {
        ~FD_form_lnf_misc();
@@ -167,7 +170,7 @@ struct FD_form_lnf_misc {
        FL_OBJECT *check_banner;
        FL_OBJECT *check_auto_region_delete;
        FL_OBJECT *check_exit_confirm;
-       FL_OBJECT *check_display_shortcuts;
+       FL_OBJECT *check_display_shrtcuts;
        FL_OBJECT *counter_autosave;
        FL_OBJECT *check_ask_new_file;
        FL_OBJECT *check_cursor_follows_scrollbar;
index 5acafa6feccbefc7a261173c6c7aaee994806efd..9f050030e5fea954b785f0092f80e7d163304074 100644 (file)
@@ -33,7 +33,7 @@ int fl_lowercase_filter(FL_OBJECT * ob,
                        int c)
 {
        if (c == 0 /* final test before handing contents to app */
-           || strchr("abcdefghijklmnopqrstuvwxyz", c)) {
+           || strchr("abcdefghijklmnopqrstuvwxyz0123456789", c)) {
                /* since we only accept numerals then it must be valid */
                return FL_VALID;
        }
index d4e83b6211cec8f5b587f91a438e45328163a664..42d7aca00d3ae2f7d7498565d22d1f617a20918c 100644 (file)
@@ -107,7 +107,7 @@ GraphicsCacheItem_pimpl::renderXPM(string const & filename)
        temp = ChangeExtension(filename, string());
        
        // Add some stuff to have it a unique temp file.
-       xpmfile = TmpFileName(string(), temp);
+       xpmfile = lyx::tempName(string(), temp); //TmpFileName(string(), temp);
        xpmfile = ChangeExtension(xpmfile, ".xpm");     
        
        command += xpmfile;
index ffcdd4330535d653db87aaa1d70d97d4fa53ac98..a323f8a0cd398621ab8a4a61fb56f98f91e18457 100644 (file)
 #include "ExternalTemplate.h"
 
 #include "lyxlex.h"
+#include "debug.h"
 #include "support/path.h"
 #include "support/LAssert.h"
+#include "support/filetools.h"
 
 using std::endl;
 using std::ostream;
index d4f5c9bc6de0f4a329852fe5dca11ed08bdf0977..1edd6043e16622df58be17291f8d5a6f01bc793f 100644 (file)
@@ -1213,8 +1213,9 @@ void InsetFig::Edit(BufferView * bv, int, int, unsigned int)
        if (form->Figure->visible) {
                fl_raise_form(form->Figure);
        } else {
-               fl_show_form(form->Figure, FL_PLACE_MOUSE | FL_PLACE_SIZE,
-                            FL_FULLBORDER, _("Figure"));
+               fl_show_form(form->Figure,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+                            _("Figure"));
        }
 }
 
index 32f8b7ae6e09bdf8a4263198beffec28b413ffee..e374b40c700840cd80d2707ecc47c4de36856011 100644 (file)
@@ -199,8 +199,8 @@ void InsetBibKey::Edit(BufferView * bv, int, int, unsigned int)
        if (bibitem_form->bibitem_form->visible) {
                fl_raise_form(bibitem_form->bibitem_form);
        } else {
-               fl_show_form(bibitem_form->bibitem_form, FL_PLACE_MOUSE,
-                            FL_FULLBORDER,
+               fl_show_form(bibitem_form->bibitem_form,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("Bibliography item"));
        }   
 }
@@ -329,7 +329,7 @@ void InsetBibtex::Edit(BufferView * bv, int, int, unsigned int)
                fl_raise_form(bibitem_form->bibitem_form);
        } else {
                fl_show_form(bibitem_form->bibitem_form,
-                            FL_PLACE_MOUSE, FL_FULLBORDER,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("BibTeX"));
        }   
 }
index 1d0590da69effe6453f1a481810c55821b6b680a..77435740d298fe1637a8a0e3c6032ac762c04f3f 100644 (file)
@@ -36,7 +36,7 @@ using std::endl;
 InsetExternal::InsetExternal() 
        : form_external(0)
 {
-       tempname = TmpFileName();
+       tempname = lyx::tempName(); //TmpFileName();
 }
 
 
@@ -291,8 +291,8 @@ void InsetExternal::Edit(BufferView * bv,
                fl_raise_form(form_external->form_external);
        } else {
                fl_show_form(form_external->form_external,
-                            FL_PLACE_MOUSE | FL_FREE_SIZE,
-                            FL_FULLBORDER, _("Insert external inset"));
+                            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;
index 718032141d15eb0c18f032f5f61022713d399a1f..c0847894251029b15377efbc1c0999df121bd1a6 100644 (file)
@@ -252,7 +252,7 @@ void InsetInclude::Edit(BufferView * bv, int, int, unsigned int)
 
        if (!form) {
                 form = create_form_include();
-               fl_set_form_atclose(form->include, IgnoreCloseBoxCB, 0);
+               fl_set_form_atclose(form->include, CancelCloseBoxCB, 0);
        }
         form->include->u_vdata = this;
     
@@ -272,7 +272,8 @@ void InsetInclude::Edit(BufferView * bv, int, int, unsigned int)
         if (form->include->visible) {
                fl_raise_form(form->include);
        } else {
-               fl_show_form(form->include, FL_PLACE_MOUSE, FL_FULLBORDER,
+               fl_show_form(form->include,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("Include"));
        }
 }
index 66c7712191bd146c36b49b96bb4fc2e071e33e7c..da55067adfffd9a09d4d64fd4ecd3ee50a003eca 100644 (file)
@@ -226,7 +226,8 @@ void InsetInfo::Edit(BufferView *bv, int, int, unsigned int)
        if (form->visible) {
                fl_raise_form(form);
        } else {
-               fl_show_form(form, FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER, 
+               fl_show_form(form,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("Note"));
                if (ow < 0) {
                        ow = form->w;
index c25e33b5a0133c759900cec153305736d877c979..2eb88498aa2ab2e26ca8111a21bc80ff1e2b8785 100644 (file)
@@ -357,6 +357,7 @@ void Intl::MenuKeymap()
 {
        if (fd_form_keymap->KeyMap->visible) {
                fl_raise_form(fd_form_keymap->KeyMap);
-       } else fl_show_form(fd_form_keymap->KeyMap, FL_PLACE_MOUSE,
-                           FL_FULLBORDER, _("Key Mappings"));
+       } else fl_show_form(fd_form_keymap->KeyMap,
+                           FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+                           _("Key Mappings"));
 }
index 440abb97c68fce4d5afae848e4967d0a398fd602..ecdf613ac1836fd5bc34dc1985d76936c551626c 100644 (file)
 #include FORMS_H_LOCATION
 #include "lyx.h"
 #include "layout_forms.h"
-#include "form1.h"
+//#include "form1.h"
 #include "lyx_main.h"
 #include "lyx_cb.h"
-#include "insets/insetref.h"
+//#include "insets/insetref.h"
 #include "insets/insetlabel.h"
 #include "insets/figinset.h"
 #include "lyxfunc.h"
 #include "filedlg.h"
 #include "lyx_gui_misc.h"
 #include "LyXView.h"
-#include "BufferView.h"
+//#include "BufferView.h"
 #include "lastfiles.h"
 #include "bufferview_funcs.h"
 #include "support/FileInfo.h"
 #include "support/syscall.h"
 #include "support/filetools.h"
 #include "support/path.h"
-#include "lyxserver.h"
+//#include "support/lyxlib.h"
+//#include "lyxserver.h"
 #include "lyxrc.h"
 #include "lyxtext.h"
-#include "CutAndPaste.h"
-#include "exporter.h"
+//#include "CutAndPaste.h"
+//#include "exporter.h"
 
 using std::ifstream;
 using std::copy;
@@ -74,7 +75,7 @@ extern bool send_fax(string const & fname, string const & sendcmd);
 
 extern void MenuSendto();
 
-extern LyXServer * lyxserver;
+//extern LyXServer * lyxserver;
 
 // this should be static, but I need it in buffer.C
 bool quitting; // flag, that we are quitting the program
@@ -398,8 +399,6 @@ void AutoSave(BufferView * bv)
        
        // tmp_ret will be located (usually) in /tmp
        // will that be a problem?
-       string tmp_ret = tmpnam(0);
-       
        pid_t pid = fork(); // If you want to debug the autosave
        // you should set pid to -1, and comment out the
        // fork.
@@ -408,6 +407,8 @@ void AutoSave(BufferView * bv)
                // to fork. But we will do the save
                // anyway.
                bool failed = false;
+               
+               string tmp_ret = lyx::tempName();
                if (!tmp_ret.empty()) {
                        bv->buffer()->writeFile(tmp_ret, 1);
                        // assume successful write of tmp_ret
@@ -573,7 +574,7 @@ void MenuLayoutCharacter()
                fl_raise_form(fd_form_character->form_character);
        } else {
                fl_show_form(fd_form_character->form_character,
-                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("Character Style"));
                if (ow < 0) {
                        ow = fd_form_character->form_character->w;
@@ -625,7 +626,7 @@ void MenuLayoutPreamble()
                } else {
                        fl_show_form(fd_form_preamble->form_preamble,
                                     FL_PLACE_MOUSE | FL_FREE_SIZE,
-                                    FL_FULLBORDER,
+                                    FL_TRANSIENT,
                                     _("LaTeX Preamble"));
                        if (ow < 0) {
                                ow = fd_form_preamble->form_preamble->w;
@@ -821,7 +822,7 @@ void Figure()
                fl_raise_form(fd_form_figure->form_figure);
        } else {
                fl_show_form(fd_form_figure->form_figure,
-                            FL_PLACE_MOUSE, FL_FULLBORDER,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("Insert Figure"));
        }
 }
index 9d1dd98389e0d6343d7be1aed6bffc154833f706..4f1ede6766f07414e95a59d522cd0b952475865e 100644 (file)
@@ -66,13 +66,6 @@ extern "C" int CancelCloseBoxCB(FL_FORM *, void *)
 }
 
 
-// Prevents LyX from being killed when the close box is pressed in a popup.
-extern "C" int IgnoreCloseBoxCB(FL_FORM *, void *)
-{
-       return FL_IGNORE;
-}
-
-
 // Prevents LyX from crashing when no buffers available
 // This is also one of the functions that we _really_ dont want
 // we should try to finds way to help us with that.
index 779167af4196bdeb8170406dc190bbd43719f54d..f94836fc0561e6e1df4dd602d431b43bb7677d3f 100644 (file)
@@ -26,8 +26,6 @@ class MiniBuffer;
 
 /// Prevents LyX from being killed when the close box is pressed in a popup.
 extern "C" int CancelCloseBoxCB(FL_FORM *, void *);
-/// Prevents LyX from being killed when the close box is pressed in a popup.
-extern "C" int IgnoreCloseBoxCB(FL_FORM *, void *);
 
 /// Prevents LyX from crashing when no buffers available
 void CloseAllBufferRelatedDialogs();
index c7af0d64a919e2b033660c656d31978eb434a2ee..8fca1ffa339ef52ba8903a20db57abeab15c6a9e 100644 (file)
@@ -47,7 +47,7 @@ bool send_fax(string const & fname, string const & sendcmd)
         return false;
     path = OnlyPath(fname);
     if (path.empty() || path == "./")
-        filename = GetCWD() + "/" + fname;
+       filename = lyx::getcwd() /*GetCWD()*/ + "/" + fname;
     else
         filename = fname;
 
@@ -83,7 +83,8 @@ bool send_fax(string const & fname, string const & sendcmd)
 
     /* show the first form */
     fl_show_form(fd_xsendfax->xsendfax,
-                FL_PLACE_MOUSE, FL_FULLBORDER, title.c_str());
+                FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+                title.c_str());
 /*
     while(true) {
         obj = fl_do_forms();
@@ -114,7 +115,7 @@ bool button_send(string const & fname, string const & sendcmd)
 
     if (phone.empty())
         return false;
-    string logfile = TmpFileName(OnlyPath(fname), "FAX");
+    string logfile = lyx::tempName(OnlyPath(fname), "FAX"); //TmpFileName(OnlyPath(fname), "FAX");
     string cmd = sendcmd + " >";
     cmd += logfile + " 2>";
     cmd += logfile;
@@ -285,7 +286,7 @@ void show_logfile(string const & logfile, bool show_if_empty)
         fl_raise_form(fd_logfile->logfile);
     } else {
         fl_show_form(fd_logfile->logfile,
-                     FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+                    FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                      _("Message-Window"));
     }
 }
@@ -322,6 +323,7 @@ void FaxOpenPhonebookCB(FL_OBJECT *, long)
 
     if (!n)
         fl_addto_browser(fd_phonebook->browser, _("@L@b@cEmpty Phonebook"));
-    fl_show_form(fd_phonebook->phonebook, FL_PLACE_MOUSE, FL_FULLBORDER,
+    fl_show_form(fd_phonebook->phonebook,
+                FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                  _("Phonebook"));
 }
index 0b14d4c6ba259f887dc1dd6a2dcc468333ced96f..083e0c6a3a9fdb688ec8e7e0a71c7093c5183516 100644 (file)
@@ -90,7 +90,7 @@ void SearchForm::StartSearch(LyXFindReplace * lfr)
                fl_raise_form(search_form->form_search);
        } else {
                fl_show_form(search_form->form_search,
-                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("Find & Replace"));      // RVDK_PATCH_5
                if (ow < 0) {
                        ow = search_form->form_search->w;
index 4ab17afc9caa0b037cede8b6d88c26e695b6810e..de506a2c032c1c1fbd43329538e29825dda4ec70 100644 (file)
@@ -14,6 +14,7 @@
 #include "buffer.h"
 #include "gettext.h"
 #include "support/filetools.h"
+#include "support/lyxlib.h"
 #include "lyxfunc.h"
 #include "LyXView.h"
 
@@ -279,7 +280,7 @@ void LyXVC::viewLog(string const & fil)
                fl_raise_form(browser->LaTeXLog);
        } else {
                fl_show_form(browser->LaTeXLog,
-                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("VC History"));
                if (ow < 0) {
                        ow = browser->LaTeXLog->w;
@@ -292,7 +293,7 @@ void LyXVC::viewLog(string const & fil)
 
 void LyXVC::showLog()
 {
-       string tmpf = tmpnam(0);
+       string tmpf = lyx::tempName();
        vcs->getLog(tmpf);
        viewLog(tmpf);
        lyx::unlink(tmpf);
index c9e215a09b3b417f300b488fd988defe12b4922a..4ae9b82cdeb02a782c87c7e3711c5fec1eb30372 100644 (file)
@@ -111,19 +111,27 @@ void button_cb(FL_OBJECT * ob, long data)
        lyxfunc->Dispatch(LFUN_INSERT_MATH, "sqrt");
       break;
     case MM_DELIM:
-      fl_show_form(fd_delim->delim, FL_PLACE_MOUSE, FL_FULLBORDER, _("Delimiter"));
+      fl_show_form(fd_delim->delim,
+                  FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+                  _("Delimiter"));
        fl_set_form_atclose(fd_delim->delim, CancelCloseBoxCB, 0);
       break;
     case MM_DECO:
-      fl_show_form(fd_deco->deco, FL_PLACE_MOUSE, FL_FULLBORDER, _("Decoration"));
+      fl_show_form(fd_deco->deco,
+                  FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+                  _("Decoration"));
        fl_set_form_atclose(fd_deco->deco, CancelCloseBoxCB, 0);
       break;
     case MM_SPACE:
-      fl_show_form(fd_space->space, FL_PLACE_MOUSE, FL_FULLBORDER, _("Spacing"));
+      fl_show_form(fd_space->space,
+                  FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+                  _("Spacing"));
        fl_set_form_atclose(fd_space->space, CancelCloseBoxCB, 0);
       break;
     case MM_MATRIX:
-      fl_show_form(fd_matrix->matrix, FL_PLACE_MOUSE, FL_FULLBORDER, _("Matrix"));
+      fl_show_form(fd_matrix->matrix,
+                  FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+                  _("Matrix"));
        fl_set_form_atclose(fd_matrix->matrix, CancelCloseBoxCB, 0);
       break;
     case MM_EQU:
@@ -364,7 +372,8 @@ void show_symbols_form(LyXFunc * lf)
     if (fd_panel->panel->visible) {
        fl_raise_form(fd_panel->panel);
     } else {
-      fl_show_form(fd_panel->panel, FL_PLACE_MOUSE,
-                  FL_FULLBORDER, _("Math Panel"));
+      fl_show_form(fd_panel->panel,
+                  FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
+                  _("Math Panel"));
     }
 }
index 7a3cb1d47c110f2dadd15e521a005992b58b93b7..de9c6c67601a352f4f2f5ebaa6bb2874d8550d65 100644 (file)
@@ -24,7 +24,6 @@
 #define S_ISBLK(x) false
 #define readlink(s, t, l) (strcpy(t, s), strlen(t))
 /*#define mkfifo(p, m) (0) *//* LyXserver is temporary disabled. */
-#define getcwd _getcwd2
 #define chdir _chdir2
 #define strcasecmp stricmp
 #if defined (__cplusplus)
index 53492cefbe31d49a770155bf9d9a3b4d79463f23..908bdfd1e8ae74ee58ca6ceeb9d44e001b1b8dca 100644 (file)
@@ -280,7 +280,7 @@ void SpellCheckerOptions()
                fl_raise_form(fd_form_spell_options->form_spell_options);
        } else {
                fl_show_form(fd_form_spell_options->form_spell_options,
-                            FL_PLACE_MOUSE, FL_FULLBORDER,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("Spellchecker Options"));
        }
 }
@@ -709,7 +709,7 @@ void ShowSpellChecker(BufferView * bv)
                fl_raise_form(fd_form_spell_check->form_spell_check);
        } else {
                fl_show_form(fd_form_spell_check->form_spell_check,
-                            FL_PLACE_MOUSE, FL_FULLBORDER,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("Spellchecker"));
        }
        fl_deactivate_object(fd_form_spell_check->slider); 
index b4ba8c50f47d01d328b7f3c88f96e1bbf178eeaa..1aa751be3cf9637c31bba13e38754babb943ab3b 100644 (file)
@@ -64,6 +64,7 @@ libsupport_la_SOURCES = \
        syscontr.C \
        syscontr.h \
        syssingleton.C \
+       tempname.C \
        translator.h \
        textutils.h \
        unlink.C
index c9605aa7f8f87dd153982a1565b8ca1601130828..5d084b314135850f8fc6f3d2d5d53ea3443214ad 100644 (file)
@@ -32,6 +32,7 @@
 #include "lyx_gui_misc.h"
 #include "FileInfo.h"
 #include "support/path.h"        // I know it's OS/2 specific (SMiyata)
+#include "support/syscall.h"
 #include "gettext.h"
 #include "lyxlib.h"
 
@@ -57,6 +58,7 @@ using std::make_pair;
 using std::pair;
 using std::endl;
 using std::ifstream;
+using std::vector;
 
 #if 0
 using std::getenv;
@@ -112,6 +114,7 @@ string const QuoteName(string const & name)
 }
 
 
+#if 0
 // Returns an unique name to be used as a temporary file. 
 string const TmpFileName(string const & dir, string const & mask)
 {// With all these temporary variables, it should be safe enough :-) (JMarc)
@@ -141,6 +144,7 @@ string const TmpFileName(string const & dir, string const & mask)
        lyxerr << "Not able to find a uniq tmpfile name." << endl;
        return string();
 }
+#endif
 
 
 // Is a file readable ?
@@ -174,7 +178,7 @@ int IsFileWriteable (string const & path)
 //      -1: error- couldn't find out
 int IsDirWriteable (string const & path)
 {
-        string const tmpfl(TmpFileName(path));
+        string const tmpfl(lyx::tempName(path)); //TmpFileName(path));
 
        if (tmpfl.empty()) {
                WriteFSAlert(_("LyX Internal Error!"), 
@@ -227,6 +231,71 @@ string const FileOpenSearch (string const & path, string const & name,
 }
 
 
+/// Returns a vector of all files in directory dir having extension ext.
+vector<string> const DirList( string const & dir, string const & ext)
+{
+       // What what what????
+       // where you tinking when you implemented this?
+#if 0
+       string lsCommand = "ls " + dir;
+       if (!ext.empty()) {
+               string::size_type sz = lsCommand.size();
+               if (lsCommand[sz - 1] != '/')
+                       lsCommand += '/';
+               lsCommand += '*';
+               if (ext[0] != '.')
+                       lsCommand += '.';
+               lsCommand += ext;
+       }
+       string tmpfile = system_tempdir + "/dirlist";
+       lsCommand += " > " + tmpfile;
+
+       Systemcalls(Systemcalls::System, lsCommand);
+
+       string contents = GetFileContents(tmpfile);
+       string rmCommand = "rm " + tmpfile;
+       Systemcalls(Systemcalls::System, rmCommand);
+
+       string tmp = strip(contents);
+       vector<string> dirlist;
+
+       while (!tmp.empty()) {
+               string file;
+               tmp = frontStrip(split(tmp, file, '\n'));
+               dirlist.push_back( file );
+       }
+       return dirlist;
+#else
+       // This is a non-error checking C/system implementation
+       // of the above.
+       string extension(ext);
+       if (extension[0] != '.') extension.insert(0u, 1u, '.');
+       vector<string> dirlist;
+       DIR * dirp = ::opendir(dir.c_str());
+       dirent * dire;
+       while ((dire = ::readdir(dirp))) {
+               string fil = dire->d_name;
+               if (prefixIs(fil, extension)) {
+                       dirlist.push_back(fil);
+               }
+       }
+       ::closedir(dirp);
+       return dirlist;
+       /* A C++ implementaion will look like this:
+          if (ext[0] != '.') ext.insert(0u, 1u, '.');
+          directory_iterator dit("dir");
+          while (dit != directory_iterator()) {
+                  string fil = (*dit).filename;
+                  if (prefixIs(fil, ext)) {
+                          dirlist.push_back(fil);
+                  }
+                  ++dit;
+          }
+       */
+#endif
+}
+
+
 // Returns the real name of file name in directory path, with optional
 // extension ext.  
 string const FileSearch(string const & path, string const & name, 
@@ -417,9 +486,18 @@ int DeleteAllFilesInDir (string const & path)
 static
 string const CreateTmpDir(string const & tempdir, string const & mask)
 {
-       string const tmpfl(TmpFileName(tempdir, mask));
+#warning Possibly buggy (Lgb)
+       lyxerr << "CreateTmpDir: tempdir=`" << tempdir << "'" << endl;
+       lyxerr << "CreateTmpDir:    mask=`" << mask << "'" << endl;
+       
+       string const tmpfl(lyx::tempName(tempdir, mask));
+       // lyx::tempName actually creates a file to make sure that it
+       // stays unique. So we have to delete it before we can create
+       // a dir with the same name. Note also that we are not thread
+       // safe because of the gap between unlink and mkdir. (Lgb)
+       lyx::unlink(tmpfl.c_str());
        
-       if ((tmpfl.empty()) || lyx::mkdir(tmpfl, 0777)) {
+       if (tmpfl.empty() || lyx::mkdir(tmpfl, 0777)) {
                WriteFSAlert(_("Error! Couldn't create temporary directory:"),
                             tempdir);
                return string();
@@ -446,7 +524,7 @@ int DestroyTmpDir(string const & tmpdir, bool Allfiles)
 
 string const CreateBufferTmpDir(string const & pathfor)
 {
-       return CreateTmpDir(pathfor, "lyx_bufrtmp");
+       return CreateTmpDir(pathfor, "lyx_tmpbuf");
 }
 
 
@@ -463,7 +541,7 @@ string const CreateLyXTmpDir(string const & deflt)
 #ifdef __EMX__
                         Path p(user_lyxdir);
 #endif
-                       string const t(CreateTmpDir(deflt, "lyx_tmp"));
+                       string const t(CreateTmpDir(deflt, "lyx_tmpdir"));
                         return t;
                } else
                         return deflt;
@@ -471,7 +549,7 @@ string const CreateLyXTmpDir(string const & deflt)
 #ifdef __EMX__
                Path p(user_lyxdir);
 #endif
-               string const t(CreateTmpDir("/tmp", "lyx_tmp"));
+               string const t(CreateTmpDir("/tmp", "lyx_tmpdir"));
                return t;
        }
 }
@@ -502,6 +580,7 @@ bool createDirectory(string const & path, int permission)
 }
 
 
+#if 0
 // Returns current working directory
 string const GetCWD ()
 {
@@ -522,6 +601,7 @@ string const GetCWD ()
        delete[] tbuf;
        return result;
 }
+#endif
 
 
 // Strip filename from path name
@@ -565,7 +645,7 @@ string const MakeAbsPath(string const & RelPath, string const & BasePath)
                delete[] with_drive;
 #endif
        } else
-               TempBase = GetCWD();
+               TempBase = lyx::getcwd(); //GetCWD();
 #ifdef __EMX__
        if (AbsolutePath(TempRel))
                return TempBase.substr(0, 2) + TempRel;
@@ -674,7 +754,7 @@ string const ExpandPath(string const & path)
        RTemp = split(RTemp, Temp, '/');
 
        if (Temp == ".") {
-               return GetCWD() + '/' + RTemp;
+               return lyx::getcwd() /*GetCWD()*/ + '/' + RTemp;
        } else if (Temp == "~") {
                return GetEnvPath("HOME") + '/' + RTemp;
        } else if (Temp == "..") {
index d1329d89e69a73bd4cc3b79db222e63fa5a0591d..f42c539749233bb1f3c7e1cfd2b301ff29cac452 100644 (file)
@@ -15,6 +15,8 @@
 #include <fcntl.h>
 #include <cerrno>
 
+#include <vector>
+
 #include "debug.h"
 #include "LString.h"
 #include "support/lstrings.h"
@@ -53,6 +55,10 @@ string const FileOpenSearch (string const & path, string const & name,
 string const FileSearch(string const & path, string const & name, 
                  string const & ext = string());
 
+/// Returns a vector of all files in directory dir having extension ext.
+std::vector<string> const DirList(string const & dir,
+                                 string const & ext = string());
+
 /** Is directory read only?
   returns 
     1: dir writeable
@@ -115,6 +121,7 @@ string const MakeLatexName(string const & file);
 /// Put the name in quotes suitable for the current shell
 string const QuoteName(string const & file);
 
+#if 0
 /** Returns an unique name to be used as a temporary file. If given,
   'mask' should the prefix to the temporary file, the rest of the
   temporary filename will be made from the pid and three letters.
@@ -122,6 +129,7 @@ string const QuoteName(string const & file);
 string const
 TmpFileName(string const & dir = string(), 
            string const & mask = "lyx_tmp");
+#endif
 
 /// Is a filename/path absolute?
 bool AbsolutePath(string const & path);
@@ -145,16 +153,17 @@ string const GetExtension(string const & name);
 /// Create absolute path. If impossible, don't do anything
 string const ExpandPath(string const & path);
 
+#if 0
 /// gets current working directory
 string const GetCWD();
-
+#endif
 
 /** Convert relative path into absolute path based on a basepath.
   If relpath is absolute, just use that.
   If basepath doesn't exist use CWD.
   */
 string const MakeAbsPath(string const & RelPath = string(), 
-                  string const & BasePath = string());
+                        string const & BasePath = string());
 
 /** Creates a nice compact path for displaying. The parameter
   threshold, if given, specifies the maximal length of the path.
index f8e096bba1ea4daa9c3919d933f552609f79b6d2..edf38b3ce59662364881f77d9d2031bfcfce4864 100644 (file)
@@ -1,10 +1,12 @@
 #include <config.h>
 
+#include <cerrno>
 #include <unistd.h>
 
 #include "support/lyxlib.h"
 
-char * lyx::getcwd(char * buffer, size_t size)
+static inline
+char * l_getcwd(char * buffer, size_t size)
 {
 #ifndef __EMX__
        return ::getcwd(buffer, size);
@@ -12,3 +14,25 @@ char * lyx::getcwd(char * buffer, size_t size)
        return ::_getcwd2(buffer, size);
 #endif
 }
+
+
+// Returns current working directory
+string const lyx::getcwd()
+{
+       int n = 256;    // Assume path is less than 256 chars
+       char * err;
+       char * tbuf = new char[n];
+       
+       // Safe. Hopefully all getcwds behave this way!
+       while (((err = l_getcwd(tbuf, n)) == 0) && (errno == ERANGE)) {
+               // Buffer too small, double the buffersize and try again
+               delete[] tbuf;
+               n = 2 * n;
+               tbuf = new char[n];
+       }
+
+       string result;
+       if (err) result = tbuf;
+       delete[] tbuf;
+       return result;
+}
index befb7bd6f8e94150f9bda4aa2c384b3618a69122..d178797b05cd6c6b59cadfc85c8b6501279a8d95 100644 (file)
@@ -27,7 +27,7 @@ namespace lyx {
 struct lyx {
 #endif 
        ///
-       OPT_STATIC char * getcwd(char * buffer, size_t size);
+       OPT_STATIC string const getcwd();
         ///
         OPT_STATIC int chdir(string const & name);
         /// Returns false if it fails
@@ -54,6 +54,9 @@ struct lyx {
         OPT_STATIC int rmdir(string const & file);
         ///
         OPT_STATIC int atoi(string const & nstr);
+       ///
+       OPT_STATIC string const tempName(string const & dir = string(),
+                                        string const & mask = string());
 #ifdef CXX_WORKING_NAMESPACES
 }
 #else
index ced3358c240c8c37a30606b858a3d2fbec733ef4..9e8f67ba8e10c83ab21b587313724c8fc49541fd 100644 (file)
@@ -3,7 +3,7 @@
 #define PATH_H
 
 #include "LString.h"
-#include "filetools.h"
+//#include "filetools.h"
 #include "lyxlib.h"
 #include <boost/utility.hpp>
 
@@ -20,7 +20,7 @@ public:
                : popped_(false)
        {
                if (!path.empty()) { 
-                       pushedDir_ = GetCWD();
+                       pushedDir_ = lyx::getcwd(); // GetCWD();
                        if (pushedDir_.empty() || lyx::chdir(path)) {
                                // should throw an exception
                                // throw DirChangeError();
diff --git a/src/support/tempname.C b/src/support/tempname.C
new file mode 100644 (file)
index 0000000..ee34988
--- /dev/null
@@ -0,0 +1,48 @@
+#include <config.h>
+
+#include "LString.h"
+
+#include <cstdlib>
+
+#include <unistd.h>
+
+#include "lyxlib.h"
+#include "debug.h"
+#include "filetools.h"
+
+extern string system_tempdir;
+
+string const lyx::tempName(string const & dir, string const & mask)
+{
+#if 0
+       // the tmpnam version...
+       char const * const tmp = ::tmpnam(0);
+       return (tmp) ? tmp : string ();
+#else
+       string tmpdir;
+       if (dir.empty())
+               tmpdir = system_tempdir;
+       else
+               tmpdir = dir;
+       string tmpfl(AddName(tmpdir, mask));
+       tmpfl += tostr(getpid());
+
+       // the supposedly safer mkstemp version
+       char * tmpl = new char[256];
+       tmpfl += ".XXXXXX";
+       ::strcpy(tmpl, tmpfl.c_str());
+       int tmpf = ::mkstemp(tmpl);
+       if (tmpf != -1) {
+               string const t(tmpl);
+               ::close(tmpf);
+               delete [] tmpl;
+               lyxerr << "Temporary file `" << t << "' created." << endl;
+               return t;
+       } else {
+               lyxerr << "LyX Error: Unable to create temporary file."
+                      << endl;
+               delete [] tmpl;
+               return string();
+       }
+#endif
+}
index 48f0d341b946c5977236ae2879120bb1b28ace2a..81efc9f6ce2a6a7c6e0c085ec47c82d81f6a599e 100644 (file)
@@ -12,6 +12,7 @@
 #include "support/LRegex.h"
 #include "support/LSubstring.h"
 #include "support/path.h"
+#include "support/filetools.h"
 #include "buffer.h"
 #include "LyXView.h"
 #include "lyxfunc.h"