mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-08 20:32:49 +00:00
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
This commit is contained in:
parent
77639efa94
commit
a6adf5d732
@ -1,3 +1,14 @@
|
||||
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.
|
||||
|
@ -19,30 +19,19 @@
|
||||
#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;
|
||||
@ -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<Gnome::Dialog>("DiaHelpCredits");
|
||||
}
|
||||
|
||||
Gtk::Text * FormCredits::text()
|
||||
{
|
||||
return getWidget<Gtk::Text>("credits_text");
|
||||
|
@ -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
|
||||
|
@ -19,13 +19,11 @@
|
||||
#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)
|
||||
{}
|
||||
|
||||
|
||||
@ -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<Gnome::Dialog>("DiaInsertUrl");
|
||||
}
|
||||
|
||||
Gtk::Entry * FormUrl::url() const
|
||||
{
|
||||
return getWidget<Gtk::Entry>("url");
|
||||
|
@ -21,11 +21,6 @@
|
||||
#include "ControlUrl.h"
|
||||
#include "GnomeBase.h"
|
||||
|
||||
//#include <gnome--/dialog.h>
|
||||
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<Gnome::Dialog> dialog_;
|
||||
Gnome::Dialog * dialog_;
|
||||
|
||||
/// Keeps the connection to the input validator.
|
||||
SigC::Connection slot_url_;
|
||||
SigC::Connection slot_name_;
|
||||
|
@ -19,8 +19,13 @@
|
||||
#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()
|
||||
@ -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<Gnome::Dialog>(widget_name_.c_str());
|
||||
|
||||
return dialog_;
|
||||
}
|
||||
|
@ -22,17 +22,12 @@
|
||||
#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 {
|
||||
@ -43,19 +38,37 @@ public:
|
||||
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_;
|
||||
};
|
||||
|
||||
|
||||
@ -81,7 +94,6 @@ template <class Controller>
|
||||
class FormCB : public GnomeBase {
|
||||
public:
|
||||
FormCB(Controller & c, string const & file, string const & name);
|
||||
|
||||
protected:
|
||||
Controller & controller();
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
namespace Gtk {
|
||||
class Button;
|
||||
class Widget;
|
||||
}
|
||||
};
|
||||
|
||||
class gnomeBC : public GuiBC<Gtk::Button, Gtk::Widget>
|
||||
{
|
||||
@ -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
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
// 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)
|
||||
|
Loading…
Reference in New Issue
Block a user