Rob's changes patch

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6500 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-03-14 11:31:07 +00:00
parent 013af42fd6
commit d08db91ed0
6 changed files with 91 additions and 61 deletions

View File

@ -1,3 +1,8 @@
2003-03-13 Rob Lahaye <lahaye@snu.ac.kr>
* ControlChanges.[Ch]: ControlChanges::find() returns the bool
from lyxfind::findNextChange(), instead of void.
2003-03-13 Angus Leeming <leeming@lyx.org>
* Dialog.h (initialiseParams): return a bool to indicate successful

View File

@ -24,9 +24,9 @@ ControlChanges::ControlChanges(Dialog & parent)
{}
void ControlChanges::find()
bool ControlChanges::find()
{
lyxfind::findNextChange(kernel().bufferview());
return lyxfind::findNextChange(kernel().bufferview());
}
@ -35,7 +35,10 @@ string const ControlChanges::getChangeDate()
Change c(kernel().bufferview()->getCurrentChange());
if (c.type == Change::UNCHANGED || !c.changetime)
return string();
return ctime(&c.changetime);
// ctime adds newline; trim it off!
string const date = rtrim(ctime(&c.changetime), "\n");
return date;
}

View File

@ -31,7 +31,7 @@ public:
virtual bool isBufferDependent() const { return true; }
/// find the next merge chunk and highlight it
void find();
bool find();
/// return date of change
string const getChangeDate();

View File

@ -1,3 +1,10 @@
2003-03-13 Rob Lahaye <lahaye@snu.ac.kr>
* FormChanges.C: "LyX: " in dialog's name is redundant;
add few comments; fix disabling buttons when no changes found.
* forms/form_changes.fd: prettify layout.
2003-03-13 Angus Leeming <leeming@lyx.org>
* Dialogs.C:

View File

@ -14,13 +14,14 @@
#include "ControlChanges.h"
#include "FormChanges.h"
#include "forms/form_changes.h"
#include "xforms_helpers.h"
#include FORMS_H_LOCATION
typedef FormController<ControlChanges, FormView<FD_changes> > base_class;
FormChanges::FormChanges(Dialog & parent)
: base_class(parent, _("LyX: Merge changes"))
: base_class(parent, _("Merge changes"))
{}
@ -28,7 +29,10 @@ void FormChanges::build()
{
dialog_.reset(build_changes(this));
// 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);
}
@ -36,9 +40,7 @@ void FormChanges::build()
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 +48,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;
} 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());
}
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());
return ButtonPolicy::SMI_VALID;
}

View File

@ -5,18 +5,19 @@ Internal Form Definition File
Number of forms: 1
Unit of measure: FL_COORD_PIXEL
SnapGrid: 5
=============== FORM ===============
Name: form_changes
Width: 400
Height: 190
Number of Objects: 8
Width: 380
Height: 185
Number of Objects: 9
--------------------
class: FL_BOX
type: UP_BOX
box: 0 0 400 190
boxtype: FL_UP_BOX
type: FLAT_BOX
box: 0 0 380 185
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
@ -33,7 +34,7 @@ argument:
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 270 110 120 30
box: 255 120 120 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -42,8 +43,8 @@ size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Reject change|#R
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
resize: FL_RESIZE_X
gravity: FL_South FL_South
name: button_reject
callback: C_FormDialogView_InputCB
argument: 0
@ -51,7 +52,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 10 110 100 30
box: 5 120 120 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -60,8 +61,8 @@ size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Next change|#N
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
resize: FL_RESIZE_X
gravity: FL_South FL_South
name: button_next
callback: C_FormDialogView_InputCB
argument: 0
@ -69,7 +70,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 130 110 120 30
box: 130 120 120 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -78,8 +79,8 @@ size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Accept change|#A
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
resize: FL_RESIZE_X
gravity: FL_South FL_South
name: button_accept
callback: C_FormDialogView_InputCB
argument: 0
@ -87,7 +88,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 310 150 80 30
box: 285 155 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -105,17 +106,17 @@ argument: 0
--------------------
class: FL_TEXT
type: NORMAL_TEXT
box: 10 10 150 20
box: 5 5 150 25
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Accept change ?
label: Changed by:
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
resize: FL_RESIZE_NONE
gravity: FL_NorthWest FL_NorthWest
name:
callback:
argument:
@ -123,36 +124,54 @@ argument:
--------------------
class: FL_TEXT
type: NORMAL_TEXT
box: 10 40 380 30
boxtype: FL_NO_BOX
box: 5 30 370 30
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: text
label: author
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: author
gravity: FL_West FL_East
name: text_author
callback:
argument:
--------------------
class: FL_TEXT
type: NORMAL_TEXT
box: 10 70 380 30
boxtype: FL_NO_BOX
box: 5 85 370 30
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: text
label: date
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: date
gravity: FL_West FL_East
name: text_date
callback:
argument:
--------------------
class: FL_TEXT
type: NORMAL_TEXT
box: 5 60 150 25
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: on:
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_West FL_NoGravity
name:
callback:
argument: