]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiExternal.cpp
Compil fix.
[lyx.git] / src / frontends / qt4 / GuiExternal.cpp
1 /**
2  * \file GuiExternal.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  * \author Angus Leeming
8  * \author Asger Alstrup
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "GuiExternal.h"
16
17 #include "FuncRequest.h"
18 #include "support/gettext.h"
19 #include "Length.h"
20 #include "LyXRC.h"
21
22 #include "insets/ExternalSupport.h"
23 #include "insets/ExternalTemplate.h"
24 #include "insets/InsetExternal.h"
25
26 #include "graphics/GraphicsCache.h"
27 #include "graphics/GraphicsCacheItem.h"
28 #include "graphics/GraphicsImage.h"
29
30 #include "support/convert.h"
31 #include "support/filetools.h"
32 #include "support/lstrings.h"
33 #include "support/lyxlib.h"
34 #include "support/os.h"
35
36 #include "LengthCombo.h"
37 #include "qt_helpers.h"
38 #include "Validator.h"
39
40 #include <QCheckBox>
41 #include <QGroupBox>
42 #include <QLineEdit>
43 #include <QPushButton>
44 #include <QTabWidget>
45 #include <QTextBrowser>
46
47 using namespace std;
48 using namespace lyx::support;
49
50 namespace lyx {
51 namespace frontend {
52
53 using namespace external;
54
55 namespace {
56
57 RotationDataType origins[] = {
58         RotationData::DEFAULT,
59         RotationData::TOPLEFT,
60         RotationData::BOTTOMLEFT,
61         RotationData::BASELINELEFT,
62         RotationData::CENTER,
63         RotationData::TOPCENTER,
64         RotationData::BOTTOMCENTER,
65         RotationData::BASELINECENTER,
66         RotationData::TOPRIGHT,
67         RotationData::BOTTOMRIGHT,
68         RotationData::BASELINERIGHT
69 };
70
71
72 // These are the strings, corresponding to the above, that the GUI should
73 // use. Note that they can/should be translated.
74 char const * const origin_gui_strs[] = {
75         N_("Default"),
76         N_("Top left"), N_("Bottom left"), N_("Baseline left"),
77         N_("Center"), N_("Top center"), N_("Bottom center"), N_("Baseline center"),
78         N_("Top right"), N_("Bottom right"), N_("Baseline right")
79 };
80
81 external::Template getTemplate(int i)
82 {
83         external::TemplateManager::Templates::const_iterator i1
84                 = external::TemplateManager::get().getTemplates().begin();
85         advance(i1, i);
86         return i1->second;
87 }
88
89 } // namespace anon
90
91
92 GuiExternal::GuiExternal(GuiView & lv)
93         : GuiDialog(lv, "external", qt_("External Material")), bbChanged_(false)
94 {
95         setupUi(this);
96
97         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
98         connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
99         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
100
101         connect(displayGB, SIGNAL(toggled(bool)),
102                 showCO, SLOT(setEnabled(bool)));
103         connect(displayGB, SIGNAL(toggled(bool)),
104                 displayscaleED, SLOT(setEnabled(bool)));
105         connect(showCO, SIGNAL(activated(QString)),
106                 this, SLOT(change_adaptor()));
107         connect(originCO, SIGNAL(activated(int)),
108                 this, SLOT(change_adaptor()));
109         connect(aspectratioCB, SIGNAL(stateChanged(int)),
110                 this, SLOT(change_adaptor()));
111         connect(browsePB, SIGNAL(clicked()),
112                 this, SLOT(browseClicked()));
113         connect(externalCO, SIGNAL(activated(QString)),
114                 this, SLOT(templateChanged()));
115         connect(extraED, SIGNAL(textChanged(QString)),
116                 this, SLOT(extraChanged(QString)));
117         connect(extraFormatCO, SIGNAL(activated(QString)),
118                 this, SLOT(formatChanged(QString)));
119         connect(widthUnitCO, SIGNAL(activated(int)),
120                 this, SLOT(widthUnitChanged()));
121         connect(heightUnitCO, SIGNAL(selectionChanged(lyx::Length::UNIT)),
122                 this, SLOT(change_adaptor()));
123         connect(displayGB, SIGNAL(toggled(bool)),
124                 this, SLOT(change_adaptor()));
125         connect(displayscaleED, SIGNAL(textChanged(QString)),
126                 this, SLOT(change_adaptor()));
127         connect(angleED, SIGNAL(textChanged(QString)),
128                 this, SLOT(change_adaptor()));
129         connect(widthED, SIGNAL(textChanged(QString)),
130                 this, SLOT(sizeChanged()));
131         connect(heightED, SIGNAL(textChanged(QString)),
132                 this, SLOT(sizeChanged()));
133         connect(fileED, SIGNAL(textChanged(QString)),
134                 this, SLOT(change_adaptor()));
135         connect(clipCB, SIGNAL(stateChanged(int)),
136                 this, SLOT(change_adaptor()));
137         connect(getbbPB, SIGNAL(clicked()), this, SLOT(getbbClicked()));
138         connect(xrED, SIGNAL(textChanged(QString)), this, SLOT(bbChanged()));
139         connect(ytED, SIGNAL(textChanged(QString)), this, SLOT(bbChanged()));
140         connect(xlED, SIGNAL(textChanged(QString)), this, SLOT(bbChanged()));
141         connect(ybED, SIGNAL(textChanged(QString)), this, SLOT(bbChanged()));
142         connect(draftCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
143
144         QIntValidator * validator = new QIntValidator(displayscaleED);
145         validator->setBottom(1);
146         displayscaleED->setValidator(validator);
147
148         angleED->setValidator(new QDoubleValidator(-360, 360, 2, angleED));
149
150         xlED->setValidator(new QIntValidator(xlED));
151         ybED->setValidator(new QIntValidator(ybED));
152         xrED->setValidator(new QIntValidator(xrED));
153         ytED->setValidator(new QIntValidator(ytED));
154
155         widthED->setValidator(unsignedLengthValidator(widthED));
156         heightED->setValidator(unsignedLengthValidator(heightED));
157
158         setFocusProxy(fileED);
159
160         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
161
162         bc().setOK(okPB);
163         bc().setApply(applyPB);
164         bc().setCancel(closePB);
165
166         bc().addReadOnly(fileED);
167         bc().addReadOnly(browsePB);
168         bc().addReadOnly(externalCO);
169         bc().addReadOnly(draftCB);
170         bc().addReadOnly(displayscaleED);
171         bc().addReadOnly(showCO);
172         bc().addReadOnly(displayGB);
173         bc().addReadOnly(angleED);
174         bc().addReadOnly(originCO);
175         bc().addReadOnly(heightUnitCO);
176         bc().addReadOnly(heightED);
177         bc().addReadOnly(aspectratioCB);
178         bc().addReadOnly(widthUnitCO);
179         bc().addReadOnly(widthED);
180         bc().addReadOnly(clipCB);
181         bc().addReadOnly(getbbPB);
182         bc().addReadOnly(ytED);
183         bc().addReadOnly(xlED);
184         bc().addReadOnly(xrED);
185         bc().addReadOnly(ybED);
186         bc().addReadOnly(extraFormatCO);
187         bc().addReadOnly(extraED);
188
189         bc().addCheckedLineEdit(angleED, angleLA);
190         bc().addCheckedLineEdit(displayscaleED, scaleLA);
191         bc().addCheckedLineEdit(heightED, heightLA);
192         bc().addCheckedLineEdit(widthED, widthLA);
193         bc().addCheckedLineEdit(xlED, lbLA);
194         bc().addCheckedLineEdit(ybED, lbLA);
195         bc().addCheckedLineEdit(xrED, rtLA);
196         bc().addCheckedLineEdit(ytED, rtLA);
197         bc().addCheckedLineEdit(fileED, fileLA);
198
199         external::TemplateManager::Templates::const_iterator i1, i2;
200         i1 = external::TemplateManager::get().getTemplates().begin();
201         i2 = external::TemplateManager::get().getTemplates().end();
202         for (; i1 != i2; ++i1)
203                 externalCO->addItem(qt_(i1->second.lyxName));
204
205         // Fill the origins combo
206         for (size_t i = 0; i != sizeof(origins) / sizeof(origins[0]); ++i)
207                 originCO->addItem(qt_(origin_gui_strs[i]));
208
209         // Fill the width combo
210         widthUnitCO->addItem(qt_("Scale%"));
211         for (int i = 0; i < num_units; i++)
212                 widthUnitCO->addItem(qt_(unit_name_gui[i]));
213 }
214
215
216 bool GuiExternal::activateAspectratio() const
217 {
218         if (widthUnitCO->currentIndex() == 0)
219                 return false;
220
221         string const wstr = fromqstr(widthED->text());
222         if (wstr.empty())
223                 return false;
224         bool const wIsDbl = isStrDbl(wstr);
225         if (wIsDbl && float_equal(convert<double>(wstr), 0.0, 0.05))
226                 return false;
227         Length l;
228         if (!wIsDbl && (!isValidLength(wstr, &l) || l.zero()))
229                 return false;
230
231         string const hstr = fromqstr(heightED->text());
232         if (hstr.empty())
233                 return false;
234         bool const hIsDbl = isStrDbl(hstr);
235         if (hIsDbl && float_equal(convert<double>(hstr), 0.0, 0.05))
236                 return false;
237         if (!hIsDbl && (!isValidLength(hstr, &l) || l.zero()))
238                 return false;
239
240         return true;
241 }
242
243
244 void GuiExternal::bbChanged()
245 {
246         bbChanged_ = true;
247         changed();
248 }
249
250
251 void GuiExternal::browseClicked()
252 {
253         int const choice =  externalCO->currentIndex();
254         QString const template_name = toqstr(getTemplate(choice).lyxName);
255         QString const str = browse(fileED->text(), template_name);
256         if (!str.isEmpty()) {
257                 fileED->setText(str);
258                 changed();
259         }
260 }
261
262
263 void GuiExternal::change_adaptor()
264 {
265         changed();
266 }
267
268
269 void GuiExternal::extraChanged(const QString & text)
270 {
271         extra_[extraFormatCO->currentText()] = text;
272         changed();
273 }
274
275
276 void GuiExternal::formatChanged(const QString & format)
277 {
278         extraED->setText(extra_[format]);
279 }
280
281
282 void GuiExternal::getbbClicked()
283 {
284         xlED->setText("0");
285         ybED->setText("0");
286         xrED->setText("0");
287         ytED->setText("0");
288
289         string const filename = fromqstr(fileED->text());
290         if (filename.empty())
291                 return;
292
293         FileName const abs_file(support::makeAbsPath(filename, fromqstr(bufferFilepath())));
294
295         // try to get it from the file, if possible
296         string bb = readBB_from_PSFile(abs_file);
297         if (bb.empty()) {
298                 // we don't, so ask the Graphics Cache if it has loaded the file
299                 int width = 0;
300                 int height = 0;
301
302                 graphics::Cache & gc = graphics::Cache::get();
303                 if (gc.inCache(abs_file)) {
304                         graphics::Image const * image = gc.item(abs_file)->image();
305
306                         if (image) {
307                                 width  = image->width();
308                                 height = image->height();
309                         }
310                 }
311                 bb = "0 0 " + convert<string>(width) + ' ' + convert<string>(height);
312         }
313
314         xlED->setText(toqstr(token(bb, ' ', 0)));
315         ybED->setText(toqstr(token(bb, ' ', 1)));
316         xrED->setText(toqstr(token(bb, ' ', 2)));
317         ytED->setText(toqstr(token(bb, ' ', 3)));
318
319         bbChanged_ = false;
320 }
321
322
323 void GuiExternal::sizeChanged()
324 {
325         aspectratioCB->setEnabled(activateAspectratio());
326         changed();
327 }
328
329
330 void GuiExternal::templateChanged()
331 {
332         updateTemplate();
333         changed();
334 }
335
336
337 void GuiExternal::widthUnitChanged()
338 {
339         bool useHeight = (widthUnitCO->currentIndex() > 0);
340
341         if (useHeight)
342                 widthED->setValidator(unsignedLengthValidator(widthED));
343         else
344                 widthED->setValidator(new QDoubleValidator(0, 1000, 2, widthED));
345
346         heightED->setEnabled(useHeight);
347         heightUnitCO->setEnabled(useHeight);
348         changed();
349 }
350
351
352 static Length::UNIT defaultUnit()
353 {
354         Length::UNIT default_unit = Length::CM;
355         switch (lyxrc.default_papersize) {
356         case PAPER_USLETTER:
357         case PAPER_USLEGAL:
358         case PAPER_USEXECUTIVE:
359                 default_unit = Length::IN;
360                 break;
361         default:
362                 break;
363         }
364         return default_unit;
365 }
366
367
368 static void setDisplay(
369         QGroupBox & displayGB, QComboBox & showCO, QLineEdit & scaleED,
370         external::DisplayType display, unsigned int scale, bool read_only)
371 {
372         int item = 0;
373         switch (display) {
374         case external::DefaultDisplay:
375                 item = 0;
376                 break;
377         case external::MonochromeDisplay:
378                 item = 1;
379                 break;
380         case external::GrayscaleDisplay:
381                 item = 2;
382                 break;
383         case external::ColorDisplay:
384                 item = 3;
385                 break;
386         case external::PreviewDisplay:
387                 item = 4;
388                 break;
389         case external::NoDisplay:
390                 item = 0;
391                 break;
392         }
393
394         showCO.setCurrentIndex(item);
395         bool const no_display = display == external::NoDisplay;
396         showCO.setEnabled(!no_display && !read_only);
397         displayGB.setChecked(!no_display);
398         scaleED.setEnabled(!no_display && !read_only);
399         scaleED.setText(QString::number(scale));
400 }
401
402
403 static external::DisplayType display(QGroupBox const & displayGB,
404         QComboBox const & showCO)
405 {
406         if (!displayGB.isChecked())
407                 return external::NoDisplay;
408         switch (showCO.currentIndex()) {
409         default:
410         case 0:
411                 return external::DefaultDisplay;
412         case 1:
413                 return external::MonochromeDisplay;
414         case 2:
415                 return external::GrayscaleDisplay;
416         case 3:
417                 return external::ColorDisplay;
418         case 4:
419                 return external::PreviewDisplay;
420         }
421 }
422
423
424 static void setRotation(QLineEdit & angleED, QComboBox & originCO,
425         external::RotationData const & data)
426 {
427         originCO.setCurrentIndex(int(data.origin()));
428         angleED.setText(toqstr(data.angle));
429 }
430
431
432 static void getRotation(external::RotationData & data,
433         QLineEdit const & angleED, QComboBox const & originCO)
434 {
435         typedef external::RotationData::OriginType OriginType;
436
437         data.origin(static_cast<OriginType>(originCO.currentIndex()));
438         data.angle = fromqstr(angleED.text());
439 }
440
441
442 static void setSize(QLineEdit & widthED, QComboBox & widthUnitCO,
443         QLineEdit & heightED, LengthCombo & heightUnitCO,
444         QCheckBox & aspectratioCB,
445         external::ResizeData const & data)
446 {
447         bool using_scale = data.usingScale();
448         string scale = data.scale;
449         if (data.no_resize()) {
450                 // Everything is zero, so default to this!
451                 using_scale = true;
452                 scale = "100";
453         }
454
455         if (using_scale) {
456                 widthED.setText(toqstr(scale));
457                 widthUnitCO.setCurrentIndex(0);
458         } else {
459                 widthED.setText(QString::number(data.width.value()));
460                 // Because 'Scale' is position 0...
461                 // Note also that width cannot be zero here, so
462                 // we don't need to worry about the default unit.
463                 widthUnitCO.setCurrentIndex(data.width.unit() + 1);
464         }
465
466         string const h = data.height.zero() ? string() : data.height.asString();
467         Length::UNIT default_unit = data.width.zero() ?
468                 defaultUnit() : data.width.unit();
469         lengthToWidgets(&heightED, &heightUnitCO, h, default_unit);
470
471         heightED.setEnabled(!using_scale);
472         heightUnitCO.setEnabled(!using_scale);
473
474         aspectratioCB.setChecked(data.keepAspectRatio);
475
476         bool const disable_aspectRatio = using_scale ||
477                 data.width.zero() || data.height.zero();
478         aspectratioCB.setEnabled(!disable_aspectRatio);
479 }
480
481
482 static void getSize(external::ResizeData & data,
483         QLineEdit const & widthED, QComboBox const & widthUnitCO,
484         QLineEdit const & heightED, LengthCombo const & heightUnitCO,
485         QCheckBox const & aspectratioCB)
486 {
487         string const width = fromqstr(widthED.text());
488
489         if (widthUnitCO.currentIndex() > 0) {
490                 // Subtract one, because scale is 0.
491                 int const unit = widthUnitCO.currentIndex() - 1;
492
493                 Length w;
494                 if (isValidLength(width, &w))
495                         data.width = w;
496                 else if (isStrDbl(width))
497                         data.width = Length(convert<double>(width),
498                                            static_cast<Length::UNIT>(unit));
499                 else
500                         data.width = Length();
501
502                 data.scale = string();
503
504         } else {
505                 // scaling instead of a width
506                 data.scale = width;
507                 data.width = Length();
508         }
509
510         data.height = Length(widgetsToLength(&heightED, &heightUnitCO));
511
512         data.keepAspectRatio = aspectratioCB.isChecked();
513 }
514
515
516 void setCrop(QCheckBox & clipCB,
517         QLineEdit & xlED, QLineEdit & ybED,
518         QLineEdit & xrED, QLineEdit & ytED,
519         external::ClipData const & data)
520 {
521         clipCB.setChecked(data.clip);
522         graphics::BoundingBox const & bbox = data.bbox;
523         xlED.setText(QString::number(bbox.xl));
524         ybED.setText(QString::number(bbox.yb));
525         xrED.setText(QString::number(bbox.xr));
526         ytED.setText(QString::number(bbox.yt));
527 }
528
529
530 static void getCrop(external::ClipData & data,
531         QCheckBox const & clipCB,
532         QLineEdit const & xlED, QLineEdit const & ybED,
533         QLineEdit const & xrED, QLineEdit const & ytED,
534         bool bb_changed)
535 {
536         data.clip = clipCB.isChecked();
537
538         if (!bb_changed)
539                 return;
540
541         data.bbox.xl = xlED.text().toInt();
542         data.bbox.yb = ybED.text().toInt();
543         data.bbox.xr = xrED.text().toInt();
544         data.bbox.yt = ytED.text().toInt();
545 }
546
547
548 void GuiExternal::updateContents()
549 {
550         tab->setCurrentIndex(0);
551
552         string const name =
553                 params_.filename.outputFilename(fromqstr(bufferFilepath()));
554         fileED->setText(toqstr(name));
555
556         int index = -1;
557         external::TemplateManager::Templates::const_iterator i1, i2;
558         i1 = external::TemplateManager::get().getTemplates().begin();
559         i2 = external::TemplateManager::get().getTemplates().end();
560         for (int i = 0; i1 != i2; ++i1, ++i) {
561                 if (i1->second.lyxName == params_.templatename()) {
562                         index = i;
563                         break;
564                 }
565         }
566
567         externalCO->setCurrentIndex(index);
568         updateTemplate();
569
570         draftCB->setChecked(params_.draft);
571
572         setDisplay(*displayGB, *showCO, *displayscaleED,
573                    params_.display, params_.lyxscale, isBufferReadonly());
574
575         setRotation(*angleED, *originCO, params_.rotationdata);
576
577         setSize(*widthED, *widthUnitCO, *heightED, *heightUnitCO,
578                 *aspectratioCB, params_.resizedata);
579
580         setCrop(*clipCB, *xlED, *ybED, *xrED, *ytED, params_.clipdata);
581         bbChanged_ = !params_.clipdata.bbox.empty();
582
583         isValid();
584 }
585
586
587 void GuiExternal::updateTemplate()
588 {
589         external::Template templ = getTemplate(externalCO->currentIndex());
590         externalTB->setPlainText(qt_(templ.helpText));
591
592         // Ascertain which (if any) transformations the template supports
593         // and disable tabs and Group Boxes hosting unsupported transforms.
594         typedef vector<external::TransformID> TransformIDs;
595         TransformIDs const transformIds = templ.transformIds;
596         TransformIDs::const_iterator tr_begin = transformIds.begin();
597         TransformIDs::const_iterator const tr_end = transformIds.end();
598
599         bool found = std::find(tr_begin, tr_end, external::Rotate) != tr_end;
600         rotationGB->setEnabled(found);
601
602         found = std::find(tr_begin, tr_end, external::Resize) != tr_end;
603         scaleGB->setEnabled(found);
604
605         found = std::find(tr_begin, tr_end, external::Clip) != tr_end;
606         cropGB->setEnabled(found);
607
608         tab->setTabEnabled(tab->indexOf(sizetab),
609                 rotationGB->isEnabled()
610                 || scaleGB->isEnabled()
611                 || cropGB->isEnabled());
612
613         found = std::find(tr_begin, tr_end, external::Extra) != tr_end;
614         optionsGB->setEnabled(found);
615
616         if (!found)
617                 return;
618
619         // Ascertain whether the template has any formats supporting
620         // the 'Extra' option
621         extra_.clear();
622         extraED->clear();
623         extraFormatCO->clear();
624
625         external::Template::Formats::const_iterator it  = templ.formats.begin();
626         external::Template::Formats::const_iterator end = templ.formats.end();
627         for (; it != end; ++it) {
628                 if (it->second.option_transformers.find(external::Extra) ==
629                     it->second.option_transformers.end())
630                         continue;
631                 string const format = it->first;
632                 string const opt = params_.extradata.get(format);
633                 extraFormatCO->addItem(toqstr(format));
634                 extra_[toqstr(format)] = toqstr(opt);
635         }
636
637         bool const enabled = extraFormatCO->count()  > 0;
638
639         optionsGB->setEnabled(enabled);
640         extraED->setEnabled(enabled && !isBufferReadonly());
641         extraFormatCO->setEnabled(enabled);
642
643         if (enabled) {
644                 extraFormatCO->setCurrentIndex(0);
645                 extraED->setText(extra_[extraFormatCO->currentText()]);
646         }
647 }
648
649
650 void GuiExternal::applyView()
651 {
652         params_.filename.set(fromqstr(fileED->text()), fromqstr(bufferFilepath()));
653         params_.settemplate(getTemplate(externalCO->currentIndex()).lyxName);
654
655         params_.draft = draftCB->isChecked();
656         params_.lyxscale = displayscaleED->text().toInt();
657         params_.display = display(*displayGB, *showCO);
658
659         if (rotationGB->isEnabled())
660                 getRotation(params_.rotationdata, *angleED, *originCO);
661
662         if (scaleGB->isEnabled())
663                 getSize(params_.resizedata, *widthED, *widthUnitCO,
664                         *heightED, *heightUnitCO, *aspectratioCB);
665
666         if (cropGB->isEnabled())
667                 getCrop(params_.clipdata, *clipCB, *xlED, *ybED,
668                         *xrED, *ytED, bbChanged_);
669
670         if (optionsGB->isEnabled()) {
671                 MapType::const_iterator it = extra_.begin();
672                 MapType::const_iterator const end = extra_.end();
673                 for (; it != end; ++it)
674                         params_.extradata.set(fromqstr(it.key()), fromqstr(it.value().trimmed()));
675         }
676 }
677
678
679 bool GuiExternal::initialiseParams(string const & data)
680 {
681         InsetExternal::string2params(data, buffer(), params_);
682         return true;
683 }
684
685
686 void GuiExternal::clearParams()
687 {
688         params_ = InsetExternalParams();
689 }
690
691
692 void GuiExternal::dispatchParams()
693 {
694         string const lfun = InsetExternal::params2string(params_, buffer());
695         dispatch(FuncRequest(getLfun(), lfun));
696 }
697
698
699 static QStringList templateFilters(QString const & template_name)
700 {
701         /// Determine the template file extension
702         external::TemplateManager const & etm =
703                 external::TemplateManager::get();
704         external::Template const * const et_ptr =
705                 etm.getTemplateByName(fromqstr(template_name));
706
707         return fileFilters(et_ptr ? toqstr(et_ptr->fileRegExp) : QString());
708 }
709
710
711 QString GuiExternal::browse(QString const & input,
712                                      QString const & template_name) const
713 {
714         QString const title = qt_("Select external file");
715         QString const bufpath = bufferFilepath();
716         QStringList const filter = templateFilters(template_name);
717
718         QString const label1 = qt_("Documents|#o#O");
719         QString const dir1 = toqstr(lyxrc.document_path);
720
721         return browseRelFile(input, bufpath, title, filter, false, label1, dir1);
722 }
723
724
725 Dialog * createGuiExternal(GuiView & lv) { return new GuiExternal(lv); }
726
727
728 } // namespace frontend
729 } // namespace lyx
730
731 #include "GuiExternal_moc.cpp"