I think the uncontroversial part of the thread "[patch] was: how to access LyX's example files" (http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg132498.html)
is the support to modify the examples folder in the preferences. We already do this for the templates folder, therefore the patch is straight forward according this.
No matter how we solve the example access, this feature would be useful. OK, to go in? Jürgen, do you want this for branch too? regards Uwe
Index: frontends/qt4/GuiPrefs.cpp =================================================================== --- frontends/qt4/GuiPrefs.cpp (revision 21760) +++ frontends/qt4/GuiPrefs.cpp (working copy) @@ -736,6 +736,7 @@ : PrefModule(_("Paths"), form, parent) { setupUi(this); + connect(exampleDirPB, SIGNAL(clicked()), this, SLOT(select_exampledir())); connect(templateDirPB, SIGNAL(clicked()), this, SLOT(select_templatedir())); connect(tempDirPB, SIGNAL(clicked()), this, SLOT(select_tempdir())); connect(backupDirPB, SIGNAL(clicked()), this, SLOT(select_backupdir())); @@ -743,6 +744,8 @@ connect(lyxserverDirPB, SIGNAL(clicked()), this, SLOT(select_lyxpipe())); connect(workingDirED, SIGNAL(textChanged(QString)), this, SIGNAL(changed())); + connect(exampleDirPB, SIGNAL(textChanged(QString)), + this, SIGNAL(changed())); connect(templateDirED, SIGNAL(textChanged(QString)), this, SIGNAL(changed())); connect(backupDirED, SIGNAL(textChanged(QString)), @@ -759,6 +762,7 @@ void PrefPaths::apply(LyXRC & rc) const { rc.document_path = internal_path(fromqstr(workingDirED->text())); + rc.example_path = internal_path(fromqstr(exampleDirED->text())); rc.template_path = internal_path(fromqstr(templateDirED->text())); rc.backupdir_path = internal_path(fromqstr(backupDirED->text())); rc.tempdir_path = internal_path(fromqstr(tempDirED->text())); @@ -771,6 +775,7 @@ void PrefPaths::update(LyXRC const & rc) { workingDirED->setText(toqstr(external_path(rc.document_path))); + exampleDirED->setText(toqstr(external_path(rc.example_path))); templateDirED->setText(toqstr(external_path(rc.template_path))); backupDirED->setText(toqstr(external_path(rc.backupdir_path))); tempDirED->setText(toqstr(external_path(rc.tempdir_path))); @@ -780,6 +785,16 @@ } +void PrefPaths::select_exampledir() +{ + docstring file(form_->browsedir( + from_utf8(internal_path(fromqstr(exampleDirED->text()))), + _("Select a document templates directory"))); + if (!file.empty()) + exampleDirED->setText(toqstr(file)); +} + + void PrefPaths::select_templatedir() { docstring file(form_->browsedir( Index: frontends/qt4/GuiPrefs.h =================================================================== --- frontends/qt4/GuiPrefs.h (revision 21760) +++ frontends/qt4/GuiPrefs.h (working copy) @@ -197,6 +197,7 @@ void update(LyXRC const & rc); private Q_SLOTS: + void select_exampledir(); void select_templatedir(); void select_tempdir(); void select_backupdir(); Index: frontends/qt4/ui/PrefPathsUi.ui =================================================================== --- frontends/qt4/ui/PrefPathsUi.ui (revision 21760) +++ frontends/qt4/ui/PrefPathsUi.ui (working copy) @@ -6,31 +6,28 @@ <x>0</x> <y>0</y> <width>347</width> - <height>227</height> + <height>259</height> </rect> </property> <property name="windowTitle" > <string/> </property> <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="3" column="0" > - <widget class="QLabel" name="lyxserverDirLA" > + <item row="0" column="0" > + <widget class="QLabel" name="workingDirLA" > <property name="text" > - <string>Ly&XServer pipe:</string> + <string>&Working directory:</string> </property> <property name="buddy" > - <cstring>lyxserverDirED</cstring> + <cstring>workingDirED</cstring> </property> </widget> </item> - <item row="1" column="2" > - <widget class="QPushButton" name="templateDirPB" > + <item row="0" column="1" > + <widget class="QLineEdit" name="workingDirED" /> + </item> + <item row="0" column="2" > + <widget class="QPushButton" name="workingDirPB" > <property name="text" > <string>Browse...</string> </property> @@ -39,11 +36,21 @@ </property> </widget> </item> - <item row="5" column="1" colspan="2" > - <widget class="QLineEdit" name="pathPrefixED" /> + <item row="1" column="0" > + <widget class="QLabel" name="templateDirLA" > + <property name="text" > + <string>&Document templates:</string> + </property> + <property name="buddy" > + <cstring>templateDirED</cstring> + </property> + </widget> </item> - <item row="2" column="2" > - <widget class="QPushButton" name="backupDirPB" > + <item row="1" column="1" > + <widget class="QLineEdit" name="templateDirED" /> + </item> + <item row="1" column="2" > + <widget class="QPushButton" name="templateDirPB" > <property name="text" > <string>Browse...</string> </property> @@ -52,24 +59,21 @@ </property> </widget> </item> - <item row="4" column="2" > - <widget class="QPushButton" name="tempDirPB" > + <item row="2" column="0" > + <widget class="QLabel" name="exampleDirLA" > <property name="text" > - <string>Browse...</string> + <string>&Example files:</string> </property> - <property name="autoDefault" > - <bool>false</bool> + <property name="buddy" > + <cstring>templateDirED</cstring> </property> </widget> </item> - <item row="3" column="1" > - <widget class="QLineEdit" name="lyxserverDirED" /> + <item row="2" column="1" > + <widget class="QLineEdit" name="exampleDirED" /> </item> - <item row="1" column="1" > - <widget class="QLineEdit" name="templateDirED" /> - </item> - <item row="0" column="2" > - <widget class="QPushButton" name="workingDirPB" > + <item row="2" column="2" > + <widget class="QPushButton" name="exampleDirPB" > <property name="text" > <string>Browse...</string> </property> @@ -78,43 +82,43 @@ </property> </widget> </item> - <item row="5" column="0" > - <widget class="QLabel" name="pathPrefixLA" > + <item row="3" column="0" > + <widget class="QLabel" name="backupDirLA" > <property name="text" > - <string>&PATH prefix:</string> + <string>&Backup directory:</string> </property> <property name="buddy" > - <cstring>pathPrefixED</cstring> + <cstring>backupDirED</cstring> </property> </widget> </item> - <item row="4" column="0" > - <widget class="QLabel" name="tempDirLA" > + <item row="3" column="1" > + <widget class="QLineEdit" name="backupDirED" /> + </item> + <item row="3" column="2" > + <widget class="QPushButton" name="backupDirPB" > <property name="text" > - <string>&Temporary directory:</string> + <string>Browse...</string> </property> - <property name="buddy" > - <cstring>tempDirED</cstring> + <property name="autoDefault" > + <bool>false</bool> </property> </widget> </item> - <item row="2" column="0" > - <widget class="QLabel" name="backupDirLA" > + <item row="4" column="0" > + <widget class="QLabel" name="lyxserverDirLA" > <property name="text" > - <string>&Backup directory:</string> + <string>Ly&XServer pipe:</string> </property> <property name="buddy" > - <cstring>backupDirED</cstring> + <cstring>lyxserverDirED</cstring> </property> </widget> </item> - <item row="2" column="1" > - <widget class="QLineEdit" name="backupDirED" /> + <item row="4" column="1" > + <widget class="QLineEdit" name="lyxserverDirED" /> </item> - <item row="0" column="1" > - <widget class="QLineEdit" name="workingDirED" /> - </item> - <item row="3" column="2" > + <item row="4" column="2" > <widget class="QPushButton" name="lyxserverDirPB" > <property name="text" > <string>Browse...</string> @@ -124,30 +128,43 @@ </property> </widget> </item> - <item row="0" column="0" > - <widget class="QLabel" name="workingDirLA" > + <item row="5" column="0" > + <widget class="QLabel" name="tempDirLA" > <property name="text" > - <string>&Working directory:</string> + <string>&Temporary directory:</string> </property> <property name="buddy" > - <cstring>workingDirED</cstring> + <cstring>tempDirED</cstring> </property> </widget> </item> - <item row="1" column="0" > - <widget class="QLabel" name="templateDirLA" > + <item row="5" column="1" > + <widget class="QLineEdit" name="tempDirED" /> + </item> + <item row="5" column="2" > + <widget class="QPushButton" name="tempDirPB" > <property name="text" > - <string>&Document templates:</string> + <string>Browse...</string> </property> + <property name="autoDefault" > + <bool>false</bool> + </property> + </widget> + </item> + <item row="6" column="0" > + <widget class="QLabel" name="pathPrefixLA" > + <property name="text" > + <string>&PATH prefix:</string> + </property> <property name="buddy" > - <cstring>templateDirED</cstring> + <cstring>pathPrefixED</cstring> </property> </widget> </item> - <item row="4" column="1" > - <widget class="QLineEdit" name="tempDirED" /> + <item row="6" column="1" colspan="2" > + <widget class="QLineEdit" name="pathPrefixED" /> </item> - <item row="6" column="0" colspan="3" > + <item row="7" column="0" colspan="3" > <spacer> <property name="orientation" > <enum>Qt::Vertical</enum> @@ -165,10 +182,6 @@ </item> </layout> </widget> - <pixmapfunction></pixmapfunction> - <includes> - <include location="local" >qt_helpers.h</include> - </includes> <tabstops> <tabstop>workingDirED</tabstop> <tabstop>workingDirPB</tabstop> @@ -181,6 +194,9 @@ <tabstop>tempDirED</tabstop> <tabstop>tempDirPB</tabstop> </tabstops> + <includes> + <include location="local" >qt_helpers.h</include> + </includes> <resources/> <connections/> </ui> Index: LyX.cpp =================================================================== --- LyX.cpp (revision 21760) +++ LyX.cpp (working copy) @@ -785,6 +785,10 @@ lyxrc.tempdir_path = package().temp_dir().absFilename(); lyxrc.document_path = package().document_dir().absFilename(); + if (lyxrc.example_path.empty()) { + lyxrc.example_path = addPath(package().system_support().absFilename(), + "examples"); + } if (lyxrc.template_path.empty()) { lyxrc.template_path = addPath(package().system_support().absFilename(), "templates"); Index: LyXRC.cpp =================================================================== --- LyXRC.cpp (revision 21760) +++ LyXRC.cpp (working copy) @@ -92,6 +92,7 @@ { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS }, { "\\document_path", LyXRC::RC_DOCUMENTPATH }, { "\\escape_chars", LyXRC::RC_ESC_CHARS }, + { "\\example_path", LyXRC::RC_EXAMPLEPATH }, { "\\font_encoding", LyXRC::RC_FONT_ENCODING }, { "\\format", LyXRC::RC_FORMAT }, { "\\index_command", LyXRC::RC_INDEX_COMMAND }, @@ -705,6 +706,13 @@ } break; + case RC_EXAMPLEPATH: + if (lexrc.next()) { + example_path = os::internal_path(lexrc.getString()); + example_path = expandPath(example_path); + } + break; + case RC_TEMPLATEPATH: if (lexrc.next()) { template_path = os::internal_path(lexrc.getString()); @@ -1932,6 +1940,14 @@ } if (tag != RC_LAST) break; + case RC_EXAMPLEPATH: + if (ignore_system_lyxrc || + example_path != system_lyxrc.example_path) { + string const path = os::external_path(example_path); + os << "\\example_path \"" << path << "\"\n"; + } + if (tag != RC_LAST) + break; case RC_TEMPLATEPATH: if (ignore_system_lyxrc || template_path != system_lyxrc.template_path) { @@ -2411,6 +2427,10 @@ str = _("Specify additional chars that can be part of a word."); break; + case RC_EXAMPLEPATH: + str = _("The path that LyX will set when offering to choose an example. An empty value selects the directory LyX was started from."); + break; + case RC_FONT_ENCODING: str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages."); break; Index: LyXRC.h =================================================================== --- LyXRC.h (revision 21760) +++ LyXRC.h (working copy) @@ -63,6 +63,7 @@ RC_DISPLAY_GRAPHICS, RC_DOCUMENTPATH, RC_ESC_CHARS, + RC_EXAMPLEPATH, RC_FONT_ENCODING, RC_FORMAT, RC_INDEX_COMMAND, @@ -226,6 +227,8 @@ /// std::string document_path; /// + std::string example_path; + /// std::string template_path; /// std::string tempdir_path;