--- /dev/null
+/**
+ * \file GVSpace.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 <config.h>
+
+#include "GVSpace.h"
+#include "ControlVSpace.h"
+#include "ghelpers.h"
+
+#include <libglademm.h>
+
+using std::string;
+using std::vector;
+
+namespace lyx {
+namespace frontend {
+
+namespace {
+string defaultUnit("cm");
+} // namespace anon
+
+GVSpace::GVSpace(Dialog & parent)
+ : GViewCB<ControlVSpace, GViewGladeB>(parent, _("VSpace Settings"), false)
+{}
+
+
+void GVSpace::doBuild()
+{
+ string const gladeName = findGladeFile("vspace");
+ xml_ = Gnome::Glade::Xml::create(gladeName);
+
+ Gtk::Button * button;
+ xml_->get_widget("Cancel", button);
+ setCancel(button);
+ xml_->get_widget("Insert", button);
+ setOK(button);
+
+ xml_->get_widget("Spacing", spacingcombo_);
+ xml_->get_widget("Value", valuespin_);
+ xml_->get_widget("ValueUnits", valueunitscombo_);
+ xml_->get_widget("Protect", protectcheck_);
+
+ cols_.add(stringcol_);
+
+ PopulateComboBox(valueunitscombo_, buildLengthNoRelUnitList());
+
+ spacingcombo_->signal_changed().connect(
+ sigc::mem_fun(*this, &GVSpace::onSpacingComboChanged));
+}
+
+
+void GVSpace::PopulateComboBox(Gtk::ComboBox * combo,
+ vector<string> const & strings)
+{
+ Glib::RefPtr<Gtk::ListStore> model = Gtk::ListStore::create(cols_);
+ vector<string>::const_iterator it = strings.begin();
+ vector<string>::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;
+ switch (space.kind()) {
+ case VSpace::DEFSKIP:
+ pos = 0;
+ break;
+ case VSpace::SMALLSKIP:
+ pos = 1;
+ break;
+ case VSpace::MEDSKIP:
+ pos = 2;
+ break;
+ case VSpace::BIGSKIP:
+ pos = 3;
+ break;
+ case VSpace::VFILL:
+ pos = 4;
+ break;
+ case VSpace::LENGTH:
+ pos = 5;
+ break;
+ }
+
+ spacingcombo_->set_active(pos);
+
+ protectcheck_->set_active(space.keep());
+
+ 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);
+ } else {
+ valuespin_->get_adjustment()->set_value(0.0f);
+ unitsComboFromLength(valueunitscombo_, stringcol_,
+ LyXLength(defaultUnit), defaultUnit);
+ }
+}
+
+
+void GVSpace::apply()
+{
+ VSpace space;
+ switch (spacingcombo_->get_active_row_number()) {
+ case 0:
+ space = VSpace(VSpace::DEFSKIP);
+ break;
+ case 1:
+ space = VSpace(VSpace::SMALLSKIP);
+ break;
+ case 2:
+ space = VSpace(VSpace::MEDSKIP);
+ break;
+ case 3:
+ space = VSpace(VSpace::BIGSKIP);
+ break;
+ case 4:
+ space = VSpace(VSpace::VFILL);
+ break;
+ case 5:
+ Glib::ustring const valueunit =
+ (*valueunitscombo_->get_active())[stringcol_];
+ space = VSpace(LyXGlueLength(valuespin_->get_text() + valueunit));
+ break;
+ }
+
+ space.setKeep(protectcheck_->get_active());
+
+ controller().params() = space;
+}
+
+
+void GVSpace::onSpacingComboChanged()
+{
+ bool const custom = spacingcombo_->get_active_row_number() == 5;
+ valueunitscombo_->set_sensitive(custom);
+ valuespin_->set_sensitive(custom);
+}
+
+} // namespace frontend
+} // namespace lyx
--- /dev/null
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+
+<widget class="GtkDialog" id="dialog">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">dialog1</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">False</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="has_separator">False</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="Cancel">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="Insert">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-5</property>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="stock">gtk-ok</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Insert</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkTable" id="table1">
+ <property name="border_width">12</property>
+ <property name="visible">True</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Spacing:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Value:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="Spacing">
+ <property name="visible">True</property>
+ <property name="items" translatable="yes">DefSkip
+SmallSkip
+MedSkip
+BigSkip
+VFill
+Custom</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkSpinButton" id="Value">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="climb_rate">1</property>
+ <property name="digits">0</property>
+ <property name="numeric">False</property>
+ <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+ <property name="snap_to_ticks">False</property>
+ <property name="wrap">False</property>
+ <property name="adjustment">1 0 10000 1 10 10</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="ValueUnits">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="padding">4</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="Protect">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Protect</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>