+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>
* several files: remove CXX_WORKING_NAMESPACES
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1995-2001 The LyX Team.
+ *
+ * ======================================================
+ */
+
#include <config.h>
-#include FORMS_H_LOCATION
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
#include "Dialogs.h"
+
+#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"
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-// temporary till ported
-extern void ShowCredits();
+#include "FormMinipage.h"
+*/
// Signal enabling all visible popups to be redrawn if so desired.
// E.g., when the GUI colours have been remapped.
-Signal0<void> Dialogs::redrawGUI;
+SigC::Signal0<void> Dialogs::redrawGUI;
Dialogs::Dialogs(LyXView * lv)
{
- dialogs_.push_back(new FormCitation(lv, this));
- dialogs_.push_back(new FormCopyright(lv, this));
- dialogs_.push_back(new FormDocument(lv, this));
- dialogs_.push_back(new FormError(lv, this));
- dialogs_.push_back(new FormGraphics(lv, this));
- dialogs_.push_back(new FormIndex(lv, this));
- dialogs_.push_back(new FormPreferences(lv, this));
- dialogs_.push_back(new FormParagraph(lv, this));
- dialogs_.push_back(new FormPrint(lv, this));
- dialogs_.push_back(new FormRef(lv, this));
- dialogs_.push_back(new FormSplash(lv, this));
- dialogs_.push_back(new FormTabular(lv, this));
- dialogs_.push_back(new FormToc(lv, this));
- dialogs_.push_back(new FormUrl(lv, this));
+ add(new GUIUrl<FormUrl, gnomeBC>(*lv, *this));
+/*
+ splash_.reset(new FormSplash(lv, this));
+
+ add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
+ add(new GUIBibtex<FormBibtex, xformsBC>(*lv, *this));
+ add(new GUICharacter<FormCharacter, xformsBC>(*lv, *this));
+ //add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
+ //add(new GUICopyright<FormCopyright, xformsBC>(*lv, *this));
+ add(new GUICredits<FormCredits, xformsBC>(*lv, *this));
+ add(new GUILog<FormLog, xformsBC>(*lv, *this));
+ add(new GUIVCLog<FormVCLog, xformsBC>(*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
// dialogs by a simple connection here.
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?
/// the nitty-griity. What is modified and passed back
InsetCommandParams params;
/// Update connection.
- Connection u_;
+ SigC::Connection u_;
/// Hide connection.
- Connection h_;
+ SigC::Connection h_;
/// inset::hide connection.
- Connection ih_;
+ SigC::Connection ih_;
/// Real GUI implementation.
Gtk::Container * dialog_;
*/
Dialogs * d_;
/// Hide connection.
- Connection h_;
+ SigC::Connection h_;
/// Destroy connection.
- Connection destroy_;
+ SigC::Connection destroy_;
};
#endif
/// pointer to the inset passed through showInset (if any)
InsetError * inset_;
/// Update connection.
- Connection u_;
+ SigC::Connection u_;
/// Hide connection.
- Connection h_;
+ SigC::Connection h_;
/// inset::hide connection.
- Connection ih_;
+ SigC::Connection ih_;
/// Real GUI implementation.
Gtk::Container * dialog_;
/// the nitty-griity. What is modified and passed back
InsetCommandParams params;
/// Update connection.
- Connection u_;
+ SigC::Connection u_;
/// Hide connection.
- Connection h_;
+ SigC::Connection h_;
/// inset::hide connection.
- Connection ih_;
+ SigC::Connection ih_;
/// Real GUI implementation.
Gtk::Container * dialog_;
+// THIS FILE IS NOT IN USE DUE TO API CHANGES.
+#include "frontends/xforms/FormToc.h"
+#if 0
// -*- C++ -*-
/* This file is part of
* ======================================================
};
#endif
+#endif
// -*- C++ -*-
/* This file is part of
- * ======================================================
+ * =================================================
+ *
+ * LyX, The Document Processor
+ * Copyright 1995-2000 The LyX Team.
*
- * LyX, The Document Processor
+ * =================================================
*
- * Copyright 2000 The LyX Team.
- *
- * ======================================================
+ * \author Baruch Even
*/
-#include <config.h>
-
#ifdef __GNUG__
#pragma implementation
#endif
+#include <config.h>
-#include "gettext.h"
-#include "Dialogs.h"
+#include "gnomeBC.h"
#include "FormUrl.h"
-#include "LyXView.h"
-#include "buffer.h"
-#include "lyxfunc.h"
-#include <gtk--/label.h>
-#include <gtk--/table.h>
-#include <gtk--/box.h>
-#include <gtk--/buttonbox.h>
-#include <gtk--/base.h>
-#include <gtk--/separator.h>
+#include <gnome--/dialog.h>
+#include <gtk--/entry.h>
+#include <gtk--/checkbutton.h>
-// temporary solution for LyXView
-#include "mainapp.h"
-extern GLyxAppWin * mainAppWin;
+FormUrl::FormUrl(ControlUrl & c)
+ : FormCB<ControlUrl>(c, "diainserturl.glade", "DiaInsertUrl")
+ , dialog_(0)
+{}
-namespace {
-// configuration keys
-string const CONF_ENTRY_URL("FormUrl_url");
-string const CONF_ENTRY_NAME("FormUrl_name");
+FormUrl::~FormUrl()
+{
+ // 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();
+}
-} // namespace anon
+
+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));
+ apply_btn()->clicked.connect(SigC::slot(this, &FormUrl::ApplyClicked));
+ restore_btn()->clicked.connect(SigC::slot(this, &FormUrl::RestoreClicked));
+
+ // Manage the buttons state
+ 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());
+}
-FormUrl::FormUrl(LyXView * lv, Dialogs * d)
- : lv_(lv), d_(d), inset_(0), u_(0), h_(0), ih_(0), dialog_(0)
+void FormUrl::connect_signals()
{
- // 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));
+ // Get notifications on input change
+ slot_url_ = url()->changed.connect(SigC::slot(this, &FormUrl::InputChanged));
+ slot_name_ = name()->changed.connect(SigC::slot(this, &FormUrl::InputChanged));
+ slot_html_ = html()->toggled.connect(SigC::slot(this, &FormUrl::InputChanged));
}
-FormUrl::~FormUrl()
+void FormUrl::disconnect_signals()
{
- hide();
+ slot_url_.disconnect();
+ slot_name_.disconnect();
+ slot_html_.disconnect();
}
-void FormUrl::showInset( InsetCommand * const inset )
+
+void FormUrl::show()
{
- if( dialog_!=0 || inset == 0 ) return;
-
- inset_ = inset;
- ih_ = inset_->hideDialog.connect(slot(this, &FormUrl::hide));
-
- params = inset->params();
- show();
+ if (!dialog_)
+ build();
+
+ update();
+ dialog_->show();
}
-void FormUrl::createInset( string const & arg )
+void FormUrl::hide()
{
- if( dialog_!=0 ) return;
-
- params.setFromString( arg );
- show();
+ dialog_->hide();
}
-void FormUrl::show()
+
+void FormUrl::apply()
{
- if (!dialog_)
- {
- using namespace Gtk::Box_Helpers;
-
- Gtk::Label * label;
- Gtk::Table * table = manage( new Gtk::Table(2, 2, FALSE) );
- 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);
- }
+ controller().params().setContents(url()->get_text());
+ controller().params().setOptions(name()->get_text());
+
+ string cmdname("url");
+ if (html()->get_active())
+ cmdname = "htmlurl";
+
+ controller().params().setCmdName(cmdname);
}
-void FormUrl::hide()
+
+void FormUrl::update()
{
- if (dialog_!=0) mainAppWin->remove_action();
+ // Disconnect signals so we dont trigger the input changed state.
+ // This avoids the problem of having the buttons enabled when the dialog
+ // starts.
+ 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();
}
-void FormUrl::free()
+
+bool FormUrl::validate() const
{
- if (dialog_!=0)
- {
- dialog_ = 0;
- u_.disconnect();
- h_.disconnect();
- inset_ = 0;
- ih_.disconnect();
- }
+ // Always valid! (not really so, needs fixing).
+ return true;
}
-void FormUrl::apply()
+
+Gnome::Dialog * FormUrl::dialog()
+{
+ 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
{
- if( lv_->buffer()->isReadonly() ) return;
-
- params.setContents( url_->get_entry()->get_text() );
- params.setOptions( name_->get_entry()->get_text() );
-
- if (html_type_->get_active())
- params.setCmdName("htmlurl");
- else
- params.setCmdName("url");
-
- if( inset_ != 0 )
- {
- // Only update if contents have changed
- if( params != inset_->params() ) {
- inset_->setParams( params );
- lv_->view()->updateInset( inset_, true );
- }
- }
- else
- {
- lv_->getLyXFunc()->Dispatch( LFUN_INSERT_URL,
- params.getAsString() );
- }
-
- // save history
- url_->save_history();
- name_->save_history();
-
- // hide the dialog
- hide();
+ return getWidget<Gtk::Button>("button_restore");
}
// -*- C++ -*-
/* This file is part of
- * ======================================================
+ * =================================================
+ *
+ * LyX, The Document Processor
+ * Copyright 1995 Matthias Ettrich.
+ * Copyright 1995-2000 The LyX Team.
*
- * LyX, The Document Processor
+ * =================================================
*
- * Copyright 2000 The LyX Team.
- *
- * ======================================================
- */
+ * \author Baruch Even
+ * */
#ifndef FORMURL_H
#define FORMURL_H
#pragma interface
#endif
-#include "DialogBase.h"
-#include "LString.h"
-#include "insets/insetcommand.h"
+#include "ControlUrl.h"
+#include "GnomeBase.h"
+
+//#include <gnome--/dialog.h>
+namespace Gnome {
+class Dialog;
+}
-#include <gtk--/container.h>
-#include <gtk--/checkbutton.h>
-#include <gnome--/entry.h>
-#include <gtk--/button.h>
+namespace Gtk {
+class Button;
+class CheckButton;
+class Entry;
+}
-/** This class provides an Gnome implementation of the FormUrl Dialog.
+/**
+ * This class implements the dialog to insert/modify urls.
*/
-class FormUrl : public DialogBase {
+class FormUrl : public FormCB<ControlUrl> {
public:
- /**@name Constructors and Destructors */
- //@{
- ///
- FormUrl(LyXView *, Dialogs *);
- ///
- ~FormUrl();
- //@}
-
+ ///
+ FormUrl(ControlUrl & c);
+ ///
+ ~FormUrl();
+
+ void apply();
+ void hide();
+ void show();
+ void update();
+
private:
- /// Slot launching dialog to (possibly) create a new inset
- void createInset( string const & );
- /// Slot launching dialog to an existing inset
- void showInset( InsetCommand * const );
-
- /// Update dialog before showing it
- virtual void update() { }
- 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?
- We could modify Dialogs to have a visible LyXFunc* instead and
- save a couple of bytes per dialog.
- */
- 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_;
+ /// Build the dialog
+ void build();
+
+ /// Returns true if the dialog input is in a valid state.
+ bool validate() const;
- /// Real GUI implementation.
- Gtk::Container * dialog_;
+ /// Do the connection of signals
+ void connect_signals();
+ /// Disconnect the signals.
+ void disconnect_signals();
- Gtk::CheckButton * html_type_;
+ void OKClicked() { OKButton(); }
+ void CancelClicked() { CancelButton(); }
+ void ApplyClicked() { ApplyButton(); }
+ void RestoreClicked() { RestoreButton(); }
+ void InputChanged() { bc().valid(validate()); }
+
+ /// 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_;
- Gnome::Entry * name_;
+ // Hold the dialog.
+ //boost::shared_ptr<Gnome::Dialog> dialog_;
+ Gnome::Dialog * dialog_;
- Gtk::Button * b_ok;
- Gtk::Button * b_cancel;
+ /// Keeps the connection to the input validator.
+ SigC::Connection slot_url_;
+ SigC::Connection slot_name_;
+ SigC::Connection slot_html_;
};
#endif
#include <gnome--/main.h>
#include "mainapp.h"
+#include <glade/glade.h>
using std::endl;
static string app_id(PACKAGE);
static string app_version(VERSION);
static Gnome::Main a(app_id, app_version, 1, argv);
+ glade_gnome_init(); // Initialize the glade library.
static GLyxAppWin appWin;
mainAppWin = &appWin;
--- /dev/null
+// -*- 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());
+}
--- /dev/null
+// -*- 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
noinst_LTLIBRARIES = libgnome.la
BOOST_INCLUDES = -I$(top_srcdir)/boost
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)
+
libgnome_la_OBJADD = \
- ../xforms/ButtonController.lo \
- ../xforms/Color.lo \
+ ../xforms/xforms_helpers.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/FormFiledialog.lo \
- ../xforms/form_filedialog.lo \
- ../xforms/FormBase.lo \
- ../xforms/FormCitation.lo \
- ../xforms/form_citation.lo \
- ../xforms/FormCopyright.lo \
- ../xforms/form_copyright.lo \
- ../xforms/FormDocument.lo \
- ../xforms/form_document.lo \
- ../xforms/FormError.lo \
- ../xforms/form_error.lo \
- ../xforms/FormGraphics.lo \
- ../xforms/form_graphics.lo \
- ../xforms/FormIndex.lo \
- ../xforms/form_index.lo \
- ../xforms/FormInset.lo \
- ../xforms/FormParagraph.lo \
- ../xforms/form_paragraph.lo \
- ../xforms/FormPreferences.lo \
- ../xforms/form_preferences.lo \
- ../xforms/FormPrint.lo \
- ../xforms/form_print.lo \
- ../xforms/FormRef.lo \
- ../xforms/form_ref.lo \
- ../xforms/FormSplash.lo \
- ../xforms/form_splash.lo \
- ../xforms/FormTabular.lo \
- ../xforms/form_tabular.lo \
- ../xforms/FormTabularCreate.lo \
- ../xforms/form_tabular_create.lo \
- ../xforms/FormToc.lo \
- ../xforms/form_toc.lo \
- ../xforms/FormUrl.lo \
- ../xforms/form_url.lo \
- ../xforms/input_validators.lo \
- ../xforms/RadioButtonGroup.lo \
- ../xforms/Timeout_pimpl.lo \
- ../xforms/Toolbar_pimpl.lo \
- ../xforms/xforms_helpers.lo
+ ../xforms/form_filedialog.lo
+# ../xforms/Timeout_pimpl.lo \
+# ../xforms/Color.lo \
+# ../xforms/FormFiledialog.lo \
+# ../xforms/form_filedialog.lo \
+# ../xforms/FormBase.lo \
+# ../xforms/FormCitation.lo \
+# ../xforms/form_citation.lo \
+# ../xforms/FormCopyright.lo \
+# ../xforms/form_copyright.lo \
+# ../xforms/FormDocument.lo \
+# ../xforms/form_document.lo \
+# ../xforms/FormError.lo \
+# ../xforms/form_error.lo \
+# ../xforms/FormGraphics.lo \
+# ../xforms/form_graphics.lo \
+# ../xforms/FormIndex.lo \
+# ../xforms/form_index.lo \
+# ../xforms/FormInset.lo \
+# ../xforms/FormParagraph.lo \
+# ../xforms/form_paragraph.lo \
+# ../xforms/FormPreferences.lo \
+# ../xforms/form_preferences.lo \
+# ../xforms/FormPrint.lo \
+# ../xforms/form_print.lo \
+# ../xforms/FormRef.lo \
+# ../xforms/form_ref.lo \
+# ../xforms/FormSplash.lo \
+# ../xforms/form_splash.lo \
+# ../xforms/FormTabular.lo \
+# ../xforms/form_tabular.lo \
+# ../xforms/FormTabularCreate.lo \
+# ../xforms/form_tabular_create.lo \
+# ../xforms/FormToc.lo \
+# ../xforms/form_toc.lo \
+# ../xforms/input_validators.lo \
+# ../xforms/RadioButtonGroup.lo \
+
LIBS=
LDFLAGS= $(libgnome_la_OBJADD)
LYXDATADIRS =
libgnome_la_SOURCES = \
Dialogs.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.h \
+ Timeout_pimpl.C \
+ Timeout_pimpl.h \
+ gnomeBC.C \
+ gnomeBC.h \
+ gnome_helpers.h \
mainapp.C \
mainapp.h \
support.c \
support.h \
- diaprint_callbacks.c \
- diaprint_callbacks.h \
- diaprint_interface.c \
- diaprint_interface.h \
- diainserturl_callbacks.c \
- 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
+ pixbutton.h \
+ GnomeBase.C \
+ GnomeBase.h \
+ FormUrl.C \
+ FormUrl.h
# These still have to be added. Sooner or later. ARRae-20000411
# GUI_defaults.C \
void Menubar::Pimpl::updateAllLists()
{
+#warning Implement me! (be 20010324)
+#if 0
// update lists
if (toc_.size() > 0)
{
vector<Buffer::TocItem> toclist = (owner_->view()->buffer()->getTocList())[Buffer::TOC_TOC];
updateList(&toclist, &toc_);
}
+#endif
}
int const max_number_of_items = 25;
--- /dev/null
+/**
+ * \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.
+}
--- /dev/null
+/**
+ * \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
<name>diainserturl</name>
<program_name>diainserturl</program_name>
<directory></directory>
- <source_directory>src</source_directory>
+ <source_directory></source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
+ <use_widget_names>True</use_widget_names>
<output_main_file>False</output_main_file>
- <output_support_files>False</output_support_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_header_file>diainserturl_interface.h</main_header_file>
<handler_source_file>diainserturl_callbacks.c</handler_source_file>
<class>GnomeDialog</class>
<name>DiaInsertUrl</name>
<border_width>2</border_width>
+ <visible>False</visible>
<title>Insert URL</title>
<type>GTK_WINDOW_DIALOG</type>
<position>GTK_WIN_POS_NONE</position>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
- <hide_on_close>False</hide_on_close>
+ <hide_on_close>True</hide_on_close>
<widget>
<class>GtkVBox</class>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area1</name>
- <layout_style>GTK_BUTTONBOX_END</layout_style>
+ <layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<pack>GTK_PACK_END</pack>
</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>
<class>GtkButton</class>
<name>button_ok</name>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</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>
<class>GtkButton</class>
<name>button_cancel</name>
<can_default>True</can_default>
+ <has_default>True</has_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
<widget>
<class>GtkLabel</class>
<name>label2</name>
- <label>Name</label>
+ <label>_Name</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
+ <default_focus_target>name</default_focus_target>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<widget>
<class>GtkLabel</class>
<name>label1</name>
- <label>URL</label>
+ <label>_URL</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
+ <default_focus_target>url</default_focus_target>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<widget>
<class>GnomeEntry</class>
- <name>url</name>
+ <name>url1</name>
<border_width>1</border_width>
<history_id>diainserturl_url</history_id>
<max_saved>10</max_saved>
<widget>
<class>GtkEntry</class>
<child_name>GnomeEntry:entry</child_name>
- <name>combo-entry1</name>
+ <name>url</name>
<can_default>True</can_default>
<has_default>True</has_default>
<can_focus>True</can_focus>
<widget>
<class>GnomeEntry</class>
- <name>name</name>
+ <name>name1</name>
<border_width>1</border_width>
<history_id>diainserturl_name</history_id>
<max_saved>10</max_saved>
<widget>
<class>GtkEntry</class>
<child_name>GnomeEntry:entry</child_name>
- <name>combo-entry2</name>
+ <name>name</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
--- /dev/null
+#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);
+ }
+ }
+}
--- /dev/null
+// -*- 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
--- /dev/null
+// -*- 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