From fc71ca34470ba19a43dd53fa511319392f9fb151 Mon Sep 17 00:00:00 2001 From: John Spray Date: Fri, 11 Mar 2005 00:25:56 +0000 Subject: [PATCH] * GGraphics, GVSpace, GBox: update to use new ghelpers functions * ghelpers: add getLengthFromWidgets, setWidgetsFromLength, comboBoxTextSet, populateUnitCombo. Remove buildLengthNoRelUnitList. * GDocument.[Ch], Makefile.am, Dialogs.C: start work on document dialog. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9709 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gtk/ChangeLog | 8 + src/frontends/gtk/Dialogs.C | 7 +- src/frontends/gtk/GBox.C | 4 +- src/frontends/gtk/GDocument.C | 289 +++ src/frontends/gtk/GDocument.h | 67 + src/frontends/gtk/GGraphics.C | 42 +- src/frontends/gtk/GGraphics.h | 4 +- src/frontends/gtk/GVSpace.C | 53 +- src/frontends/gtk/GVSpace.h | 8 +- src/frontends/gtk/Makefile.am | 3 +- src/frontends/gtk/ghelpers.C | 74 +- src/frontends/gtk/ghelpers.h | 26 +- src/frontends/gtk/glade/Makefile.am | 1 + src/frontends/gtk/glade/document.glade | 2225 ++++++++++++++++++++++++ src/frontends/gtk/glade/graphics.glade | 82 +- src/frontends/gtk/glade/vspace.glade | 72 +- 16 files changed, 2765 insertions(+), 200 deletions(-) create mode 100644 src/frontends/gtk/GDocument.C create mode 100644 src/frontends/gtk/GDocument.h create mode 100644 src/frontends/gtk/glade/document.glade diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 9316c350d1..914b2c1cf0 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,11 @@ +2005-03-10 John Spray + + * GGraphics, GVSpace, GBox: update to use new ghelpers functions + * ghelpers: add getLengthFromWidgets, setWidgetsFromLength, + comboBoxTextSet, populateUnitCombo. Remove buildLengthNoRelUnitList. + * GDocument.[Ch], Makefile.am, Dialogs.C: start work on document + dialog. + 2005-03-04 John Spray * GToolbar.C: remember existing selection when update()ing diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index c36edbcb90..34e09dc27d 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -67,7 +67,7 @@ #include "GChanges.h" #include "GCharacter.h" #include "FormCitation.h" -#include "FormDocument.h" +#include "GDocument.h" #include "GErrorList.h" #include "GERT.h" #include "FormExternal.h" @@ -217,9 +217,10 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new FormCitation(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "document") { + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlDocument(*dialog)); - dialog->setView(new FormDocument(*dialog)); - dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); + dialog->setView(new GDocument(*dialog)); + dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "errorlist") { dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlErrorList(*dialog)); diff --git a/src/frontends/gtk/GBox.C b/src/frontends/gtk/GBox.C index adb17fd1cd..4bc5e162d1 100644 --- a/src/frontends/gtk/GBox.C +++ b/src/frontends/gtk/GBox.C @@ -115,7 +115,7 @@ void GBox::doBuild() //widthunitscombo_ is populated in setSpecial box_gui_tokens_special_length(ids_spec_, gui_names_spec_); - vector heightunits = buildLengthUnitList(); + vector heightunits = buildLengthUnitList(true); // Append special entries, skipping the first item "None" heightunits.insert(heightunits.end(), ++gui_names_spec_.begin(), gui_names_spec_.end()); @@ -220,7 +220,7 @@ void GBox::setSpecial(bool ibox) unsigned int const initselection = widthunitscombo_->get_active_row_number(); widthunitsstore_->clear(); - vector normalunits = buildLengthUnitList(); + vector normalunits = buildLengthUnitList(true); if (ibox) { vector::const_iterator it = normalunits.begin(); vector::const_iterator end = normalunits.end(); diff --git a/src/frontends/gtk/GDocument.C b/src/frontends/gtk/GDocument.C new file mode 100644 index 0000000000..82f0548c37 --- /dev/null +++ b/src/frontends/gtk/GDocument.C @@ -0,0 +1,289 @@ +/** + * \file GDocument.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author John Spray + * + * Full author contact details are available in file CREDITS. + */ + +#include + +// Too hard to make concept checks work with this file +#ifdef _GLIBCXX_CONCEPT_CHECKS +#undef _GLIBCXX_CONCEPT_CHECKS +#endif +#ifdef _GLIBCPP_CONCEPT_CHECKS +#undef _GLIBCPP_CONCEPT_CHECKS +#endif + +#include "GDocument.h" +#include "ghelpers.h" + +#include "ControlDocument.h" +#include "controllers/helper_funcs.h" + +#include "support/lstrings.h" + +#include "lyxtextclasslist.h" +#include "bufferparams.h" +#include "tex-strings.h" + +using std::string; + +namespace lyx { + +using support::bformat; + +namespace frontend { + +GDocument::GDocument(Dialog & parent) + : GViewCB(parent, _("Document Settings"), false) +{} + +void GDocument::doBuild() +{ + string const gladeName = findGladeFile("document"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + // Manage the action area buttons + Gtk::Button * button; + xml_->get_widget("Cancel", button); + setCancel(button); + xml_->get_widget("OK", button); + setOK(button); + xml_->get_widget("Apply", button); + setApply(button); + xml_->get_widget("Revert", button); + setRestore(button); + + xml_->get_widget("UseClassDefaults", button); + button->signal_clicked().connect( + sigc::mem_fun(*this, &GDocument::resetToDefaults)); + xml_->get_widget("SaveAsDocumentDefaults", button); + button->signal_clicked().connect( + sigc::mem_fun(*this, &GDocument::saveAsDefaults)); + + + // *** Start "Document" Page *** + Gtk::Box * box = NULL; + xml_->get_widget("DocumentClass", box); + // Prevent combo making dialog super-wide due to long class names + classcombo_.set_size_request(1, -1); + box->pack_start(classcombo_, true, true, 0); + box->show_all(); + + // Populate Document Class combo + for (LyXTextClassList::const_iterator cit = textclasslist.begin(); + cit != textclasslist.end(); ++cit) { + if (cit->isTeXClassAvailable()) { + classcombo_.append_text(cit->description()); + } else { + string item = + bformat(_("Unavailable: %1$s"), cit->description()); + classcombo_.append_text(item); + } + } + + xml_->get_widget("ExtraOptions", extraoptionsentry_); + + xml_->get_widget("PostscriptDriver", box); + box->pack_start(psdrivercombo_, true, true, 0); + box->show_all(); + + // Populate Postscript driver combo + for (int i = 0; tex_graphics[i][0]; ++i) { + psdrivercombo_.append_text(tex_graphics[i]); + } + + xml_->get_widget("Font", box); + box->pack_start(fontcombo_, true, true, 0); + box->show_all(); + + // Populate font combo + for (int i = 0; tex_fonts[i][0]; ++i) { + fontcombo_.append_text(tex_fonts[i]); + } + + xml_->get_widget("FontSize", box); + box->pack_start(fontsizecombo_, true, true, 0); + box->show_all(); + fontsizecombo_.append_text(_("Default")); + fontsizecombo_.append_text(_("10")); + fontsizecombo_.append_text(_("11")); + fontsizecombo_.append_text(_("12")); + // These are the corresponding strings to be passed to the backend + fontsizemap_[0] = "default"; + fontsizemap_[1] = "10"; + fontsizemap_[2] = "11"; + fontsizemap_[3] = "12"; + + Gtk::SpinButton * spin; + xml_->get_widget("LineSpacing", spin); + linespacingadj_ = spin->get_adjustment(); + + xml_->get_widget("Indentation", indentradio_); + xml_->get_widget("VerticalSpace", vspaceradio_); + vspaceradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GDocument::updateParagraphSeparationSensitivity)); + + xml_->get_widget("VerticalSpaceSize", box); + box->pack_start(vspacesizecombo_, true, true, 0); + box->show_all(); + // The order of these items is magic + vspacesizecombo_.append_text(_("Small Skip")); + vspacesizecombo_.append_text(_("Medium Skip")); + vspacesizecombo_.append_text(_("Big Skip")); + vspacesizecombo_.append_text(_("Custom")); + vspacesizemap_[0] = VSpace::SMALLSKIP; + vspacesizemap_[1] = VSpace::MEDSKIP; + vspacesizemap_[2] = VSpace::BIGSKIP; + vspacesizemap_[3] = VSpace::LENGTH; + + vspacesizecombo_.signal_changed().connect( + sigc::mem_fun(*this, + &GDocument::updateParagraphSeparationSensitivity)); + + xml_->get_widget("VerticalSpaceLength", vspacelengthspin_); + vspacelengthadj_ = vspacelengthspin_->get_adjustment(); + + xml_->get_widget("VerticalSpaceUnit", box); + box->pack_start(vspaceunitcombo_, true, true, 0); + box->show_all(); + + populateUnitCombo(vspaceunitcombo_, false); + + updateParagraphSeparationSensitivity(); + + // *** End "Document" Page *** +} + + +void GDocument::update() +{ + BufferParams & params = controller().params(); + + // *** Start "Document" Page *** + + // Document Class + classcombo_.set_active(params.textclass); + + // Extra Options + extraoptionsentry_->set_text(params.options); + + // Postscript driver + comboBoxTextSet(psdrivercombo_, params.graphicsDriver); + + // Font & Size + comboBoxTextSet(fontcombo_, params.fonts); + for (int i = 0; i <= 3; ++i) { + if (fontsizemap_[i] == params.fontsize) + fontsizecombo_.set_active(i); + } + + // Line Spacing + linespacingadj_->set_value(params.spacing().getValue()); + + // Paragraph Separation + if (params.paragraph_separation == BufferParams::PARSEP_INDENT) { + indentradio_->set_active(true); + } else { + vspaceradio_->set_active(true); + } + + // Paragraph Separation Vertical Space Size + VSpace::vspace_kind const skipkind = params.getDefSkip().kind(); + for (int i = 0; i <= 3; ++i) { + if (vspacesizemap_[i] == skipkind) + vspacesizecombo_.set_active(i); + } + + LyXLength vspacelen = params.getDefSkip().length().len(); + setWidgetsFromLength(*vspacelengthadj_, vspaceunitcombo_, vspacelen); + + // *** End "Document" Page *** + + // Be a cheesy bastard, for the moment + bc().valid(); +} + + +void GDocument::apply() +{ + BufferParams & params = controller().params(); + + // *** Start "Document" Page *** + + // Document Class + params.textclass = classcombo_.get_active_row_number(); + + // Extra Options + params.options = extraoptionsentry_->get_text(); + + // Postscript Driver + params.graphicsDriver = psdrivercombo_.get_active_text(); + + // Font & Size + params.fonts = fontcombo_.get_active_text(); + params.fontsize = + fontsizemap_[fontsizecombo_.get_active_row_number()]; + + // Line Spacing + params.spacing().set(Spacing::Other, linespacingadj_->get_value()); + + // Paragraph Separation + if (indentradio_->get_active()) { + params.paragraph_separation = BufferParams::PARSEP_INDENT; + } else { + params.paragraph_separation = BufferParams::PARSEP_SKIP; + } + + // Paragraph Separation Vertical Space Size + VSpace::vspace_kind const selection = + vspacesizemap_[vspacesizecombo_.get_active_row_number()]; + params.setDefSkip(VSpace(selection)); + if (selection == VSpace::LENGTH) { + string const length = + getLengthFromWidgets(*vspacelengthadj_, + vspaceunitcombo_); + + params.setDefSkip(VSpace(LyXGlueLength(length))); + } + + // *** End "Document" Page *** +} + + +void GDocument::saveAsDefaults() +{ + apply(); + controller().saveAsDefault(); +} + + +void GDocument::resetToDefaults() +{ + BufferParams & params = controller().params(); + params.textclass = classcombo_.get_active_row_number(); + params.useClassDefaults(); + update(); +} + + +void GDocument::updateParagraphSeparationSensitivity() +{ + bool const vspacesensitive = vspaceradio_->get_active(); + + vspacesizecombo_.set_sensitive(vspacesensitive); + + bool const lengthsensitive = vspacesensitive && + (vspacesizecombo_.get_active_row_number() == 3); + + vspacelengthspin_->set_sensitive(lengthsensitive); + vspaceunitcombo_.set_sensitive(lengthsensitive); +} + + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GDocument.h b/src/frontends/gtk/GDocument.h new file mode 100644 index 0000000000..b536ac2191 --- /dev/null +++ b/src/frontends/gtk/GDocument.h @@ -0,0 +1,67 @@ +// -*- C++ -*- +/** + * \file GDocument.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \auther John Spray + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef GDOCUMENT_H +#define GDOCUMENT_H + +#include "GViewBase.h" +#include "vspace.h" + +#include + +#include + +namespace lyx { +namespace frontend { + +class ControlDocument; + +/** This class provides a gtk implementation of the document dialog. + */ +class GDocument + : public GViewCB { +public: + GDocument(Dialog &); +private: + /// Build the dialog + virtual void doBuild(); + /// Apply from dialog + virtual void apply(); + /// Update the dialog + virtual void update(); + + void saveAsDefaults(); + void resetToDefaults(); + + // *** Start "Document" Page *** + Gtk::ComboBoxText classcombo_; + Gtk::Entry * extraoptionsentry_; + Gtk::ComboBoxText psdrivercombo_; + Gtk::ComboBoxText fontcombo_; + Gtk::ComboBoxText fontsizecombo_; + Gtk::Adjustment * linespacingadj_; + Gtk::RadioButton * indentradio_; + Gtk::RadioButton * vspaceradio_; + Gtk::ComboBoxText vspacesizecombo_; + std::map fontsizemap_; + std::map vspacesizemap_; + Gtk::ComboBoxText vspaceunitcombo_; + Gtk::SpinButton * vspacelengthspin_; + Gtk::Adjustment * vspacelengthadj_; + void updateParagraphSeparationSensitivity(); + // *** End "Document" Page *** + +}; + +} // namespace frontend +} // namespace lyx + +#endif diff --git a/src/frontends/gtk/GGraphics.C b/src/frontends/gtk/GGraphics.C index 7679478488..41db396837 100644 --- a/src/frontends/gtk/GGraphics.C +++ b/src/frontends/gtk/GGraphics.C @@ -81,8 +81,15 @@ void GGraphics::doBuild() xml_->get_widget("Width", widthspin_); xml_->get_widget("Height", heightspin_); xml_->get_widget("MaintainAspectRatio", aspectcheck_); - xml_->get_widget("WidthUnits", widthunitscombo_); - xml_->get_widget("HeightUnits", heightunitscombo_); + + Gtk::VBox * box; + xml_->get_widget("WidthUnits", box); + box->pack_start(widthunitscombo_, true, true, 0); + box->show_all(); + xml_->get_widget("HeightUnits", box); + box->pack_start(heightunitscombo_, true, true, 0); + box->show_all(); + xml_->get_widget("SetScaling", setscalingradio_); xml_->get_widget("SetSize", setsizeradio_); @@ -123,11 +130,11 @@ void GGraphics::doBuild() sigc::mem_fun(*this, &GGraphics::onInput)); heightspin_->signal_changed().connect( sigc::mem_fun(*this, &GGraphics::onInput)); - heightunitscombo_->signal_changed().connect( + heightunitscombo_.signal_changed().connect( sigc::mem_fun(*this, &GGraphics::onInput)); widthspin_->signal_changed().connect( sigc::mem_fun(*this, &GGraphics::onInput)); - widthunitscombo_->signal_changed().connect( + widthunitscombo_.signal_changed().connect( sigc::mem_fun(*this, &GGraphics::onInput)); aspectcheck_->signal_toggled().connect( sigc::mem_fun(*this, &GGraphics::onInput)); @@ -143,9 +150,8 @@ void GGraphics::doBuild() editbutton_->signal_clicked().connect( sigc::mem_fun(*this, &GGraphics::onEditClicked)); - vector const unit_list = buildLengthUnitList(); - PopulateComboBox(heightunitscombo_, unit_list); - PopulateComboBox(widthunitscombo_, unit_list); + populateUnitCombo(widthunitscombo_, true); + populateUnitCombo(heightunitscombo_, true); // the bounding box page leftbottomxspin_->signal_changed().connect( @@ -211,8 +217,8 @@ void GGraphics::onSizingModeChange() outputscalespin_->set_sensitive(scalingmode); widthspin_->set_sensitive(!scalingmode); heightspin_->set_sensitive(!scalingmode); - widthunitscombo_->set_sensitive(!scalingmode); - heightunitscombo_->set_sensitive(!scalingmode); + widthunitscombo_.set_sensitive(!scalingmode); + heightunitscombo_.set_sensitive(!scalingmode); aspectcheck_->set_sensitive(!scalingmode); bc().input(ButtonPolicy::SMI_VALID); } @@ -276,15 +282,10 @@ void GGraphics::apply() igp.width = LyXLength(); } else { igp.scale = string(); - Glib::ustring const widthunit = - (*widthunitscombo_->get_active())[stringcol_]; - igp.width = LyXLength(widthspin_->get_text() + widthunit); + igp.width = LyXLength(getLengthFromWidgets(*widthspin_->get_adjustment(), widthunitscombo_)); } - - Glib::ustring const heightunit = - (*heightunitscombo_->get_active())[stringcol_]; - igp.height = LyXLength(heightspin_->get_text() + heightunit); + igp.height = LyXLength(getLengthFromWidgets(*heightspin_->get_adjustment(), heightunitscombo_)); igp.keepAspectRatio = aspectcheck_->get_active(); igp.draft = draftcheck_->get_active(); @@ -375,12 +376,9 @@ void GGraphics::update() { } outputscalespin_->get_adjustment()->set_value(convert(igp.scale)); - widthspin_->get_adjustment()->set_value(igp.width.value()); - unitsComboFromLength(widthunitscombo_, stringcol_, - igp.width, defaultUnit); - heightspin_->get_adjustment()->set_value(igp.height.value()); - unitsComboFromLength(heightunitscombo_, stringcol_, - igp.height, defaultUnit); + + setWidgetsFromLength(*widthspin_->get_adjustment(), widthunitscombo_, igp.width); + setWidgetsFromLength(*heightspin_->get_adjustment(), heightunitscombo_, igp.height); if (!igp.scale.empty() && !float_equal(convert(igp.scale), 0.0, 0.05)) { diff --git a/src/frontends/gtk/GGraphics.h b/src/frontends/gtk/GGraphics.h index 3a943d5a4f..1907d81b9d 100644 --- a/src/frontends/gtk/GGraphics.h +++ b/src/frontends/gtk/GGraphics.h @@ -65,8 +65,8 @@ private: Gtk::SpinButton * widthspin_; Gtk::SpinButton * heightspin_; Gtk::CheckButton * aspectcheck_; - Gtk::ComboBox * widthunitscombo_; - Gtk::ComboBox * heightunitscombo_; + Gtk::ComboBoxText widthunitscombo_; + Gtk::ComboBoxText heightunitscombo_; Gtk::RadioButton * setscalingradio_; Gtk::RadioButton * setsizeradio_; diff --git a/src/frontends/gtk/GVSpace.C b/src/frontends/gtk/GVSpace.C index 9f2862a0e7..e31a063b1d 100644 --- a/src/frontends/gtk/GVSpace.C +++ b/src/frontends/gtk/GVSpace.C @@ -30,10 +30,6 @@ using std::vector; namespace lyx { namespace frontend { -namespace { -string defaultUnit("cm"); -} // namespace anon - GVSpace::GVSpace(Dialog & parent) : GViewCB(parent, _("VSpace Settings"), false) {} @@ -47,46 +43,27 @@ void GVSpace::doBuild() Gtk::Button * button; xml_->get_widget("Cancel", button); setCancel(button); - xml_->get_widget("Insert", button); + xml_->get_widget("OK", button); setOK(button); xml_->get_widget("Spacing", spacingcombo_); xml_->get_widget("Value", valuespin_); - xml_->get_widget("ValueUnits", valueunitscombo_); + Gtk::VBox * box; + xml_->get_widget("ValueUnits", box); + box->pack_start(valueunitscombo_, true, true, 0); + box->show_all(); + xml_->get_widget("Protect", protectcheck_); - cols_.add(stringcol_); - - PopulateComboBox(valueunitscombo_, buildLengthNoRelUnitList()); + populateUnitCombo(valueunitscombo_, false); spacingcombo_->signal_changed().connect( sigc::mem_fun(*this, &GVSpace::onSpacingComboChanged)); } -void GVSpace::PopulateComboBox(Gtk::ComboBox * combo, - vector const & strings) -{ - Glib::RefPtr model = Gtk::ListStore::create(cols_); - vector::const_iterator it = strings.begin(); - vector::const_iterator end = strings.end(); - for (int rowindex = 0; it != end; ++it, ++rowindex) { - Gtk::TreeModel::iterator row = model->append(); - (*row)[stringcol_] = *it; - } - - combo->set_model(model); - Gtk::CellRendererText * cell = Gtk::manage(new Gtk::CellRendererText); - combo->pack_start(*cell, true); - combo->add_attribute(*cell, "text", 0); -} - - void GVSpace::update() { - // set the right default unit - defaultUnit = getDefaultUnit(); - VSpace const space = controller().params(); int pos = 0; @@ -117,14 +94,10 @@ void GVSpace::update() bool const custom_vspace = space.kind() == VSpace::LENGTH; if (custom_vspace) { - LyXLength length(space.length().asString()); - valuespin_->get_adjustment()->set_value(length.value()); - unitsComboFromLength(valueunitscombo_, stringcol_, - length, defaultUnit); + setWidgetsFromLength(*valuespin_->get_adjustment(), valueunitscombo_, space.length().len()); } else { - valuespin_->get_adjustment()->set_value(0.0f); - unitsComboFromLength(valueunitscombo_, stringcol_, - LyXLength(defaultUnit), defaultUnit); + setWidgetsFromLength(*valuespin_->get_adjustment(), valueunitscombo_, LyXLength()); + } } @@ -149,9 +122,7 @@ void GVSpace::apply() space = VSpace(VSpace::VFILL); break; case 5: - Glib::ustring const valueunit = - (*valueunitscombo_->get_active())[stringcol_]; - space = VSpace(LyXGlueLength(valuespin_->get_text() + valueunit)); + space = VSpace(LyXGlueLength(getLengthFromWidgets(*valuespin_->get_adjustment(), valueunitscombo_))); break; } @@ -164,7 +135,7 @@ void GVSpace::apply() void GVSpace::onSpacingComboChanged() { bool const custom = spacingcombo_->get_active_row_number() == 5; - valueunitscombo_->set_sensitive(custom); + valueunitscombo_.set_sensitive(custom); valuespin_->set_sensitive(custom); } diff --git a/src/frontends/gtk/GVSpace.h b/src/frontends/gtk/GVSpace.h index 3619245d51..a24c358526 100644 --- a/src/frontends/gtk/GVSpace.h +++ b/src/frontends/gtk/GVSpace.h @@ -29,17 +29,11 @@ private: virtual void doBuild(); virtual void update(); - void PopulateComboBox(Gtk::ComboBox * combo, - std::vector const & strings); - void onSpacingComboChanged(); - Gtk::TreeModelColumn stringcol_; - Gtk::TreeModel::ColumnRecord cols_; - Gtk::ComboBox * spacingcombo_; Gtk::SpinButton * valuespin_; - Gtk::ComboBox * valueunitscombo_; + Gtk::ComboBoxText valueunitscombo_; Gtk::CheckButton * protectcheck_; }; diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index 8a088141f8..ba192dacbc 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -33,6 +33,8 @@ libgtk_la_SOURCES = \ GChanges.h \ GCharacter.C \ GCharacter.h \ + GDocument.C \ + GDocument.h \ GErrorList.C \ GErrorList.h \ GERT.C \ @@ -130,7 +132,6 @@ xforms_objects = \ ../xforms/FormCitation.lo \ ../xforms/FormColorpicker.lo \ ../xforms/FormDialogView.lo \ - ../xforms/FormDocument.lo \ ../xforms/FormExternal.lo \ ../xforms/FormMathsBitmap.lo \ ../xforms/FormMathsDelim.lo \ diff --git a/src/frontends/gtk/ghelpers.C b/src/frontends/gtk/ghelpers.C index 72e5bac497..d86f38a011 100644 --- a/src/frontends/gtk/ghelpers.C +++ b/src/frontends/gtk/ghelpers.C @@ -28,20 +28,64 @@ #include "support/filetools.h" #include "support/package.h" +#include + using std::string; using std::vector; namespace lyx { namespace frontend { +string const getLengthFromWidgets(Gtk::Adjustment const & adj, Gtk::ComboBoxText const & combo) +{ + std::ostringstream os; + os << adj.get_value(); + os << combo.get_active_text(); + return os.str(); +} + + +void setWidgetsFromLength(Gtk::Adjustment & adj, Gtk::ComboBoxText & combo, LyXLength const & length) +{ + adj.set_value(length.value()); + + string unit = stringFromUnit(length.unit()); + if (unit.empty()) + unit = getDefaultUnit(); + + comboBoxTextSet(combo,unit); +} + + +void populateUnitCombo(Gtk::ComboBoxText & combo, bool const userelative) +{ + vector units = buildLengthUnitList(userelative); + + vector::const_iterator it = units.begin(); + vector::const_iterator end = units.end(); + for(; it != end; ++it) + combo.append_text(*it); +} + + +int comboBoxTextSet(Gtk::ComboBoxText & combo, Glib::ustring target) +{ + int const children = combo.get_model()->children().size(); + for (int i = 0; i < children; i++) { + combo.set_active(i); + if (combo.get_active_text() == target) + return 0; + } + return -1; +} + + Gtk::BuiltinStockID getGTKStockIcon(FuncRequest const & func) { switch (func.action) { - case LFUN_MENUWRITE: return Gtk::Stock::SAVE; case LFUN_MENUNEW: return Gtk::Stock::NEW; case LFUN_WRITEAS: return Gtk::Stock::SAVE_AS; - case LFUN_CENTER: return Gtk::Stock::JUSTIFY_CENTER; case LFUN_TOCVIEW: return Gtk::Stock::INDEX; case LFUN_CLOSEBUFFER: return Gtk::Stock::CLOSE; @@ -93,7 +137,7 @@ string const getDefaultUnit() void unitsComboFromLength(Gtk::ComboBox * combo, Gtk::TreeModelColumn const & stringcol, LyXLength const & len, - std::string defunit) + std::string const & defunit) { string unit = stringFromUnit(len.unit()); if (unit.empty()) @@ -115,23 +159,19 @@ void unitsComboFromLength(Gtk::ComboBox * combo, } -vector const buildLengthUnitList() -{ - vector data(unit_name_gui, unit_name_gui + num_units); - - return data; -} - - -vector const buildLengthNoRelUnitList() +vector const buildLengthUnitList(bool const userelative) { + //vector data(unit_name_gui, unit_name_gui + num_units); vector data; - for (int i = 0; i < num_units; ++i) { - string str(unit_name_gui[i]); - if (str.find("%") == string::npos) - data.push_back(unit_name_gui[i]); + if (userelative) { + data = vector(unit_name_gui, unit_name_gui + num_units); + } else { + for (int i = 0; i < num_units; ++i) { + string str(unit_name_gui[i]); + if (str.find("%") == string::npos) + data.push_back(unit_name_gui[i]); + } } - return data; } diff --git a/src/frontends/gtk/ghelpers.h b/src/frontends/gtk/ghelpers.h index 3700e13209..5372232d80 100644 --- a/src/frontends/gtk/ghelpers.h +++ b/src/frontends/gtk/ghelpers.h @@ -24,20 +24,32 @@ class FuncRequest; namespace lyx { namespace frontend { +std::string const getLengthFromWidgets( + Gtk::Adjustment const & adj, + Gtk::ComboBoxText const & combo); + +void setWidgetsFromLength( + Gtk::Adjustment & adj, + Gtk::ComboBoxText & combo, + LyXLength const & length); + +int comboBoxTextSet(Gtk::ComboBoxText & combo, Glib::ustring target); + +void populateUnitCombo(Gtk::ComboBoxText & combo, bool userelative); + // Get a GTK stockID from a lyx function id. // Return Gtk::Stock::MISSING_IMAGE if no suitable stock found Gtk::BuiltinStockID getGTKStockIcon(FuncRequest const & func); std::string const getDefaultUnit(); -void unitsComboFromLength(Gtk::ComboBox * combo, - Gtk::TreeModelColumn const & stringcol, - LyXLength const & len, - std::string defunit); - -std::vector const buildLengthUnitList(); +void unitsComboFromLength( + Gtk::ComboBox * combo, + Gtk::TreeModelColumn const & stringcol, + LyXLength const & len, + std::string const & defunit); -std::vector const buildLengthNoRelUnitList(); +std::vector const buildLengthUnitList(bool userelative); /** name is the name of the glade file, without path or extension. * Eg, "aboutlyx", "tableCreate". diff --git a/src/frontends/gtk/glade/Makefile.am b/src/frontends/gtk/glade/Makefile.am index 02c60fd79f..e9cb7262ef 100644 --- a/src/frontends/gtk/glade/Makefile.am +++ b/src/frontends/gtk/glade/Makefile.am @@ -8,6 +8,7 @@ dist_glade_DATA = \ box.glade \ changes.glade \ character.glade \ + document.glade errors.glade \ ERT.glade \ float.glade \ diff --git a/src/frontends/gtk/glade/document.glade b/src/frontends/gtk/glade/document.glade new file mode 100644 index 0000000000..341fa58335 --- /dev/null +++ b/src/frontends/gtk/glade/document.glade @@ -0,0 +1,2225 @@ + + + + + + + Document Settings + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-revert-to-saved + True + GTK_RELIEF_NORMAL + True + 0 + + + + + + True + True + True + gtk-apply + True + GTK_RELIEF_NORMAL + True + -10 + + + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + GTK_BUTTONBOX_DEFAULT_STYLE + 9 + + + 0 + False + True + GTK_PACK_END + + + + + + True + False + 0 + + + + True + True + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-save + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Save as Document Defaults + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 4 + False + False + GTK_PACK_END + + + + + + True + True + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-clear + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Use C_lass Defaults + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + GTK_PACK_END + + + + + 0 + True + True + GTK_PACK_END + + + + + + 6 + True + True + True + True + GTK_POS_TOP + True + False + + + + True + False + 0 + + + + 12 + True + 12 + 3 + False + 4 + 12 + + + + True + _Postscript driver: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PostscriptDriver + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + False + 0 + + + + + + + 2 + 3 + 1 + 2 + fill + + + + + + True + True + True + True + 0 + + True + * + False + + + 2 + 3 + 2 + 3 + + + + + + + True + _Font: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + Font + + + 1 + 2 + 6 + 7 + fill + + + + + + + True + False + 0 + + + + + + + 2 + 3 + 6 + 7 + fill + fill + + + + + + True + False + 0 + + + + + + + 2 + 3 + 7 + 8 + fill + fill + + + + + + True + Li_ne spacing: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + LineSpacing + + + 1 + 2 + 10 + 11 + fill + + + + + + + True + True + 1 + 2 + False + GTK_UPDATE_ALWAYS + False + False + 1.5 0.01 100 0.5 10 10 + + + 2 + 3 + 10 + 11 + + + + + + + True + False + 0 + + + + True + True + Indentation + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + Vertical space + True + GTK_RELIEF_NORMAL + True + False + False + True + Indentation + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 6 + 0 + 12 + 0 + + + + True + False + 6 + + + + True + False + 12 + + + + True + False + 0 + + + + + + + 0 + True + True + + + + + + True + True + 1 + 2 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 65536 0.01 10 10 + + + 0 + True + True + + + + + + True + False + 0 + + + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + 0 + True + True + + + + + 2 + 3 + 11 + 12 + fill + fill + + + + + + True + Separation: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0 + 0 + 0 + + + 1 + 2 + 11 + 12 + fill + fill + + + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 0 + 0 + + + + True + E_xtra options: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + ExtraOptions + + + + + 1 + 2 + 2 + 3 + fill + fill + + + + + + True + <b>Paragraphs</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 3 + 9 + 10 + fill + + + + + + + True + <b>Text</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 3 + 5 + 6 + fill + + + + + + + True + <b>Document</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 3 + 0 + 1 + fill + + + + + + + True + Doc_ument class: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + DocumentClass + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + Font s_ize: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + FontSize + + + 1 + 2 + 7 + 8 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 8 + 9 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + False + 0 + + + + + + + 2 + 3 + 3 + 4 + fill + fill + + + + + 0 + True + True + + + + + False + True + + + + + + True + _Document + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 12 + True + False + 0 + + + + True + <b>Dimensions</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 6 + 12 + 12 + 0 + + + + True + 3 + 3 + False + 6 + 12 + + + + True + S_ize: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Wid_th: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + spinbutton1 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + _Height: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + spinbutton2 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + + + 1 + 3 + 0 + 1 + fill + + + + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 1 0 65536 1 10 10 + + + 1 + 2 + 1 + 2 + + + + + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 1 0 65536 1 10 10 + + + 1 + 2 + 2 + 3 + + + + + + + True + + + 2 + 3 + 2 + 3 + fill + fill + + + + + + True + + + 2 + 3 + 1 + 2 + fill + fill + + + + + + + 0 + True + True + + + + + + True + <b>Orientation</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 6 + 12 + 12 + 0 + + + + True + False + 0 + + + + True + True + Po_rtrait + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + _Landscape + True + GTK_RELIEF_NORMAL + True + False + False + True + radiobutton1 + + + 0 + False + False + + + + + + + 0 + True + True + + + + + + True + <b>Layout</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 6 + 0 + 12 + 0 + + + + True + False + 6 + + + + True + False + 12 + + + + True + Page st_yle: + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PageStyle + + + 0 + False + False + + + + + + True + Default +Empty +Plain +Headings +Fancy + + + 0 + True + True + + + + + 0 + False + False + + + + + + True + True + Do_uble-sided + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + T_wo columns + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + + 0 + True + True + + + + + False + True + + + + + + True + _Page + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 12 + True + False + 12 + + + + True + True + Us_e Default Margins + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + 7 + 3 + False + 6 + 12 + + + + True + _Top: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + MarginTop + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + _Bottom: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + spinbutton10 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + _Inner: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + spinbutton11 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + O_uter: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + spinbutton12 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + Head _sep + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + spinbutton13 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + Head _height: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + spinbutton14 + + + 0 + 1 + 5 + 6 + fill + + + + + + + True + _Foot skip: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + spinbutton15 + + + 0 + 1 + 6 + 7 + fill + + + + + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 666 0 65536 0.01 10 10 + + + 1 + 2 + 0 + 1 + + + + + + + True + + + 2 + 3 + 0 + 1 + fill + + + + + + True + + + 2 + 3 + 1 + 2 + fill + fill + + + + + + True + + + 2 + 3 + 2 + 3 + fill + fill + + + + + + True + + + 2 + 3 + 3 + 4 + fill + fill + + + + + + True + + + 2 + 3 + 4 + 5 + fill + fill + + + + + + True + + + 2 + 3 + 5 + 6 + fill + fill + + + + + + True + + + 2 + 3 + 6 + 7 + fill + fill + + + + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 666 0 65536 0.01 10 10 + + + 1 + 2 + 1 + 2 + + + + + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 666 0 65536 0.01 10 10 + + + 1 + 2 + 2 + 3 + + + + + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 666 0 65536 0.01 10 10 + + + 1 + 2 + 3 + 4 + + + + + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 666 0 65536 0.01 10 10 + + + 1 + 2 + 4 + 5 + + + + + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 666 0 65536 0.01 10 10 + + + 1 + 2 + 5 + 6 + + + + + + + True + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 666 0 65536 0.01 10 10 + + + 1 + 2 + 6 + 7 + + + + + + + + 0 + True + True + + + + + False + True + + + + + + True + _Margins + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + True + 8 + 3 + False + 6 + 12 + + + + True + <b>Item</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + <b>Numbered</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + <b>Show in TOC</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + C_hapter + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + checkbutton1 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + C_hapter + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + C_hapter + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + C_hapter + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + C_hapter + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 5 + 6 + fill + + + + + + + True + C_hapter + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 6 + 7 + fill + + + + + + + True + C_hapter + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 7 + 8 + fill + + + + + + + True + True + Numbered + True + GTK_RELIEF_NORMAL + True + False + False + False + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + True + Show in TOC + True + GTK_RELIEF_NORMAL + True + False + False + False + + + 2 + 3 + 1 + 2 + fill + + + + + + False + True + + + + + + True + Language + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + + diff --git a/src/frontends/gtk/glade/graphics.glade b/src/frontends/gtk/glade/graphics.glade index 679cea91a4..2ef1b3f616 100644 --- a/src/frontends/gtk/glade/graphics.glade +++ b/src/frontends/gtk/glade/graphics.glade @@ -113,28 +113,28 @@ - + True True True - gtk-ok + gtk-cancel True GTK_RELIEF_NORMAL True - -5 + -6 - + True True True - gtk-close + gtk-ok True GTK_RELIEF_NORMAL True - -7 + -5 @@ -773,36 +773,6 @@ Do not display - - - True - False - - - 3 - 4 - 2 - 3 - fill - fill - - - - - - True - False - - - 3 - 4 - 3 - 4 - fill - fill - - - True @@ -884,6 +854,46 @@ Do not display + + + + True + False + 0 + + + + + + + 3 + 4 + 2 + 3 + fill + fill + + + + + + True + False + 0 + + + + + + + 3 + 4 + 3 + 4 + fill + fill + + diff --git a/src/frontends/gtk/glade/vspace.glade b/src/frontends/gtk/glade/vspace.glade index e2bb818b03..b40bea2fe6 100644 --- a/src/frontends/gtk/glade/vspace.glade +++ b/src/frontends/gtk/glade/vspace.glade @@ -43,73 +43,15 @@ - + True True True + gtk-ok + True GTK_RELIEF_NORMAL True -5 - - - - True - 0.5 - 0.5 - 0 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-ok - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - _Insert - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - @@ -224,8 +166,14 @@ Custom - + True + False + 0 + + + + 4 -- 2.39.2