2002-09-25 14:26:13 +00:00
|
|
|
/**
|
|
|
|
* \file GnomeBase.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 21:21:28 +00:00
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
* \author Baruch Even
|
2001-03-28 11:14:05 +00:00
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
*/
|
2001-03-28 11:14:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include "GnomeBase.h"
|
|
|
|
#include "support/LAssert.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "support/filetools.h"
|
2003-02-08 00:25:34 +00:00
|
|
|
#include "ControlButtons.h"
|
2001-03-28 11:14:05 +00:00
|
|
|
#include <glib.h>
|
2002-06-02 04:15:33 +00:00
|
|
|
#include <gtkmm/dialog.h>
|
2001-03-30 18:49:10 +00:00
|
|
|
|
2003-02-08 00:25:34 +00:00
|
|
|
GnomeBase::GnomeBase(string const & name)
|
|
|
|
: ViewBase(),
|
|
|
|
updating_(false),
|
|
|
|
file_(name + ".glade"),
|
|
|
|
title_(name),
|
2003-02-25 13:17:01 +00:00
|
|
|
widget_name_(name),
|
2003-02-08 00:25:34 +00:00
|
|
|
xml_(0),
|
|
|
|
dialog_(0)
|
2001-03-28 11:14:05 +00:00
|
|
|
{
|
2002-06-02 04:15:33 +00:00
|
|
|
loadXML();
|
2001-03-28 11:14:05 +00:00
|
|
|
}
|
|
|
|
|
2002-06-02 04:15:33 +00:00
|
|
|
GnomeBase::~GnomeBase()
|
|
|
|
{}
|
|
|
|
|
2003-02-08 00:25:34 +00:00
|
|
|
gnomeBC & GnomeBase::bc()
|
|
|
|
{
|
|
|
|
return static_cast<gnomeBC &>(getController().bc());
|
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-12-01 22:59:25 +00:00
|
|
|
void GnomeBase::loadXML()
|
2001-03-28 11:14:05 +00:00
|
|
|
{
|
2001-04-17 00:19:49 +00:00
|
|
|
#ifdef WITH_WARNINGS
|
2001-03-28 11:14:05 +00:00
|
|
|
#warning Change this before declaring it production code! (be 20010325)
|
2001-04-17 00:19:49 +00:00
|
|
|
#endif
|
2003-02-08 00:25:34 +00:00
|
|
|
string const path("src/frontends/gnome/dialogs/;frontends/gnome/dialogs/;");
|
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
string const file = FileOpenSearch(path, file_, "glade");
|
|
|
|
|
|
|
|
if (file.empty()) {
|
|
|
|
lyxerr << "Cannot find glade file. Aborting." << std::endl;
|
2001-04-29 10:47:13 +00:00
|
|
|
lyx::Assert(true);
|
2001-03-28 11:14:05 +00:00
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
lyxerr[Debug::GUI] << "Glade file to open is " << file << '\n';
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-06-02 04:15:33 +00:00
|
|
|
xml_ = Gnome::Glade::Xml::create (file, widget_name_);
|
2001-03-28 11:14:05 +00:00
|
|
|
}
|
2001-03-30 18:49:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
void GnomeBase::show()
|
|
|
|
{
|
|
|
|
update();
|
2002-03-27 10:07:57 +00:00
|
|
|
dialog()->show();
|
2001-03-30 18:49:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GnomeBase::hide()
|
|
|
|
{
|
2002-03-27 10:07:57 +00:00
|
|
|
dialog()->hide();
|
2001-03-30 18:49:10 +00:00
|
|
|
}
|
|
|
|
|
2003-02-08 00:25:34 +00:00
|
|
|
bool GnomeBase::isValid()
|
2002-01-16 12:30:17 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
void GnomeBase::OKClicked()
|
|
|
|
{
|
2002-03-27 10:07:57 +00:00
|
|
|
lyxerr[Debug::GUI] << "GnomeBase::OKClicked()\n";
|
2003-02-08 00:25:34 +00:00
|
|
|
getController().OKButton();
|
2002-01-16 12:30:17 +00:00
|
|
|
}
|
|
|
|
|
2002-12-01 22:59:25 +00:00
|
|
|
void GnomeBase::CancelClicked()
|
|
|
|
{
|
2002-03-27 10:07:57 +00:00
|
|
|
lyxerr[Debug::GUI] << "GnomeBase::CancelClicked()\n";
|
2003-02-08 00:25:34 +00:00
|
|
|
getController().CancelButton();
|
2002-01-16 12:30:17 +00:00
|
|
|
}
|
|
|
|
|
2002-12-01 22:59:25 +00:00
|
|
|
void GnomeBase::ApplyClicked()
|
|
|
|
{
|
2002-03-27 10:07:57 +00:00
|
|
|
lyxerr[Debug::GUI] << "GnomeBase::ApplyClicked()\n";
|
2003-02-08 00:25:34 +00:00
|
|
|
getController().ApplyButton();
|
2002-01-16 12:30:17 +00:00
|
|
|
}
|
|
|
|
|
2002-12-01 22:59:25 +00:00
|
|
|
void GnomeBase::RestoreClicked()
|
|
|
|
{
|
2002-03-27 10:07:57 +00:00
|
|
|
lyxerr[Debug::GUI] << "GnomeBase::RestoreClicked()\n";
|
2003-02-08 00:25:34 +00:00
|
|
|
getController().RestoreButton();
|
2002-01-16 12:30:17 +00:00
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
void GnomeBase::InputChanged()
|
|
|
|
{
|
2003-02-08 00:25:34 +00:00
|
|
|
bc().valid(isValid());
|
2002-01-16 12:30:17 +00:00
|
|
|
}
|
2001-03-30 18:49:10 +00:00
|
|
|
|
2002-06-02 04:15:33 +00:00
|
|
|
Gtk::Dialog * GnomeBase::dialog()
|
2001-03-30 18:49:10 +00:00
|
|
|
{
|
2002-03-21 21:21:28 +00:00
|
|
|
if (!dialog_)
|
2002-06-02 04:15:33 +00:00
|
|
|
dialog_ = getWidget<Gtk::Dialog>(widget_name_);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-03-30 18:49:10 +00:00
|
|
|
return dialog_;
|
|
|
|
}
|
2003-02-08 00:25:34 +00:00
|
|
|
|
|
|
|
bool GnomeBase::isVisible() const
|
|
|
|
{
|
|
|
|
return dialog_ && dialog_->is_visible();
|
|
|
|
}
|