From: Angus Leeming Date: Wed, 16 Jan 2002 12:30:17 +0000 (+0000) Subject: Michael's latest gnome changes. X-Git-Tag: 1.6.10~20007 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=3f0903efb052c8509df4a49e860d16eb8d6a5cc8;p=features.git Michael's latest gnome changes. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3386 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/gnome/ChangeLog b/src/frontends/gnome/ChangeLog index e04b9a8599..f35c1ecbb9 100644 --- a/src/frontends/gnome/ChangeLog +++ b/src/frontends/gnome/ChangeLog @@ -7,6 +7,36 @@ frontend, so I've removed the LyXGnomified and menubar code. The menubar wasn't working properly anyway. +2002-01-12 Michael A. Koziarski + + * various: Cleaned out the old stuff, standardised the new + stuff. + * GnomeBase.C + * GnomeBase.h: Changed the constructor to take one argument. The + dialog name. The path and name of the glade files can be + calculated from there. These two now provide default validate() & + *Clicked functions. + * FormUrl.C + * FormUrl.h + * FormError.C + * FormError.h + * FormTabularCreate.C + * FormTabularCreate.h: updated them to use the new system. + Removed Local inline *Clicked functions as they're now in the base + class. + * README: new, brief outline of what I'm doing here. + * accessors.py: Described in README, generates the accessor + functions from the glade file. + +2002-01-12 Michael A. Koziarski + + * Menubar_pimpl.C + * Menubar_pimpl.h + * mainapp.h + * mainapp.C: Removed, We should behave similarly to the qt2 + frontend, so I've removed the LyXGnomified and menubar code. The + menubar wasn't working properly anyway. + 2002-01-08 Martin Vermeer * Menubar_pimpl.C (composeUIInfo): diff --git a/src/frontends/gnome/FormError.C b/src/frontends/gnome/FormError.C index d95ec3cc65..729fc05a49 100644 --- a/src/frontends/gnome/FormError.C +++ b/src/frontends/gnome/FormError.C @@ -22,17 +22,17 @@ #include FormError::FormError(ControlError & c) - : FormCB(c, "diaerror.glade", "DiaError") + : FormCB(c, "FormError") {} void FormError::build() { // Connect the buttons. - close_btn()->clicked.connect(SigC::slot(this, &FormError::CloseClicked)); + button_close()->clicked.connect(SigC::slot(this, &FormError::CloseClicked)); // Manage the buttons state - bc().setCancel(close_btn()); + bc().setCancel(button_close()); // Make sure everything is in the correct state. bc().refresh(); @@ -44,14 +44,12 @@ void FormError::update() textarea()->insert(controller().params()); } - -Gtk::Button * FormError::close_btn() const +Gtk::Button * FormError::button_close() const { - return getWidget("button_close"); + return getWidget("r_button_close"); } - -Gtk::Text * FormError::textarea() const +Gtk::Text * FormError::textarea() const { - return getWidget("textarea"); + return getWidget("r_textarea"); } diff --git a/src/frontends/gnome/FormError.h b/src/frontends/gnome/FormError.h index e8a57302d3..0b193e1a00 100644 --- a/src/frontends/gnome/FormError.h +++ b/src/frontends/gnome/FormError.h @@ -49,9 +49,12 @@ private: void CloseClicked() { CancelButton(); } - /// The close button - Gtk::Button * close_btn() const; + + /// generated by accessors.py + Gtk::Button * button_close() const; + /// generated by accessors.py Gtk::Text * textarea() const; + }; #endif diff --git a/src/frontends/gnome/FormTabularCreate.C b/src/frontends/gnome/FormTabularCreate.C index 84e93252c1..e2b74b6696 100644 --- a/src/frontends/gnome/FormTabularCreate.C +++ b/src/frontends/gnome/FormTabularCreate.C @@ -23,8 +23,7 @@ #include FormTabularCreate::FormTabularCreate(ControlTabularCreate & c) - : FormCB(c, "diainserttabular.glade", - "DiaInsertTabular") + : FormCB(c, "FormTabularCreate") {} @@ -59,50 +58,42 @@ void FormTabularCreate::build() void FormTabularCreate::apply() { - unsigned int ysize = (unsigned int)(rows_spin()->get_value_as_int()); - unsigned int xsize = (unsigned int)(columns_spin()->get_value_as_int()); + unsigned int ysize = (unsigned int)(rows()->get_value_as_int()); + unsigned int xsize = (unsigned int)(cols()->get_value_as_int()); controller().params() = std::make_pair(xsize, ysize); } void FormTabularCreate::update() -{ -} +{} bool FormTabularCreate::validate() const { - // Always valid! (not really so, needs fixing). - return true; + return ( rows()->get_value_as_int() > 0 ) && + ( cols()->get_value_as_int() > 0 ); } -Gtk::SpinButton * FormTabularCreate::rows_spin() const +Gtk::Button * FormTabularCreate::ok_btn() const { - return getWidget("tabular_spin_rows"); + return getWidget("r_ok_btn"); } - - -Gtk::SpinButton * FormTabularCreate::columns_spin() const +Gtk::Button * FormTabularCreate::apply_btn() const { - return getWidget("tabular_spin_columns"); + return getWidget("r_apply_btn"); } - - -Gtk::Button * FormTabularCreate::ok_btn() const +Gtk::Button * FormTabularCreate::cancel_btn() const { - return getWidget("button_ok"); + return getWidget("r_cancel_btn"); } - - -Gtk::Button * FormTabularCreate::cancel_btn() const +Gtk::SpinButton * FormTabularCreate::rows() const { - return getWidget("button_cancel"); + return getWidget("r_rows"); } - - -Gtk::Button * FormTabularCreate::apply_btn() const +Gtk::SpinButton * FormTabularCreate::cols() const { - return getWidget("button_apply"); + return getWidget("r_cols"); } + diff --git a/src/frontends/gnome/FormTabularCreate.h b/src/frontends/gnome/FormTabularCreate.h index 345676c12f..eb2d06c033 100644 --- a/src/frontends/gnome/FormTabularCreate.h +++ b/src/frontends/gnome/FormTabularCreate.h @@ -49,15 +49,17 @@ private: void CancelClicked() { CancelButton(); } void ApplyClicked() { ApplyButton(); } - /// The SpinButtons - Gtk::SpinButton * rows_spin() const; - Gtk::SpinButton * columns_spin() const; - /// The ok button + /// generated by accessors.py Gtk::Button * ok_btn() const; - /// The cancel button - Gtk::Button * cancel_btn() const; - /// The apply button + /// generated by accessors.py Gtk::Button * apply_btn() const; + /// generated by accessors.py + Gtk::Button * cancel_btn() const; + /// generated by accessors.py + Gtk::SpinButton * rows() const; + /// generated by accessors.py + Gtk::SpinButton * cols() const; + }; #endif diff --git a/src/frontends/gnome/FormUrl.C b/src/frontends/gnome/FormUrl.C index 84e00f07a3..a968af512f 100644 --- a/src/frontends/gnome/FormUrl.C +++ b/src/frontends/gnome/FormUrl.C @@ -22,7 +22,7 @@ #include FormUrl::FormUrl(ControlUrl & c) - : FormCB(c, "diainserturl.glade", "DiaInsertUrl") + : FormCB(c, "FormUrl") {} @@ -53,7 +53,7 @@ void FormUrl::build() bc().refresh(); // Manage the read-only aware widgets. - bc().addReadOnly(html()); + bc().addReadOnly(html_cb()); bc().addReadOnly(name()); bc().addReadOnly(url()); } @@ -64,7 +64,7 @@ void FormUrl::connect_signals() // Get notifications on input change slot_url_ = url()->changed.connect(SigC::slot(this, &FormUrl::InputChanged)); slot_name_ = name()->changed.connect(SigC::slot(this, &FormUrl::InputChanged)); - slot_html_ = html()->toggled.connect(SigC::slot(this, &FormUrl::InputChanged)); + slot_html_ = html_cb()->toggled.connect(SigC::slot(this, &FormUrl::InputChanged)); } @@ -78,14 +78,16 @@ void FormUrl::disconnect_signals() void FormUrl::apply() { + disconnect_signals(); controller().params().setContents(url()->get_text()); controller().params().setOptions(name()->get_text()); string cmdname("url"); - if (html()->get_active()) + if (html_cb()->get_active()) cmdname = "htmlurl"; controller().params().setCmdName(cmdname); + connect_signals(); } @@ -99,7 +101,7 @@ void FormUrl::update() url()->set_text(controller().params().getContents()); name()->set_text(controller().params().getOptions()); - html()->set_active("url" != controller().params().getCmdName()); + html_cb()->set_active("url" != controller().params().getCmdName()); // Reconnect the signals. connect_signals(); @@ -108,46 +110,36 @@ void FormUrl::update() bool FormUrl::validate() const { - // Always valid! (not really so, needs fixing). - return true; + return !url()->get_text().empty() && !name()->get_text().empty(); } - -Gtk::Entry * FormUrl::url() const +Gtk::Button * FormUrl::restore_btn() const { - return getWidget("url"); + return getWidget("r_restore_btn"); } - -Gtk::Entry * FormUrl::name() const +Gtk::Button * FormUrl::ok_btn() const { - return getWidget("name"); + return getWidget("r_ok_btn"); } - -Gtk::CheckButton * FormUrl::html() const +Gtk::Button * FormUrl::apply_btn() const { - return getWidget("html_type"); + return getWidget("r_apply_btn"); } - - -Gtk::Button * FormUrl::ok_btn() const +Gtk::Button * FormUrl::cancel_btn() const { - return getWidget("button_ok"); + return getWidget("r_cancel_btn"); } - - -Gtk::Button * FormUrl::cancel_btn() const +Gtk::Entry * FormUrl::url() const { - return getWidget("button_cancel"); + return getWidget("r_url"); } - - -Gtk::Button * FormUrl::apply_btn() const +Gtk::Entry * FormUrl::name() const { - return getWidget("button_apply"); + return getWidget("r_name"); } - - -Gtk::Button * FormUrl::restore_btn() const +Gtk::CheckButton * FormUrl::html_cb() const { - return getWidget("button_restore"); + return getWidget("r_html_cb"); } + + diff --git a/src/frontends/gnome/FormUrl.h b/src/frontends/gnome/FormUrl.h index 0ee41de96f..3d25fc5389 100644 --- a/src/frontends/gnome/FormUrl.h +++ b/src/frontends/gnome/FormUrl.h @@ -52,27 +52,21 @@ private: /// Disconnect the signals. void disconnect_signals(); - void OKClicked() { OKButton(); } - void CancelClicked() { CancelButton(); } - void ApplyClicked() { ApplyButton(); } - void RestoreClicked() { RestoreButton(); } - void InputChanged() { bc().valid(validate()); } - - /// The url entry - Gtk::Entry * url() const; - /// The name entry - Gtk::Entry * name() const; - /// The html type checkbutton - Gtk::CheckButton * html() const; - /// The ok button + /// generated by accessors.py + Gtk::Button * restore_btn() const; + /// gene rated by accessors.py Gtk::Button * ok_btn() const; - /// The cancel button - Gtk::Button * cancel_btn() const; - /// The apply button + /// generated by accessors.py Gtk::Button * apply_btn() const; - /// The restore button - Gtk::Button * restore_btn() const; - + /// generated by accessors.py + Gtk::Button * cancel_btn() const; + /// generated by accessors.py + Gtk::Entry * url() const; + /// generated by accessors.py + Gtk::Entry * name() const; + /// generated by accessors.py + Gtk::CheckButton * html_cb() const; + /// Keeps the connection to the input validator. SigC::Connection slot_url_; SigC::Connection slot_name_; diff --git a/src/frontends/gnome/GnomeBase.C b/src/frontends/gnome/GnomeBase.C index cb56013590..72e80aa385 100644 --- a/src/frontends/gnome/GnomeBase.C +++ b/src/frontends/gnome/GnomeBase.C @@ -21,9 +21,9 @@ #include GnomeBase::GnomeBase(ControlButtons & c, - string const & glade_file, string const & name) + string const & name) : ViewBC(c) - , file_(glade_file), widget_name_(name), xml_(0) + , file_(name + ".glade"), widget_name_(name), xml_(0) , dialog_(0) {} @@ -71,6 +71,35 @@ void GnomeBase::hide() dialog_->hide(); } +bool GnomeBase::validate() +{ + return true; +} + +void GnomeBase::OKClicked() +{ + OKButton(); +} + +void GnomeBase::CancelClicked() +{ + CancelButton(); +} + +void GnomeBase::ApplyClicked() +{ + ApplyButton(); +} + +void GnomeBase::RestoreClicked() +{ + RestoreButton(); +} + +void GnomeBase::InputChanged() +{ + bc().valid(validate()); +} Gnome::Dialog * GnomeBase::dialog() { diff --git a/src/frontends/gnome/GnomeBase.h b/src/frontends/gnome/GnomeBase.h index fe3751474e..2b4f2f0064 100644 --- a/src/frontends/gnome/GnomeBase.h +++ b/src/frontends/gnome/GnomeBase.h @@ -33,7 +33,7 @@ class Dialog; class GnomeBase : public ViewBC, public SigC::Object { public: /// - GnomeBase(ControlButtons & c, string const & glade_file, string const & name); + GnomeBase(ControlButtons & c, string const & name); /// virtual ~GnomeBase(); @@ -49,9 +49,20 @@ protected: void show(); /// Hide the dialog. void hide(); - /// Build the dialog. Also connects signals and prepares it for work. virtual void build() = 0; + /// Dialog is valid + virtual bool validate(); + /// Default OK behaviour + virtual void OKClicked(); + /// Default Cancel behaviour + virtual void CancelClicked(); + /// Default Restore behaviour + virtual void RestoreClicked(); + /// Default apply behaviour + virtual void ApplyClicked(); + /// Default changed input behaviour + virtual void InputChanged(); private: /// Loads the glade file to memory. @@ -93,14 +104,14 @@ T* GnomeBase::getWidget(char const * name) const template class FormCB : public GnomeBase { public: - FormCB(Controller & c, string const & file, string const & name); + FormCB(Controller & c, string const & name); protected: Controller & controller(); }; template -FormCB::FormCB(Controller & c, string const & file, string const & name) - : GnomeBase(c, file, name) +FormCB::FormCB(Controller & c, string const & name) + : GnomeBase(c, name) {} template