+
+ return tmp ? trim(tmp) : string();
+}
+
+string getLengthFromWidgets(FL_OBJECT * input, FL_OBJECT * choice)
+{
+ // Paranoia check
+ BOOST_ASSERT(input && input->objclass == FL_INPUT &&
+ choice && choice->objclass == FL_CHOICE);
+
+ string const length = trim(fl_get_input(input));
+ if (length.empty())
+ return string();
+
+ // don't return unit-from-choice if the input(field) contains a unit
+ if (isValidGlueLength(length))
+ return length;
+
+ string unit = trim(fl_get_choice_text(choice));
+ unit = subst(unit, "%%", "%");
+
+ return length + unit;
+}
+
+
+void updateWidgetsFromLengthString(FL_OBJECT * input, FL_OBJECT * choice,
+ string const & str,
+ string const & default_unit)
+{
+ // Paranoia check
+ BOOST_ASSERT(input && input->objclass == FL_INPUT &&
+ choice && choice->objclass == FL_CHOICE);
+
+ // use input field only for gluelengths
+ if (!isValidLength(str) && !isStrDbl(str)) {
+ fl_set_input(input, str.c_str());
+ // we assume that "default_unit" is in the choice as "we"
+ // have control over that!
+ // No need to check for its presence in the choice, therefore.
+ fl_set_choice_text(choice, default_unit.c_str());
+ } else {
+ updateWidgetsFromLength(input, choice,
+ LyXLength(str), default_unit);