*
* \author John Levon
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "xformsBC.h"
-#include "ControlChanges.h"
#include "FormChanges.h"
+#include "ControlChanges.h"
#include "forms/form_changes.h"
-#include FORMS_H_LOCATION
-
-typedef FormCB<ControlChanges, FormDB<FD_changes> > base_class;
+#include "xformsBC.h"
+#include "xforms_helpers.h"
+
+#include "lyx_forms.h"
-FormChanges::FormChanges()
- : base_class(_("LyX: Merge changes"))
+
+using std::string;
+
+
+typedef FormController<ControlChanges, FormView<FD_changes> > base_class;
+
+FormChanges::FormChanges(Dialog & parent)
+ : base_class(parent, _("Merge Changes"))
{}
{
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);
}
-
+
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;
-
- controller().find();
-
- 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());
- // Yes, this is needed.
- fl_redraw_form(form());
+ } else if (obj == dialog_->button_next) {
+
+ bool const exist = controller().find();
+ setEnabled(dialog_->button_accept, exist);
+ setEnabled(dialog_->button_reject, exist);
+ setEnabled(dialog_->button_next, exist);
+
+ 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());
+ }
return ButtonPolicy::SMI_VALID;
}