]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/gnome/FormUrl.C
ws cleanup
[lyx.git] / src / frontends / gnome / FormUrl.C
index b3b3a02b42b982b72acfd4d461a0d4124b336e93..0b128ed39bfc9c1c1fe5a62e75b9e48fcc3ff88f 100644 (file)
@@ -1,11 +1,10 @@
-// -*- C++ -*-
 /* This file is part of
  * =================================================
- * 
+ *
  *          LyX, The Document Processor
  *          Copyright 1995-2000 The LyX Team.
  *
- * ================================================= 
+ * =================================================
  *
  * \author Baruch Even
  */
 #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)
+       : FormCB<ControlUrl>(c, "FormUrl")
 {}
 
 
@@ -40,9 +37,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));
@@ -53,13 +47,13 @@ void FormUrl::build()
        bc().setOK(ok_btn());
        bc().setCancel(cancel_btn());
        bc().setApply(apply_btn());
-       bc().setUndoAll(restore_btn());
+       bc().setRestore(restore_btn());
 
        // Make sure everything is in the correct state.
        bc().refresh();
-       
+
        // Manage the read-only aware widgets.
-       bc().addReadOnly(html());
+       bc().addReadOnly(html_cb());
        bc().addReadOnly(name());
        bc().addReadOnly(url());
 }
@@ -70,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));
 }
 
 
@@ -82,32 +76,18 @@ void FormUrl::disconnect_signals()
 }
 
 
-void FormUrl::show()
-{
-       if (!dialog_)
-               build();
-       
-       update();
-       dialog_->show();
-}
-
-
-void FormUrl::hide()
-{
-       dialog_->hide();
-}
-
-
 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();
 }
 
 
@@ -117,11 +97,11 @@ void FormUrl::update()
        // 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());
+       html_cb()->set_active("url" != controller().params().getCmdName());
 
        // Reconnect the signals.
        connect_signals();
@@ -130,51 +110,34 @@ void FormUrl::update()
 
 bool FormUrl::validate() const
 {
-       // Always valid! (not really so, needs fixing).
-       return true;
-}
-
-
-Gnome::Dialog * FormUrl::dialog()
-{
-       return getWidget<Gnome::Dialog>("DiaInsertUrl");
+       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");
 }