#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)
: FormBaseBD(lv, d, _("Print"), new OkApplyCancelPolicy),
// It would be nice if we checked for cases like:
// Print only-odd-pages and from_page == an even number
//
-bool FormPrint::input(FL_OBJECT *, 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);
+ }
+}
FL_OBJECT *obj;
FD_form_print *fdui = new FD_form_print;
- fdui->form = fl_bgn_form(FL_NO_BOX, 340, 360);
+ fdui->form = fl_bgn_form(FL_NO_BOX, 340, 390);
fdui->form->u_vdata = this;
- obj = fl_add_box(FL_UP_BOX, 0, 0, 340, 360, "");
+ obj = fl_add_box(FL_UP_BOX, 0, 0, 340, 390, "");
fdui->input_printer = obj = fl_add_input(FL_NORMAL_INPUT, 90, 225, 230, 30, "");
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_end_group();
- fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 10, 315, 100, 30, _("OK"));
+ fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 10, 350, 100, 30, _("OK"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseOKCB, 0);
{
char const * const dummy = N_("Apply|#A");
- fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 120, 315, 100, 30, idex(_(dummy)));
+ fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 120, 350, 100, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseApplyCB, 0);
{
char const * const dummy = N_("Cancel|C#C^[");
- fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 230, 315, 100, 30, idex(_(dummy)));
+ fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 230, 350, 100, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 180, 110, 150, 90, _("Copies"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lstyle(obj, FL_BOLD_STYLE);
- obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 10, 210, 320, 100, _("Print to"));
+ obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 10, 210, 320, 130, _("Print to"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lstyle(obj, FL_BOLD_STYLE);
+ {
+ char const * const dummy = N_("Browse|#B");
+ fdui->button_browse = obj = fl_add_button(FL_NORMAL_BUTTON, 220, 300, 100, 30, idex(_(dummy)));
+ fl_set_button_shortcut(obj, scex(_(dummy)), 1);
+ }
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_end_form();
fdui->form->fdui = fdui;