bc().setOK(dialog_->button_ok);
bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_cancel);
- bc().refresh();
// allow controlling of input and ok/apply (de)activation
fl_set_input_return(dialog_->input_printer,
}
if (ob == dialog_->button_browse) {
- browse();
+ // Get the filename from the dialog
+ string const in_name = fl_get_input(dialog_->input_file);
+ string const out_name = controller().Browse(in_name);
+
+ // Save the filename to the dialog
+ if (out_name != in_name && !out_name.empty()) {
+ fl_set_input(dialog_->input_file, out_name.c_str());
+ input(0, 0);
+ }
+
+ // select the file radio
+ if (!out_name.empty()) {
+ fl_set_button(dialog_->radio_file, 1);
+ fl_set_button(dialog_->radio_printer, 0);
+ }
}
- // it is probably legal to have no printer name since the system will
- // have a default printer set. Or should have.
-// if (fl_get_button(dialog_->radio_printer)
-// && !strlen(fl_get_input(dialog_->input_printer))) {
-// activate = ButtonPolicy::SMI_INVALID;
-// }
- return activate;
-}
-
-
-void FormPrint::browse()
-{
- // Get the filename from the dialog
- string const filename = fl_get_input(dialog_->input_file);
-
- string const title = N_("Print to file");
- string const pattern = "*.ps";
-
- // Show the file browser dialog
- string const new_filename =
- browseFile(controller().lv(), filename, title, pattern,
- make_pair(string(), string()),
- make_pair(string(), string()));
-
- // Save the filename to the dialog
- if (new_filename != filename && !new_filename.empty()) {
- fl_set_input(dialog_->input_file, new_filename.c_str());
- input(0, 0);
+ // if we type into file, select that as a target
+ if (ob == dialog_->input_file && fl_get_button(dialog_->radio_printer)
+ && strlen(fl_get_input(dialog_->input_file))) {
+ fl_set_button(dialog_->radio_file, 1);
+ fl_set_button(dialog_->radio_printer, 0);
+ } else if (ob == dialog_->input_printer) {
+ fl_set_button(dialog_->radio_file, 0);
+ fl_set_button(dialog_->radio_printer, 1);
}
+
+ return activate;
}