Fixed the behaviour of Goto-Ref (?)

Needs to be ported to the other frontends!


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1634 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2001-02-27 12:32:01 +00:00
parent 53675c6ce8
commit 697939d609
2 changed files with 12 additions and 34 deletions

View File

@ -33,9 +33,11 @@ using std::max;
using std::sort; using std::sort;
using std::vector; using std::vector;
bool saved_position;
FormRef::FormRef(LyXView * lv, Dialogs * d) FormRef::FormRef(LyXView * lv, Dialogs * d)
: FormCommand(lv, d, _("Reference"), new NoRepeatedApplyPolicy), : FormCommand(lv, d, _("Reference"), new NoRepeatedApplyPolicy),
toggle(GOBACK), dialog_(0) at_ref(false), dialog_(0)
{ {
// let the dialog be shown // let the dialog be shown
// These are permanent connections so we won't bother // These are permanent connections so we won't bother
@ -102,9 +104,7 @@ void FormRef::update()
InsetRef::getType(params.getCmdName()) + 1); InsetRef::getType(params.getCmdName()) + 1);
} }
lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_SAVE, "0"); at_ref = false;
toggle = GOBACK;
fl_set_object_label(dialog_->button_go, _("Goto reference")); fl_set_object_label(dialog_->button_go, _("Goto reference"));
// Name is irrelevant to LaTeX/Literate documents, while // Name is irrelevant to LaTeX/Literate documents, while
@ -192,7 +192,6 @@ void FormRef::apply()
} else { } else {
lv_->getLyXFunc()->Dispatch(LFUN_REF_INSERT, lv_->getLyXFunc()->Dispatch(LFUN_REF_INSERT,
params.getAsString()); params.getAsString());
lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_SAVE, "0");
} }
} }
@ -207,30 +206,18 @@ bool FormRef::input(FL_OBJECT *, long data)
// No change to data // No change to data
activate = false; activate = false;
toggle = static_cast<Goto>(toggle + 1); at_ref = !at_ref;
if (toggle == GOFIRST ) toggle = GOREF; if (at_ref) {
lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_SAVE, "0");
switch (toggle) {
case GOREF:
{
lv_->getLyXFunc()-> lv_->getLyXFunc()->
Dispatch(LFUN_REF_GOTO, Dispatch(LFUN_REF_GOTO,
fl_get_input(dialog_->ref)); fl_get_input(dialog_->ref));
fl_set_object_label(dialog_->button_go, _("Go back")); fl_set_object_label(dialog_->button_go, _("Go back"));
} } else {
break;
case GOBACK:
{
lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0"); lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0");
fl_set_object_label(dialog_->button_go, fl_set_object_label(dialog_->button_go,
_("Goto reference")); _("Goto reference"));
} }
break;
default:
break;
}
} }
break; break;
@ -245,8 +232,9 @@ bool FormRef::input(FL_OBJECT *, long data)
fl_set_input(dialog_->ref, s.c_str()); fl_set_input(dialog_->ref, s.c_str());
} }
toggle = GOBACK; if (at_ref)
lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0"); lv_->getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0");
at_ref = false;
fl_set_object_label(dialog_->button_go, _("Goto reference")); fl_set_object_label(dialog_->button_go, _("Goto reference"));
fl_activate_object(dialog_->type); fl_activate_object(dialog_->type);

View File

@ -29,16 +29,6 @@ public:
~FormRef(); ~FormRef();
/// ///
private: private:
///
enum Goto {
///
GOREF,
///
GOBACK,
///
GOFIRST
};
/// Disconnect signals. Also perform any necessary housekeeping. /// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect(); virtual void disconnect();
@ -59,7 +49,7 @@ private:
FD_form_ref * build_ref(); FD_form_ref * build_ref();
/// ///
Goto toggle; bool at_ref;
/// ///
std::vector<string> refs; std::vector<string> refs;