2001-03-28 11:14:05 +00:00
|
|
|
/* This file is part of
|
|
|
|
* =================================================
|
2002-03-21 21:21:28 +00:00
|
|
|
*
|
2001-03-28 11:14:05 +00:00
|
|
|
* LyX, The Document Processor
|
|
|
|
* Copyright 1995 Matthias Ettrich.
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* ================================================= */
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include "GnomeBase.h"
|
|
|
|
#include "support/LAssert.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "support/filetools.h"
|
|
|
|
#include <glib.h>
|
|
|
|
|
2001-03-30 18:49:10 +00:00
|
|
|
#include <gnome--/dialog.h>
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
GnomeBase::GnomeBase(ControlButtons & c,
|
2002-01-16 12:30:17 +00:00
|
|
|
string const & name)
|
2001-03-30 18:49:10 +00:00
|
|
|
: ViewBC<gnomeBC>(c)
|
2002-01-16 12:30:17 +00:00
|
|
|
, file_(name + ".glade"), widget_name_(name), xml_(0)
|
2001-03-30 18:49:10 +00:00
|
|
|
, dialog_(0)
|
2001-03-28 11:14:05 +00:00
|
|
|
{}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
GnomeBase::~GnomeBase()
|
|
|
|
{
|
2001-03-29 14:47:17 +00:00
|
|
|
if (xml_)
|
|
|
|
gtk_object_unref(GTK_OBJECT(xml_));
|
2001-03-28 11:14:05 +00:00
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
void GnomeBase::loadXML() const
|
|
|
|
{
|
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
|
2002-03-27 10:07:57 +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
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
xml_ = glade_xml_new(file.c_str(), widget_name_.c_str());
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2002-01-16 12:30:17 +00:00
|
|
|
bool GnomeBase::validate()
|
|
|
|
{
|
|
|
|
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";
|
2002-03-21 21:21:28 +00:00
|
|
|
OKButton();
|
2002-01-16 12:30:17 +00:00
|
|
|
}
|
|
|
|
|
2002-03-27 10:07:57 +00:00
|
|
|
void GnomeBase::CancelClicked()
|
|
|
|
{
|
|
|
|
lyxerr[Debug::GUI] << "GnomeBase::CancelClicked()\n";
|
|
|
|
CancelButton();
|
2002-01-16 12:30:17 +00:00
|
|
|
}
|
|
|
|
|
2002-03-27 10:07:57 +00:00
|
|
|
void GnomeBase::ApplyClicked()
|
|
|
|
{
|
|
|
|
lyxerr[Debug::GUI] << "GnomeBase::ApplyClicked()\n";
|
|
|
|
ApplyButton();
|
2002-01-16 12:30:17 +00:00
|
|
|
}
|
|
|
|
|
2002-03-27 10:07:57 +00:00
|
|
|
void GnomeBase::RestoreClicked()
|
|
|
|
{
|
|
|
|
lyxerr[Debug::GUI] << "GnomeBase::RestoreClicked()\n";
|
|
|
|
RestoreButton();
|
2002-01-16 12:30:17 +00:00
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
void GnomeBase::InputChanged()
|
|
|
|
{
|
|
|
|
bc().valid(validate());
|
2002-01-16 12:30:17 +00:00
|
|
|
}
|
2001-03-30 18:49:10 +00:00
|
|
|
|
|
|
|
Gnome::Dialog * GnomeBase::dialog()
|
|
|
|
{
|
2002-03-21 21:21:28 +00:00
|
|
|
if (!dialog_)
|
2001-03-30 18:49:10 +00:00
|
|
|
dialog_ = getWidget<Gnome::Dialog>(widget_name_.c_str());
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-03-30 18:49:10 +00:00
|
|
|
return dialog_;
|
|
|
|
}
|