mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 13:46:43 +00:00
d1182f17da
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2141 a592a061-630c-0410-9148-cb99ea01b6c8
97 lines
1.9 KiB
C
97 lines
1.9 KiB
C
/* This file is part of
|
|
* ======================================================
|
|
*
|
|
* LyX, The Document Processor
|
|
*
|
|
* Copyright 2001 The LyX Team.
|
|
*
|
|
*======================================================
|
|
*
|
|
* \file ControlPrint.C
|
|
* \author Angus Leeming, a.leeming@.ac.uk
|
|
*/
|
|
|
|
#include <config.h>
|
|
#include <utility>
|
|
|
|
#ifdef __GNUG__
|
|
#pragma implementation
|
|
#endif
|
|
|
|
#include "ViewBase.h"
|
|
#include "ButtonControllerBase.h"
|
|
#include "ControlPrint.h"
|
|
#include "buffer.h"
|
|
#include "Dialogs.h"
|
|
#include "LyXView.h"
|
|
#include "lyxrc.h"
|
|
#include "PrinterParams.h"
|
|
#include "Liason.h"
|
|
#include "helper_funcs.h" // browseFile
|
|
#include "lyx_gui_misc.h" // WriteAlert
|
|
#include "gettext.h"
|
|
#include "BufferView.h"
|
|
|
|
using Liason::printBuffer;
|
|
using Liason::getPrinterParams;
|
|
using std::make_pair;
|
|
|
|
ControlPrint::ControlPrint(LyXView & lv, Dialogs & d)
|
|
: ControlDialog<ControlConnectBD>(lv, d),
|
|
params_(0)
|
|
{
|
|
d_.showPrint.connect(SigC::slot(this, &ControlPrint::show));
|
|
}
|
|
|
|
|
|
void ControlPrint::apply()
|
|
{
|
|
if (!lv_.view()->available())
|
|
return;
|
|
|
|
view().apply();
|
|
|
|
if (!printBuffer(lv_.buffer(), params())) {
|
|
WriteAlert(_("Error:"),
|
|
_("Unable to print"),
|
|
_("Check that your parameters are correct"));
|
|
}
|
|
}
|
|
|
|
|
|
PrinterParams & ControlPrint::params() const
|
|
{
|
|
lyx::Assert(params_);
|
|
return *params_;
|
|
}
|
|
|
|
|
|
void ControlPrint::setParams()
|
|
{
|
|
if (params_) delete params_;
|
|
params_ = new PrinterParams(getPrinterParams(lv_.buffer()));
|
|
|
|
bc().valid(); // so that the user can press Ok
|
|
}
|
|
|
|
|
|
void ControlPrint::clearParams()
|
|
{
|
|
if (params_) {
|
|
delete params_;
|
|
params_ = 0;
|
|
}
|
|
}
|
|
|
|
|
|
string const ControlPrint::Browse(string const & in_name)
|
|
{
|
|
string const title = N_("Print to file");
|
|
string const pattern = "*.ps";
|
|
|
|
// Show the file browser dialog
|
|
return browseFile(&lv_, in_name, title, pattern,
|
|
make_pair(string(), string()),
|
|
make_pair(string(), string()));
|
|
}
|