+2001-03-30 Baruch Even <baruch@lyx.org>
+
+ * 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 <a.leeming@ic.ac.uk>
* GnomeBase.[Ch]: changed ControlBase to ControlButton.
#include "gnomeBC.h"
#include "FormCredits.h"
-#include <gnome--/dialog.h>
#include <gtk--/button.h>
#include <gtk--/text.h>
FormCredits::FormCredits(ControlCredits & c)
: FormCB<ControlCredits>(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;
}
-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<Gnome::Dialog>("DiaHelpCredits");
-}
-
Gtk::Text * FormCredits::text()
{
return getWidget<Gtk::Text>("credits_text");
#include "ControlCredits.h"
#include "GnomeBase.h"
-namespace Gnome {
-class Dialog;
-}
-
namespace Gtk {
class Button;
class Text;
///
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
#include "gnomeBC.h"
#include "FormUrl.h"
-#include <gnome--/dialog.h>
#include <gtk--/entry.h>
#include <gtk--/checkbutton.h>
FormUrl::FormUrl(ControlUrl & c)
: FormCB<ControlUrl>(c, "diainserturl.glade", "DiaInsertUrl")
- , dialog_(0)
{}
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));
}
-void FormUrl::show()
-{
- if (!dialog_)
- build();
-
- update();
- dialog_->show();
-}
-
-
-void FormUrl::hide()
-{
- dialog_->hide();
-}
-
-
void FormUrl::apply()
{
controller().params().setContents(url()->get_text());
}
-Gnome::Dialog * FormUrl::dialog()
-{
- return getWidget<Gnome::Dialog>("DiaInsertUrl");
-}
-
Gtk::Entry * FormUrl::url() const
{
return getWidget<Gtk::Entry>("url");
#include "ControlUrl.h"
#include "GnomeBase.h"
-//#include <gnome--/dialog.h>
-namespace Gnome {
-class Dialog;
-}
-
namespace Gtk {
class Button;
class CheckButton;
~FormUrl();
void apply();
- void hide();
- void show();
void update();
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
/// The restore button
Gtk::Button * restore_btn() const;
- // Hold the dialog.
- //boost::shared_ptr<Gnome::Dialog> dialog_;
- Gnome::Dialog * dialog_;
-
/// Keeps the connection to the input validator.
SigC::Connection slot_url_;
SigC::Connection slot_name_;
#include "support/filetools.h"
#include <glib.h>
-GnomeBase::GnomeBase(ControlButton & c, string const & glade_file, string const & name)
- : ViewBC<gnomeBC>(c), file_(glade_file), widget_name_(name), xml_(0)
+#include <gnome--/dialog.h>
+
+GnomeBase::GnomeBase(ControlButton & c,
+ string const & glade_file, string const & name)
+ : ViewBC<gnomeBC>(c)
+ , file_(glade_file), widget_name_(name), xml_(0)
+ , dialog_(0)
{}
GnomeBase::~GnomeBase()
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<Gnome::Dialog>(widget_name_.c_str());
+
+ return dialog_;
+}
#include <sigc++/signal_system.h>
#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<gnomeBC>, public SigC::Object {
virtual ~GnomeBase();
protected:
+ /// Get the widget named 'name' from the xml representation.
template <class T>
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_;
};
class FormCB : public GnomeBase {
public:
FormCB(Controller & c, string const & file, string const & name);
-
protected:
Controller & controller();
};
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);
}
namespace Gtk {
class Button;
class Widget;
-}
+};
class gnomeBC : public GuiBC<Gtk::Button, Gtk::Widget>
{
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
// Glade Helper Function.
template<class T>
-T* getWidgetPtr(GladeXML* xml, const char* name)
+T* getWidgetPtr(GladeXML* xml, char const * name)
{
T* result = static_cast<T*>(Gtk::wrap_auto((GtkObject*)glade_xml_get_widget(xml, name)));
if (result == NULL)