]> git.lyx.org Git - features.git/commitdiff
Fixes to get it to compile after the latest ButtonController changes.
authorBaruch Even <baruch@lyx.org>
Fri, 30 Mar 2001 18:49:10 +0000 (18:49 +0000)
committerBaruch Even <baruch@lyx.org>
Fri, 30 Mar 2001 18:49:10 +0000 (18:49 +0000)
Refactoring of the dialogs into GnomeBase to remove common code.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1862 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/gnome/ChangeLog
src/frontends/gnome/FormCredits.C
src/frontends/gnome/FormCredits.h
src/frontends/gnome/FormUrl.C
src/frontends/gnome/FormUrl.h
src/frontends/gnome/GnomeBase.C
src/frontends/gnome/GnomeBase.h
src/frontends/gnome/gnomeBC.C
src/frontends/gnome/gnomeBC.h
src/frontends/gnome/gnome_helpers.h

index ca4ff4d86c88f3a28198de70d2d3bb1a385d1126..b69bb20c67535475f5419b06fd0f0ee2ea348f03 100644 (file)
@@ -1,3 +1,14 @@
+2001-03-30  Baruch Even  <baruch@lyx.org>
+
+       * GnomeBase.[Ch]: Added the dialog as a responsibility.
+
+       * FormUrl.[Ch]: Changed accordingly.
+       * FormCredits.[Ch]: ditto.
+
+       * gnomeBC.[Ch]: Fixed to get it to compile.
+
+       * gnome_helpers.h: Changed declaration from const char * to char const *
+
 2001-03-30  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * GnomeBase.[Ch]: changed ControlBase to ControlButton.
index 9f693acc9f152d28f9e07e851f2007e66039723a..f40f7ae948b644d4a7b27fba60d0c0721530c1cf 100644 (file)
 #include "gnomeBC.h"
 #include "FormCredits.h"
 
-#include <gnome--/dialog.h>
 #include <gtk--/button.h>
 #include <gtk--/text.h>
 
 FormCredits::FormCredits(ControlCredits & c)
        : FormCB<ControlCredits>(c, "diahelpcredits.glade", "DiaHelpCredits")
-       , dialog_(0)
 {
-
-}
-
-
-FormCredits::~FormCredits()
-{
-       //dialog_->destroy();
 }
 
 
 void FormCredits::build()
 {
-       dialog_ = dialog();
-
        // It is better to show an OK button, but the policy require that we
-       // got a click on "Cancel"
+       // get a click on "Cancel"
        ok()->clicked.connect(SigC::slot(this, &FormCredits::CancelClicked));
 
        std::stringstream ss;
@@ -50,37 +39,6 @@ void FormCredits::build()
 }
 
 
-void FormCredits::show()
-{
-       if (!dialog_)
-               build();
-       
-       update();
-       dialog_->show();
-}
-
-
-void FormCredits::hide()
-{
-       dialog_->hide();
-}
-
-
-void FormCredits::apply()
-{
-}
-
-
-void FormCredits::update()
-{
-}
-
-
-Gnome::Dialog * FormCredits::dialog()
-{
-       return getWidget<Gnome::Dialog>("DiaHelpCredits");
-}
-
 Gtk::Text * FormCredits::text()
 {
        return getWidget<Gtk::Text>("credits_text");
index b924ff1053976cc893b55e4ba1ff166f46341b8b..b80a3ebf93cdb6a2a2e9c6357d49cb0556f83083 100644 (file)
 #include "ControlCredits.h"
 #include "GnomeBase.h"
 
-namespace Gnome {
-class Dialog;
-}
-
 namespace Gtk {
 class Button;
 class Text;
@@ -38,31 +34,22 @@ public:
        ///
        FormCredits(ControlCredits & c);
        ///
-       ~FormCredits();
+       ~FormCredits() {};
 
-       void apply();
-
-       void hide();
-       void show();
-       void update();
+       void apply() {};
+       void update() {};
        
 private:
        
        /// Build the dialog
        void build();
 
-       /// get the dialog
-       Gnome::Dialog * dialog();
-    
        void CancelClicked() { CancelButton(); }
 
        /// The ok button
        Gtk::Button * ok();
        
        Gtk::Text * text();
-
-       // Hold the dialog.
-       Gnome::Dialog * dialog_;
 };
 
 #endif
index b3b3a02b42b982b72acfd4d461a0d4124b336e93..f3b6f51b01a80fcd6017cb9a92d6ce44cd82d388 100644 (file)
 #include "gnomeBC.h"
 #include "FormUrl.h"
 
-#include <gnome--/dialog.h>
 #include <gtk--/entry.h>
 #include <gtk--/checkbutton.h>
 
 FormUrl::FormUrl(ControlUrl & c)
        : FormCB<ControlUrl>(c, "diainserturl.glade", "DiaInsertUrl")
-       , dialog_(0)
 {}
 
 
@@ -40,9 +38,6 @@ FormUrl::~FormUrl()
 
 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));
@@ -82,22 +77,6 @@ void FormUrl::disconnect_signals()
 }
 
 
-void FormUrl::show()
-{
-       if (!dialog_)
-               build();
-       
-       update();
-       dialog_->show();
-}
-
-
-void FormUrl::hide()
-{
-       dialog_->hide();
-}
-
-
 void FormUrl::apply()
 {
        controller().params().setContents(url()->get_text());
@@ -135,11 +114,6 @@ bool FormUrl::validate() const
 }
 
 
-Gnome::Dialog * FormUrl::dialog()
-{
-       return getWidget<Gnome::Dialog>("DiaInsertUrl");
-}
-
 Gtk::Entry * FormUrl::url() const
 {
        return getWidget<Gtk::Entry>("url");
index eeca5b50a77fdb4db1d56a9533105995f68ea841..0ee41de96fe143497f51dbc151c4b14507873a8c 100644 (file)
 #include "ControlUrl.h"
 #include "GnomeBase.h"
 
-//#include <gnome--/dialog.h>
-namespace Gnome {
-class Dialog;
-}
-
 namespace Gtk {
 class Button;
 class CheckButton;
@@ -43,8 +38,6 @@ public:
        ~FormUrl();
 
        void apply();
-       void hide();
-       void show();
        void update();
        
 private:
@@ -65,8 +58,6 @@ private:
        void RestoreClicked() { RestoreButton(); }
        void InputChanged() { bc().valid(validate()); }
        
-       /// Get the dialog
-       Gnome::Dialog * dialog();
        /// The url entry
        Gtk::Entry * url() const;
        /// The name entry
@@ -82,10 +73,6 @@ private:
        /// The restore button
        Gtk::Button * restore_btn() const;
 
-       // Hold the dialog.
-       //boost::shared_ptr<Gnome::Dialog> dialog_;
-       Gnome::Dialog * dialog_;
-
        /// Keeps the connection to the input validator.
        SigC::Connection slot_url_;
        SigC::Connection slot_name_;
index 36c93f92286566420487a8ec5709e641d9cc8be3..8b68b16bb706c1f36eccf17f46054a80c3cc9db4 100644 (file)
 #include "support/filetools.h"
 #include <glib.h>
 
-GnomeBase::GnomeBase(ControlButton & c, string const & glade_file, string const & name)
-       : ViewBC<gnomeBC>(c), file_(glade_file), widget_name_(name), xml_(0)
+#include <gnome--/dialog.h>
+
+GnomeBase::GnomeBase(ControlButton & c, 
+               string const & glade_file, string const & name)
+       : ViewBC<gnomeBC>(c)
+       , file_(glade_file), widget_name_(name), xml_(0)
+       , dialog_(0)
 {}
        
 GnomeBase::~GnomeBase()
@@ -45,3 +50,31 @@ void GnomeBase::loadXML() const
        
        xml_ = glade_xml_new(file.c_str(), widget_name_.c_str());
 }
+
+
+void GnomeBase::show()
+{
+       if (!dialog_) {
+               dialog_ = dialog();
+               build();
+       }
+
+       update();
+       dialog_->show();
+}
+
+
+void GnomeBase::hide()
+{
+       if (dialog_)
+               dialog_->hide();
+}
+
+
+Gnome::Dialog * GnomeBase::dialog()
+{
+       if (!dialog_) 
+               dialog_ = getWidget<Gnome::Dialog>(widget_name_.c_str());
+               
+       return dialog_;
+}
index 5f8cbb9b366016f2b30e7ac830b436d9b9c4b2c9..b7541b7c731d1b48b0b6b0f82362ec7f4221cbc7 100644 (file)
 #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
+ * This is a base class for Gnome dialogs. It handles all the common
  * work that is needed for all dialogs.
  */
 class GnomeBase : public ViewBC<gnomeBC>, public SigC::Object {
@@ -43,19 +38,37 @@ public:
        virtual ~GnomeBase();
 
 protected:
+       /// Get the widget named 'name' from the xml representation.
        template <class T>
        T* getWidget(char const * name) const; 
 
+       /// Get the dialog we use.
+       Gnome::Dialog * dialog();
+
+       /// Show the dialog.
+       void show();
+       /// Hide the dialog.
+       void hide();
+       
+       /// Build the dialog. Also connects signals and prepares it for work.
+       virtual void build() = 0;
+
 private:
        /// Loads the glade file to memory.
        void loadXML() const;
 
        /// The glade file name
-       string file_;
+       const string file_;
        /// The widget name
-       string widget_name_;
+       const string widget_name_;
        /// The XML representation of the dialogs.
        mutable GladeXML * xml_;
+
+       /** The dialog we work with, since it is managed by libglade, we do not
+        *  need to delete it or destroy it, it will be destroyed with the rest
+        *  of the libglade GladeXML structure.
+        */
+       Gnome::Dialog * dialog_;
 };
 
 
@@ -81,7 +94,6 @@ template <class Controller>
 class FormCB : public GnomeBase {
 public:
        FormCB(Controller & c, string const & file, string const & name);
-       
 protected:
        Controller & controller();
 };
index d47decabcbbb8fd7509317da07c3436c4c611347..5d057bfaa8e0f9e4f835311e6591853400749701 100644 (file)
@@ -22,12 +22,14 @@ void gnomeBC::setWidgetEnabled(Gtk::Widget * obj, bool enabled)
 
 void gnomeBC::setButtonEnabled(Gtk::Button * btn, bool enabled) 
 {
-       setWidgetEnabled(btn, enabled);
+       if (btn)
+               btn->set_sensitive(enabled);
 }
 
 
 void gnomeBC::setButtonLabel(Gtk::Button * obj, string const & label)
 {
 #warning Implement me! (be 20010329)
-       obj->set_text(label);
+       // There is no methods set_text!
+       //obj->set_text(label);
 }
index 15b1157b037f276f998a5dce353138287f707ca9..42c4e528b850bfb9aa0197d7a72179b437a5467c 100644 (file)
@@ -26,7 +26,7 @@
 namespace Gtk {
 class Button;
 class Widget;
-}
+};
 
 class gnomeBC : public GuiBC<Gtk::Button, Gtk::Widget>
 {
@@ -42,7 +42,7 @@ private:
        void setWidgetEnabled(Gtk::Widget * obj, bool enabled);
 
        /// Set the label on the button
-       void setButtonLabel(Gtk::Button * btn, string const & label)
+       void setButtonLabel(Gtk::Button * btn, string const & label);
 };
 
 #endif // GNOMEBC_H
index c67ef97175f1e895bf410884a639d0a1399ac787..e6a89dca08732b19cf4187f896e4544420454660 100644 (file)
@@ -20,7 +20,7 @@
 
 // Glade Helper Function.  
 template<class T>
-T* getWidgetPtr(GladeXML* xml, const char* name)
+T* getWidgetPtr(GladeXML* xml, char const * name)
 {   
        T* result = static_cast<T*>(Gtk::wrap_auto((GtkObject*)glade_xml_get_widget(xml, name)));
        if (result == NULL)