]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/gtk/GPrint.C
the convert patch
[lyx.git] / src / frontends / gtk / GPrint.C
index d43be55f7323d87231415439c02d5ce7f186d424..cd9de15b83a13e2d4ac4064877486f18d50ba36d 100644 (file)
@@ -9,18 +9,30 @@
  */
 
 #include <config.h>
-#include <gtkmm.h>
-#include <libglademm.h>
+
+// Too hard to make concept checks work with this file
+#ifdef _GLIBCPP_CONCEPT_CHECKS
+#undef _GLIBCPP_CONCEPT_CHECKS
+#endif
 
 #include "GPrint.h"
 #include "ControlPrint.h"
 #include "ghelpers.h"
 
 #include "PrinterParams.h"
+
+#include "support/convert.h"
 #include "support/lstrings.h"
 
+#include <libglademm.h>
+
+using std::string;
+using namespace lyx::support;
+
+namespace lyx {
+namespace frontend {
 
-GPrint::GPrint(Dialog & parent, string title)
+GPrint::GPrint(Dialog & parent, string const & title)
        : GViewCB<ControlPrint, GViewGladeB>(parent, title, false)
 {
 }
@@ -31,13 +43,13 @@ void GPrint::apply()
        PrinterParams pp;
        pp.target = printer_->get_active() ? PrinterParams::PRINTER : PrinterParams::FILE;
        pp.printer_name = printerEntry_->get_text();
-       pp.file_name = printerEntry_->get_text();
+       pp.file_name = fileEntry_->get_text();
        pp.all_pages = all_->get_active();
        pp.from_page = pp.to_page = 0;
        if (!fromEntry_->get_text().empty()) {
-               pp.from_page = strToInt(fromEntry_->get_text());
+               pp.from_page = convert<int>(fromEntry_->get_text());
                if (!toEntry_->get_text().empty())
-                       pp.to_page = strToInt(toEntry_->get_text());
+                       pp.to_page = convert<int>(toEntry_->get_text());
        }
        pp.odd_pages = odd_->get_active();
        pp.even_pages = even_->get_active();
@@ -56,8 +68,8 @@ void GPrint::update()
        fileEntry_->set_text(pp.file_name);
        all_->set_active(pp.all_pages);
 
-       string const from = ( pp.from_page ? tostr(pp.from_page) : string() );
-       string const to   = ( pp.to_page   ? tostr(pp.to_page)   : string() );
+       string const from = ( pp.from_page ? convert<string>(pp.from_page) : string() );
+       string const to   = ( pp.to_page   ? convert<string>(pp.to_page)   : string() );
        fromEntry_->set_text(from);
        toEntry_->set_text(to);
        odd_->set_active(pp.odd_pages);
@@ -81,7 +93,7 @@ void GPrint::updateUI()
        if (fromTo_->get_active()) {
                string from = fromEntry_->get_text();
                string to = toEntry_->get_text();
-               if (from.empty() || (!to.empty() && strToInt(from) > strToInt(to)))
+               if (from.empty() || (!to.empty() && convert<int>(from) > convert<int>(to)))
                        activate = ButtonPolicy::SMI_INVALID;
        }
        bool const enableCounter = printer_->get_active();
@@ -95,7 +107,7 @@ void GPrint::updateUI()
 void GPrint::onBrowse()
 {
        string const inName = fileEntry_->get_text();
-       string const outName = Glib::locale_to_utf8(controller().Browse(Glib::locale_from_utf8(inName)));
+       string const outName = Glib::locale_to_utf8(controller().browse(Glib::locale_from_utf8(inName)));
        if (outName != inName && !outName.empty())
                fileEntry_->set_text(outName);
        if (!outName.empty())
@@ -133,33 +145,38 @@ void GPrint::doBuild()
        xml_->get_widget("Even", even_);
        xml_->get_widget("Reverse", reverse_);
        xml_->get_widget("Number", number_);
-       xml_->get_widget("Sorted", sorted_);
+       xml_->get_widget("Collate", sorted_);
        xml_->get_widget("FromEntry", fromEntry_);
        xml_->get_widget("ToEntry", toEntry_);
        xml_->get_widget("PrinterEntry", printerEntry_);
        xml_->get_widget("FileEntry", fileEntry_);
+
        Gtk::Button * ok;
        Gtk::Button * cancel;
-       Gtk::Button * apply;
-       xml_->get_widget("OkButton", ok);
+       xml_->get_widget("PrintButton", ok);
        xml_->get_widget("CancelButton", cancel);
-       xml_->get_widget("ApplyButton", apply);
-       bc().setOK(ok);
-       bc().setApply(apply);
-       bc().setCancel(cancel);
-       ok->signal_clicked().connect(SigC::slot(*this, &GViewBase::onOK));
-       apply->signal_clicked().connect(SigC::slot(*this, &GViewBase::onApply));
-       cancel->signal_clicked().connect(SigC::slot(*this, &GViewBase::onCancel));
+
+       setOK(ok);
+       setCancel(cancel);
+
        Gtk::Button * browse;
        xml_->get_widget("Browse", browse);
-       browse->signal_clicked().connect(SigC::slot(*this, &GPrint::onBrowse));
-       fileEntry_->signal_changed().connect(SigC::bind(SigC::slot(*this, &GPrint::onTargetEdit), fileEntry_));
-       printerEntry_->signal_changed().connect(SigC::bind(SigC::slot(*this, &GPrint::onTargetEdit), printerEntry_));
-       fromEntry_->signal_changed().connect(SigC::slot(*this, &GPrint::onFromToEdit));
-       toEntry_->signal_changed().connect(SigC::slot(*this, &GPrint::onFromToEdit));
-       printer_->signal_toggled().connect(SigC::slot(*this, &GPrint::updateUI));
-       file_->signal_toggled().connect(SigC::slot(*this, &GPrint::updateUI));
-       all_->signal_toggled().connect(SigC::slot(*this, &GPrint::updateUI));
-       fromTo_->signal_toggled().connect(SigC::slot(*this, &GPrint::updateUI));
-       number_->signal_changed().connect(SigC::slot(*this, &GPrint::updateUI));
+       browse->signal_clicked().connect(sigc::mem_fun(*this, &GPrint::onBrowse));
+
+       fileEntry_->signal_changed().connect(sigc::bind(sigc::mem_fun(*this, &GPrint::onTargetEdit), fileEntry_));
+       printerEntry_->signal_changed().connect(sigc::bind(sigc::mem_fun(*this, &GPrint::onTargetEdit), printerEntry_));
+       fromEntry_->signal_changed().connect(sigc::mem_fun(*this, &GPrint::onFromToEdit));
+       toEntry_->signal_changed().connect(sigc::mem_fun(*this, &GPrint::onFromToEdit));
+       printer_->signal_toggled().connect(sigc::mem_fun(*this, &GPrint::updateUI));
+       file_->signal_toggled().connect(sigc::mem_fun(*this, &GPrint::updateUI));
+       all_->signal_toggled().connect(sigc::mem_fun(*this, &GPrint::updateUI));
+       fromTo_->signal_toggled().connect(sigc::mem_fun(*this, &GPrint::updateUI));
+       number_->signal_changed().connect(sigc::mem_fun(*this, &GPrint::updateUI));
+
+       controller().initialiseParams("");
+       update();
+       updateUI();
 }
+
+} // namespace frontend
+} // namespace lyx