- if (params_.templ.automaticProduction) {
- fl_deactivate_object(dialog_->button_update);
- fl_set_object_lcol(dialog_->button_update, FL_INACTIVE);
- } else {
- fl_activate_object(dialog_->button_update);
- fl_set_object_lcol(dialog_->button_update, FL_BLACK);
- }
-}
-
-
-bool FormExternal::input(FL_OBJECT *, long)
-{
- // FIXME: anything to do here ?
- return true;
-}
-
-
-void FormExternal::apply()
-{
- Assert(inset_);
-
- if (lv_->buffer()->isReadonly())
- return;
-
- params_.filename = fl_get_input(dialog_->input_filename);
- params_.parameters = fl_get_input(dialog_->input_parameters);
- params_.templ = getTemplate(fl_get_choice(dialog_->choice_template));
-
- inset_->setFromParams(params_);
- lv_->view()->updateInset(inset_, true);
-}
-
-
-void FormExternal::templateCB(FL_OBJECT * ob, long)
-{
- FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
-
- // set to the chosen template
- form->params_.templ = form->getTemplate(fl_get_choice(form->dialog_->choice_template));
-
- form->updateComboChange();
-}
-
-
-void FormExternal::browseCB(FL_OBJECT * ob, long)
-{
- FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
-
- static string current_path;
- static int once = 0;
-
- string p = fl_get_input(form->dialog_->input_filename);
- string buf = MakeAbsPath(form->lv_->buffer()->fileName());
- string buf2 = OnlyPath(buf);
-
- if (!p.empty()) {
- buf = MakeAbsPath(p, buf2);
- buf = OnlyPath(buf);
- } else {
- buf = OnlyPath(form->lv_->buffer()->fileName());
- }
-
- FileDialog fileDlg(form->lv_, _("Select external file"),
- LFUN_SELECT_FILE_SYNC,
- make_pair(string(_("Document")), string(buf)));
-
- /// Determine the template file extension
- ExternalTemplate const & et = form->params_.templ;
-
- string regexp = et.fileRegExp;
- if (regexp.empty())
- regexp = "*";
-
- // FIXME: a temporary hack until the FileDialog interface is updated
- regexp += "|";
-
- while (1) {
- string const path = (once) ? current_path : buf;
- FileDialog::Result result = fileDlg.Select(path, regexp, fl_get_input(form->dialog_->input_filename));
-
- if (result.second.empty())
- return;
-
- string p = result.second;
-
- buf = MakeRelPath(p, buf2);
- current_path = OnlyPath(p);
- once = 1;
-
- if (contains(p, "#") || contains(p, "~") || contains(p, "$")
- || contains(p, "%")) {
- WriteAlert(_("Filename can't contain any "
- "of these characters:"),
- // xgettext:no-c-format
- _("'#', '~', '$' or '%'."));
- } else
- break;
- }
-
- fl_set_input(form->dialog_->input_filename, buf.c_str());
-}
-
-
-void FormExternal::editCB(FL_OBJECT * ob, long)
-{
- FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
-
- form->apply();
- form->inset_->editExternal();
-}
-
-
-void FormExternal::viewCB(FL_OBJECT * ob, long)
-{
- FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
-
- form->apply();
- form->inset_->viewExternal();
-}
-
-
-void FormExternal::updateCB(FL_OBJECT * ob, long)
-{
- FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
-
- form->apply();
- form->inset_->updateExternal();