#include "Liason.h"
#include "debug.h"
#include "BufferView.h"
-#include "lyx_gui_misc.h" // WriteAlert
+#include "lyx_gui_misc.h" // WriteAlert
+#include "xform_helpers.h" // for browseFile
#ifdef SIGC_CXX_NAMESPACES
using SigC::slot;
using Liason::getPrinterParams;
#endif
+using std::make_pair;
FormPrint::FormPrint(LyXView * lv, Dialogs * d)
- : FormBase(lv, d, BUFFER_DEPENDENT, _("Print"), new OkApplyCancelPolicy),
+ : FormBaseBD(lv, d, _("Print"), new OkApplyCancelPolicy),
dialog_(0), target_(2), order_(2), which_(3)
{
// let the dialog be shown
{
dialog_ = build_print();
- // manage the ok, apply and cancel/close buttons
+ // Workaround dumb xforms sizing bug
+ minw_ = form()->w;
+ minh_ = form()->h;
+
+ // Manage the ok, apply and cancel/close buttons
bc_.setOK(dialog_->button_ok);
bc_.setApply(dialog_->button_apply);
bc_.setCancel(dialog_->button_cancel);
}
-void FormPrint::connect()
-{
- FormBase::connect();
- fl_set_form_minsize(dialog_->form,
- dialog_->form->w,
- dialog_->form->h);
-}
-
-
-FL_FORM * const FormPrint::form() const
+FL_FORM * FormPrint::form() const
{
if (dialog_) return dialog_->form;
return 0;
string(fl_get_input(dialog_->input_file)),
wp, from, to,
static_cast<bool>(order_.getButton()),
- static_cast<bool>(fl_get_button(dialog_->
- radio_unsorted)),
+ !static_cast<bool>(fl_get_button(dialog_->
+ radio_collated)),
strToInt(fl_get_input(dialog_->input_count))))) {
WriteAlert(_("Error:"),
_("Unable to print"),
fl_set_input(dialog_->input_count,
tostr(pp.count_copies).c_str());
+ bc_.valid(true);
}
}
// It would be nice if we checked for cases like:
// Print only-odd-pages and from_page == an even number
//
-bool FormPrint::input(long)
+bool FormPrint::input(FL_OBJECT * ob, long)
{
bool activate = true;
activate = false;
}
+ if (ob == dialog_->button_browse) {
+ browse();
+ }
+
// 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)
// }
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(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);
+ }
+}