frontend, so I've removed the LyXGnomified and menubar code. The
menubar wasn't working properly anyway.
+2002-01-12 Michael A. Koziarski <michael@koziarski.com>
+
+ * 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 <michael@koziarski.com>
+
+ * 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 <martin.vermeer@hut.fi>
* Menubar_pimpl.C (composeUIInfo):
#include <gtk--/text.h>
FormError::FormError(ControlError & c)
- : FormCB<ControlError>(c, "diaerror.glade", "DiaError")
+ : FormCB<ControlError>(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();
textarea()->insert(controller().params());
}
-
-Gtk::Button * FormError::close_btn() const
+Gtk::Button * FormError::button_close() const
{
- return getWidget<Gtk::Button>("button_close");
+ return getWidget<Gtk::Button>("r_button_close");
}
-
-Gtk::Text * FormError::textarea() const
+Gtk::Text * FormError::textarea() const
{
- return getWidget<Gtk::Text>("textarea");
+ return getWidget<Gtk::Text>("r_textarea");
}
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
#include <gtk--/button.h>
FormTabularCreate::FormTabularCreate(ControlTabularCreate & c)
- : FormCB<ControlTabularCreate>(c, "diainserttabular.glade",
- "DiaInsertTabular")
+ : FormCB<ControlTabularCreate>(c, "FormTabularCreate")
{}
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<Gtk::SpinButton>("tabular_spin_rows");
+ return getWidget<Gtk::Button>("r_ok_btn");
}
-
-
-Gtk::SpinButton * FormTabularCreate::columns_spin() const
+Gtk::Button * FormTabularCreate::apply_btn() const
{
- return getWidget<Gtk::SpinButton>("tabular_spin_columns");
+ return getWidget<Gtk::Button>("r_apply_btn");
}
-
-
-Gtk::Button * FormTabularCreate::ok_btn() const
+Gtk::Button * FormTabularCreate::cancel_btn() const
{
- return getWidget<Gtk::Button>("button_ok");
+ return getWidget<Gtk::Button>("r_cancel_btn");
}
-
-
-Gtk::Button * FormTabularCreate::cancel_btn() const
+Gtk::SpinButton * FormTabularCreate::rows() const
{
- return getWidget<Gtk::Button>("button_cancel");
+ return getWidget<Gtk::SpinButton>("r_rows");
}
-
-
-Gtk::Button * FormTabularCreate::apply_btn() const
+Gtk::SpinButton * FormTabularCreate::cols() const
{
- return getWidget<Gtk::Button>("button_apply");
+ return getWidget<Gtk::SpinButton>("r_cols");
}
+
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
#include <gtk--/checkbutton.h>
FormUrl::FormUrl(ControlUrl & c)
- : FormCB<ControlUrl>(c, "diainserturl.glade", "DiaInsertUrl")
+ : FormCB<ControlUrl>(c, "FormUrl")
{}
bc().refresh();
// Manage the read-only aware widgets.
- bc().addReadOnly(html());
+ bc().addReadOnly(html_cb());
bc().addReadOnly(name());
bc().addReadOnly(url());
}
// 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));
}
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();
}
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();
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<Gtk::Entry>("url");
+ return getWidget<Gtk::Button>("r_restore_btn");
}
-
-Gtk::Entry * FormUrl::name() const
+Gtk::Button * FormUrl::ok_btn() const
{
- return getWidget<Gtk::Entry>("name");
+ return getWidget<Gtk::Button>("r_ok_btn");
}
-
-Gtk::CheckButton * FormUrl::html() const
+Gtk::Button * FormUrl::apply_btn() const
{
- return getWidget<Gtk::CheckButton>("html_type");
+ return getWidget<Gtk::Button>("r_apply_btn");
}
-
-
-Gtk::Button * FormUrl::ok_btn() const
+Gtk::Button * FormUrl::cancel_btn() const
{
- return getWidget<Gtk::Button>("button_ok");
+ return getWidget<Gtk::Button>("r_cancel_btn");
}
-
-
-Gtk::Button * FormUrl::cancel_btn() const
+Gtk::Entry * FormUrl::url() const
{
- return getWidget<Gtk::Button>("button_cancel");
+ return getWidget<Gtk::Entry>("r_url");
}
-
-
-Gtk::Button * FormUrl::apply_btn() const
+Gtk::Entry * FormUrl::name() const
{
- return getWidget<Gtk::Button>("button_apply");
+ return getWidget<Gtk::Entry>("r_name");
}
-
-
-Gtk::Button * FormUrl::restore_btn() const
+Gtk::CheckButton * FormUrl::html_cb() const
{
- return getWidget<Gtk::Button>("button_restore");
+ return getWidget<Gtk::CheckButton>("r_html_cb");
}
+
+
/// 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_;
#include <gnome--/dialog.h>
GnomeBase::GnomeBase(ControlButtons & c,
- string const & glade_file, string const & name)
+ string const & name)
: ViewBC<gnomeBC>(c)
- , file_(glade_file), widget_name_(name), xml_(0)
+ , file_(name + ".glade"), widget_name_(name), xml_(0)
, dialog_(0)
{}
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()
{
class GnomeBase : public ViewBC<gnomeBC>, public SigC::Object {
public:
///
- GnomeBase(ControlButtons & c, string const & glade_file, string const & name);
+ GnomeBase(ControlButtons & c, string const & name);
///
virtual ~GnomeBase();
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.
template <class Controller>
class FormCB : public GnomeBase {
public:
- FormCB(Controller & c, string const & file, string const & name);
+ FormCB(Controller & c, string const & name);
protected:
Controller & controller();
};
template <class Controller>
-FormCB<Controller>::FormCB(Controller & c, string const & file, string const & name)
- : GnomeBase(c, file, name)
+FormCB<Controller>::FormCB(Controller & c, string const & name)
+ : GnomeBase(c, name)
{}
template <class Controller>