diff options
Diffstat (limited to 'src/extension/internal/pdfinput/pdf-input.cpp')
| -rw-r--r-- | src/extension/internal/pdfinput/pdf-input.cpp | 111 |
1 files changed, 59 insertions, 52 deletions
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index c1940b16a..2ee713085 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -39,10 +39,8 @@ #include <gtkmm/radiobutton.h> #include <gtkmm/scale.h> -#if WITH_GTKMM_3_0 #include <glibmm/convert.h> #include <glibmm/miscutils.h> -#endif #include "extension/system.h" #include "extension/input.h" @@ -87,19 +85,13 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _poppler_doc = NULL; #endif // HAVE_POPPLER_CAIRO _pdf_doc = doc; - cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel"))); - okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))); + cancelbutton = Gtk::manage(new Gtk::Button(_("_Cancel"), true)); + okbutton = Gtk::manage(new Gtk::Button(_("_OK"), true)); _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:"))); // Page number -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _pdf_doc->getNumPages(), 1, 10, 0); + auto _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _pdf_doc->getNumPages(), 1, 10, 0); _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1)); -#else - Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage( - new class Gtk::Adjustment(1, 1, _pdf_doc->getNumPages(), 1, 10, 0)); - _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1)); -#endif _labelTotalPages = Gtk::manage(new class Gtk::Label()); hbox2 = Gtk::manage(new class Gtk::HBox(false, 0)); // Disable the page selector when there's only one page @@ -137,13 +129,8 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _labelViaInternal = Gtk::manage(new class Gtk::Label(_("Import via internal (Poppler derived) library. Text is stored as text but white space is missing. Meshes are converted to tiles, the number depends on the precision set below."))); #endif -#if WITH_GTKMM_3_0 _fallbackPrecisionSlider_adj = Gtk::Adjustment::create(2, 1, 256, 1, 10, 10); _fallbackPrecisionSlider = Gtk::manage(new class Gtk::Scale(_fallbackPrecisionSlider_adj)); -#else - _fallbackPrecisionSlider_adj = Gtk::manage(new class Gtk::Adjustment(2, 1, 256, 1, 10, 10)); - _fallbackPrecisionSlider = Gtk::manage(new class Gtk::HScale(*_fallbackPrecisionSlider_adj)); -#endif _fallbackPrecisionSlider->set_value(2.0); _labelPrecisionComment = Gtk::manage(new class Gtk::Label(_("rough"))); hbox6 = Gtk::manage(new class Gtk::HBox(false, 4)); @@ -170,9 +157,50 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) okbutton->set_can_focus(); okbutton->set_can_default(); okbutton->set_relief(Gtk::RELIEF_NORMAL); - this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END); + +#if GTK_CHECK_VERSION(3,16,0) + _labelSelect->set_xalign(0.5); + _labelSelect->set_yalign(0.5); + _labelTotalPages->set_xalign(0.5); + _labelTotalPages->set_yalign(0.5); + _labelPrecision->set_xalign(0.0); + _labelPrecision->set_yalign(0.5); + _labelPrecisionWarning->set_xalign(0.0); + _labelPrecisionWarning->set_yalign(0.5); + _labelPrecisionComment->set_xalign(0.5); + _labelPrecisionComment->set_yalign(0.5); +#else _labelSelect->set_alignment(0.5,0.5); - _labelSelect->set_padding(4,0); + _labelTotalPages->set_alignment(0.5,0.5); + _labelPrecision->set_alignment(0,0.5); + _labelPrecisionWarning->set_alignment(0,0.5); + _labelPrecisionComment->set_alignment(0.5,0.5); +#endif + +#if GTK_CHECK_VERSION(3,12,0) + _labelSelect->set_margin_start(4); + _labelSelect->set_margin_end(4); + _labelTotalPages->set_margin_start(4); + _labelTotalPages->set_margin_end(4); + _labelPrecision->set_margin_start(4); + _labelPrecision->set_margin_end(4); + _labelPrecisionWarning->set_margin_start(4); + _labelPrecisionWarning->set_margin_end(4); + _labelPrecisionComment->set_margin_start(4); + _labelPrecisionComment->set_margin_end(4); +#else + _labelSelect->set_margin_left(4); + _labelSelect->set_margin_right(4); + _labelTotalPages->set_margin_left(4); + _labelTotalPages->set_margin_right(4); + _labelPrecision->set_margin_left(4); + _labelPrecision->set_margin_right(4); + _labelPrecisionWarning->set_margin_left(4); + _labelPrecisionWarning->set_margin_right(4); + _labelPrecisionComment->set_margin_left(4); + _labelPrecisionComment->set_margin_right(4); +#endif + _labelSelect->set_justify(Gtk::JUSTIFY_LEFT); _labelSelect->set_line_wrap(false); _labelSelect->set_use_markup(false); @@ -182,8 +210,6 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _pageNumberSpin->set_numeric(true); _pageNumberSpin->set_digits(0); _pageNumberSpin->set_wrap(false); - _labelTotalPages->set_alignment(0.5,0.5); - _labelTotalPages->set_padding(4,0); _labelTotalPages->set_justify(Gtk::JUSTIFY_LEFT); _labelTotalPages->set_line_wrap(false); _labelTotalPages->set_use_markup(false); @@ -202,14 +228,10 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) vbox2->pack_start(*hbox3); _pageSettingsFrame->add(*vbox2); _pageSettingsFrame->set_border_width(4); - _labelPrecision->set_alignment(0,0.5); - _labelPrecision->set_padding(4,0); _labelPrecision->set_justify(Gtk::JUSTIFY_LEFT); _labelPrecision->set_line_wrap(true); _labelPrecision->set_use_markup(false); _labelPrecision->set_selectable(false); - _labelPrecisionWarning->set_alignment(0,0.5); - _labelPrecisionWarning->set_padding(4,0); _labelPrecisionWarning->set_justify(Gtk::JUSTIFY_LEFT); _labelPrecisionWarning->set_line_wrap(true); _labelPrecisionWarning->set_use_markup(true); @@ -226,6 +248,14 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _importViaInternal->set_active(true); _labelViaPoppler->set_line_wrap(true); _labelViaInternal->set_line_wrap(true); + +# if GTK_CHECK_VERSION(3,16,0) + _labelViaPoppler->set_xalign(0); + _labelViaInternal->set_xalign(0); +# else + _labelViaPoppler->set_alignment(0, 0.5); + _labelViaInternal->set_alignment(0, 0.5); +# endif #endif _fallbackPrecisionSlider->set_size_request(180,-1); @@ -235,8 +265,6 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _fallbackPrecisionSlider->set_draw_value(true); _fallbackPrecisionSlider->set_value_pos(Gtk::POS_TOP); _labelPrecisionComment->set_size_request(90,-1); - _labelPrecisionComment->set_alignment(0.5,0.5); - _labelPrecisionComment->set_padding(4,0); _labelPrecisionComment->set_justify(Gtk::JUSTIFY_LEFT); _labelPrecisionComment->set_line_wrap(false); _labelPrecisionComment->set_use_markup(false); @@ -273,20 +301,14 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) // vbox3->pack_start(*hbox5, Gtk::PACK_SHRINK, 4); _importSettingsFrame->add(*vbox3); _importSettingsFrame->set_border_width(4); - vbox1->pack_start(*_pageSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0); - vbox1->pack_start(*_importSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0); + vbox1->pack_start(*_pageSettingsFrame, Gtk::PACK_SHRINK, 0); + vbox1->pack_start(*_importSettingsFrame, Gtk::PACK_SHRINK, 0); hbox1->pack_start(*vbox1); - hbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 4); + hbox1->pack_start(*_previewArea, Gtk::PACK_SHRINK, 4); -#if WITH_GTKMM_3_0 get_content_area()->set_homogeneous(false); get_content_area()->set_spacing(0); get_content_area()->pack_start(*hbox1); -#else - this->get_vbox()->set_homogeneous(false); - this->get_vbox()->set_spacing(0); - this->get_vbox()->pack_start(*hbox1); -#endif this->set_title(_("PDF Import Settings")); this->set_modal(true); @@ -300,12 +322,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) this->show_all(); // Connect signals -#if WITH_GTKMM_3_0 _previewArea->signal_draw().connect(sigc::mem_fun(*this, &PdfImportDialog::_onDraw)); -#else - _previewArea->signal_expose_event().connect(sigc::mem_fun(*this, &PdfImportDialog::_onExposePreview)); -#endif - _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &PdfImportDialog::_onPageNumberChanged)); _cropCheck->signal_toggled().connect(sigc::mem_fun(*this, &PdfImportDialog::_onToggleCropping)); _fallbackPrecisionSlider_adj->signal_value_changed().connect(sigc::mem_fun(*this, &PdfImportDialog::_onPrecisionChanged)); @@ -527,16 +544,6 @@ static void copy_cairo_surface_to_pixbuf (cairo_surface_t *surface, #endif -/** - * \brief Updates the preview area with the previously rendered thumbnail - */ -#if !WITH_GTKMM_3_0 -bool PdfImportDialog::_onExposePreview(GdkEventExpose * /*event*/) { - Cairo::RefPtr<Cairo::Context> cr = _previewArea->get_window()->create_cairo_context(); - return _onDraw(cr); -} -#endif - bool PdfImportDialog::_onDraw(const Cairo::RefPtr<Cairo::Context>& cr) { // Check if we have a thumbnail at all if (!_thumb_data) { @@ -939,8 +946,8 @@ void PdfInput::init(void) { "<input>\n" "<extension>.pdf</extension>\n" "<mimetype>application/pdf</mimetype>\n" - "<filetypename>" N_("Adobe PDF (*.pdf)") "</filetypename>\n" - "<filetypetooltip>" N_("Adobe Portable Document Format") "</filetypetooltip>\n" + "<filetypename>" N_("Portable Document Format (*.pdf)") "</filetypename>\n" + "<filetypetooltip>" N_("Portable Document Format") "</filetypetooltip>\n" "</input>\n" "</inkscape-extension>", new PdfInput()); |
