- State state = static_cast<State>(data);
-
- switch (state) {
- case BROWSE: {
- // Should browsing too be disabled in RO-mode?
- LyXFileDlg fileDlg;
-
- string ext;
-
- fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
-
- /* input TeX, verbatim, or LyX file ? */
- if (fl_get_button(dialog_->flag2))
- ext = "*.tex";
- else if (fl_get_button(dialog_->flag4))
- ext = "*";
- else
- ext = "*.lyx";
-
- string mpath;
-
- /* FIXME: what do I do here ? */
- //if (inset_)
- // mpath = OnlyPath(inset_->getMasterFilename());
-
- string const filename = fileDlg.Select(_("Select Child Document"),
- mpath, ext, fl_get_input(dialog_->filename));
- XFlush(fl_get_display());
-
- // check selected filename
- if (filename.empty())
- break;
-
- string const filename2 = MakeRelPath(filename, mpath);
-
- if (prefixIs(filename2, ".."))
- fl_set_input(dialog_->filename, filename.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:
- cout << "inputinclude" << endl;
- /* 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;