Fixed compilation problems.

Added infrastructure for MVC dialogs and implemented FormUrl as an MVC dialog.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1841 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Baruch Even 2001-03-28 11:14:05 +00:00
parent b14052f6a5
commit bed3713ff0
20 changed files with 863 additions and 400 deletions

View File

@ -1,3 +1,26 @@
2001-03-26 Baruch Even <baruch@lyx.org>
* Various files: Fixes to get the gnome frontend to compile again.
Removed most xforms dialogs in order to reduce compilation breaks caused
by the moves to MVC in the xforms frontend.
* GUIRuntime.C: Added libglade library initialization.
* gnomeBC.h:
* gnomeBC.C: Added file for the MVC support.
* gnome_helpers.h: Added file with support functions.
* GnomeBase.h:
* GnomeBase.C: Added file to be the base class of MVC dialogs that use
libglade.
* FormUrl.h:
* FormUrl.C: Recreated the dialog in the MVC way.
* Timeout_pimpl.h:
* Timeout_pimpl.C: Implementation of the Timeout pimpl.
2001-03-15 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com> 2001-03-15 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
* several files: remove CXX_WORKING_NAMESPACES * several files: remove CXX_WORKING_NAMESPACES

View File

@ -1,66 +1,117 @@
#include <config.h> /* This file is part of
#include FORMS_H_LOCATION * ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995-2001 The LyX Team.
*
* ======================================================
*/
#include "Dialogs.h" #include <config.h>
#include "FormCitation.h"
#include "FormCopyright.h"
#include "FormDocument.h"
#include "FormError.h"
#include "FormGraphics.h"
#include "FormIndex.h"
#include "FormParagraph.h"
#include "FormPreferences.h"
#include "FormPrint.h"
#include "FormRef.h"
#include "FormSplash.h"
#include "FormTabular.h"
#include "FormToc.h"
#include "FormUrl.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
#endif #endif
// temporary till ported #include "Dialogs.h"
extern void ShowCredits();
#include "gnomeBC.h"
#include "ControlBibitem.h"
#include "ControlBibtex.h"
#include "ControlCharacter.h"
#include "ControlCitation.h"
#include "ControlCopyright.h"
#include "ControlCredits.h"
#include "ControlInclude.h"
#include "ControlLog.h"
#include "ControlUrl.h"
#include "ControlVCLog.h"
#include "GUI.h"
#include "FormUrl.h"
/*
#include "FormBibitem.h"
#include "FormBibtex.h"
#include "FormCharacter.h"
#include "FormCitation.h"
#include "FormCopyright.h"
#include "FormCredits.h"
#include "FormLog.h"
#include "FormVCLog.h"
#include "FormDocument.h"
#include "FormError.h"
#include "FormExternal.h"
#include "FormGraphics.h"
#include "FormInclude.h"
#include "FormIndex.h"
#include "FormMathsPanel.h"
#include "FormParagraph.h"
#include "FormPreamble.h"
#include "FormPreferences.h"
#include "FormPrint.h"
#include "FormRef.h"
#include "FormSearch.h"
#include "FormSplash.h"
#include "FormTabular.h"
#include "FormTabularCreate.h"
#include "FormToc.h"
#include "FormUrl.h"
#include "FormMinipage.h"
*/
// Signal enabling all visible popups to be redrawn if so desired. // Signal enabling all visible popups to be redrawn if so desired.
// E.g., when the GUI colours have been remapped. // E.g., when the GUI colours have been remapped.
Signal0<void> Dialogs::redrawGUI; SigC::Signal0<void> Dialogs::redrawGUI;
Dialogs::Dialogs(LyXView * lv) Dialogs::Dialogs(LyXView * lv)
{ {
dialogs_.push_back(new FormCitation(lv, this)); add(new GUIUrl<FormUrl, gnomeBC>(*lv, *this));
dialogs_.push_back(new FormCopyright(lv, this)); /*
dialogs_.push_back(new FormDocument(lv, this)); splash_.reset(new FormSplash(lv, this));
dialogs_.push_back(new FormError(lv, this));
dialogs_.push_back(new FormGraphics(lv, this)); add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
dialogs_.push_back(new FormIndex(lv, this)); add(new GUIBibtex<FormBibtex, xformsBC>(*lv, *this));
dialogs_.push_back(new FormPreferences(lv, this)); add(new GUICharacter<FormCharacter, xformsBC>(*lv, *this));
dialogs_.push_back(new FormParagraph(lv, this)); //add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
dialogs_.push_back(new FormPrint(lv, this)); //add(new GUICopyright<FormCopyright, xformsBC>(*lv, *this));
dialogs_.push_back(new FormRef(lv, this)); add(new GUICredits<FormCredits, xformsBC>(*lv, *this));
dialogs_.push_back(new FormSplash(lv, this)); add(new GUILog<FormLog, xformsBC>(*lv, *this));
dialogs_.push_back(new FormTabular(lv, this)); add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
dialogs_.push_back(new FormToc(lv, this));
dialogs_.push_back(new FormUrl(lv, this)); // For now we use the gnome non MVC dialogs
add(new FormCitation(lv, this));
add(new FormCopyright(lv, this));
add(new FormDocument(lv, this));
add(new FormError(lv, this));
add(new FormExternal(lv, this));
add(new FormGraphics(lv, this));
add(new FormInclude(lv, this));
add(new FormIndex(lv, this));
add(new FormMathsPanel(lv, this));
add(new FormParagraph(lv, this));
add(new FormPreamble(lv, this));
add(new FormPreferences(lv, this));
add(new FormPrint(lv, this));
add(new FormRef(lv, this));
add(new FormSearch(lv, this));
add(new FormSplash(lv, this));
add(new FormTabular(lv, this));
add(new FormTabularCreate(lv, this));
add(new FormToc(lv, this));
add(new FormUrl(lv, this));
add(new FormMinipage(lv, this));
*/
// reduce the number of connections needed in // reduce the number of connections needed in
// dialogs by a simple connection here. // dialogs by a simple connection here.
hideAll.connect(hideBufferDependent.slot()); hideAll.connect(hideBufferDependent.slot());
} }
Dialogs::~Dialogs()
{
for (vector<DialogBase *>::iterator iter = dialogs_.begin();
iter != dialogs_.end();
++iter) {
delete *iter;
}
}
/***************************************************************************** /*****************************************************************************
Q. WHY does Dialogs::Dialogs pass `this' to dialog constructors? Q. WHY does Dialogs::Dialogs pass `this' to dialog constructors?

View File

@ -125,11 +125,11 @@ private:
/// the nitty-griity. What is modified and passed back /// the nitty-griity. What is modified and passed back
InsetCommandParams params; InsetCommandParams params;
/// Update connection. /// Update connection.
Connection u_; SigC::Connection u_;
/// Hide connection. /// Hide connection.
Connection h_; SigC::Connection h_;
/// inset::hide connection. /// inset::hide connection.
Connection ih_; SigC::Connection ih_;
/// Real GUI implementation. /// Real GUI implementation.
Gtk::Container * dialog_; Gtk::Container * dialog_;

View File

@ -49,9 +49,9 @@ private:
*/ */
Dialogs * d_; Dialogs * d_;
/// Hide connection. /// Hide connection.
Connection h_; SigC::Connection h_;
/// Destroy connection. /// Destroy connection.
Connection destroy_; SigC::Connection destroy_;
}; };
#endif #endif

View File

@ -58,11 +58,11 @@ private:
/// pointer to the inset passed through showInset (if any) /// pointer to the inset passed through showInset (if any)
InsetError * inset_; InsetError * inset_;
/// Update connection. /// Update connection.
Connection u_; SigC::Connection u_;
/// Hide connection. /// Hide connection.
Connection h_; SigC::Connection h_;
/// inset::hide connection. /// inset::hide connection.
Connection ih_; SigC::Connection ih_;
/// Real GUI implementation. /// Real GUI implementation.
Gtk::Container * dialog_; Gtk::Container * dialog_;

View File

@ -64,11 +64,11 @@ private:
/// the nitty-griity. What is modified and passed back /// the nitty-griity. What is modified and passed back
InsetCommandParams params; InsetCommandParams params;
/// Update connection. /// Update connection.
Connection u_; SigC::Connection u_;
/// Hide connection. /// Hide connection.
Connection h_; SigC::Connection h_;
/// inset::hide connection. /// inset::hide connection.
Connection ih_; SigC::Connection ih_;
/// Real GUI implementation. /// Real GUI implementation.
Gtk::Container * dialog_; Gtk::Container * dialog_;

View File

@ -1,3 +1,6 @@
// THIS FILE IS NOT IN USE DUE TO API CHANGES.
#include "frontends/xforms/FormToc.h"
#if 0
// -*- C++ -*- // -*- C++ -*-
/* This file is part of /* This file is part of
* ====================================================== * ======================================================
@ -84,3 +87,4 @@ private:
}; };
#endif #endif
#endif

View File

@ -1,232 +1,180 @@
// -*- C++ -*- // -*- C++ -*-
/* This file is part of /* This file is part of
* ====================================================== * =================================================
* *
* LyX, The Document Processor * LyX, The Document Processor
* Copyright 1995-2000 The LyX Team.
* *
* Copyright 2000 The LyX Team. * =================================================
* *
* ====================================================== * \author Baruch Even
*/ */
#include <config.h>
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
#endif #endif
#include <config.h>
#include "gettext.h" #include "gnomeBC.h"
#include "Dialogs.h"
#include "FormUrl.h" #include "FormUrl.h"
#include "LyXView.h"
#include "buffer.h"
#include "lyxfunc.h"
#include <gtk--/label.h> #include <gnome--/dialog.h>
#include <gtk--/table.h> #include <gtk--/entry.h>
#include <gtk--/box.h> #include <gtk--/checkbutton.h>
#include <gtk--/buttonbox.h>
#include <gtk--/base.h>
#include <gtk--/separator.h>
// temporary solution for LyXView FormUrl::FormUrl(ControlUrl & c)
#include "mainapp.h" : FormCB<ControlUrl>(c, "diainserturl.glade", "DiaInsertUrl")
extern GLyxAppWin * mainAppWin; , dialog_(0)
{}
namespace {
// configuration keys
string const CONF_ENTRY_URL("FormUrl_url");
string const CONF_ENTRY_NAME("FormUrl_name");
} // namespace anon
FormUrl::FormUrl(LyXView * lv, Dialogs * d)
: lv_(lv), d_(d), inset_(0), u_(0), h_(0), ih_(0), dialog_(0)
{
// let the dialog be shown
// These are permanent connections so we won't bother
// storing a copy because we won't be disconnecting.
d->showUrl.connect(slot(this, &FormUrl::showInset));
d->createUrl.connect(slot(this, &FormUrl::createInset));
}
FormUrl::~FormUrl() FormUrl::~FormUrl()
{ {
hide(); // Note that there is no need to destroy the class itself, it seems
// like everything is managed inside it. Deleting the class itself will
// a crash at the end of the program.
dialog_->destroy();
} }
void FormUrl::showInset( InsetCommand * const inset )
void FormUrl::build()
{ {
if( dialog_!=0 || inset == 0 ) return; // Make sure the dialog is loaded.
dialog_ = dialog();
inset_ = inset; // Connect the buttons.
ih_ = inset_->hideDialog.connect(slot(this, &FormUrl::hide)); ok_btn()->clicked.connect(SigC::slot(this, &FormUrl::OKClicked));
cancel_btn()->clicked.connect(SigC::slot(this, &FormUrl::CancelClicked));
apply_btn()->clicked.connect(SigC::slot(this, &FormUrl::ApplyClicked));
restore_btn()->clicked.connect(SigC::slot(this, &FormUrl::RestoreClicked));
params = inset->params(); // Manage the buttons state
show(); bc().setOK(ok_btn());
bc().setCancel(cancel_btn());
bc().setApply(apply_btn());
bc().setUndoAll(restore_btn());
// Make sure everything is in the correct state.
bc().refresh();
// Manage the read-only aware widgets.
bc().addReadOnly(html());
bc().addReadOnly(name());
bc().addReadOnly(url());
} }
void FormUrl::createInset( string const & arg ) void FormUrl::connect_signals()
{ {
if( dialog_!=0 ) return; // Get notifications on input change
slot_url_ = url()->changed.connect(SigC::slot(this, &FormUrl::InputChanged));
params.setFromString( arg ); slot_name_ = name()->changed.connect(SigC::slot(this, &FormUrl::InputChanged));
show(); slot_html_ = html()->toggled.connect(SigC::slot(this, &FormUrl::InputChanged));
} }
void FormUrl::disconnect_signals()
{
slot_url_.disconnect();
slot_name_.disconnect();
slot_html_.disconnect();
}
void FormUrl::show() void FormUrl::show()
{ {
if (!dialog_) if (!dialog_)
{ build();
using namespace Gtk::Box_Helpers;
Gtk::Label * label; update();
Gtk::Table * table = manage( new Gtk::Table(2, 2, FALSE) ); dialog_->show();
Gtk::Box * mbox = manage( new Gtk::HBox() );
Gtk::ButtonBox * bbox = manage( new Gtk::VButtonBox() );
Gtk::Separator * sep = manage( new Gtk::VSeparator() );
url_ = manage( new Gnome::Entry() );
name_ = manage( new Gnome::Entry() );
html_type_ = manage( new Gtk::CheckButton(_("HTML type")) );
b_ok = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_OK) ) );
b_cancel = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL) ) );
// set up spacing
table->set_row_spacings(2);
table->set_col_spacings(2);
mbox->set_spacing(2);
bbox->set_spacing(4);
// configure entries
url_->set_history_id(CONF_ENTRY_URL);
url_->set_max_saved(10);
url_->load_history();
url_->set_use_arrows_always(true);
name_->set_history_id(CONF_ENTRY_NAME);
name_->set_max_saved(10);
name_->load_history();
name_->set_use_arrows_always(true);
// pack widgets
bbox->children().push_back(Element(*b_ok, false, false));
bbox->children().push_back(Element(*b_cancel, false, false));
label = manage( new Gtk::Label(_("URL")) );
table->attach( *label, 0, 1, 0, 1, 0, 0 );
label = manage( new Gtk::Label(_("Name")) );
table->attach( *label, 0, 1, 1, 2, 0, 0 );
table->attach( *url_, 1, 2, 0, 1 );
table->attach( *name_, 1, 2, 1, 2 );
mbox->children().push_back(Element(*table));
mbox->children().push_back(Element(*html_type_, false, false));
mbox->children().push_back(Element(*sep, false, false));
mbox->children().push_back(Element(*bbox, false, false));
// packing dialog to main window
dialog_ = mbox;
mainAppWin->add_action(*dialog_, _(" URL "));
// setting focus
GTK_WIDGET_SET_FLAGS (GTK_WIDGET(url_->get_entry()->gtkobj()), GTK_CAN_DEFAULT);
gtk_widget_grab_focus (GTK_WIDGET(url_->get_entry()->gtkobj()));
gtk_widget_grab_default (GTK_WIDGET(url_->get_entry()->gtkobj()));
// connecting signals
b_ok->clicked.connect(slot(this, &FormUrl::apply));
name_->get_entry()->activate.connect(slot(this, &FormUrl::apply));
b_cancel->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action));
dialog_->destroy.connect(slot(this, &FormUrl::free));
u_ = d_->updateBufferDependent.connect(slot(this, &FormUrl::updateSlot));
h_ = d_->hideBufferDependent.connect(slot(this, &FormUrl::hide));
updateSlot(); // make sure its up-to-date
}
} }
void FormUrl::updateSlot(bool switched)
{
if (switched)
{
hide();
return;
}
if (dialog_ != 0 &&
lv_->view()->available())
{
url_->get_entry()->set_text(params.getContents().c_str());
name_->get_entry()->set_text(params.getOptions().c_str());
html_type_->set_active( (params.getCmdName() == "htmlurl") );
bool sens = (!(lv_->buffer()->isReadonly()));
html_type_->set_sensitive(sens);
url_->set_sensitive(sens);
name_->set_sensitive(sens);
b_ok->set_sensitive(sens);
}
}
void FormUrl::hide() void FormUrl::hide()
{ {
if (dialog_!=0) mainAppWin->remove_action(); dialog_->hide();
} }
void FormUrl::free()
{
if (dialog_!=0)
{
dialog_ = 0;
u_.disconnect();
h_.disconnect();
inset_ = 0;
ih_.disconnect();
}
}
void FormUrl::apply() void FormUrl::apply()
{ {
if( lv_->buffer()->isReadonly() ) return; controller().params().setContents(url()->get_text());
controller().params().setOptions(name()->get_text());
params.setContents( url_->get_entry()->get_text() ); string cmdname("url");
params.setOptions( name_->get_entry()->get_text() ); if (html()->get_active())
cmdname = "htmlurl";
if (html_type_->get_active()) controller().params().setCmdName(cmdname);
params.setCmdName("htmlurl"); }
else
params.setCmdName("url");
if( inset_ != 0 )
void FormUrl::update()
{ {
// Only update if contents have changed // Disconnect signals so we dont trigger the input changed state.
if( params != inset_->params() ) { // This avoids the problem of having the buttons enabled when the dialog
inset_->setParams( params ); // starts.
lv_->view()->updateInset( inset_, true ); disconnect_signals();
url()->set_text(controller().params().getContents());
name()->set_text(controller().params().getOptions());
html()->set_active("url" != controller().params().getCmdName());
// Reconnect the signals.
connect_signals();
} }
}
else
bool FormUrl::validate() const
{ {
lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL, // Always valid! (not really so, needs fixing).
params.getAsString() ); return true;
} }
// save history
url_->save_history();
name_->save_history();
// hide the dialog Gnome::Dialog * FormUrl::dialog()
hide(); {
return getWidget<Gnome::Dialog>("DiaInsertUrl");
}
Gtk::Entry * FormUrl::url() const
{
return getWidget<Gtk::Entry>("url");
}
Gtk::Entry * FormUrl::name() const
{
return getWidget<Gtk::Entry>("name");
}
Gtk::CheckButton * FormUrl::html() const
{
return getWidget<Gtk::CheckButton>("html_type");
}
Gtk::Button * FormUrl::ok_btn() const
{
return getWidget<Gtk::Button>("button_ok");
}
Gtk::Button * FormUrl::cancel_btn() const
{
return getWidget<Gtk::Button>("button_cancel");
}
Gtk::Button * FormUrl::apply_btn() const
{
return getWidget<Gtk::Button>("button_apply");
}
Gtk::Button * FormUrl::restore_btn() const
{
return getWidget<Gtk::Button>("button_restore");
} }

View File

@ -1,13 +1,15 @@
// -*- C++ -*- // -*- C++ -*-
/* This file is part of /* This file is part of
* ====================================================== * =================================================
* *
* LyX, The Document Processor * LyX, The Document Processor
* Copyright 1995 Matthias Ettrich.
* Copyright 1995-2000 The LyX Team.
* *
* Copyright 2000 The LyX Team. * =================================================
* *
* ====================================================== * \author Baruch Even
*/ * */
#ifndef FORMURL_H #ifndef FORMURL_H
#define FORMURL_H #define FORMURL_H
@ -16,75 +18,78 @@
#pragma interface #pragma interface
#endif #endif
#include "DialogBase.h" #include "ControlUrl.h"
#include "LString.h" #include "GnomeBase.h"
#include "insets/insetcommand.h"
#include <gtk--/container.h> //#include <gnome--/dialog.h>
#include <gtk--/checkbutton.h> namespace Gnome {
#include <gnome--/entry.h> class Dialog;
#include <gtk--/button.h> }
/** This class provides an Gnome implementation of the FormUrl Dialog. namespace Gtk {
class Button;
class CheckButton;
class Entry;
}
/**
* This class implements the dialog to insert/modify urls.
*/ */
class FormUrl : public DialogBase { class FormUrl : public FormCB<ControlUrl> {
public: public:
/**@name Constructors and Destructors */
//@{
/// ///
FormUrl(LyXView *, Dialogs *); FormUrl(ControlUrl & c);
/// ///
~FormUrl(); ~FormUrl();
//@}
void apply();
void hide();
void show();
void update();
private: private:
/// Slot launching dialog to (possibly) create a new inset /// Build the dialog
void createInset( string const & ); void build();
/// Slot launching dialog to an existing inset
void showInset( InsetCommand * const );
/// Update dialog before showing it /// Returns true if the dialog input is in a valid state.
virtual void update() { } bool validate() const;
virtual void updateSlot(bool = false);
/// Apply from dialog (modify or create inset)
virtual void apply();
/// Explicitly free the dialog.
void free();
/// Create the dialog if necessary, update it and display it.
void show();
/// Hide the dialog.
void hide();
/** Which LyXFunc do we use? /// Do the connection of signals
We could modify Dialogs to have a visible LyXFunc* instead and void connect_signals();
save a couple of bytes per dialog. /// Disconnect the signals.
*/ void disconnect_signals();
LyXView * lv_;
/** Which Dialogs do we belong to?
Used so we can get at the signals we have to connect to.
*/
Dialogs * d_;
/// pointer to the inset passed through showInset (if any)
InsetCommand * inset_;
/// the nitty-griity. What is modified and passed back
InsetCommandParams params;
/// Update connection.
Connection u_;
/// Hide connection.
Connection h_;
/// inset::hide connection.
Connection ih_;
/// Real GUI implementation. void OKClicked() { OKButton(); }
Gtk::Container * dialog_; void CancelClicked() { CancelButton(); }
void ApplyClicked() { ApplyButton(); }
void RestoreClicked() { RestoreButton(); }
void InputChanged() { bc().valid(validate()); }
Gtk::CheckButton * html_type_; /// Get the dialog
Gnome::Dialog * dialog();
/// The url entry
Gtk::Entry * url() const;
/// The name entry
Gtk::Entry * name() const;
/// The html type checkbutton
Gtk::CheckButton * html() const;
/// The ok button
Gtk::Button * ok_btn() const;
/// The cancel button
Gtk::Button * cancel_btn() const;
/// The apply button
Gtk::Button * apply_btn() const;
/// The restore button
Gtk::Button * restore_btn() const;
Gnome::Entry * url_; // Hold the dialog.
Gnome::Entry * name_; //boost::shared_ptr<Gnome::Dialog> dialog_;
Gnome::Dialog * dialog_;
Gtk::Button * b_ok; /// Keeps the connection to the input validator.
Gtk::Button * b_cancel; SigC::Connection slot_url_;
SigC::Connection slot_name_;
SigC::Connection slot_html_;
}; };
#endif #endif

View File

@ -20,6 +20,7 @@
#include <gnome--/main.h> #include <gnome--/main.h>
#include "mainapp.h" #include "mainapp.h"
#include <glade/glade.h>
using std::endl; using std::endl;
@ -73,6 +74,7 @@ int GUIRunTime::initApplication(int, char * argv[])
static string app_id(PACKAGE); static string app_id(PACKAGE);
static string app_version(VERSION); static string app_version(VERSION);
static Gnome::Main a(app_id, app_version, 1, argv); static Gnome::Main a(app_id, app_version, 1, argv);
glade_gnome_init(); // Initialize the glade library.
static GLyxAppWin appWin; static GLyxAppWin appWin;
mainAppWin = &appWin; mainAppWin = &appWin;

View File

@ -0,0 +1,46 @@
// -*- C++ -*-
/* This file is part of
* =================================================
*
* 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>
GnomeBase::GnomeBase(ControlBase & c, string const & glade_file, string const & name)
: ViewBC<gnomeBC>(c), file_(glade_file), widget_name_(name), xml_(0)
{}
GnomeBase::~GnomeBase()
{
gtk_object_unref(GTK_OBJECT(xml_));
}
void GnomeBase::loadXML() const
{
#warning Change this before declaring it production code! (be 20010325)
string const path("src/frontends/gnome/dialogs/;frontends/gnome/dialogs/;/home/baruch/prog/lyx/graphics/src/frontends/gnome/dialogs/");
string const file = FileOpenSearch(path, file_, "glade");
if (file.empty()) {
lyxerr << "Cannot find glade file. Aborting." << std::endl;
Assert(true);
}
lyxerr[Debug::GUI] << "Glade file to open is " << file << '\n';
xml_ = glade_xml_new(file.c_str(), widget_name_.c_str());
}

View File

@ -0,0 +1,101 @@
// -*- C++ -*-
/* This file is part of
* =================================================
*
* LyX, The Document Processor
* Copyright 1995-2000 The LyX Team.
*
* =================================================
*
* \author Baruch Even
**/
#ifndef GnomeBase_H
#define GnomeBase_H
#ifdef __GNUG__
#pragma interface
#endif
#include "ViewBase.h"
#include "gnomeBC.h"
#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
* work that is needed for all dialogs.
*/
class GnomeBase : public ViewBC<gnomeBC>, public SigC::Object {
public:
///
GnomeBase(ControlBase & c, string const & glade_file, string const & name);
///
virtual ~GnomeBase();
protected:
template <class T>
T* getWidget(char const * name) const;
private:
/// Loads the glade file to memory.
void loadXML() const;
/// The glade file name
string file_;
/// The widget name
string widget_name_;
/// The XML representation of the dialogs.
mutable GladeXML * xml_;
};
template <class T>
T* GnomeBase::getWidget(char const * name) const
{
if (xml_ == 0)
loadXML();
return getWidgetPtr<T>(xml_, name);
}
/**
* This class is used to provide a simple automatic casting of the controller.
* We chose not to make GnomeBase a template since it has some size and we
* have no reason to duplicate it by making it a template.
*
* Basically the FormCB<Controller> template instantiates GnomeBase and passes
* the parameters to it and it also adds the controller() method to give us
* a reference to the controller of the correct type (the type is set by the
* template parameter).
*/
template <class Controller>
class FormCB : public GnomeBase {
public:
FormCB(Controller & c, string const & file, string const & name);
protected:
Controller & controller();
};
template <class Controller>
FormCB<Controller>::FormCB(Controller & c, string const & file, string const & name)
: GnomeBase(c, file, name)
{}
template <class Controller>
Controller &
FormCB<Controller>::controller()
{
return static_cast<Controller &>(controller_);
}
#endif

View File

@ -4,51 +4,62 @@ MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
noinst_LTLIBRARIES = libgnome.la noinst_LTLIBRARIES = libgnome.la
BOOST_INCLUDES = -I$(top_srcdir)/boost BOOST_INCLUDES = -I$(top_srcdir)/boost
INCLUDES = ${FRONTEND_INCLUDES} -I${top_srcdir}/src/ \ INCLUDES = ${FRONTEND_INCLUDES} -I${top_srcdir}/src/ \
-I${top_srcdir}/src/frontends/ -I${top_srcdir}/src/frontends/xforms \ -I${top_srcdir}/src/frontends/ \
-I${top_srcdir}/src/frontends/xforms \
-I${top_srcdir}/src/frontends/controllers \
${SIGC_CFLAGS} $(BOOST_INCLUDES) ${SIGC_CFLAGS} $(BOOST_INCLUDES)
libgnome_la_OBJADD = \ libgnome_la_OBJADD = \
../xforms/ButtonController.lo \ ../xforms/xforms_helpers.lo \
../xforms/Color.lo \ ../xforms/Toolbar_pimpl.lo \
../xforms/combox.lo \
../xforms/MathsSymbols.lo \
../xforms/FormMathsBitmap.lo \
../xforms/FormMathsDeco.lo \
../xforms/FormMathsDelim.lo \
../xforms/FormMathsMatrix.lo \
../xforms/FormMathsPanel.lo \
../xforms/FormMathsSpace.lo \
../xforms/FileDialog.lo \ ../xforms/FileDialog.lo \
../xforms/FormFiledialog.lo \ ../xforms/FormFiledialog.lo \
../xforms/form_filedialog.lo \ ../xforms/form_filedialog.lo
../xforms/FormBase.lo \ # ../xforms/Timeout_pimpl.lo \
../xforms/FormCitation.lo \ # ../xforms/Color.lo \
../xforms/form_citation.lo \ # ../xforms/FormFiledialog.lo \
../xforms/FormCopyright.lo \ # ../xforms/form_filedialog.lo \
../xforms/form_copyright.lo \ # ../xforms/FormBase.lo \
../xforms/FormDocument.lo \ # ../xforms/FormCitation.lo \
../xforms/form_document.lo \ # ../xforms/form_citation.lo \
../xforms/FormError.lo \ # ../xforms/FormCopyright.lo \
../xforms/form_error.lo \ # ../xforms/form_copyright.lo \
../xforms/FormGraphics.lo \ # ../xforms/FormDocument.lo \
../xforms/form_graphics.lo \ # ../xforms/form_document.lo \
../xforms/FormIndex.lo \ # ../xforms/FormError.lo \
../xforms/form_index.lo \ # ../xforms/form_error.lo \
../xforms/FormInset.lo \ # ../xforms/FormGraphics.lo \
../xforms/FormParagraph.lo \ # ../xforms/form_graphics.lo \
../xforms/form_paragraph.lo \ # ../xforms/FormIndex.lo \
../xforms/FormPreferences.lo \ # ../xforms/form_index.lo \
../xforms/form_preferences.lo \ # ../xforms/FormInset.lo \
../xforms/FormPrint.lo \ # ../xforms/FormParagraph.lo \
../xforms/form_print.lo \ # ../xforms/form_paragraph.lo \
../xforms/FormRef.lo \ # ../xforms/FormPreferences.lo \
../xforms/form_ref.lo \ # ../xforms/form_preferences.lo \
../xforms/FormSplash.lo \ # ../xforms/FormPrint.lo \
../xforms/form_splash.lo \ # ../xforms/form_print.lo \
../xforms/FormTabular.lo \ # ../xforms/FormRef.lo \
../xforms/form_tabular.lo \ # ../xforms/form_ref.lo \
../xforms/FormTabularCreate.lo \ # ../xforms/FormSplash.lo \
../xforms/form_tabular_create.lo \ # ../xforms/form_splash.lo \
../xforms/FormToc.lo \ # ../xforms/FormTabular.lo \
../xforms/form_toc.lo \ # ../xforms/form_tabular.lo \
../xforms/FormUrl.lo \ # ../xforms/FormTabularCreate.lo \
../xforms/form_url.lo \ # ../xforms/form_tabular_create.lo \
../xforms/input_validators.lo \ # ../xforms/FormToc.lo \
../xforms/RadioButtonGroup.lo \ # ../xforms/form_toc.lo \
../xforms/Timeout_pimpl.lo \ # ../xforms/input_validators.lo \
../xforms/Toolbar_pimpl.lo \ # ../xforms/RadioButtonGroup.lo \
../xforms/xforms_helpers.lo
LIBS= LIBS=
LDFLAGS= $(libgnome_la_OBJADD) LDFLAGS= $(libgnome_la_OBJADD)
LYXDATADIRS = LYXDATADIRS =
@ -56,49 +67,22 @@ LYXDATADIRS =
libgnome_la_SOURCES = \ libgnome_la_SOURCES = \
Dialogs.C \ Dialogs.C \
GUIRunTime.C \ GUIRunTime.C \
FormCitation.C \
FormCitation.h \
FormCopyright.C \
FormCopyright.h \
FormError.C \
FormError.h \
FormPrint.C \
FormPrint.h \
FormRef.C \
FormRef.h \
FormUrl.C \
FormUrl.h \
FormIndex.C \
FormIndex.h \
FormToc.C \
FormToc.h \
Menubar_pimpl.C \ Menubar_pimpl.C \
Menubar_pimpl.h \ Menubar_pimpl.h \
Timeout_pimpl.C \
Timeout_pimpl.h \
gnomeBC.C \
gnomeBC.h \
gnome_helpers.h \
mainapp.C \ mainapp.C \
mainapp.h \ mainapp.h \
support.c \ support.c \
support.h \ support.h \
diaprint_callbacks.c \ pixbutton.h \
diaprint_callbacks.h \ GnomeBase.C \
diaprint_interface.c \ GnomeBase.h \
diaprint_interface.h \ FormUrl.C \
diainserturl_callbacks.c \ FormUrl.h
diainserturl_interface.c \
diainserturl_callbacks.h \
diainserturl_interface.h \
diainsertindex_callbacks.c \
diainsertindex_interface.c \
diainsertindex_callbacks.h \
diainsertindex_interface.h \
diatoc_callbacks.c \
diatoc_interface.c \
diatoc_callbacks.h \
diatoc_interface.h \
diainsertcitation_interface.c \
diainsertcitation_interface.h \
diainsertcitation_callbacks.c \
diainsertcitation_callbacks.h \
pixbutton.h
# These still have to be added. Sooner or later. ARRae-20000411 # These still have to be added. Sooner or later. ARRae-20000411
# GUI_defaults.C \ # GUI_defaults.C \

View File

@ -92,12 +92,15 @@ void Menubar::Pimpl::set(string const & menu_name)
void Menubar::Pimpl::updateAllLists() void Menubar::Pimpl::updateAllLists()
{ {
#warning Implement me! (be 20010324)
#if 0
// update lists // update lists
if (toc_.size() > 0) if (toc_.size() > 0)
{ {
vector<Buffer::TocItem> toclist = (owner_->view()->buffer()->getTocList())[Buffer::TOC_TOC]; vector<Buffer::TocItem> toclist = (owner_->view()->buffer()->getTocList())[Buffer::TOC_TOC];
updateList(&toclist, &toc_); updateList(&toclist, &toc_);
} }
#endif
} }
int const max_number_of_items = 25; int const max_number_of_items = 25;

View File

@ -0,0 +1,56 @@
/**
* \file Timeout_pimpl.C
* Copyright 2001 LyX Team
* Read COPYING
*
* \author Baruch Even
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <gnome--/main.h>
#include "Timeout_pimpl.h"
#include "debug.h"
Timeout::Pimpl::Pimpl(Timeout * owner)
: owner_(owner)
{
}
void Timeout::Pimpl::reset()
{
stop();
}
void Timeout::Pimpl::start()
{
if (conn_.connected()) {
lyxerr << "Timeout::start: already running!" << std::endl;
stop();
}
conn_ = Gnome::Main::timeout.connect(
SigC::slot(this, &Timeout::Pimpl::timeoutEvent),
owner_->timeout_ms
);
}
void Timeout::Pimpl::stop()
{
conn_.disconnect();
}
gint Timeout::Pimpl::timeoutEvent()
{
owner_->emit();
return 0; // discontinue emitting timeouts.
}

View File

@ -0,0 +1,47 @@
/**
* \file Timeout_pimpl.h
* Copyright 2001 LyX Team
* Read COPYING
*
* \author Baruch Even
*/
#ifndef TIMEOUTPIMPL_H
#define TIMEOUTPIMPL_H
#include <config.h>
#include "frontends/Timeout.h"
#include "glib.h" // for gint
#include <sigc++/signal_system.h>
#ifdef __GNUG__
#pragma interface
#endif
/**
* This class executes the callback when the timeout expires
* using Gnome mechanisms
*/
struct Timeout::Pimpl : public SigC::Object {
public:
///
Pimpl(Timeout * owner_);
/// start the timer
void start();
/// stop the timer
void stop();
/// reset
void reset();
public:
/// The timeout signal, this gets called when the timeout passed.
gint timeoutEvent();
private:
/// the owning timer
Timeout * owner_;
/// Timer connection
SigC::Connection conn_;
};
#endif

View File

@ -5,14 +5,15 @@
<name>diainserturl</name> <name>diainserturl</name>
<program_name>diainserturl</program_name> <program_name>diainserturl</program_name>
<directory></directory> <directory></directory>
<source_directory>src</source_directory> <source_directory></source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory> <pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language> <language>C</language>
<gnome_support>True</gnome_support> <gnome_support>True</gnome_support>
<gettext_support>True</gettext_support> <gettext_support>True</gettext_support>
<use_widget_names>True</use_widget_names>
<output_main_file>False</output_main_file> <output_main_file>False</output_main_file>
<output_support_files>False</output_support_files>
<output_build_files>False</output_build_files> <output_build_files>False</output_build_files>
<gnome_help_support>True</gnome_help_support>
<main_source_file>diainserturl_interface.c</main_source_file> <main_source_file>diainserturl_interface.c</main_source_file>
<main_header_file>diainserturl_interface.h</main_header_file> <main_header_file>diainserturl_interface.h</main_header_file>
<handler_source_file>diainserturl_callbacks.c</handler_source_file> <handler_source_file>diainserturl_callbacks.c</handler_source_file>
@ -23,6 +24,7 @@
<class>GnomeDialog</class> <class>GnomeDialog</class>
<name>DiaInsertUrl</name> <name>DiaInsertUrl</name>
<border_width>2</border_width> <border_width>2</border_width>
<visible>False</visible>
<title>Insert URL</title> <title>Insert URL</title>
<type>GTK_WINDOW_DIALOG</type> <type>GTK_WINDOW_DIALOG</type>
<position>GTK_WIN_POS_NONE</position> <position>GTK_WIN_POS_NONE</position>
@ -31,7 +33,7 @@
<allow_grow>True</allow_grow> <allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink> <auto_shrink>False</auto_shrink>
<auto_close>False</auto_close> <auto_close>False</auto_close>
<hide_on_close>False</hide_on_close> <hide_on_close>True</hide_on_close>
<widget> <widget>
<class>GtkVBox</class> <class>GtkVBox</class>
@ -49,7 +51,7 @@
<class>GtkHButtonBox</class> <class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name> <child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area1</name> <name>dialog-action_area1</name>
<layout_style>GTK_BUTTONBOX_END</layout_style> <layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style>
<spacing>8</spacing> <spacing>8</spacing>
<child_min_width>85</child_min_width> <child_min_width>85</child_min_width>
<child_min_height>27</child_min_height> <child_min_height>27</child_min_height>
@ -62,6 +64,15 @@
<pack>GTK_PACK_END</pack> <pack>GTK_PACK_END</pack>
</child> </child>
<widget>
<class>GtkButton</class>
<name>button_restore</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<label>Restore</label>
<stock_pixmap>GNOME_STOCK_PIXMAP_UNDO</stock_pixmap>
</widget>
<widget> <widget>
<class>GtkButton</class> <class>GtkButton</class>
<name>button_ok</name> <name>button_ok</name>
@ -70,10 +81,19 @@
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button> <stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget> </widget>
<widget>
<class>GtkButton</class>
<name>button_apply</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
</widget>
<widget> <widget>
<class>GtkButton</class> <class>GtkButton</class>
<name>button_cancel</name> <name>button_cancel</name>
<can_default>True</can_default> <can_default>True</can_default>
<has_default>True</has_default>
<can_focus>True</can_focus> <can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button> <stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget> </widget>
@ -107,13 +127,14 @@
<widget> <widget>
<class>GtkLabel</class> <class>GtkLabel</class>
<name>label2</name> <name>label2</name>
<label>Name</label> <label>_Name</label>
<justify>GTK_JUSTIFY_LEFT</justify> <justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap> <wrap>False</wrap>
<xalign>0.5</xalign> <xalign>0.5</xalign>
<yalign>0.5</yalign> <yalign>0.5</yalign>
<xpad>0</xpad> <xpad>0</xpad>
<ypad>0</ypad> <ypad>0</ypad>
<default_focus_target>name</default_focus_target>
<child> <child>
<left_attach>0</left_attach> <left_attach>0</left_attach>
<right_attach>1</right_attach> <right_attach>1</right_attach>
@ -133,13 +154,14 @@
<widget> <widget>
<class>GtkLabel</class> <class>GtkLabel</class>
<name>label1</name> <name>label1</name>
<label>URL</label> <label>_URL</label>
<justify>GTK_JUSTIFY_LEFT</justify> <justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap> <wrap>False</wrap>
<xalign>0.5</xalign> <xalign>0.5</xalign>
<yalign>0.5</yalign> <yalign>0.5</yalign>
<xpad>0</xpad> <xpad>0</xpad>
<ypad>0</ypad> <ypad>0</ypad>
<default_focus_target>url</default_focus_target>
<child> <child>
<left_attach>0</left_attach> <left_attach>0</left_attach>
<right_attach>1</right_attach> <right_attach>1</right_attach>
@ -158,7 +180,7 @@
<widget> <widget>
<class>GnomeEntry</class> <class>GnomeEntry</class>
<name>url</name> <name>url1</name>
<border_width>1</border_width> <border_width>1</border_width>
<history_id>diainserturl_url</history_id> <history_id>diainserturl_url</history_id>
<max_saved>10</max_saved> <max_saved>10</max_saved>
@ -180,7 +202,7 @@
<widget> <widget>
<class>GtkEntry</class> <class>GtkEntry</class>
<child_name>GnomeEntry:entry</child_name> <child_name>GnomeEntry:entry</child_name>
<name>combo-entry1</name> <name>url</name>
<can_default>True</can_default> <can_default>True</can_default>
<has_default>True</has_default> <has_default>True</has_default>
<can_focus>True</can_focus> <can_focus>True</can_focus>
@ -194,7 +216,7 @@
<widget> <widget>
<class>GnomeEntry</class> <class>GnomeEntry</class>
<name>name</name> <name>name1</name>
<border_width>1</border_width> <border_width>1</border_width>
<history_id>diainserturl_name</history_id> <history_id>diainserturl_name</history_id>
<max_saved>10</max_saved> <max_saved>10</max_saved>
@ -216,7 +238,7 @@
<widget> <widget>
<class>GtkEntry</class> <class>GtkEntry</class>
<child_name>GnomeEntry:entry</child_name> <child_name>GnomeEntry:entry</child_name>
<name>combo-entry2</name> <name>name</name>
<can_focus>True</can_focus> <can_focus>True</can_focus>
<editable>True</editable> <editable>True</editable>
<text_visible>True</text_visible> <text_visible>True</text_visible>

View File

@ -0,0 +1,54 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "gnomeBC.h"
#include "gtk--/widget.h"
#include "gtk--/button.h"
gnomeBC::gnomeBC(string const & cancel, string const & close)
: ButtonControllerBase(cancel, close),
okay_(0), apply_(0), cancel_(0), undo_all_(0)
{}
void gnomeBC::setSensitive(Gtk::Button * btn, ButtonPolicy::Button id)
{
if (btn) {
bool const enabled = bp().buttonStatus(id);
btn->set_sensitive(enabled);
}
}
void gnomeBC::refresh()
{
setSensitive(okay_, ButtonPolicy::OKAY);
setSensitive(apply_, ButtonPolicy::APPLY);
setSensitive(undo_all_, ButtonPolicy::UNDO_ALL);
#warning Handle the cancel button correctly! (be 20010327)
#if 0
if (cancel_) {
bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL);
// if (enabled)
// Change label to cancel_label_
// else
// Change label to close_label_
//Need to adapt it somehow since we use stock Gnome buttons.
}
#endif
if (!read_only_.empty()) {
bool enable = true;
if (bp().isReadOnly()) enable = false;
WidgetList::const_iterator end = read_only_.end();
for (WidgetList::const_iterator iter = read_only_.begin();
iter != end; ++iter) {
(*iter)->set_sensitive(enable);
}
}
}

View File

@ -0,0 +1,81 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995-2000 The LyX Team.
*
* ======================================================
*
* Author: Baruch Even <baruch@lyx.org>
*/
#ifndef GNOMEBC_H
#define GNOMEBC_H
#include "ButtonController.h"
#include <list>
#ifdef __GNUG__
#pragma interface
#endif
namespace Gtk {
class Button;
class Widget;
}
class gnomeBC : public ButtonControllerBase
{
public:
///
gnomeBC(string const & cancel, string const & close);
/* Initialise Button Functions */
/// Call refresh() when finished setting the buttons.
void setOK(Gtk::Button * obj) {
okay_ = obj;
}
///
void setApply(Gtk::Button * obj) {
apply_ = obj;
}
///
void setCancel(Gtk::Button * obj) {
cancel_ = obj;
}
///
void setUndoAll(Gtk::Button * obj) {
undo_all_ = obj;
}
///
void addReadOnly(Gtk::Widget * obj) {
read_only_.push_front(obj);
}
///
void eraseReadOnly() {
read_only_.clear();
}
/* Action Functions */
/// force a refresh of the buttons
virtual void refresh();
private:
/// Updates the button sensitivity (enabled/disabled)
void setSensitive(Gtk::Button * btn, ButtonPolicy::Button id);
///
Gtk::Button * okay_;
///
Gtk::Button * apply_;
///
Gtk::Button * cancel_;
///
Gtk::Button * undo_all_;
/// List of items to be deactivated when in one of the read-only states
typedef std::list<Gtk::Widget *> WidgetList;
WidgetList read_only_;
};
#endif // GNOMEBC_H

View File

@ -0,0 +1,36 @@
// -*- C++ -*-
/* This file is part of
* =================================================
*
* LyX, The Document Processor
* Copyright 1995-2000 The LyX Team.
*
* ================================================= */
#ifndef GNOME_HELPERS_H
#define GNOME_HELPERS_H
#ifdef __GNUG__
#pragma interface
#endif
#include "debug.h"
#include <glade/glade-xml.h>
#include <glib.h>
// Glade Helper Function.
template<class T>
T* getWidgetPtr(GladeXML* xml, const char* name)
{
T* result = static_cast<T*>(Gtk::wrap_auto((GtkObject*)glade_xml_get_widget(xml, name)));
if (result == NULL)
{
lyxerr << "** ERROR **: unable to load widget: " << name << endl;
g_assert(result != NULL);
}
return result;
}
#endif