From a6adf5d7327b54c3f21d6542fb590e44c556b7a8 Mon Sep 17 00:00:00 2001 From: Baruch Even Date: Fri, 30 Mar 2001 18:49:10 +0000 Subject: [PATCH] Fixes to get it to compile after the latest ButtonController changes. Refactoring of the dialogs into GnomeBase to remove common code. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1862 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gnome/ChangeLog | 11 ++++++++ src/frontends/gnome/FormCredits.C | 44 +---------------------------- src/frontends/gnome/FormCredits.h | 19 ++----------- src/frontends/gnome/FormUrl.C | 26 ----------------- src/frontends/gnome/FormUrl.h | 13 --------- src/frontends/gnome/GnomeBase.C | 37 ++++++++++++++++++++++-- src/frontends/gnome/GnomeBase.h | 30 ++++++++++++++------ src/frontends/gnome/gnomeBC.C | 6 ++-- src/frontends/gnome/gnomeBC.h | 4 +-- src/frontends/gnome/gnome_helpers.h | 2 +- 10 files changed, 78 insertions(+), 114 deletions(-) diff --git a/src/frontends/gnome/ChangeLog b/src/frontends/gnome/ChangeLog index ca4ff4d86c..b69bb20c67 100644 --- a/src/frontends/gnome/ChangeLog +++ b/src/frontends/gnome/ChangeLog @@ -1,3 +1,14 @@ +2001-03-30 Baruch Even + + * GnomeBase.[Ch]: Added the dialog as a responsibility. + + * FormUrl.[Ch]: Changed accordingly. + * FormCredits.[Ch]: ditto. + + * gnomeBC.[Ch]: Fixed to get it to compile. + + * gnome_helpers.h: Changed declaration from const char * to char const * + 2001-03-30 Angus Leeming * GnomeBase.[Ch]: changed ControlBase to ControlButton. diff --git a/src/frontends/gnome/FormCredits.C b/src/frontends/gnome/FormCredits.C index 9f693acc9f..f40f7ae948 100644 --- a/src/frontends/gnome/FormCredits.C +++ b/src/frontends/gnome/FormCredits.C @@ -19,30 +19,19 @@ #include "gnomeBC.h" #include "FormCredits.h" -#include #include #include FormCredits::FormCredits(ControlCredits & c) : FormCB(c, "diahelpcredits.glade", "DiaHelpCredits") - , dialog_(0) { - -} - - -FormCredits::~FormCredits() -{ - //dialog_->destroy(); } void FormCredits::build() { - dialog_ = dialog(); - // It is better to show an OK button, but the policy require that we - // got a click on "Cancel" + // get a click on "Cancel" ok()->clicked.connect(SigC::slot(this, &FormCredits::CancelClicked)); std::stringstream ss; @@ -50,37 +39,6 @@ void FormCredits::build() } -void FormCredits::show() -{ - if (!dialog_) - build(); - - update(); - dialog_->show(); -} - - -void FormCredits::hide() -{ - dialog_->hide(); -} - - -void FormCredits::apply() -{ -} - - -void FormCredits::update() -{ -} - - -Gnome::Dialog * FormCredits::dialog() -{ - return getWidget("DiaHelpCredits"); -} - Gtk::Text * FormCredits::text() { return getWidget("credits_text"); diff --git a/src/frontends/gnome/FormCredits.h b/src/frontends/gnome/FormCredits.h index b924ff1053..b80a3ebf93 100644 --- a/src/frontends/gnome/FormCredits.h +++ b/src/frontends/gnome/FormCredits.h @@ -21,10 +21,6 @@ #include "ControlCredits.h" #include "GnomeBase.h" -namespace Gnome { -class Dialog; -} - namespace Gtk { class Button; class Text; @@ -38,31 +34,22 @@ public: /// FormCredits(ControlCredits & c); /// - ~FormCredits(); + ~FormCredits() {}; - void apply(); - - void hide(); - void show(); - void update(); + void apply() {}; + void update() {}; private: /// Build the dialog void build(); - /// get the dialog - Gnome::Dialog * dialog(); - void CancelClicked() { CancelButton(); } /// The ok button Gtk::Button * ok(); Gtk::Text * text(); - - // Hold the dialog. - Gnome::Dialog * dialog_; }; #endif diff --git a/src/frontends/gnome/FormUrl.C b/src/frontends/gnome/FormUrl.C index b3b3a02b42..f3b6f51b01 100644 --- a/src/frontends/gnome/FormUrl.C +++ b/src/frontends/gnome/FormUrl.C @@ -19,13 +19,11 @@ #include "gnomeBC.h" #include "FormUrl.h" -#include #include #include FormUrl::FormUrl(ControlUrl & c) : FormCB(c, "diainserturl.glade", "DiaInsertUrl") - , dialog_(0) {} @@ -40,9 +38,6 @@ FormUrl::~FormUrl() void FormUrl::build() { - // Make sure the dialog is loaded. - dialog_ = dialog(); - // Connect the buttons. ok_btn()->clicked.connect(SigC::slot(this, &FormUrl::OKClicked)); cancel_btn()->clicked.connect(SigC::slot(this, &FormUrl::CancelClicked)); @@ -82,22 +77,6 @@ void FormUrl::disconnect_signals() } -void FormUrl::show() -{ - if (!dialog_) - build(); - - update(); - dialog_->show(); -} - - -void FormUrl::hide() -{ - dialog_->hide(); -} - - void FormUrl::apply() { controller().params().setContents(url()->get_text()); @@ -135,11 +114,6 @@ bool FormUrl::validate() const } -Gnome::Dialog * FormUrl::dialog() -{ - return getWidget("DiaInsertUrl"); -} - Gtk::Entry * FormUrl::url() const { return getWidget("url"); diff --git a/src/frontends/gnome/FormUrl.h b/src/frontends/gnome/FormUrl.h index eeca5b50a7..0ee41de96f 100644 --- a/src/frontends/gnome/FormUrl.h +++ b/src/frontends/gnome/FormUrl.h @@ -21,11 +21,6 @@ #include "ControlUrl.h" #include "GnomeBase.h" -//#include -namespace Gnome { -class Dialog; -} - namespace Gtk { class Button; class CheckButton; @@ -43,8 +38,6 @@ public: ~FormUrl(); void apply(); - void hide(); - void show(); void update(); private: @@ -65,8 +58,6 @@ private: void RestoreClicked() { RestoreButton(); } void InputChanged() { bc().valid(validate()); } - /// Get the dialog - Gnome::Dialog * dialog(); /// The url entry Gtk::Entry * url() const; /// The name entry @@ -82,10 +73,6 @@ private: /// The restore button Gtk::Button * restore_btn() const; - // Hold the dialog. - //boost::shared_ptr dialog_; - Gnome::Dialog * dialog_; - /// 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 36c93f9228..8b68b16bb7 100644 --- a/src/frontends/gnome/GnomeBase.C +++ b/src/frontends/gnome/GnomeBase.C @@ -19,8 +19,13 @@ #include "support/filetools.h" #include -GnomeBase::GnomeBase(ControlButton & c, string const & glade_file, string const & name) - : ViewBC(c), file_(glade_file), widget_name_(name), xml_(0) +#include + +GnomeBase::GnomeBase(ControlButton & c, + string const & glade_file, string const & name) + : ViewBC(c) + , file_(glade_file), widget_name_(name), xml_(0) + , dialog_(0) {} GnomeBase::~GnomeBase() @@ -45,3 +50,31 @@ void GnomeBase::loadXML() const xml_ = glade_xml_new(file.c_str(), widget_name_.c_str()); } + + +void GnomeBase::show() +{ + if (!dialog_) { + dialog_ = dialog(); + build(); + } + + update(); + dialog_->show(); +} + + +void GnomeBase::hide() +{ + if (dialog_) + dialog_->hide(); +} + + +Gnome::Dialog * GnomeBase::dialog() +{ + if (!dialog_) + dialog_ = getWidget(widget_name_.c_str()); + + return dialog_; +} diff --git a/src/frontends/gnome/GnomeBase.h b/src/frontends/gnome/GnomeBase.h index 5f8cbb9b36..b7541b7c73 100644 --- a/src/frontends/gnome/GnomeBase.h +++ b/src/frontends/gnome/GnomeBase.h @@ -22,17 +22,12 @@ #include #include "gnome_helpers.h" -namespace Gtk { -class Button; -class Entry; -}; - namespace Gnome { class Dialog; }; /** - * This is a base class for Gnome dialogs. Basically it handles all the common + * This is a base class for Gnome dialogs. It handles all the common * work that is needed for all dialogs. */ class GnomeBase : public ViewBC, public SigC::Object { @@ -43,19 +38,37 @@ public: virtual ~GnomeBase(); protected: + /// Get the widget named 'name' from the xml representation. template T* getWidget(char const * name) const; + /// Get the dialog we use. + Gnome::Dialog * dialog(); + + /// Show the dialog. + void show(); + /// Hide the dialog. + void hide(); + + /// Build the dialog. Also connects signals and prepares it for work. + virtual void build() = 0; + private: /// Loads the glade file to memory. void loadXML() const; /// The glade file name - string file_; + const string file_; /// The widget name - string widget_name_; + const string widget_name_; /// The XML representation of the dialogs. mutable GladeXML * xml_; + + /** The dialog we work with, since it is managed by libglade, we do not + * need to delete it or destroy it, it will be destroyed with the rest + * of the libglade GladeXML structure. + */ + Gnome::Dialog * dialog_; }; @@ -81,7 +94,6 @@ template class FormCB : public GnomeBase { public: FormCB(Controller & c, string const & file, string const & name); - protected: Controller & controller(); }; diff --git a/src/frontends/gnome/gnomeBC.C b/src/frontends/gnome/gnomeBC.C index d47decabcb..5d057bfaa8 100644 --- a/src/frontends/gnome/gnomeBC.C +++ b/src/frontends/gnome/gnomeBC.C @@ -22,12 +22,14 @@ void gnomeBC::setWidgetEnabled(Gtk::Widget * obj, bool enabled) void gnomeBC::setButtonEnabled(Gtk::Button * btn, bool enabled) { - setWidgetEnabled(btn, enabled); + if (btn) + btn->set_sensitive(enabled); } void gnomeBC::setButtonLabel(Gtk::Button * obj, string const & label) { #warning Implement me! (be 20010329) - obj->set_text(label); + // There is no methods set_text! + //obj->set_text(label); } diff --git a/src/frontends/gnome/gnomeBC.h b/src/frontends/gnome/gnomeBC.h index 15b1157b03..42c4e528b8 100644 --- a/src/frontends/gnome/gnomeBC.h +++ b/src/frontends/gnome/gnomeBC.h @@ -26,7 +26,7 @@ namespace Gtk { class Button; class Widget; -} +}; class gnomeBC : public GuiBC { @@ -42,7 +42,7 @@ private: void setWidgetEnabled(Gtk::Widget * obj, bool enabled); /// Set the label on the button - void setButtonLabel(Gtk::Button * btn, string const & label) + void setButtonLabel(Gtk::Button * btn, string const & label); }; #endif // GNOMEBC_H diff --git a/src/frontends/gnome/gnome_helpers.h b/src/frontends/gnome/gnome_helpers.h index c67ef97175..e6a89dca08 100644 --- a/src/frontends/gnome/gnome_helpers.h +++ b/src/frontends/gnome/gnome_helpers.h @@ -20,7 +20,7 @@ // Glade Helper Function. template -T* getWidgetPtr(GladeXML* xml, const char* name) +T* getWidgetPtr(GladeXML* xml, char const * name) { T* result = static_cast(Gtk::wrap_auto((GtkObject*)glade_xml_get_widget(xml, name))); if (result == NULL) -- 2.39.2