Regarding the spacingadj_ pointer, it turned out that it was not necessary to create one anyway, one came with the spinbutton.
Requested changes to spacing etc have been made. Patch to Makefile.am, Dialogs.C from previous message still applies. Attached is also an addition to GViewBase: update() every time the dialog is shown. This is necessary for dialogs such as the paragraph settings (where the deficiency had not been apparent for dialogs such as find/replace and print). Revised glade file makes dialog modal. This would not be necessary if I could get a signal each time the cursor in the workarea changes position (to load the present paragraph's settings into the dialog), but that would be more work than it's worth right now. John
Index: GViewBase.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/gtk/GViewBase.C,v retrieving revision 1.9 diff -u -3 -p -r1.9 GViewBase.C --- GViewBase.C 2004/09/26 18:36:07 1.9 +++ GViewBase.C 2004/09/29 19:25:10 @@ -53,6 +53,7 @@ void GViewBase::show() if (!window()) { build(); } + update(); window()->show(); }
/** * \file GParagraph.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 "GParagraph.h" #include "ghelpers.h" #include "ControlParagraph.h" #include "controllers/helper_funcs.h" #include "ParagraphParameters.h" #include "Spacing.h" #include "support/lstrings.h" #include "support/tostr.h" using std::string; namespace lyx { namespace frontend { namespace { } // namespace anon GParagraph::GParagraph(Dialog & parent) : GViewCB<ControlParagraph, GViewGladeB>(parent, _("Paragraph Settings"), false) {} void GParagraph::doBuild() { string const gladeName = findGladeFile("paragraph"); xml_ = Gnome::Glade::Xml::create(gladeName); xml_->get_widget("LineSpacing", spacingspin_); xml_->get_widget("DefaultLineSpacing", defaultspacingcheck_); xml_->get_widget("MaxLabelWidth", maxlabelwidthentry_); xml_->get_widget("Indent", indentcheck_); xml_->get_widget("AlignBlock", blockradio_); xml_->get_widget("AlignLeft", leftradio_); xml_->get_widget("AlignRight", rightradio_); xml_->get_widget("AlignCenter", centerradio_); // Manage the Close button Gtk::Button * button; xml_->get_widget("Close", button); setCancel(button); // Make the main hbox sensitive to readonly Gtk::HBox * controlbox; xml_->get_widget("ControlBox", controlbox); bcview().addReadOnly(controlbox); spacingadj_ = spacingspin_->get_adjustment(); defaultspacingcheck_->signal_toggled().connect( sigc::mem_fun(*this, &GParagraph::onDefaultSpacingToggled)); indentcheck_->signal_toggled().connect( sigc::mem_fun(*this, &GParagraph::onIndentToggled)); spacingadj_->signal_value_changed().connect( sigc::mem_fun(*this, &GParagraph::onSpacingChanged)); maxlabelwidthentry_->signal_changed().connect( sigc::mem_fun(*this, &GParagraph::onMaxLabelWidthChanged)); blockradio_->signal_toggled().connect( sigc::mem_fun(*this, &GParagraph::onAlignToggled)); leftradio_->signal_toggled().connect( sigc::mem_fun(*this, &GParagraph::onAlignToggled)); rightradio_->signal_toggled().connect( sigc::mem_fun(*this, &GParagraph::onAlignToggled)); centerradio_->signal_toggled().connect( sigc::mem_fun(*this, &GParagraph::onAlignToggled)); } void GParagraph::update() { // label width string const labelwidth = controller().params().labelWidthString(); maxlabelwidthentry_->set_text(labelwidth); maxlabelwidthentry_->set_sensitive( labelwidth != _("Senseless with this layout!")); // alignment LyXAlignment const current_alignment = controller().params().align(); switch (current_alignment) { case LYX_ALIGN_BLOCK: blockradio_->set_active(true); break; case LYX_ALIGN_LEFT: leftradio_->set_active(true); break; case LYX_ALIGN_RIGHT: rightradio_->set_active(true); break; case LYX_ALIGN_CENTER: centerradio_->set_active(true); break; default: // LYX_ALIGN_SPECIAL or so? Don't ask, don't tell. centerradio_->set_active(false); blockradio_->set_active(false); rightradio_->set_active(false); leftradio_->set_active(false); } //Find out which alignments options are available LyXAlignment alignpos = controller().alignPossible(); blockradio_->set_sensitive(bool(alignpos & LYX_ALIGN_BLOCK)); centerradio_->set_sensitive(bool(alignpos & LYX_ALIGN_CENTER)); leftradio_->set_sensitive(bool(alignpos & LYX_ALIGN_LEFT)); rightradio_->set_sensitive(bool(alignpos & LYX_ALIGN_RIGHT)); // We give the user a checkbox with an affirmative description, so // invert the setting indentcheck_->set_active(!controller().params().noindent()); // linespacing Spacing const space = controller().params().spacing(); // This emits the toggled signal, setting up sensitivities defaultspacingcheck_->set_active( space.getSpace() == Spacing::Default); spacingadj_->set_value(space.getValue()); } void GParagraph::onDefaultSpacingToggled() { if (defaultspacingcheck_->get_active()) { spacingspin_->set_sensitive(false); Spacing const spacing(Spacing::Default, spacingadj_->get_value()); controller().params().spacing(spacing); } else { spacingspin_->set_sensitive(true); Spacing const spacing(Spacing::Other, spacingadj_->get_value()); controller().params().spacing(spacing); } controller().dispatchParams(); } void GParagraph::onIndentToggled() { controller().params().noindent(!indentcheck_->get_active()); controller().dispatchParams(); } void GParagraph::onSpacingChanged() { Spacing const spacing(Spacing::Other, spacingadj_->get_value()); controller().params().spacing(spacing); controller().dispatchParams(); } void GParagraph::onMaxLabelWidthChanged() { controller().params().labelWidthString( maxlabelwidthentry_->get_text()); controller().dispatchParams(); } void GParagraph::onAlignToggled() { if (blockradio_->get_active()) controller().params().align(LYX_ALIGN_BLOCK); else if (leftradio_->get_active()) controller().params().align(LYX_ALIGN_LEFT); else if (rightradio_->get_active()) controller().params().align(LYX_ALIGN_RIGHT); else if (centerradio_->get_active()) controller().params().align(LYX_ALIGN_CENTER); controller().dispatchParams(); } } // namespace frontend } // namespace lyx
// -*- C++ -*- /** * \file GParagraph.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 GPARAGRAPH_H #define GPARAGRAPH_H #include "GViewBase.h" #include <gtkmm.h> namespace lyx { namespace frontend { class ControlParagraph; /** This class provides a gtk implementation of the paragraph dialog. */ class GParagraph : public GViewCB<ControlParagraph, GViewGladeB> { public: GParagraph(Dialog &); private: /// Build the dialog virtual void doBuild(); /// Apply from dialog virtual void apply() {} /// Update the dialog virtual void update(); Gtk::SpinButton * spacingspin_; Gtk::Entry * maxlabelwidthentry_; Gtk::CheckButton * indentcheck_; Gtk::CheckButton * defaultspacingcheck_; Gtk::RadioButton * blockradio_; Gtk::RadioButton * leftradio_; Gtk::RadioButton * rightradio_; Gtk::RadioButton * centerradio_; Gtk::Adjustment * spacingadj_; void onDefaultSpacingToggled(); void onMaxLabelWidthChanged(); void onSpacingChanged(); void onIndentToggled(); void onAlignToggled(); }; } // namespace frontend } // namespace lyx #endif
paragraph.glade
Description: application/glade