- State state = static_cast<State>(data);
-
- switch (state) {
- case BROWSE: {
- // Should browsing too be disabled in RO-mode?
- FileDialog fileDlg(lv_, _("Select document to include"),
- LFUN_SELECT_FILE_SYNC,
- make_pair(string(_("Documents")), string(lyxrc.document_path)));
-
- string ext;
-
- /* input TeX, verbatim, or LyX file ? */
- if (fl_get_button(dialog_->flag2))
- ext = _("*.tex| LaTeX Documents (*.tex)");
- else if (fl_get_button(dialog_->flag4))
- ext = _("*| All files ");
- else
- ext = _("*.lyx| LyX Documents (*.lyx)");
-
- string mpath;
-
- /* FIXME: what do I do here ? */
- //if (inset_)
- // mpath = OnlyPath(inset_->getMasterFilename());
-
- FileDialog::Result result = fileDlg.Select(mpath, ext, fl_get_input(dialog_->filename));
-
- // check selected filename
- if (result.second.empty())
- break;
-
- string const filename2 = MakeRelPath(result.second, mpath);
-
- if (prefixIs(filename2, ".."))
- fl_set_input(dialog_->filename, result.second.c_str());
- else
- fl_set_input(dialog_->filename, filename2.c_str());
-
- } break;
-
- case LOAD:
- apply();
- lv_->getLyXFunc()->Dispatch(LFUN_CHILDOPEN, params.getContents());
- break;
-
- case VERBATIM:
- setEnabled(dialog_->flag41, true);
- break;
-
- case INPUTINCLUDE:
- /* FIXME: huh ? why doesn't this work ? */
- setEnabled(dialog_->flag41, false);
- fl_set_button(dialog_->flag41, 0);
- break;
+ ButtonPolicy::SMInput action = ButtonPolicy::SMI_VALID;
+
+ if (ob == dialog_->button_browse) {
+ ControlInclude::Type type;
+ if (fl_get_button(dialog_->check_useinput))
+ type = ControlInclude::INPUT;
+ else if (fl_get_button(dialog_->check_verbatim))
+ type = ControlInclude::VERBATIM;
+ else
+ type = ControlInclude::INCLUDE;
+
+ string const in_name = fl_get_input(dialog_->input_filename);
+ fl_freeze_form(form());
+ string const out_name = controller().Browse(in_name, type);
+ fl_set_input(dialog_->input_filename, out_name.c_str());
+ fl_unfreeze_form(form());
+
+ } else if (ob == dialog_->button_load) {
+ string const in_name = fl_get_input(dialog_->input_filename);
+ if (!strip(in_name).empty() && controller().fileExists(in_name)) {
+// ApplyButton();
+ OKButton();
+ controller().load(strip(in_name));
+ action = ButtonPolicy::SMI_NOOP;
+ }
+
+ } else if (ob == dialog_->check_verbatim) {
+ setEnabled(dialog_->check_visiblespace, true);
+
+ } else if (ob == dialog_->check_useinclude ||
+ ob == dialog_->check_useinput) {
+ fl_set_button(dialog_->check_visiblespace, 0);
+ setEnabled(dialog_->check_visiblespace, false);
+
+ } else if (ob == dialog_->input_filename) {
+ string const in_name = fl_get_input(dialog_->input_filename);
+ if (strip(in_name).empty())
+ action = ButtonPolicy::SMI_INVALID;