3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
21 #include "GDocument.h"
24 #include "ControlDocument.h"
25 #include "controllers/helper_funcs.h"
26 #include "controllers/frnt_lang.h"
28 #include "support/lstrings.h"
31 #include "lyxtextclasslist.h"
32 #include "bufferparams.h"
33 #include "tex-strings.h"
41 using support::bformat;
43 using support::contains;
49 char const * const encodings[] = { "Language Default", "LaTeX default",
50 "latin1", "latin2", "latin3", "latin4", "latin5", "latin9",
51 "koi8-r", "koi8-u", "cp866", "cp1251", "iso88595", "pt154", 0
57 GDocument::GDocument(Dialog & parent)
58 : GViewCB<ControlDocument, GViewGladeB>(parent, _("Document Settings"), false),
59 lang_(getSecond(getLanguageData(false)))
62 void GDocument::doBuild()
64 string const gladeName = findGladeFile("document");
65 xml_ = Gnome::Glade::Xml::create(gladeName);
67 // Manage the action area buttons
69 xml_->get_widget("Cancel", button);
71 xml_->get_widget("OK", button);
73 xml_->get_widget("Apply", button);
75 xml_->get_widget("Revert", button);
78 xml_->get_widget("UseClassDefaults", button);
79 button->signal_clicked().connect(
80 sigc::mem_fun(*this, &GDocument::resetToDefaults));
81 xml_->get_widget("SaveAsDocumentDefaults", button);
82 button->signal_clicked().connect(
83 sigc::mem_fun(*this, &GDocument::saveAsDefaults));
86 // *** Start "Document" Page ***
87 Gtk::Box * box = NULL;
88 xml_->get_widget("DocumentClass", box);
89 // Prevent combo making dialog super-wide due to long class names
90 classcombo_.set_size_request(1, -1);
91 box->pack_start(classcombo_, true, true, 0);
94 classcombo_.signal_changed().connect(
95 sigc::mem_fun(*this, &GDocument::classChanged));
97 // Populate Document Class combo
98 for (LyXTextClassList::const_iterator cit = textclasslist.begin();
99 cit != textclasslist.end(); ++cit) {
100 if (cit->isTeXClassAvailable()) {
101 classcombo_.append_text(cit->description());
104 bformat(_("Unavailable: %1$s"), cit->description());
105 classcombo_.append_text(item);
109 xml_->get_widget("ExtraOptions", extraoptionsentry_);
111 xml_->get_widget("PostscriptDriver", box);
112 box->pack_start(psdrivercombo_, true, true, 0);
115 // Populate Postscript driver combo
116 for (int i = 0; tex_graphics[i][0]; ++i) {
117 psdrivercombo_.append_text(tex_graphics[i]);
120 xml_->get_widget("Font", box);
121 box->pack_start(fontcombo_, true, true, 0);
124 // Populate font combo
125 for (int i = 0; tex_fonts[i][0]; ++i) {
126 fontcombo_.append_text(tex_fonts[i]);
129 xml_->get_widget("FontSize", box);
130 box->pack_start(fontsizecombo_, true, true, 0);
133 Gtk::SpinButton * spin;
134 xml_->get_widget("LineSpacing", spin);
135 linespacingadj_ = spin->get_adjustment();
137 xml_->get_widget("Indentation", indentradio_);
138 xml_->get_widget("VerticalSpace", vspaceradio_);
139 vspaceradio_->signal_toggled().connect(
140 sigc::mem_fun(*this, &GDocument::updateParagraphSeparationSensitivity));
143 xml_->get_widget("VerticalSpaceSize", box);
144 box->pack_start(vspacesizecombo_, true, true, 0);
146 // The order of these items is magic
147 vspacesizecombo_.append_text(_("Small Skip"));
148 vspacesizecombo_.append_text(_("Medium Skip"));
149 vspacesizecombo_.append_text(_("Big Skip"));
150 vspacesizecombo_.append_text(_("Custom"));
151 vspacesizemap_[0] = VSpace::SMALLSKIP;
152 vspacesizemap_[1] = VSpace::MEDSKIP;
153 vspacesizemap_[2] = VSpace::BIGSKIP;
154 vspacesizemap_[3] = VSpace::LENGTH;
156 vspacesizecombo_.signal_changed().connect(
158 &GDocument::updateParagraphSeparationSensitivity));
160 xml_->get_widget_derived("VerticalSpaceLength", vspacelengthentry_);
161 vspacelengthentry_->set_relative(false);
163 updateParagraphSeparationSensitivity();
164 // *** End "Document" Page ***
166 // *** Begin "Page" Page ***
167 xml_->get_widget("PageSize", box);
168 box->pack_start(pagesizecombo_, true, true, 0);
170 pagesizecombo_.append_text(_("Default"));
171 pagesizecombo_.append_text(_("Custom"));
172 pagesizecombo_.append_text(_("US letter"));
173 pagesizecombo_.append_text(_("US legal"));
174 pagesizecombo_.append_text(_("US executive"));
175 pagesizecombo_.append_text(_("A3"));
176 pagesizecombo_.append_text(_("A4"));
177 pagesizecombo_.append_text(_("A5"));
178 pagesizecombo_.append_text(_("B3"));
179 pagesizecombo_.append_text(_("B4"));
180 pagesizecombo_.append_text(_("B5"));
181 pagesizecombo_.signal_changed().connect(
182 sigc::mem_fun(*this, &GDocument::pageSizeChanged));
184 xml_->get_widget_derived("PageWidth", pagewidthlengthentry_);
185 xml_->get_widget_derived("PageHeight", pageheightlengthentry_);
186 pagewidthlengthentry_->set_relative(false);
187 pageheightlengthentry_->set_relative(false);
189 xml_->get_widget("Portrait", portraitradio_);
190 xml_->get_widget("Landscape", landscaperadio_);
192 xml_->get_widget("PageStyle", box);
193 box->pack_start(pagestylecombo_, true, true, 0);
195 xml_->get_widget("DoubleSided", doublesidedtoggle_);
196 xml_->get_widget("TwoColumns", twocolumnstoggle_);
197 // *** End "Page" Page ***
199 // *** Begin "Margins" Page ***
200 xml_->get_widget("DefaultMargins", defaultmargins_);
201 defaultmargins_->signal_toggled().connect(
202 sigc::mem_fun(*this, &GDocument::marginsChanged));
204 xml_->get_widget_derived("MarginsTop", mtoplengthentry_);
205 xml_->get_widget_derived("MarginsBottom", mbottomlengthentry_);
206 xml_->get_widget_derived("MarginsInner", minnerlengthentry_);
207 xml_->get_widget_derived("MarginsOuter", mouterlengthentry_);
208 xml_->get_widget_derived("MarginsHeadSep", mheadseplengthentry_);
209 xml_->get_widget_derived("MarginsHeadHeight", mheadheightlengthentry_);
210 xml_->get_widget_derived("MarginsFootSkip", mfootskiplengthentry_);
211 // *** End "Margins" Page ***
213 // *** Start "Language" Page ***
214 xml_->get_widget("Language", box);
215 box->pack_start(languagecombo_, true, true, 0);
218 vector<LanguagePair> const langs = getLanguageData(false);
219 vector<LanguagePair>::const_iterator lit = langs.begin();
220 vector<LanguagePair>::const_iterator lend = langs.end();
221 for (; lit != lend; ++lit) {
222 languagecombo_.append_text(lit->first);
225 xml_->get_widget("TextEncoding", box);
226 box->pack_start(encodingcombo_, true, true, 0);
231 encodingcombo_.append_text(encodings[i++]);
233 xml_->get_widget("EnglishQuote", qenglishradio_);
234 xml_->get_widget("SwedishQuote", qswedishradio_);
235 xml_->get_widget("GermanQuote", qgermanradio_);
236 xml_->get_widget("PolishQuote", qpolishradio_);
237 xml_->get_widget("FrenchQuote", qfrenchradio_);
238 xml_->get_widget("DanishQuote", qdanishradio_);
239 // *** End "Language" Page ***
241 // *** Start "Numbering" Page ***
243 xml_->get_widget("Numbering", scale);
244 numberingadj_ = scale->get_adjustment();
245 numberingadj_->signal_value_changed().connect(
246 sigc::mem_fun(*this, &GDocument::numberingChanged));
247 xml_->get_widget("NumberingLabel", numberinglabel_);
249 xml_->get_widget("TOC", scale);
250 TOCadj_ = scale->get_adjustment();
251 TOCadj_->signal_value_changed().connect(
252 sigc::mem_fun(*this, &GDocument::TOCChanged));
253 xml_->get_widget("TOCLabel", TOClabel_);
254 // *** End "Numbering" Page ***
256 // *** Start "Bibliography" Page ***
257 xml_->get_widget("BasicNumerical", basicnumericalradio_);
258 xml_->get_widget("NatbibNumerical", natbibnumericalradio_);
259 xml_->get_widget("NatbibAuthorYear", natbibauthoryearradio_);
260 xml_->get_widget("Jurabib", jurabibradio_);
261 xml_->get_widget("SectionedBibliography", sectionedbibliographytoggle_);
262 // *** End "Bibliography" Page ***
264 // *** Start "Math" Page ***
265 xml_->get_widget("AMSAutomatically", AMSautomaticallyradio_);
266 xml_->get_widget("AMSAlways", AMSalwaysradio_);
267 xml_->get_widget("AMSNever", AMSneverradio_);
268 // *** End "Math" Page ***
270 // *** Start "Floats" Page ***
271 xml_->get_widget("DocumentDefault", defaultradio_);
272 xml_->get_widget("HereDefinitely", heredefinitelyradio_);
273 xml_->get_widget("Alternative", alternativeradio_);
274 alternativeradio_->signal_toggled().connect(
275 sigc::mem_fun(*this, &GDocument::alternativeChanged));
276 xml_->get_widget("TopOfPage", topcheck_);
277 xml_->get_widget("BottomOfPage", bottomcheck_);
278 xml_->get_widget("PageOfFloats", pageoffloatscheck_);
279 xml_->get_widget("HereIfPossible", hereifpossiblecheck_);
280 xml_->get_widget("IgnoreRules", ignorerulescheck_);
281 // Initial sensitivity
282 GDocument::alternativeChanged();
284 // *** End "Floats" Page ***
286 // *** Start "Bullets" Page ***
287 // *** End "Bullets" Page ***
289 // *** Start "Branches" Page ***
290 xml_->get_widget("Branches", branchesview_);
291 xml_->get_widget("AddBranch", addbranchbutton_);
292 addbranchbutton_->signal_clicked().connect(
293 sigc::mem_fun(*this, &GDocument::addBranch));
294 xml_->get_widget("RemoveBranch", removebranchbutton_);
295 removebranchbutton_->signal_clicked().connect(
296 sigc::mem_fun(*this, &GDocument::removeBranch));
297 branchCols_.add(branchColName_);
298 branchCols_.add(branchColActivated_);
299 branchCols_.add(branchColColor_);
301 branchliststore_ = Gtk::ListStore::create(branchCols_);
302 branchesview_->set_model(branchliststore_);
303 branchesview_->append_column_editable(_("Name"), branchColName_);
304 branchesview_->append_column_editable(_("Activated"), branchColActivated_);
305 branchesview_->append_column_editable(_("Color"), branchColColor_);
306 branchsel_ = branchesview_->get_selection();
308 branchsel_->signal_changed().connect(
309 sigc::mem_fun(*this, &GDocument::branchSelChanged));
312 ErrorList::const_iterator cit = errors.begin();
313 ErrorList::const_iterator end = errors.end();
314 for (int rowindex = 0; cit != end; ++cit, ++rowindex) {
315 Gtk::ListStore::Row row = *errliststore_->append();
317 errlistsel_->select(*row);
319 (*row)[listCol_] = cit->error;
320 (*row)[listColIndex_] = rowindex;
323 Gtk::ListStore::Row row = *branchliststore_->append();
324 (*row)[branchColName_] = "Munch";
325 (*row)[branchColActivated_] = false;
326 row = *branchliststore_->append();
327 (*row)[branchColName_] = "Hunch";
328 (*row)[branchColActivated_] = true;
329 // *** End "Branches" Page ***
331 // *** Begin "Preamble" Page ***
333 xml_->get_widget ("Preamble", view);
334 preamblebuffer_ = view->get_buffer();
335 // *** End "Preamble" Page ***
339 void GDocument::update()
341 BufferParams & params = controller().params();
343 // *** Start "Document" Page ***
346 classcombo_.set_active(params.textclass);
349 extraoptionsentry_->set_text(params.options);
352 comboBoxTextSet(psdrivercombo_, params.graphicsDriver);
355 comboBoxTextSet(fontcombo_, params.fonts);
356 comboBoxTextSet(fontsizecombo_, params.fontsize);
359 linespacingadj_->set_value(params.spacing().getValue());
361 // Paragraph Separation
362 if (params.paragraph_separation == BufferParams::PARSEP_INDENT) {
363 indentradio_->set_active(true);
365 vspaceradio_->set_active(true);
368 // Paragraph Separation Vertical Space Size
369 VSpace::vspace_kind const skipkind = params.getDefSkip().kind();
370 for (int i = 0; i <= 3; ++i) {
371 if (vspacesizemap_[i] == skipkind)
372 vspacesizecombo_.set_active(i);
375 LyXLength vspacelen = params.getDefSkip().length().len();
376 vspacelengthentry_->set_length (vspacelen);
378 // *** End "Document" Page ***
380 // *** Begin "Page" Page ***
381 int const psize = params.papersize;
382 pagesizecombo_.set_active(psize);
384 pagewidthlengthentry_->set_length(LyXLength(params.paperwidth));
385 pageheightlengthentry_->set_length(LyXLength(params.paperheight));
387 if (params.orientation == ORIENTATION_PORTRAIT)
388 portraitradio_->set_active();
390 landscaperadio_->set_active();
392 if (params.columns == 2)
393 twocolumnstoggle_->set_active(true);
395 twocolumnstoggle_->set_active(false);
397 doublesidedtoggle_->set_active(params.sides == LyXTextClass::TwoSides);
399 comboBoxTextSet(pagestylecombo_, params.pagestyle);
400 // *** End "Page" Page ***
402 defaultmargins_->set_active(!params.use_geometry);
404 mtoplengthentry_->set_length(params.topmargin);
405 mbottomlengthentry_->set_length(params.bottommargin);
406 minnerlengthentry_->set_length(params.leftmargin);
407 mouterlengthentry_->set_length(params.rightmargin);
408 mheadseplengthentry_->set_length(params.headsep);
409 mheadheightlengthentry_->set_length(params.headheight);
410 mfootskiplengthentry_->set_length(params.footskip);
413 // *** End "Margins" Page ***
415 // *** Start "Language" Page ***
416 int const langpos = findPos(lang_,
417 params.language->lang());
418 languagecombo_.set_active(langpos);
421 encodingcombo_.set_active(0);
422 if (params.inputenc == "default") {
423 encodingcombo_.set_active(1);
426 while (encodings[i]) {
427 if (encodings[i] == params.inputenc)
428 encodingcombo_.set_active(i);
433 switch (params.quotes_language) {
434 case InsetQuotes::EnglishQ:
435 qenglishradio_->set_active();
437 case InsetQuotes::SwedishQ:
438 qswedishradio_->set_active();
440 case InsetQuotes::GermanQ:
441 qgermanradio_->set_active();
443 case InsetQuotes::PolishQ:
444 qpolishradio_->set_active();
446 case InsetQuotes::FrenchQ:
447 qfrenchradio_->set_active();
449 case InsetQuotes::DanishQ:
450 qdanishradio_->set_active();
454 // *** End "Language" Page ***
456 // *** Start "Numbering" Page ***
457 numberingadj_->set_value(params.secnumdepth + 2);
458 TOCadj_->set_value(params.tocdepth + 1);
459 // *** End "Numbering" Page ***
461 // *** Start "Bibliography" Page ***
462 switch (params.cite_engine) {
463 case biblio::ENGINE_BASIC:
464 basicnumericalradio_->set_active();
466 case biblio::ENGINE_NATBIB_NUMERICAL:
467 natbibnumericalradio_->set_active();
469 case biblio::ENGINE_NATBIB_AUTHORYEAR:
470 natbibauthoryearradio_->set_active();
472 case biblio::ENGINE_JURABIB:
473 jurabibradio_->set_active();
477 sectionedbibliographytoggle_->set_active(params.use_bibtopic);
478 // *** End "Bibliography" Page ***
480 // *** Start "Math" Page ***
481 switch (params.use_amsmath) {
482 case BufferParams::AMS_AUTO:
483 AMSautomaticallyradio_->set_active();
485 case BufferParams::AMS_ON:
486 AMSalwaysradio_->set_active();
488 case BufferParams::AMS_OFF:
489 AMSneverradio_->set_active();
492 // *** End "Math" Page ***
494 // *** Start "Floats" Page ***
495 string const placement = params.float_placement;
496 bool const here_definitely = contains(placement, 'H');
497 bool const top = contains(placement, 't');
498 bool const bottom = contains(placement, 'b');
499 bool const page = contains(placement, 'p');
500 bool const here = contains(placement, 'h');
501 bool const force = contains(placement, '!');
502 bool const alternatives = top || bottom || page || here;
505 alternativeradio_->set_active(true);
506 } else if (here_definitely) {
507 heredefinitelyradio_->set_active(true);
509 defaultradio_->set_active(true);
511 ignorerulescheck_->set_active(force);
512 topcheck_->set_active(top);
513 bottomcheck_->set_active(bottom);
514 pageoffloatscheck_->set_active(page);
515 hereifpossiblecheck_->set_active(here);
517 // *** End "Floats" Page ***
519 // *** Start "Bullets" Page ***
520 // *** End "Bullets" Page ***
522 // *** Start "Branches" Page ***
523 branchliststore_->clear();
525 BranchList::const_iterator it = params.branchlist().begin();
526 BranchList::const_iterator const end = params.branchlist().end();
527 for (; it != end; ++it) {
528 Gtk::ListStore::Row row = *branchliststore_->append();
529 (*row)[branchColName_] = (*it).getBranch();
530 std::cerr << "update: loading '" << (*it).getBranch() << "'\n";
531 (*row)[branchColActivated_] = (*it).getSelected();
532 (*row)[branchColColor_] = (*it).getColor();
534 // *** End "Branches" Page ***
536 // *** Begin "Preamble" Page ***
537 preamblebuffer_->set_text(params.preamble);
538 // *** End "Preamble" Page ***
540 // Be a cheesy bastard, for the moment
545 void GDocument::apply()
547 BufferParams & params = controller().params();
549 // *** Start "Document" Page ***
552 params.textclass = classcombo_.get_active_row_number();
555 params.options = extraoptionsentry_->get_text();
558 params.graphicsDriver = psdrivercombo_.get_active_text();
561 params.fonts = fontcombo_.get_active_text();
562 params.fontsize = fontsizecombo_.get_active_text();
565 params.spacing().set(Spacing::Other, linespacingadj_->get_value());
567 // Paragraph Separation
568 if (indentradio_->get_active()) {
569 params.paragraph_separation = BufferParams::PARSEP_INDENT;
571 params.paragraph_separation = BufferParams::PARSEP_SKIP;
574 // Paragraph Separation Vertical Space Size
575 VSpace::vspace_kind const selection =
576 vspacesizemap_[vspacesizecombo_.get_active_row_number()];
577 params.setDefSkip(VSpace(selection));
578 if (selection == VSpace::LENGTH) {
579 LyXLength length = vspacelengthentry_->get_length();
580 params.setDefSkip(VSpace(LyXGlueLength(length)));
583 // *** End "Document" Page ***
585 // *** Begin "Page" Page ***
586 params.papersize = PAPER_SIZE(
587 pagesizecombo_.get_active_row_number());
589 params.paperwidth = pagewidthlengthentry_->get_length_string();
590 params.paperheight = pageheightlengthentry_->get_length_string();
592 if (portraitradio_->get_active())
593 params.orientation = ORIENTATION_PORTRAIT;
595 params.orientation = ORIENTATION_LANDSCAPE;
597 if (twocolumnstoggle_->get_active())
602 if (doublesidedtoggle_->get_active())
603 params.sides = LyXTextClass::TwoSides;
605 params.sides = LyXTextClass::OneSide;
607 params.pagestyle = pagestylecombo_.get_active_text();
608 // *** End "Page" Page ***
610 // *** Begin "Margins" Page ***
611 params.use_geometry = !defaultmargins_->get_active();
613 params.topmargin = mtoplengthentry_->get_length_string();
614 params.bottommargin = mbottomlengthentry_->get_length_string();
615 params.leftmargin = minnerlengthentry_->get_length_string();
616 params.rightmargin = mouterlengthentry_->get_length_string();
617 params.headsep = mheadseplengthentry_->get_length_string();
618 params.headheight = mheadheightlengthentry_->get_length_string();
619 params.footskip = mfootskiplengthentry_->get_length_string();
620 // *** End "Margins" Page ***
622 // *** Start "Language" Page ***
623 int const encodingsel = encodingcombo_.get_active_row_number();
624 if (encodingsel == 0)
625 params.inputenc = "auto";
626 else if (encodingsel == 1)
627 params.inputenc = "default";
629 params.inputenc = encodings[encodingsel];
631 int const langsel = languagecombo_.get_active_row_number();
632 params.language = languages.getLanguage(lang_[langsel]);
634 if (qenglishradio_->get_active())
635 params.quotes_language = InsetQuotes::EnglishQ;
636 else if (qswedishradio_->get_active())
637 params.quotes_language = InsetQuotes::SwedishQ;
638 else if (qgermanradio_->get_active())
639 params.quotes_language = InsetQuotes::GermanQ;
640 else if (qpolishradio_->get_active())
641 params.quotes_language = InsetQuotes::PolishQ;
642 else if (qfrenchradio_->get_active())
643 params.quotes_language = InsetQuotes::FrenchQ;
644 else if (qdanishradio_->get_active())
645 params.quotes_language = InsetQuotes::DanishQ;
646 // *** End "Language" Page ***
648 // *** Start "Numbering" Page ***
649 params.secnumdepth = (int)(numberingadj_->get_value()) - 2;
650 params.tocdepth = (int)(TOCadj_->get_value()) - 1;
651 // *** End "Numbering" Page ***
653 // *** Start "Bibliography" Page ***
654 if (basicnumericalradio_->get_active())
655 params.cite_engine = biblio::ENGINE_BASIC;
656 else if (natbibnumericalradio_->get_active())
657 params.cite_engine = biblio::ENGINE_NATBIB_NUMERICAL;
658 else if (natbibauthoryearradio_->get_active())
659 params.cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
660 else if (jurabibradio_->get_active())
661 params.cite_engine = biblio::ENGINE_JURABIB;
663 params.use_bibtopic = sectionedbibliographytoggle_->get_active();
664 // *** End "Bibliography" Page ***
666 // *** Start "Math" Page ***
667 if (AMSautomaticallyradio_->get_active())
668 params.use_amsmath = BufferParams::AMS_AUTO;
669 else if (AMSalwaysradio_->get_active())
670 params.use_amsmath = BufferParams::AMS_ON;
671 else if (AMSneverradio_->get_active())
672 params.use_amsmath = BufferParams::AMS_OFF;
673 // *** End "Math" Page ***
675 // *** Start "Floats" Page ***
677 if (alternativeradio_->get_active()) {
678 if (ignorerulescheck_->get_active())
680 if (topcheck_->get_active())
682 if (bottomcheck_->get_active())
684 if (pageoffloatscheck_->get_active())
686 if (hereifpossiblecheck_->get_active())
688 if (placement == "!")
690 } else if (heredefinitelyradio_->get_active())
693 params.float_placement = placement;
694 // *** End "Floats" Page ***
696 // *** Start "Bullets" Page ***
697 // *** End "Bullets" Page ***
699 // *** Start "Branches" Page ***
700 /*branchliststore_->clear();
702 BranchList::const_iterator it = params.branchlist().begin();
703 BranchList::const_iterator const end = params.branchlist().end();
704 for (; it != end; ++it) {
705 Gtk::ListStore::Row row = *branchliststore_->append();
706 (*row)[branchColName_] = (*it).getBranch();
707 (*row)[branchColActivated_] = (*it).getSelected();
708 (*row)[branchColColor_] = (*it).getColor();
711 BranchList branchlist;
713 Gtk::ListStore::iterator it = branchliststore_->children().begin();
714 Gtk::ListStore::iterator const end = branchliststore_->children().end();
715 for (; it != end; ++it) {
716 Gtk::ListStore::Row row = *it;
717 Glib::ustring const name = (*row)[branchColName_];
718 if (branchlist.add(name)) {
719 std::cerr << "apply: adding '" << name << "'\n";
720 Branch * newbranch = branchlist.find(name);
721 newbranch->setSelected((*row)[branchColActivated_]);
722 Glib::ustring const color = (*row)[branchColColor_];
723 newbranch->setColor(color);
727 params.branchlist() = branchlist;
729 // *** End "Branches" Page ***
731 // *** Begin "Preamble" Page ***
732 params.preamble = preamblebuffer_->get_text();
733 // *** End "Preamble" Page ***
737 void GDocument::saveAsDefaults()
740 controller().saveAsDefault();
744 void GDocument::resetToDefaults()
746 BufferParams & params = controller().params();
747 params.textclass = classcombo_.get_active_row_number();
748 params.useClassDefaults();
753 void GDocument::updateParagraphSeparationSensitivity()
755 bool const vspacesensitive = vspaceradio_->get_active();
757 vspacesizecombo_.set_sensitive(vspacesensitive);
759 bool const lengthsensitive = vspacesensitive &&
760 (vspacesizecombo_.get_active_row_number() == 3);
762 vspacelengthentry_->set_sensitive(lengthsensitive);
766 void GDocument::classChanged()
768 ControlDocument & ctrl = controller();
769 BufferParams & params = ctrl.params();
771 lyx::textclass_type const tc = classcombo_.get_active_row_number();
773 if (ctrl.loadTextclass(tc)) {
774 params.textclass = tc;
776 if (lyxrc.auto_reset_options) {
777 params.useClassDefaults();
780 fontsizecombo_.clear();
781 fontsizecombo_.append_text("default");
783 string const fontsizeitems = ctrl.textClass().opt_fontsize();
784 for (int n = 0; !token(fontsizeitems, '|', n).empty(); ++n)
785 fontsizecombo_.append_text(token(fontsizeitems, '|', n));
787 comboBoxTextSet(fontsizecombo_, params.fontsize);
789 pagestylecombo_.clear();
790 pagestylecombo_.append_text("default");
792 string const pagestyleitems = ctrl.textClass().opt_pagestyle();
793 for (int n=0; !token(pagestyleitems,'|',n).empty(); ++n)
794 pagestylecombo_.append_text(token(pagestyleitems,'|',n));
796 comboBoxTextSet(pagestylecombo_, params.pagestyle);
799 classcombo_.set_active(params.textclass);
804 void GDocument::pageSizeChanged()
806 bool const customsize = pagesizecombo_.get_active_row_number() == 1;
807 pagewidthlengthentry_->set_sensitive(customsize);
808 pageheightlengthentry_->set_sensitive(customsize);
811 portraitradio_->set_active();
815 void GDocument::marginsChanged()
817 bool const custom = !defaultmargins_->get_active();
819 mtoplengthentry_->set_sensitive(custom);
820 mbottomlengthentry_->set_sensitive(custom);
821 minnerlengthentry_->set_sensitive(custom);
822 mouterlengthentry_->set_sensitive(custom);
823 mheadseplengthentry_->set_sensitive(custom);
824 mheadheightlengthentry_->set_sensitive(custom);
825 mfootskiplengthentry_->set_sensitive(custom);
829 void GDocument::numberingChanged()
831 string const numberinglabels[] = {
832 _("No headings numbered"),
833 _("Only parts numbered"),
834 _("Chapters and above numbered"),
835 _("Sections and above numbered"),
836 _("Subsections and above numbered"),
837 _("Subsubsections and above numbered"),
838 _("Paragraphs and above numbered"),
839 _("All headings numbered")
842 int const value = (int)(numberingadj_->get_value());
843 numberinglabel_->set_label("<i>" + numberinglabels[value] + "</i>");
847 void GDocument::TOCChanged()
849 string const TOClabels[] = {
850 _("Only Parts appear in TOC"),
851 _("Chapters and above appear in TOC"),
852 _("Sections and above appear in TOC"),
853 _("Subsections and above appear in TOC"),
854 _("Subsubsections and above appear in TOC"),
855 _("Paragraphs and above appear in TOC"),
856 _("TOC contains all headings")
859 int const value = (int)(TOCadj_->get_value());
860 TOClabel_->set_label("<i>" + TOClabels[value] + "</i>");
864 void GDocument::alternativeChanged()
866 bool const sens = alternativeradio_->get_active();
867 topcheck_->set_sensitive(sens);
868 bottomcheck_->set_sensitive(sens);
869 pageoffloatscheck_->set_sensitive(sens);
870 hereifpossiblecheck_->set_sensitive(sens);
871 ignorerulescheck_->set_sensitive(sens);
875 void GDocument::addBranch()
877 Gtk::ListStore::Row row = *branchliststore_->append();
878 (*row)[branchColName_] = "New Branch";
879 (*row)[branchColActivated_] = false;
880 (*row)[branchColColor_] = "#000000";
884 void GDocument::removeBranch()
886 Gtk::TreeModel::iterator const selected = branchsel_->get_selected();
887 if (!branchliststore_->iter_is_valid(selected))
890 branchliststore_->erase (selected);
894 void GDocument::branchSelChanged()
896 if (branchsel_->get_selected() == branchliststore_->children().end())
897 removebranchbutton_->set_sensitive(false);
899 removebranchbutton_->set_sensitive(true);
902 } // namespace frontend