]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlPrint.C
Really dull and boring header shit
[lyx.git] / src / frontends / controllers / ControlPrint.C
index ed9d21a3bf382019c43ffde28d9dc89574ad035a..3baa4f9500d52d9cccea99c6fd2bec30951860b5 100644 (file)
@@ -1,14 +1,10 @@
-/* This file is part of
- * ======================================================
- * 
- *           LyX, The Document Processor
- *      
- *          Copyright 2001 The LyX Team.
+/**
+ * \file ControlPrint.C
+ * See the file COPYING.
  *
- *======================================================
+ * \author Angus Leeming
  *
- * \file ControlPrint.C
- * \author Angus Leeming, a.leeming@.ac.uk
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 #endif
 
 #include "ControlPrint.h"
+
+#include "ViewBase.h"
+#include "ButtonControllerBase.h"
+
 #include "buffer.h"
-#include "Dialogs.h"
-#include "LyXView.h"
-#include "lyxrc.h"
+#include "gettext.h"
+#include "helper_funcs.h"
 #include "PrinterParams.h"
-#include "Liason.h"
 
-#include "lyx_gui_misc.h" // WriteAlert
+#include "frontends/Alert.h"
+#include "frontends/Liason.h"
+
+#include "support/LAssert.h"
 
 using Liason::printBuffer;
 using Liason::getPrinterParams;
 
+
 ControlPrint::ControlPrint(LyXView & lv, Dialogs & d)
-       : ControlDialog<ControlConnectBD>(lv, d)
-{
-       d_.showPrint.connect(SigC::slot(this, &ControlPrint::show));
-}
+       : ControlDialogBD(lv, d),
+         params_(0)
+{}
 
 
 void ControlPrint::apply()
 {
-       if (!lv_.view()->available())
+       if (!bufferIsAvailable())
                return;
-   
+
        view().apply();
 
-       if (!printBuffer(lv_.buffer(), params())) {
-               WriteAlert(_("Error:"),
+       if (!printBuffer(buffer(), params())) {
+               Alert::alert(_("Error:"),
                           _("Unable to print"),
                           _("Check that your parameters are correct"));
        }
 }
 
 
-LyXView * ControlPrint::lv() const
-{
-       return &lv_;
-}
-
-
 PrinterParams & ControlPrint::params() const
 {
-       Assert(params_);
+       lyx::Assert(params_);
        return *params_;
 }
 
@@ -68,7 +63,9 @@ PrinterParams & ControlPrint::params() const
 void ControlPrint::setParams()
 {
        if (params_) delete params_;
-       params_ = new PrinterParams(getPrinterParams(lv_.buffer()));
+       params_ = new PrinterParams(getPrinterParams(buffer()));
+
+       bc().valid(); // so that the user can press Ok
 }
 
 
@@ -81,3 +78,12 @@ void ControlPrint::clearParams()
 }
 
 
+string const ControlPrint::Browse(string const & in_name)
+{
+       string const title = _("Print to file");
+       string const pattern = "*.ps";
+
+       // Show the file browser dialog
+       return browseRelFile(&lv_, in_name, buffer()->filePath(),
+                            title, pattern);
+}