]> git.lyx.org Git - features.git/commitdiff
Michael's latest gnome changes.
authorAngus Leeming <leeming@lyx.org>
Wed, 16 Jan 2002 12:30:17 +0000 (12:30 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 16 Jan 2002 12:30:17 +0000 (12:30 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3386 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/gnome/ChangeLog
src/frontends/gnome/FormError.C
src/frontends/gnome/FormError.h
src/frontends/gnome/FormTabularCreate.C
src/frontends/gnome/FormTabularCreate.h
src/frontends/gnome/FormUrl.C
src/frontends/gnome/FormUrl.h
src/frontends/gnome/GnomeBase.C
src/frontends/gnome/GnomeBase.h

index e04b9a8599df67499d2d621007fd3eb46b2e1d68..f35c1ecbb990ac71da8b058d753349f85daeecdf 100644 (file)
@@ -7,6 +7,36 @@
        frontend, so I've removed the LyXGnomified and menubar code.  The
        menubar wasn't working properly anyway.
 
+2002-01-12  Michael A. Koziarski  <michael@koziarski.com>
+
+       * various:  Cleaned out the old stuff, standardised the new
+       stuff. 
+       * GnomeBase.C
+       * GnomeBase.h: Changed the constructor to take one argument.  The
+       dialog name.  The path and name of the glade files can be
+       calculated from there.  These two now provide default validate() &
+       *Clicked functions.
+       * FormUrl.C
+       * FormUrl.h
+       * FormError.C
+       * FormError.h
+       * FormTabularCreate.C
+       * FormTabularCreate.h: updated them to use the new system.
+       Removed Local inline *Clicked functions as they're now in the base
+       class. 
+       * README: new, brief outline of what I'm doing here.
+       * accessors.py: Described in README, generates the accessor
+       functions from the glade file.
+
+2002-01-12  Michael A. Koziarski  <michael@koziarski.com>
+
+       * Menubar_pimpl.C
+       * Menubar_pimpl.h
+       * mainapp.h
+       * mainapp.C: Removed,  We should behave similarly to the qt2
+       frontend, so I've removed the LyXGnomified and menubar code.  The
+       menubar wasn't working properly anyway.
+
 2002-01-08  Martin Vermeer  <martin.vermeer@hut.fi>
 
        * Menubar_pimpl.C (composeUIInfo): 
index d95ec3cc65916ab1579de32b735962dfcf08076f..729fc05a498bb0066f3d1abe5b7e3eef0306ad6f 100644 (file)
 #include <gtk--/text.h>
 
 FormError::FormError(ControlError & c)
-       : FormCB<ControlError>(c, "diaerror.glade", "DiaError")
+       : FormCB<ControlError>(c, "FormError")
 {}
 
 
 void FormError::build()
 {
        // Connect the buttons.
-       close_btn()->clicked.connect(SigC::slot(this, &FormError::CloseClicked));
+       button_close()->clicked.connect(SigC::slot(this, &FormError::CloseClicked));
 
        // Manage the buttons state
-       bc().setCancel(close_btn());
+       bc().setCancel(button_close());
 
        // Make sure everything is in the correct state.
        bc().refresh();
@@ -44,14 +44,12 @@ void FormError::update()
        textarea()->insert(controller().params());
 }
 
-
-Gtk::Button * FormError::close_btn() const
+Gtk::Button * FormError::button_close() const 
 {
-       return getWidget<Gtk::Button>("button_close");
+        return getWidget<Gtk::Button>("r_button_close");
 }
 
-
-Gtk::Text * FormError::textarea() const
+Gtk::Text * FormError::textarea() const 
 {
-       return getWidget<Gtk::Text>("textarea");
+        return getWidget<Gtk::Text>("r_textarea");
 }
index e8a57302d34b708a556794769b1c4e77ffd7cf27..0b193e1a00a3e9778fc2e3be97f09c6be2aaff59 100644 (file)
@@ -49,9 +49,12 @@ private:
 
        void CloseClicked() { CancelButton(); }
        
-       /// The close button
-       Gtk::Button * close_btn() const;
+
+       /// generated by accessors.py
+       Gtk::Button * button_close() const;
+       /// generated by accessors.py
        Gtk::Text * textarea() const;
+
 };
 
 #endif
index 84e93252c1004b1d10c4fdfa629e209641392c9c..e2b74b669673ec445a111a3e03dc2fc7847234be 100644 (file)
@@ -23,8 +23,7 @@
 #include <gtk--/button.h>
 
 FormTabularCreate::FormTabularCreate(ControlTabularCreate & c)
-       : FormCB<ControlTabularCreate>(c, "diainserttabular.glade", 
-                                      "DiaInsertTabular")
+       : FormCB<ControlTabularCreate>(c, "FormTabularCreate")
 {}
 
 
@@ -59,50 +58,42 @@ void FormTabularCreate::build()
 
 void FormTabularCreate::apply()
 {
-       unsigned int ysize = (unsigned int)(rows_spin()->get_value_as_int());
-       unsigned int xsize = (unsigned int)(columns_spin()->get_value_as_int());
+       unsigned int ysize = (unsigned int)(rows()->get_value_as_int());
+       unsigned int xsize = (unsigned int)(cols()->get_value_as_int());
 
        controller().params() = std::make_pair(xsize, ysize);
 }
 
 
 void FormTabularCreate::update()
-{
-}
+{}
 
 
 bool FormTabularCreate::validate() const
 {
-       // Always valid! (not really so, needs fixing).
-       return true;
+       return ( rows()->get_value_as_int() > 0 ) && 
+              ( cols()->get_value_as_int() > 0 );
 }
 
 
-Gtk::SpinButton * FormTabularCreate::rows_spin() const
+Gtk::Button * FormTabularCreate::ok_btn() const 
 {
-       return getWidget<Gtk::SpinButton>("tabular_spin_rows");
+        return getWidget<Gtk::Button>("r_ok_btn");
 }
-
-
-Gtk::SpinButton * FormTabularCreate::columns_spin() const
+Gtk::Button * FormTabularCreate::apply_btn() const 
 {
-       return getWidget<Gtk::SpinButton>("tabular_spin_columns");
+        return getWidget<Gtk::Button>("r_apply_btn");
 }
-
-
-Gtk::Button * FormTabularCreate::ok_btn() const
+Gtk::Button * FormTabularCreate::cancel_btn() const 
 {
-       return getWidget<Gtk::Button>("button_ok");
+        return getWidget<Gtk::Button>("r_cancel_btn");
 }
-
-
-Gtk::Button * FormTabularCreate::cancel_btn() const
+Gtk::SpinButton * FormTabularCreate::rows() const 
 {
-       return getWidget<Gtk::Button>("button_cancel");
+        return getWidget<Gtk::SpinButton>("r_rows");
 }
-
-
-Gtk::Button * FormTabularCreate::apply_btn() const
+Gtk::SpinButton * FormTabularCreate::cols() const 
 {
-       return getWidget<Gtk::Button>("button_apply");
+        return getWidget<Gtk::SpinButton>("r_cols");
 }
+
index 345676c12f240f615a3c7962ad8556ca34218e71..eb2d06c0337bf261877fd4b9bdcc302d7f45c11d 100644 (file)
@@ -49,15 +49,17 @@ private:
        void CancelClicked() { CancelButton(); }
        void ApplyClicked() { ApplyButton(); }
 
-       /// The SpinButtons
-       Gtk::SpinButton * rows_spin() const;
-       Gtk::SpinButton * columns_spin() const;
-       /// The ok button
+       /// generated by accessors.py
        Gtk::Button * ok_btn() const;
-       /// The cancel button
-       Gtk::Button * cancel_btn() const;
-       /// The apply button
+       /// generated by accessors.py
        Gtk::Button * apply_btn() const;
+       /// generated by accessors.py
+       Gtk::Button * cancel_btn() const;
+       /// generated by accessors.py
+       Gtk::SpinButton * rows() const;
+       /// generated by accessors.py
+       Gtk::SpinButton * cols() const;
+
 };
 
 #endif
index 84e00f07a34a725a23069a9ac4a547727a146d05..a968af512f8a5415d5cda5e0d217bc112d32a978 100644 (file)
@@ -22,7 +22,7 @@
 #include <gtk--/checkbutton.h>
 
 FormUrl::FormUrl(ControlUrl & c)
-       : FormCB<ControlUrl>(c, "diainserturl.glade", "DiaInsertUrl")
+       : FormCB<ControlUrl>(c, "FormUrl")
 {}
 
 
@@ -53,7 +53,7 @@ void FormUrl::build()
        bc().refresh();
        
        // Manage the read-only aware widgets.
-       bc().addReadOnly(html());
+       bc().addReadOnly(html_cb());
        bc().addReadOnly(name());
        bc().addReadOnly(url());
 }
@@ -64,7 +64,7 @@ void FormUrl::connect_signals()
        // 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));
+       slot_html_ = html_cb()->toggled.connect(SigC::slot(this, &FormUrl::InputChanged));
 }
 
 
@@ -78,14 +78,16 @@ void FormUrl::disconnect_signals()
 
 void FormUrl::apply()
 {
+       disconnect_signals();
        controller().params().setContents(url()->get_text());
        controller().params().setOptions(name()->get_text());
 
        string cmdname("url");
-       if (html()->get_active())
+       if (html_cb()->get_active())
                cmdname = "htmlurl";
 
        controller().params().setCmdName(cmdname);
+       connect_signals();
 }
 
 
@@ -99,7 +101,7 @@ void FormUrl::update()
        url()->set_text(controller().params().getContents());
        name()->set_text(controller().params().getOptions());
 
-       html()->set_active("url" != controller().params().getCmdName());
+       html_cb()->set_active("url" != controller().params().getCmdName());
 
        // Reconnect the signals.
        connect_signals();
@@ -108,46 +110,36 @@ void FormUrl::update()
 
 bool FormUrl::validate() const
 {
-       // Always valid! (not really so, needs fixing).
-       return true;
+       return !url()->get_text().empty() && !name()->get_text().empty();
 }
 
-
-Gtk::Entry * FormUrl::url() const
+Gtk::Button * FormUrl::restore_btn() const 
 {
-       return getWidget<Gtk::Entry>("url");
+        return getWidget<Gtk::Button>("r_restore_btn");
 }
-
-Gtk::Entry * FormUrl::name() const
+Gtk::Button * FormUrl::ok_btn() const 
 {
-       return getWidget<Gtk::Entry>("name");
+        return getWidget<Gtk::Button>("r_ok_btn");
 }
-
-Gtk::CheckButton * FormUrl::html() const
+Gtk::Button * FormUrl::apply_btn() const 
 {
-       return getWidget<Gtk::CheckButton>("html_type");
+        return getWidget<Gtk::Button>("r_apply_btn");
 }
-
-
-Gtk::Button * FormUrl::ok_btn() const
+Gtk::Button * FormUrl::cancel_btn() const 
 {
-       return getWidget<Gtk::Button>("button_ok");
+        return getWidget<Gtk::Button>("r_cancel_btn");
 }
-
-
-Gtk::Button * FormUrl::cancel_btn() const
+Gtk::Entry * FormUrl::url() const 
 {
-       return getWidget<Gtk::Button>("button_cancel");
+        return getWidget<Gtk::Entry>("r_url");
 }
-
-
-Gtk::Button * FormUrl::apply_btn() const
+Gtk::Entry * FormUrl::name() const 
 {
-       return getWidget<Gtk::Button>("button_apply");
+        return getWidget<Gtk::Entry>("r_name");
 }
-
-
-Gtk::Button * FormUrl::restore_btn() const
+Gtk::CheckButton * FormUrl::html_cb() const 
 {
-       return getWidget<Gtk::Button>("button_restore");
+        return getWidget<Gtk::CheckButton>("r_html_cb");
 }
+
+
index 0ee41de96fe143497f51dbc151c4b14507873a8c..3d25fc5389cca96957d32665f9a8a43893271a4f 100644 (file)
@@ -52,27 +52,21 @@ private:
        /// Disconnect the signals.
        void disconnect_signals();
 
-       void OKClicked() { OKButton(); }
-       void CancelClicked() { CancelButton(); }
-       void ApplyClicked() { ApplyButton(); }
-       void RestoreClicked() { RestoreButton(); }
-       void InputChanged() { bc().valid(validate()); }
-       
-       /// 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
+       /// generated by accessors.py
+       Gtk::Button * restore_btn() const;
+       /// gene rated by accessors.py
        Gtk::Button * ok_btn() const;
-       /// The cancel button
-       Gtk::Button * cancel_btn() const;
-       /// The apply button
+       /// generated by accessors.py
        Gtk::Button * apply_btn() const;
-       /// The restore button
-       Gtk::Button * restore_btn() const;
-
+       /// generated by accessors.py
+       Gtk::Button * cancel_btn() const;
+       /// generated by accessors.py
+       Gtk::Entry * url() const;
+       /// generated by accessors.py
+       Gtk::Entry * name() const;
+       /// generated by accessors.py
+       Gtk::CheckButton * html_cb() const;
+       
        /// Keeps the connection to the input validator.
        SigC::Connection slot_url_;
        SigC::Connection slot_name_;
index cb56013590aed57c5c43cc5df64a1dad1986f9f4..72e80aa3859db456b42d1213ba2c034a0c362219 100644 (file)
@@ -21,9 +21,9 @@
 #include <gnome--/dialog.h>
 
 GnomeBase::GnomeBase(ControlButtons & c, 
-               string const & glade_file, string const & name)
+                string const & name)
        : ViewBC<gnomeBC>(c)
-       , file_(glade_file), widget_name_(name), xml_(0)
+       , file_(name + ".glade"), widget_name_(name), xml_(0)
        , dialog_(0)
 {}
        
@@ -71,6 +71,35 @@ void GnomeBase::hide()
                dialog_->hide();
 }
 
+bool GnomeBase::validate()
+{
+       return true;
+}
+
+void GnomeBase::OKClicked() 
+{ 
+       OKButton(); 
+}
+
+void GnomeBase::CancelClicked() 
+{ 
+       CancelButton(); 
+}
+
+void GnomeBase::ApplyClicked() 
+{ 
+       ApplyButton(); 
+}
+
+void GnomeBase::RestoreClicked() 
+{ 
+       RestoreButton(); 
+}
+
+void GnomeBase::InputChanged() 
+{ 
+       bc().valid(validate()); 
+}
 
 Gnome::Dialog * GnomeBase::dialog()
 {
index fe3751474e6990fff1a6779fcd677f8be45ff730..2b4f2f0064a94534baa3ec5a8754044759dcbb1a 100644 (file)
@@ -33,7 +33,7 @@ class Dialog;
 class GnomeBase : public ViewBC<gnomeBC>, public SigC::Object {
 public:
        /// 
-       GnomeBase(ControlButtons & c, string const & glade_file, string const & name);
+       GnomeBase(ControlButtons & c,  string const & name);
        ///
        virtual ~GnomeBase();
 
@@ -49,9 +49,20 @@ protected:
        void show();
        /// Hide the dialog.
        void hide();
-       
        /// Build the dialog. Also connects signals and prepares it for work.
        virtual void build() = 0;
+       /// Dialog is valid
+       virtual bool validate();
+       /// Default OK behaviour
+       virtual void OKClicked();
+       /// Default Cancel behaviour
+       virtual void CancelClicked();
+       /// Default Restore behaviour
+       virtual void RestoreClicked();
+       /// Default apply behaviour
+       virtual void ApplyClicked();
+       /// Default changed input behaviour
+       virtual void InputChanged();
 
 private:
        /// Loads the glade file to memory.
@@ -93,14 +104,14 @@ T* GnomeBase::getWidget(char const * name) const
 template <class Controller>
 class FormCB : public GnomeBase {
 public:
-       FormCB(Controller & c, string const & file, string const & name);
+       FormCB(Controller & c, string const & name);
 protected:
        Controller & controller();
 };
 
 template <class Controller>
-FormCB<Controller>::FormCB(Controller & c, string const & file, string const & name)
-       : GnomeBase(c, file, name)
+FormCB<Controller>::FormCB(Controller & c,  string const & name)
+       : GnomeBase(c, name)
 {}
 
 template <class Controller>