]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiListings.cpp
BoxUi.ui: revert unintended commit [a6e42e50/lyxgit]
[lyx.git] / src / frontends / qt4 / GuiListings.cpp
1 /**
2  * \file GuiListings.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Bo Peng
7  * \author Jürgen Spitzmüller
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "GuiListings.h"
15
16 #include "qt_helpers.h"
17
18 #include "FuncRequest.h"
19
20 #include "insets/InsetListings.h"
21 #include "insets/InsetListingsParams.h"
22
23 #include "support/convert.h"
24 #include "support/gettext.h"
25 #include "support/lstrings.h"
26
27 #include <QLineEdit>
28 #include <QPushButton>
29 #include <QValidator>
30 #include <QRegExpValidator>
31
32 using namespace std;
33 using namespace lyx::support;
34
35 namespace lyx {
36 namespace frontend {
37
38
39 /////////////////////////////////////////////////////////////////////
40 //
41 // GuiListings
42 //
43 /////////////////////////////////////////////////////////////////////
44
45
46 char const * languages_supported[] =
47 { "no language", "ABAP", "ACSL", "Ada", "ALGOL", "Assembler", "Awk", "bash", "Basic", "C",
48   "C++", "Caml", "Clean", "Cobol", "Comal 80", "command.com", "Comsol", "csh", "Delphi",
49   "Eiffel", "Elan", "erlang", "Euphoria", "Fortran", "Gnuplot", "Haskell", "HTML", "IDL", "inform",
50   "Java", "JVMIS", "ksh", "Lingo", "Lisp", "Logo", "make", "Mathematica", "Matlab", "Mercury",
51   "MetaPost", "Miranda", "ML", "Modula-2", "MuPAD", "NASTRAN", "Oberon-2", "OCL", "Octave",
52   "Oz", "Pascal", "Perl", "PHP", "PL/I", "Plasm", "PostScript", "POV", "Prolog", "Promela",
53   "PSTricks", "Python", "R", "Reduce", "Rexx", "RSL", "Ruby", "S", "SAS", "Scilab", "sh",
54   "SHELXL", "Simula", "tcl", "SPARQL", "SQL", "tcl", "TeX", "VBScript", "Verilog", "VHDL",
55   "VRML", "XML", "XSLT", "" };
56
57
58 char const * languages_gui[] =
59 { N_("No language"), "ABAP", "ACSL", "Ada", "ALGOL", "Assembler", "Awk", "bash", "Basic",
60   "C", "C++", "Caml", "Clean", "Cobol", "Comal 80", "command.com", "Comsol", "csh", "Delphi",
61   "Eiffel", "Elan", "Erlang", "Euphoria", "Fortran", "Gnuplot", "Haskell", "HTML", "IDL", "inform",
62   "Java", "JVMIS", "ksh", "Lingo", "Lisp", "Logo", "make", "Mathematica", "Matlab", "Mercury",
63   "MetaPost", "Miranda", "ML", "Modula-2", "MuPAD", "NASTRAN", "Oberon-2", "OCL", "Octave",
64   "Oz", "Pascal", "Perl", "PHP", "PL/I", "Plasm", "PostScript", "POV", "Prolog", "Promela",
65   "PSTricks", "Python", "R", "Reduce", "Rexx", "RSL", "Ruby", "S", "SAS", "Scilab", "sh",
66   "SHELXL", "Simula", "tcl", "SPARQL", "SQL", "tcl", "TeX", "VBScript", "Verilog", "VHDL",
67   "VRML", "XML", "XSLT", "" };
68
69
70 struct dialect_info {
71         /// the dialect
72         char const * dialect;
73         /// the associated language
74         char const * language;
75         /// representation of the dialect in the gui
76         char const * gui;
77         /// is this the default dialect?
78         bool is_default;
79 };
80
81
82 dialect_info const dialects[] = {
83         { "R/2 4.3", "ABAP", "R/2 4.3", false },
84         { "R/2 5.0", "ABAP", "R/2 5.0", false },
85         { "R/3 3.1", "ABAP", "R/3 3.1", false },
86         { "R/3 4.6C", "ABAP", "R/3 4.6C", false },
87         { "R/3 6.10", "ABAP", "R/3 6.10", true },
88         { "2005", "Ada", "2005", true },
89         { "83", "Ada", "83", false },
90         { "95", "Ada", "95", false },
91         { "60", "Algol", "60", false },
92         { "68", "Algol", "68", true },
93         { "Motorola68k", "Assembler", "Motorola 68xxx", false },
94         { "x86masm", "Assembler", "x86 (MASM)", false },
95         { "gnu", "Awk", "gnu", true },
96         { "POSIX", "Awk", "POSIX", false },
97         { "Visual", "Basic", "Visual", false },
98         { "ANSI", "C", "ANSI", true },
99         { "Handel", "C", "Handel", false },
100         { "Objective", "C", "Objective", false },
101         { "Sharp", "C", "Sharp", false },
102         { "ANSI", "C++", "ANSI", false },
103         { "GNU", "C++", "GNU", false },
104         { "ISO", "C++", "ISO", true },
105         { "Visual", "C++", "Visual", false },
106         { "light", "Caml", "light", true },
107         { "Objective", "Caml", "Objective", false },
108         { "1974", "Cobol", "1974", false },
109         { "1985", "Cobol", "1985", true },
110         { "ibm", "Cobol", "IBM", false },
111         { "WinXP", "command.com", "Windows XP", true },
112         { "77", "Fortran", "77", false },
113         { "90", "Fortran", "90", false },
114         { "95", "Fortran", "95", true },
115         { "CORBA", "IDL", "CORBA", false },
116         { "AspectJ", "Java", "Aspect J", false },
117         { "Auto", "Lisp", "Auto", false },
118         { "gnu", "make", "gnu", false },
119         { "1.0", "Mathematica", "1.0", false },
120         { "3.0", "Mathematica", "3.0", false },
121         { "5.2", "Mathematica", "5.2", true },
122         { "decorative", "OCL", "decorative", false },
123         { "OMG", "OCL", "OMG", true },
124         { "Borland6", "Pascal", "Borland 6", false },
125         { "Standard", "Pascal", "Standard", true },
126         { "XSC", "Pascal", "XSC", false },
127         { "PLUS", "S", "PLUS", false },
128         { "67", "Simula", "67", true },
129         { "CII", "Simula", "CII", false },
130         { "DEC", "Simula", "DEC", false },
131         { "IBM", "Simula", "IBM", false },
132         { "tk", "tcl", "tk", false },
133         { "AlLaTeX", "TeX", "AlLaTeX", false },
134         { "common", "TeX", "common", false },
135         { "LaTeX", "TeX", "LaTeX", false },
136         { "plain", "TeX", "plain", true },
137         { "primitive", "TeX", "primitive", false },
138         { "AMS", "VHDL", "AMS", false },
139         { "97", "VRML", "97", true }
140 };
141
142
143 size_t const nr_dialects = sizeof(dialects) / sizeof(dialect_info);
144
145
146 char const * font_sizes[] =
147 { "default", "tiny", "scriptsize", "footnotesize", "small", "normalsize", "large",
148   "Large", "" };
149
150 char const * font_sizes_gui[] =
151 { N_("Default"), N_("Tiny"), N_("Smallest"), N_("Smaller"), N_("Small"), N_("Normal"),
152   N_("Large"), N_("Larger"), "" };
153
154 char const * font_styles[] =
155 { "default", "rmfamily", "ttfamily", "sffamily", "" };
156
157 char const * font_styles_gui[] =
158 { N_("Default"), N_("Roman"), N_("Typewriter"), N_("Sans Serif"), "" };
159
160
161
162 GuiListings::GuiListings(GuiView & lv)
163         : GuiDialog(lv, "listings", qt_("Program Listing Settings"))
164 {
165         setupUi(this);
166
167         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
168         connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
169         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
170
171         connect(languageCO, SIGNAL(currentIndexChanged(int)),
172                 this, SLOT(change_adaptor()));
173         connect(dialectCO, SIGNAL(currentIndexChanged(int)),
174                 this, SLOT(change_adaptor()));
175         connect(inlineCB, SIGNAL(clicked()),
176                 this, SLOT(change_adaptor()));
177         connect(floatCB, SIGNAL(clicked()),
178                 this, SLOT(change_adaptor()));
179         connect(placementLE, SIGNAL(textChanged(QString)),
180                 this, SLOT(change_adaptor()));
181         connect(numberSideCO, SIGNAL(currentIndexChanged(int)),
182                 this, SLOT(change_adaptor()));
183         connect(numberStepLE, SIGNAL(textChanged(QString)),
184                 this, SLOT(change_adaptor()));
185         connect(numberFontSizeCO, SIGNAL(currentIndexChanged(int)),
186                 this, SLOT(change_adaptor()));
187         connect(firstlineLE, SIGNAL(textChanged(QString)),
188                 this, SLOT(change_adaptor()));
189         connect(lastlineLE, SIGNAL(textChanged(QString)),
190                 this, SLOT(change_adaptor()));
191         connect(fontsizeCO, SIGNAL(currentIndexChanged(int)),
192                 this, SLOT(change_adaptor()));
193         connect(fontstyleCO, SIGNAL(currentIndexChanged(int)),
194                 this, SLOT(change_adaptor()));
195         connect(breaklinesCB, SIGNAL(clicked()),
196                 this, SLOT(change_adaptor()));
197         connect(spaceCB, SIGNAL(clicked()),
198                 this, SLOT(change_adaptor()));
199         connect(spaceInStringCB, SIGNAL(clicked()),
200                 this, SLOT(change_adaptor()));
201         connect(tabsizeSB, SIGNAL(valueChanged(int)),
202                 this, SLOT(change_adaptor()));
203         connect(extendedcharsCB, SIGNAL(clicked()),
204                 this, SLOT(change_adaptor()));
205
206         connect(listingsED,  SIGNAL(textChanged()),
207                 this, SLOT(change_adaptor()));
208         connect(listingsED,  SIGNAL(textChanged()),
209                 this, SLOT(setListingsMsg()));
210         connect(bypassCB, SIGNAL(clicked()),
211                 this, SLOT(change_adaptor()));
212         connect(bypassCB, SIGNAL(clicked()),
213                 this, SLOT(setListingsMsg()));
214
215         for (int n = 0; languages_supported[n][0]; ++n)
216                 languageCO->addItem(qt_(languages_gui[n]));
217
218         for (int n = 0; font_styles[n][0]; ++n)
219                 fontstyleCO->addItem(qt_(font_styles_gui[n]));
220
221         for (int n = 0; font_sizes[n][0]; ++n) {
222                 QString font = qt_(font_sizes_gui[n]);
223                 fontsizeCO->addItem(font);
224                 numberFontSizeCO->addItem(font);
225         }
226
227         // set validators
228         numberStepLE->setValidator(new QIntValidator(0, 1000000, this));
229         firstlineLE->setValidator(new QIntValidator(0, 1000000, this));
230         lastlineLE->setValidator(new QIntValidator(0, 1000000, this));
231         placementLE->setValidator(new QRegExpValidator(QRegExp("[\\*tbph]*"), this));
232
233         bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
234         bc().setOK(okPB);
235         bc().setApply(applyPB);
236         bc().setCancel(closePB);
237         listingsTB->setPlainText(
238                 qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
239
240         updateContents();
241
242 }
243
244
245 void GuiListings::change_adaptor()
246 {
247         changed();
248 }
249
250
251 string GuiListings::construct_params()
252 {
253         string language = languages_supported[qMax(0, languageCO->currentIndex())];
254         string dialect;
255         string const dialect_gui = fromqstr(dialectCO->currentText());
256         if (dialectCO->currentIndex() > 0) {
257                 for (size_t i = 0; i != nr_dialects; ++i) {
258                         if (dialect_gui == dialects[i].gui
259                         && dialects[i].language == language
260                         && !dialects[i].is_default) {
261                                 dialect = dialects[i].dialect;
262                                 break;
263                         }
264                 }
265         }
266
267         bool float_ = floatCB->isChecked();
268         string placement;
269         if (placementLE->isEnabled())
270                 placement = fromqstr(placementLE->text());
271
272         string numberSide;
273         switch (qMax(0, numberSideCO->currentIndex())) {
274         case 0:
275                 numberSide = "none";
276                 break;
277         case 1:
278                 numberSide = "left";
279                 break;
280         case 2:
281                 numberSide = "right";
282                 break;
283         default:
284                 numberSide = "none";
285                 break;
286         }
287         string stepnumber = fromqstr(numberStepLE->text());
288         string numberfontsize = font_sizes[qMax(0, numberFontSizeCO->currentIndex())];
289         string firstline = fromqstr(firstlineLE->text());
290         string lastline = fromqstr(lastlineLE->text());
291
292         string fontsize = font_sizes[qMax(0, fontsizeCO->currentIndex())];
293         string fontstyle = font_styles[qMax(0, fontstyleCO->currentIndex())];
294         string basicstyle;
295         if (fontsize != "default")
296                 basicstyle = "\\" + fontsize;
297         if (fontstyle != "default")
298                 basicstyle += "\\" + fontstyle;
299         bool breakline = breaklinesCB->isChecked();
300         bool space = spaceCB->isChecked();
301         int tabsize = tabsizeSB->value();
302         bool spaceInString = spaceInStringCB->isChecked();
303         bool extendedchars = extendedcharsCB->isChecked();
304         string extra = fromqstr(listingsED->toPlainText());
305
306         // compose a string
307         InsetListingsParams par;
308         if (language != "no language" && !contains(extra, "language=")) {
309                 if (dialect.empty())
310                         par.addParam("language", language);
311                 else
312                         par.addParam("language", "{[" + dialect + "]" + language + "}");
313         }
314         // this dialog uses float=placement instead of float,floatplacement=placement
315         // because float accepts *tbph and floatplacement accepts bph.
316         // our placement textedit is actually for the float parameter
317         if (float_)
318                 par.addParam("float", placement);
319         if (numberSide != "none")
320                 par.addParam("numbers", numberSide);
321         if (numberfontsize != "default" && numberSide != "none")
322                 par.addParam("numberstyle", "\\" + numberfontsize);
323         if (!stepnumber.empty() && numberSide != "none")
324                 par.addParam("stepnumber", stepnumber);
325         if (!firstline.empty())
326                 par.addParam("firstline", firstline);
327         if (!lastline.empty())
328                 par.addParam("lastline", lastline);
329         if (!basicstyle.empty())
330                 par.addParam("basicstyle", basicstyle);
331         if (breakline)
332                 par.addParam("breaklines", "true");
333         if (space)
334                 par.addParam("showspaces", "true");
335         if (!spaceInString)
336                 par.addParam("showstringspaces", "false");
337         if (tabsize != 8)
338                 par.addParam("tabsize", convert<string>(tabsize));
339         if (extendedchars)
340                 par.addParam("extendedchars", "true");
341         par.addParams(extra);
342         return par.params();
343 }
344
345
346 docstring GuiListings::validate_listings_params()
347 {
348         // use a cache here to avoid repeated validation
349         // of the same parameters
350         static string param_cache;
351         static docstring msg_cache;
352         
353         if (bypassCB->isChecked())
354                 return docstring();
355
356         string params = construct_params();
357         if (params != param_cache) {
358                 param_cache = params;
359                 msg_cache = InsetListingsParams(params).validate();
360         }
361         return msg_cache;
362 }
363
364
365 void GuiListings::setListingsMsg()
366 {
367         static bool isOK = true;
368         docstring msg = validate_listings_params();
369         if (msg.empty()) {
370                 if (isOK)
371                         return;
372                 isOK = true;
373                 listingsTB->setPlainText(
374                         qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
375         } else {
376                 isOK = false;
377                 listingsTB->setPlainText(toqstr(msg));
378         }
379 }
380
381
382 void GuiListings::on_floatCB_stateChanged(int state)
383 {
384         if (state == Qt::Checked) {
385                 inlineCB->setChecked(false);
386                 placementLE->setEnabled(true);
387         } else
388                 placementLE->setEnabled(false);
389 }
390
391
392 void GuiListings::on_inlineCB_stateChanged(int state)
393 {
394         if (state == Qt::Checked) {
395                 floatCB->setChecked(false);
396                 placementLE->setEnabled(false);
397         }
398 }
399
400
401 void GuiListings::on_numberSideCO_currentIndexChanged(int index)
402 {
403         numberStepLE->setEnabled(index > 0);
404         numberFontSizeCO->setEnabled(index > 0);
405 }
406
407
408 void GuiListings::on_languageCO_currentIndexChanged(int index)
409 {
410         dialectCO->clear();
411         // 0 is "no dialect"
412         int default_dialect = 0;
413         dialectCO->addItem(qt_("No dialect"));
414         string const language = languages_supported[index];
415
416         for (size_t i = 0; i != nr_dialects; ++i) {
417                 if (language == dialects[i].language) {
418                         dialectCO->addItem(qt_(dialects[i].gui));
419                         if (dialects[i].is_default)
420                                 default_dialect =
421                                         dialectCO->findText(qt_(dialects[i].gui));
422                 }
423         }
424         dialectCO->setCurrentIndex(default_dialect);
425         dialectCO->setEnabled(dialectCO->count() > 1);
426 }
427
428
429 void GuiListings::applyView()
430 {
431         params_.setInline(inlineCB->isChecked());
432         params_.setParams(construct_params());
433 }
434
435
436 static string plainParam(string const & par)
437 {
438         // remove enclosing braces
439         if (prefixIs(par, "{") && suffixIs(par, "}"))
440                 return par.substr(1, par.size() - 2);
441         return par;
442 }
443
444
445 void GuiListings::updateContents()
446 {
447         // set default values
448         listingsTB->setPlainText(
449                 qt_("Input listing parameters on the right. Enter ? for a list of parameters."));
450         languageCO->setCurrentIndex(findToken(languages_supported, "no language"));
451         dialectCO->setCurrentIndex(0);
452         floatCB->setChecked(false);
453         placementLE->clear();
454         numberSideCO->setCurrentIndex(0);
455         numberStepLE->clear();
456         numberFontSizeCO->setCurrentIndex(findToken(font_sizes, "default"));
457         firstlineLE->clear();
458         lastlineLE->clear();
459         fontstyleCO->setCurrentIndex(findToken(font_styles, "default"));
460         fontsizeCO->setCurrentIndex(findToken(font_sizes, "default"));
461         breaklinesCB->setChecked(false);
462         spaceCB->setChecked(false);
463         spaceInStringCB->setChecked(true);
464         tabsizeSB->setValue(8);
465         extendedcharsCB->setChecked(false);
466
467         // set values from param string
468         inlineCB->setChecked(params_.isInline());
469         if (params_.isInline()) {
470                 floatCB->setChecked(false);
471                 placementLE->setEnabled(false);
472         }
473         // break other parameters and set values
474         vector<string> pars = getVectorFromString(params_.separatedParams(), "\n");
475         // process each of them
476         for (vector<string>::iterator it = pars.begin();
477             it != pars.end(); ++it) {
478                 if (prefixIs(*it, "language=")) {
479                         string arg = plainParam(it->substr(9));
480                         // has dialect?
481                         string language;
482                         string dialect;
483                         bool in_gui = false;
484                         if (prefixIs(arg, "[") && contains(arg, "]")) {
485                                 size_t end_dialect = arg.find("]");
486                                 dialect = arg.substr(1, end_dialect - 1);
487                                 language = arg.substr(end_dialect + 1);
488                         } else {
489                                 language = arg;
490                         }
491                         int n = findToken(languages_supported, language);
492                         if (n >= 0) {
493                                 languageCO->setCurrentIndex(n);
494                                 in_gui = true;
495                         }
496                         // on_languageCO_currentIndexChanged should have set dialects
497                         if (!dialect.empty()) {
498                                 string dialect_gui;
499                                 for (size_t i = 0; i != nr_dialects; ++i) {
500                                         if (dialect == dialects[i].dialect
501                                             && dialects[i].language == language) {
502                                                 dialect_gui = dialects[i].gui;
503                                                 break;
504                                         }
505                                 }
506                                 n = dialectCO->findText(qt_(dialect_gui));
507                                 if (n >= 0)
508                                         dialectCO->setCurrentIndex(n);
509                                 else
510                                         in_gui = false;
511                         }
512                         if (in_gui)
513                                 *it = "";
514                         languageCO->setEnabled(in_gui);
515                         dialectCO->setEnabled(
516                                 in_gui && dialectCO->count() > 1);
517                 } else if (prefixIs(*it, "float")) {
518                         floatCB->setChecked(true);
519                         inlineCB->setChecked(false);
520                         placementLE->setEnabled(true);
521                         if (prefixIs(*it, "float="))
522                                 placementLE->setText(
523                                         toqstr(plainParam(it->substr(6))));
524                         *it = "";
525                 } else if (prefixIs(*it, "numbers=")) {
526                         string s = plainParam(it->substr(8));
527                         int n = 0;
528                         if (s == "left")
529                                 n = 1;
530                         else if (s == "right")
531                                 n = 2;
532                         numberSideCO->setCurrentIndex(n);
533                         *it = "";
534                 } else if (prefixIs(*it, "stepnumber=")) {
535                         numberStepLE->setText(
536                                 toqstr(plainParam(it->substr(11))));
537                         *it = "";
538                 } else if (prefixIs(*it, "numberstyle=")) {
539                         string par = plainParam(it->substr(12));
540                         int n = findToken(font_sizes, par.substr(1));
541                         if (n >= 0)
542                                 numberFontSizeCO->setCurrentIndex(n);
543                         *it = "";
544                 } else if (prefixIs(*it, "firstline=")) {
545                         firstlineLE->setText(
546                                 toqstr(plainParam(it->substr(10))));
547                         *it = "";
548                 } else if (prefixIs(*it, "lastline=")) {
549                         lastlineLE->setText(
550                                 toqstr(plainParam(it->substr(9))));
551                         *it = "";
552                 } else if (prefixIs(*it, "basicstyle=")) {
553                         string style;
554                         string size;
555                         for (int n = 0; font_styles[n][0]; ++n) {
556                                 string const s = font_styles[n];
557                                 if (contains(*it, "\\" + s)) {
558                                         style = "\\" + s;
559                                         break;
560                                 }
561                         }
562                         for (int n = 0; font_sizes[n][0]; ++n) {
563                                 string const s = font_sizes[n];
564                                 if (contains(*it, "\\" + s)) {
565                                         size = "\\" + s;
566                                         break;
567                                 }
568                         }
569                         if (plainParam(it->substr(11)) == style + size
570                             || plainParam(it->substr(11)) == size + style) {
571                                 if (!style.empty()) {
572                                         int n = findToken(font_styles, style.substr(1));
573                                         if (n >= 0)
574                                                 fontstyleCO->setCurrentIndex(n);
575                                 }
576                                 if (!size.empty()) {
577                                         int n = findToken(font_sizes, size.substr(1));
578                                         if (n >= 0)
579                                                 fontsizeCO->setCurrentIndex(n);
580                                 }
581                                 *it = "";
582                         }
583                 } else if (prefixIs(*it, "breaklines=")) {
584                         breaklinesCB->setChecked(contains(*it, "true"));
585                         *it = "";
586                 } else if (prefixIs(*it, "showspaces=")) {
587                         spaceCB->setChecked(contains(*it, "true"));
588                         *it = "";
589                 } else if (prefixIs(*it, "showstringspaces=")) {
590                         spaceInStringCB->setChecked(contains(*it, "true"));
591                         *it = "";
592                 } else if (prefixIs(*it, "tabsize=")) {
593                         tabsizeSB->setValue(convert<int>(plainParam(it->substr(8))));
594                         *it = "";
595                 } else if (prefixIs(*it, "extendedchars=")) {
596                         extendedcharsCB->setChecked(contains(*it, "true"));
597                         *it = "";
598                 }
599         }
600
601         numberStepLE->setEnabled(numberSideCO->currentIndex() > 0);
602         numberFontSizeCO->setEnabled(numberSideCO->currentIndex() > 0);
603         // parameters that can be handled by widgets are cleared
604         // the rest is put to the extra edit box.
605         string extra = getStringFromVector(pars);
606         listingsED->setPlainText(toqstr(InsetListingsParams(extra).separatedParams()));
607 }
608
609
610 bool GuiListings::isValid()
611 {
612         return validate_listings_params().empty();
613 }
614
615
616 bool GuiListings::initialiseParams(string const & data)
617 {
618         InsetListings::string2params(data, params_);
619         return true;
620 }
621
622
623 void GuiListings::clearParams()
624 {
625         params_.clear();
626 }
627
628
629 void GuiListings::dispatchParams()
630 {
631         string const lfun = InsetListings::params2string(params_);
632         dispatch(FuncRequest(getLfun(), lfun));
633 }
634
635
636 void GuiListings::setParams(InsetListingsParams const & params)
637 {
638         params_ = params;
639 }
640
641
642 Dialog * createGuiListings(GuiView & lv) { return new GuiListings(lv); }
643
644
645 } // namespace frontend
646 } // namespace lyx
647
648
649 #include "moc_GuiListings.cpp"