Alex Fernandez wrote: > But that is not the argument I am making. Instead, it is: this nice > little hack solves a problem (HTML export with different tools) in the > long term, and it does not add to the big issue (clutter in the export > menu) significantly. The "better" solution is an overall improvement, > but completely orthogonal to the HTML export problem we have now. So > what I say is: let us solve the issue that people are demanding now, > since someone is offering to help; and let us worry about the > perceived clutter later, since nobody is volunteering to do that. > Reversing the order (i.e. if a solution for menu clutter was in the > works, wait for that and then fix HTML export) would not change the > perceived difficulty of either problem.
OK, let's try to turn this discussion to a more productive direction. Do you want to volunteer to help us doing it properly? I attach the uncommitted stuff I have done so far. I didn't touch it for a long time, but I remember it still had some glitches. Anyway, it's a start. As said, I don't have time to finish it myself ATM, but I'm willing to help where ever I can. The idea goes as follows: * in configure.py, check for \viewer_alternatives and \converter_alternatives next to the \viewer and \converter we already check for. That is: the first found viewer/converter in the list (currently the one that is used exclusively) is stored as \viewer or \converter (as we do already), but we continue the search and store the other found ones as \viewer_alternative and \converter_alternative. This is what we are already doing for programs such as bibtex and makeindex (look at \bibtex_alternative and \index_alternative in trunk). * In the preferences dialog, you can then select from a list of preconfigured viewers (I've implemented a combo for this). For the converters, we should add the "alternative" converters to the browser and add a check box to enable/disable converters in the menu (with the "alternatives" deselected by default). Thus, the \converter rc would need a "menu" flag. The patch attempts to implement the \viewer_alternative idea. The \converter_alternative, the thing you are actually looking for, could be easily added in the same vein. Jürgen
Index: src/LyXRC.h =================================================================== --- src/LyXRC.h (Revision 31282) +++ src/LyXRC.h (Arbeitskopie) @@ -24,6 +24,7 @@ #include <set> #include <string> +#include <vector> namespace lyx { @@ -177,6 +178,7 @@ RC_USE_SPELL_LIB, RC_VIEWDVI_PAPEROPTION, RC_VIEWER, + RC_VIEWER_ALTERNATIVES, RC_VISUAL_CURSOR, RC_LAST }; @@ -383,6 +385,8 @@ std::string gui_language; /// std::string default_view_format; + /// all available viewers + std::vector<std::pair<std::string, std::string> > viewer_alternatives; /// bool mac_like_word_movement; /// Index: src/frontends/qt4/GuiPrefs.cpp =================================================================== --- src/frontends/qt4/GuiPrefs.cpp (Revision 31282) +++ src/frontends/qt4/GuiPrefs.cpp (Arbeitskopie) @@ -1632,6 +1632,8 @@ this, SIGNAL(changed())); connect(defaultFormatCB, SIGNAL(activated(QString)), this, SIGNAL(changed())); + connect(viewerCO, SIGNAL(activated(int)), + this, SIGNAL(changed())); } @@ -1667,6 +1669,7 @@ rc.default_view_format)); defaultFormatCB->setCurrentIndex(pos); } + viewer_alternatives = rc.viewer_alternatives; } @@ -1713,10 +1716,26 @@ extensionED->setText(toqstr(f.extension())); shortcutED->setText( toqstr(l10n_shortcut(f.prettyname(), f.shortcut()))); - viewerED->setText(toqstr(f.viewer())); editorED->setText(toqstr(f.editor())); documentCB->setChecked((f.documentFormat())); vectorCB->setChecked((f.vectorFormat())); + + viewerCO->clear(); + viewerCO->addItem(qt_("Custom"), QString()); + for (vector<pair<string, string> >::const_iterator it = viewer_alternatives.begin(); + it != viewer_alternatives.end(); ++it) { + if (it->first == f.name()) + viewerCO->addItem(toqstr(it->second), toqstr(it->second)); + } + + int pos = viewerCO->findData(toqstr(f.viewer())); + if (pos != -1) { + viewerED->clear(); + viewerCO->setCurrentIndex(pos); + } else { + viewerED->setText(toqstr(f.viewer())); + viewerCO->setCurrentIndex(0); + } } Index: src/frontends/qt4/ui/PrefFileformatsUi.ui =================================================================== --- src/frontends/qt4/ui/PrefFileformatsUi.ui (Revision 31282) +++ src/frontends/qt4/ui/PrefFileformatsUi.ui (Arbeitskopie) @@ -5,109 +5,28 @@ <rect> <x>0</x> <y>0</y> - <width>427</width> - <height>413</height> + <width>443</width> + <height>477</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="10" column="0" colspan="4" > - <widget class="QGroupBox" name="defaultFormatGB" > - <property name="toolTip" > - <string>Specify the default output format when using (PDF)LaTeX</string> - </property> - <property name="title" > - <string>Default Format</string> - </property> - <property name="flat" > - <bool>true</bool> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="defaultFormatLA" > - <property name="text" > - <string>De&fault Output Format:</string> - </property> - <property name="buddy" > - <cstring>defaultFormatCB</cstring> - </property> - </widget> - </item> - <item row="0" column="1" > - <widget class="QComboBox" name="defaultFormatCB" /> - </item> - </layout> - </widget> - </item> - <item row="9" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>124</width> - <height>21</height> - </size> - </property> - </spacer> - </item> - <item row="8" column="1" colspan="3" > - <widget class="QLineEdit" name="copierED" /> - </item> - <item row="6" column="1" > - <widget class="QLineEdit" name="editorED" /> - </item> - <item row="0" column="2" > - <widget class="QPushButton" name="formatNewPB" > + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="formatsLA" > <property name="text" > - <string>&New...</string> + <string>&Format:</string> </property> - </widget> - </item> - <item row="0" column="3" > - <widget class="QPushButton" name="formatRemovePB" > - <property name="text" > - <string>Re&move</string> - </property> - </widget> - </item> - <item row="5" column="1" > - <widget class="QLineEdit" name="shortcutED" /> - </item> - <item row="3" column="1" > - <widget class="QLineEdit" name="formatED" /> - </item> - <item row="3" column="0" > - <widget class="QLabel" name="formatLA" > - <property name="text" > - <string>S&hort Name:</string> - </property> <property name="buddy" > - <cstring>formatED</cstring> + <cstring>formatsCB</cstring> </property> </widget> </item> <item row="0" column="1" > <widget class="QComboBox" name="formatsCB" > <property name="sizePolicy" > - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>0</vsizetype> + <sizepolicy vsizetype="Fixed" hsizetype="Expanding" > <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -126,53 +45,60 @@ </property> </widget> </item> - <item row="2" column="1" colspan="3" > - <widget class="QCheckBox" name="vectorCB" > + <item row="0" column="2" colspan="2" > + <widget class="QPushButton" name="formatNewPB" > <property name="text" > - <string>Vector &graphics format</string> + <string>&New...</string> </property> </widget> </item> - <item row="0" column="0" > - <widget class="QLabel" name="formatsLA" > + <item row="0" column="4" > + <widget class="QPushButton" name="formatRemovePB" > <property name="text" > - <string>&Format:</string> + <string>Re&move</string> </property> - <property name="buddy" > - <cstring>formatsCB</cstring> - </property> </widget> </item> - <item row="1" column="1" colspan="3" > + <item row="1" column="1" colspan="4" > <widget class="QCheckBox" name="documentCB" > <property name="text" > <string>&Document format</string> </property> </widget> </item> - <item row="7" column="0" > - <widget class="QLabel" name="viewerLA" > + <item row="2" column="1" colspan="4" > + <widget class="QCheckBox" name="vectorCB" > <property name="text" > - <string>&Viewer:</string> + <string>Vector &graphics format</string> </property> + </widget> + </item> + <item row="3" column="0" > + <widget class="QLabel" name="formatLA" > + <property name="text" > + <string>S&hort Name:</string> + </property> <property name="buddy" > - <cstring>viewerED</cstring> + <cstring>formatED</cstring> </property> </widget> </item> - <item row="7" column="1" > - <widget class="QLineEdit" name="viewerED" /> + <item row="3" column="1" > + <widget class="QLineEdit" name="formatED" /> </item> - <item row="6" column="0" > - <widget class="QLabel" name="editorLA" > + <item row="4" column="0" > + <widget class="QLabel" name="extensionLA" > <property name="text" > - <string>Ed&itor:</string> + <string>E&xtension:</string> </property> <property name="buddy" > - <cstring>editorED</cstring> + <cstring>extensionED</cstring> </property> </widget> </item> + <item row="4" column="1" > + <widget class="QLineEdit" name="extensionED" /> + </item> <item row="5" column="0" > <widget class="QLabel" name="shortcutLA" > <property name="text" > @@ -183,19 +109,38 @@ </property> </widget> </item> - <item row="4" column="0" > - <widget class="QLabel" name="extensionLA" > + <item row="5" column="1" > + <widget class="QLineEdit" name="shortcutED" /> + </item> + <item row="6" column="0" > + <widget class="QLabel" name="editorLA" > <property name="text" > - <string>E&xtension:</string> + <string>Ed&itor:</string> </property> <property name="buddy" > - <cstring>extensionED</cstring> + <cstring>editorED</cstring> </property> </widget> </item> - <item row="4" column="1" > - <widget class="QLineEdit" name="extensionED" /> + <item row="6" column="1" > + <widget class="QLineEdit" name="editorED" /> </item> + <item row="7" column="0" > + <widget class="QLabel" name="viewerLA" > + <property name="text" > + <string>&Viewer:</string> + </property> + <property name="buddy" > + <cstring>viewerCO</cstring> + </property> + </widget> + </item> + <item row="7" column="1" colspan="2" > + <widget class="QComboBox" name="viewerCO" /> + </item> + <item row="7" column="3" colspan="2" > + <widget class="QLineEdit" name="viewerED" /> + </item> <item row="8" column="0" > <widget class="QLabel" name="label" > <property name="text" > @@ -206,6 +151,56 @@ </property> </widget> </item> + <item row="8" column="1" colspan="4" > + <widget class="QLineEdit" name="copierED" /> + </item> + <item row="9" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>124</width> + <height>21</height> + </size> + </property> + </spacer> + </item> + <item row="10" column="0" colspan="5" > + <widget class="QGroupBox" name="defaultFormatGB" > + <property name="toolTip" > + <string>Specify the default output format when using (PDF)LaTeX</string> + </property> + <property name="title" > + <string>Default Format</string> + </property> + <property name="flat" > + <bool>true</bool> + </property> + <layout class="QGridLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item row="0" column="0" > + <widget class="QLabel" name="defaultFormatLA" > + <property name="text" > + <string>De&fault Output Format:</string> + </property> + <property name="buddy" > + <cstring>defaultFormatCB</cstring> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QComboBox" name="defaultFormatCB" /> + </item> + </layout> + </widget> + </item> </layout> </widget> <tabstops> Index: src/frontends/qt4/GuiPrefs.h =================================================================== --- src/frontends/qt4/GuiPrefs.h (Revision 31282) +++ src/frontends/qt4/GuiPrefs.h (Arbeitskopie) @@ -372,6 +372,8 @@ private: Format & currentFormat(); + /// + std::vector<std::pair<std::string, std::string> > viewer_alternatives; }; Index: src/LyXFunc.cpp =================================================================== --- src/LyXFunc.cpp (Revision 31282) +++ src/LyXFunc.cpp (Arbeitskopie) @@ -2079,6 +2079,7 @@ case LyXRC::RC_FULL_SCREEN_WIDTH: case LyXRC::RC_VISUAL_CURSOR: case LyXRC::RC_VIEWER: + case LyXRC::RC_VIEWER_ALTERNATIVES: case LyXRC::RC_LAST: break; } Index: src/LyXRC.cpp =================================================================== --- src/LyXRC.cpp (Revision 31282) +++ src/LyXRC.cpp (Arbeitskopie) @@ -195,6 +195,7 @@ { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION }, // compatibility with versions older than 1.4.0 only { "\\viewer", LyXRC::RC_VIEWER}, + { "\\viewer_alternatives", LyXRC::RC_VIEWER_ALTERNATIVES }, { "\\visual_cursor" ,LyXRC::RC_VISUAL_CURSOR} }; @@ -1032,6 +1033,13 @@ } break; } + case RC_VIEWER_ALTERNATIVES: { + string format, command; + lexrc >> format >> command; + viewer_alternatives.push_back(make_pair(format, command)); + break; + } + case RC_DEFAULT_VIEW_FORMAT: lexrc >> default_view_format; break; @@ -2459,6 +2467,16 @@ << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n"; if (tag != RC_LAST) break; + case RC_VIEWER_ALTERNATIVES: + if (ignore_system_lyxrc || + viewer_alternatives != system_lyxrc.viewer_alternatives) { + for (vector<pair<string, string> >::const_iterator it = viewer_alternatives.begin(); + it != viewer_alternatives.end(); ++it) + os << "\\viewer_alternatives " + << it->first << " " << it->second << "\n"; + } + if (tag != RC_LAST) + break; case RC_DEFAULT_VIEW_FORMAT: if (ignore_system_lyxrc || default_view_format != system_lyxrc.default_view_format) { Index: lib/configure.py =================================================================== --- lib/configure.py (Revision 31282) +++ lib/configure.py (Arbeitskopie) @@ -178,7 +178,6 @@ return ['', not_found] -## Searching some useful programs def checkProgAlternatives(description, progs, rc_entry = [], alt_rc_entry = [], path = [], not_found = ''): ''' The same as checkProg, but additionally, all found programs will be added @@ -188,10 +187,6 @@ if len(rc_entry) > 1 and len(rc_entry) != len(progs) + 1: logger.error("rc entry should have one item or item for each prog and not_found.") sys.exit(2) - # check if alt rcs are given - if len(alt_rc_entry) > 1 and len(alt_rc_entry) != len(rc_entry): - logger.error("invalid alt_rc_entry specification.") - sys.exit(2) logger.info('checking for ' + description + '...') ## print '(' + ','.join(progs) + ')', found_prime = False @@ -221,9 +216,17 @@ real_ac_word = ac_word found_prime = True if len(alt_rc_entry) == 1: - addToRC(alt_rc_entry[0].replace('%%', ac_prog)) + alt_rc = alt_rc_entry[0] + if alt_rc == "": + # if no explicit alt_rc is given, construct one + alt_rc = rc_entry[0] + "_alternatives" + addToRC(alt_rc.replace('%%', ac_prog)) elif len(alt_rc_entry) > 1: - addToRC(alt_rc_entry[idx].replace('%%', ac_prog)) + alt_rc = alt_rc_entry[idx] + if alt_rc == "": + # if no explicit alt_rc is given, construct one + alt_rc = rc_entry[idx] + "_alternatives" + addToRC(alt_rc.replace('%%', ac_prog)) found_alt = True break if found_alt: @@ -240,8 +243,47 @@ def checkViewer(description, progs, rc_entry = [], path = []): - ''' The same as checkProg, but for viewers and editors ''' - return checkProg(description, progs, rc_entry, path, not_found = 'auto') + ''' The same as checkProgAlternatives, but for viewers and editors ''' + if len(rc_entry) > 1 and len(rc_entry) != len(progs) + 1: + logger.error("rc entry should have one item or item for each prog and not_found.") + sys.exit(2) + alt_rc_entry = [] + for idx in range(len(progs)): + r = re.compile(r'\\Format (\S+).*$') + m = None + if len(rc_entry) == 1: + logger.info("rc_entry: " + rc_entry[0]) + rcs = rc_entry[0].split('\n') + alt = '' + for idxx in range(len(rcs)): + if len(rcs) == 1: + m = r.match(rcs[0]) + if m: + alt = r'\viewer_alternatives ' + m.group(1) + " %%" + elif len(rcs) > 1: + m = r.match(rcs[idxx]) + if m: + if idxx > 0: + alt += '\n' + alt += r'\viewer_alternatives ' + m.group(1) + " %%" + alt_rc_entry.insert(0, alt) + elif len(rc_entry) > 1: + logger.info("rc_entry: " + rc_entry[idx]) + rcs = rc_entry[idx].split('\n') + alt = '' + for idxx in range(len(rcs)): + if len(rcs) == 1: + m = r.match(rcs[0]) + if m: + alt = r'\viewer_alternatives ' + m.group(1) + " %%" + elif len(rcs) > 1: + m = r.match(rcs[idxx]) + if m: + if idxx > 0: + alt += '\n' + alt += r'\viewer_alternatives ' + m.group(1) + " %%" + alt_rc_entry.insert(idx, alt) + return checkProgAlternatives(description, progs, rc_entry, alt_rc_entry, path, not_found = 'auto') def checkDTLtools():