]> git.lyx.org Git - features.git/commitdiff
Fixed compilation problems.
authorBaruch Even <baruch@lyx.org>
Wed, 28 Mar 2001 11:14:05 +0000 (11:14 +0000)
committerBaruch Even <baruch@lyx.org>
Wed, 28 Mar 2001 11:14:05 +0000 (11:14 +0000)
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

20 files changed:
src/frontends/gnome/ChangeLog
src/frontends/gnome/Dialogs.C
src/frontends/gnome/FormCitation.h
src/frontends/gnome/FormCopyright.h
src/frontends/gnome/FormError.h
src/frontends/gnome/FormIndex.h
src/frontends/gnome/FormToc.h
src/frontends/gnome/FormUrl.C
src/frontends/gnome/FormUrl.h
src/frontends/gnome/GUIRunTime.C
src/frontends/gnome/GnomeBase.C [new file with mode: 0644]
src/frontends/gnome/GnomeBase.h [new file with mode: 0644]
src/frontends/gnome/Makefile.am
src/frontends/gnome/Menubar_pimpl.C
src/frontends/gnome/Timeout_pimpl.C [new file with mode: 0644]
src/frontends/gnome/Timeout_pimpl.h [new file with mode: 0644]
src/frontends/gnome/dialogs/diainserturl.glade
src/frontends/gnome/gnomeBC.C [new file with mode: 0644]
src/frontends/gnome/gnomeBC.h [new file with mode: 0644]
src/frontends/gnome/gnome_helpers.h [new file with mode: 0644]

index 2748fdedb4e53bab95efcb1485ef0e4dfc292efd..450d5ca8d2131a83b4214c567f335da68807dd6f 100644 (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>
 
        * several files: remove CXX_WORKING_NAMESPACES
index 7247dcb39c239e5234e746944485229c10d01d0c..210f26804df7319ef0c252ceae8f4b63aaa4a820 100644 (file)
+/* 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?
index d0b3ce0c70bd4c20adcd13808a05e94865b661be..48b7a8b1ca7662f21b4158f39ff402d008f8bb92 100644 (file)
@@ -125,11 +125,11 @@ private:
   /// 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_;
index 961559d9cac2718c4e22df1548e039721a337035..2e5489e21a81ac782e88d2c5ec0ac05dc37ac097 100644 (file)
@@ -49,9 +49,9 @@ private:
        */
        Dialogs * d_;
        /// Hide connection.
-       Connection h_;
+       SigC::Connection h_;
        /// Destroy connection.
-       Connection destroy_;
+       SigC::Connection destroy_;
 };
 
 #endif
index 5a3d9c82cd72a7a280ea853d3b70d214a4fa53aa..ee39e17f64188ef7d735cbe2b674ba14fe1bca65 100644 (file)
@@ -58,11 +58,11 @@ private:
   /// 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_;
index 540ed7377b5725773d3c5cc34e96e6f0859cea10..28132b648b49ba4a28a61405dd052c931d42404f 100644 (file)
@@ -64,11 +64,11 @@ private:
   /// 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_;
index 68f73e678cc0a7f0917681e66dd8017b084cd198..b03363a1330e7480559c27a9e8f4775dd472bd54 100644 (file)
@@ -1,3 +1,6 @@
+// THIS FILE IS NOT IN USE DUE TO API CHANGES.
+#include "frontends/xforms/FormToc.h"
+#if 0
 // -*- C++ -*-
 /* This file is part of
  * ====================================================== 
@@ -84,3 +87,4 @@ private:
 };
 
 #endif
+#endif
index d26e96faa0025bb9ddf8a6944563f05ed7c80e4b..0b4ea0fd08fd26baf3d161a5545bfea40e054b14 100644 (file)
 // -*- 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");
 }
index 6c8aeb221c72ac77231cb4ecb8e0468188368d42..eeca5b50a77fdb4db1d56a9533105995f68ea841 100644 (file)
@@ -1,13 +1,15 @@
 // -*- 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
index d87fee67b7040dd34aa0b4a385d5fc9b5f3410e2..b650a37c0ca1fcd467dcb58cab8378baa5818034 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <gnome--/main.h>
 #include "mainapp.h"
+#include <glade/glade.h>
 
 using std::endl;
 
@@ -73,6 +74,7 @@ int GUIRunTime::initApplication(int, char * argv[])
        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;
 
diff --git a/src/frontends/gnome/GnomeBase.C b/src/frontends/gnome/GnomeBase.C
new file mode 100644 (file)
index 0000000..631d5f2
--- /dev/null
@@ -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());
+}
diff --git a/src/frontends/gnome/GnomeBase.h b/src/frontends/gnome/GnomeBase.h
new file mode 100644 (file)
index 0000000..d982e8b
--- /dev/null
@@ -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
index 5789ec57511fa4268789516290c86f8b3bafea71..9789632a9c9ff9a8b9123a44eafe42a122e40e31 100644 (file)
@@ -4,51 +4,62 @@ MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
 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 = 
@@ -56,49 +67,22 @@ 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 \
index 4dbebc6471e215f0e33f710bb6e773cc7ed457b0..ff30401f8a8d6c48c72e6aec5baa78c761e5999c 100644 (file)
@@ -92,12 +92,15 @@ void Menubar::Pimpl::set(string const & menu_name)
 
 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;
diff --git a/src/frontends/gnome/Timeout_pimpl.C b/src/frontends/gnome/Timeout_pimpl.C
new file mode 100644 (file)
index 0000000..ba31cc2
--- /dev/null
@@ -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.
+}
diff --git a/src/frontends/gnome/Timeout_pimpl.h b/src/frontends/gnome/Timeout_pimpl.h
new file mode 100644 (file)
index 0000000..92308e2
--- /dev/null
@@ -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
index 5c12b415dfc9cb4fdf23d615c11ee90df6887934..f29a0498a4c73c39f940073a6bc747dc0dcc6c8b 100644 (file)
@@ -5,14 +5,15 @@
   <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>
@@ -23,6 +24,7 @@
   <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>
@@ -31,7 +33,7 @@
   <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>
@@ -49,7 +51,7 @@
       <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>
diff --git a/src/frontends/gnome/gnomeBC.C b/src/frontends/gnome/gnomeBC.C
new file mode 100644 (file)
index 0000000..76b88e9
--- /dev/null
@@ -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);
+               }
+       }
+}
diff --git a/src/frontends/gnome/gnomeBC.h b/src/frontends/gnome/gnomeBC.h
new file mode 100644 (file)
index 0000000..8f0524e
--- /dev/null
@@ -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
diff --git a/src/frontends/gnome/gnome_helpers.h b/src/frontends/gnome/gnome_helpers.h
new file mode 100644 (file)
index 0000000..c67ef97
--- /dev/null
@@ -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