From 76721181999c0b10c1d0b062a131188413ac9679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Sun, 17 Jul 2005 16:36:21 +0000 Subject: [PATCH] use the real label dialog in math as well git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10295 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_hullinset.C | 46 +++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index b84a021d7e..6f82efd91d 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -39,8 +39,10 @@ #include "undo.h" #include "insets/render_preview.h" +#include "insets/insetlabel.h" -#include "frontends/Alert.h" +#include "frontends/Dialogs.h" +#include "frontends/LyXView.h" #include "graphics/PreviewImage.h" #include "graphics/PreviewLoader.h" @@ -1041,23 +1043,37 @@ void MathHullInset::doDispatch(LCursor & cur, FuncRequest & cmd) recordUndoInset(cur); row_type r = (type_ == "multline") ? nrows() - 1 : cur.row(); string old_label = label(r); - string new_label = cmd.argument; + string const default_label = + (lyxrc.label_init_length >= 0) ? "eq:" : ""; + string const contents = cmd.argument.empty() ? + label(r) : cmd.argument; - if (new_label.empty()) { - string const default_label = - (lyxrc.label_init_length >= 0) ? "eq:" : ""; - pair const res = old_label.empty() - ? Alert::askForText(_("Enter new label to insert:"), default_label) - : Alert::askForText(_("Enter label:"), old_label); - if (res.first) - new_label = lyx::support::trim(res.second); - else - new_label = old_label; + InsetCommandParams p("label", contents); + string const data = InsetCommandMailer::params2string("label", p); + + if (cmd.argument.empty()) { + cur.bv().owner()->getDialogs().show("label", data, 0); + } else { + FuncRequest fr(LFUN_INSET_INSERT, data); + dispatch(cur, fr); } + break; + } - if (!new_label.empty()) - numbered(r, true); - label(r, new_label); + case LFUN_INSET_INSERT: { + //lyxerr << "arg: " << cmd.argument << endl; + string const name = cmd.getArg(0); + if (name == "label") { + InsetCommandParams icp; + InsetCommandMailer::string2params(name, cmd.argument, icp); + string str = icp.getContents(); + recordUndoInset(cur); + row_type const r = (type_ == "multline") ? nrows() - 1 : cur.row(); + str = lyx::support::trim(str); + if (!str.empty()) + numbered(r, true); + label(r, str); + } break; }