]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormChanges.C
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / FormChanges.C
index bb2d592bf26e9638d5a6980612a7a69f715bd02e..4e086062c0283b0263dcc4b4f3cad22aa92d08c2 100644 (file)
@@ -5,22 +5,28 @@
  *
  * \author John Levon
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-#include "xformsBC.h"
-#include "ControlChanges.h"
 #include "FormChanges.h"
+#include "ControlChanges.h"
 #include "forms/form_changes.h"
 
-#include FORMS_H_LOCATION
+#include "xformsBC.h"
+#include "xforms_helpers.h"
+
+#include "lyx_forms.h"
+
+
+using std::string;
+
 
 typedef FormController<ControlChanges, FormView<FD_changes> > base_class;
 
 FormChanges::FormChanges(Dialog & parent)
-       : base_class(parent, _("LyX: Merge changes"))
+       : base_class(parent, _("Merge Changes"))
 {}
 
 
@@ -28,17 +34,18 @@ void FormChanges::build()
 {
        dialog_.reset(build_changes(this));
 
-       bc().setCancel(dialog_->button_close);
-       bc().addReadOnly(dialog_->button_accept);
-       bc().addReadOnly(dialog_->button_reject);
+       // Manage the cancel/close buttons
+       bcview().setCancel(dialog_->button_close);
+
+       // disable for read-only documents
+       bcview().addReadOnly(dialog_->button_accept);
+       bcview().addReadOnly(dialog_->button_reject);
 }
 
 
 void FormChanges::update()
 {
-       fl_set_object_label(dialog_->author, "");
-       fl_set_object_label(dialog_->date, "");
-       // FIXME: enable/disable accept/reject
+       input(dialog_->button_next, 0);
 }
 
 
@@ -46,32 +53,26 @@ ButtonPolicy::SMInput FormChanges::input(FL_OBJECT * obj, long)
 {
        if (obj == dialog_->button_accept) {
                controller().accept();
-               return ButtonPolicy::SMI_VALID;
-       }
 
-       if (obj == dialog_->button_reject) {
+       } else if (obj == dialog_->button_reject) {
                controller().reject();
-               return ButtonPolicy::SMI_VALID;
-       }
 
-       if (obj != dialog_->button_next)
-               return ButtonPolicy::SMI_VALID;
+       } else if (obj == dialog_->button_next) {
 
-       controller().find();
+               bool const exist = controller().find();
+               setEnabled(dialog_->button_accept, exist);
+               setEnabled(dialog_->button_reject, exist);
+               setEnabled(dialog_->button_next, exist);
 
-       string author(controller().getChangeAuthor());
-       string date(controller().getChangeDate());
-       if (!date.empty()) {
-               date = _("Changed at : ") + date;
-       }
-       if (!author.empty()) {
-               author = _("Change made by : ") + author;
-       }
-       fl_set_object_label(dialog_->author, author.c_str());
-       fl_set_object_label(dialog_->date, date.c_str());
+               string const author = exist ? controller().getChangeAuthor() : "";
+               fl_set_object_label(dialog_->text_author, author.c_str());
+
+               string const date = exist ? controller().getChangeDate() : "";
+               fl_set_object_label(dialog_->text_date, date.c_str());
 
-       // Yes, this is needed.
-       fl_redraw_form(form());
+               // Yes, this is needed.
+               fl_redraw_form(form());
+       }
 
        return ButtonPolicy::SMI_VALID;
 }