diff options
| author | Moritz Eberl <moritz@semiodesk.com> | 2016-04-13 10:22:31 +0000 |
|---|---|---|
| committer | Moritz Eberl <moritz@semiodesk.com> | 2016-04-13 10:22:31 +0000 |
| commit | 9dc9b855edf5f891856ad1c9a63eae2266bb9cfa (patch) | |
| tree | 45c8c6d192dbf72c2e543f6e4b5716999c3bb3af /src/extension | |
| parent | Modified the windows build to integrate gmodule-2.0 and loader.cpp/.h (diff) | |
| parent | Fixed FIXMEs in Cmake build (set flags when needed) (diff) | |
| download | inkscape-9dc9b855edf5f891856ad1c9a63eae2266bb9cfa.tar.gz inkscape-9dc9b855edf5f891856ad1c9a63eae2266bb9cfa.zip | |
Merge
(bzr r14761.1.4)
Diffstat (limited to 'src/extension')
| -rw-r--r-- | src/extension/dbus/document-interface.cpp | 4 | ||||
| -rw-r--r-- | src/extension/execution-env.cpp | 2 | ||||
| -rw-r--r-- | src/extension/internal/image-resolution.cpp | 78 |
3 files changed, 74 insertions, 10 deletions
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 121a49a25..d0a2e81aa 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -1052,7 +1052,7 @@ void document_interface_pause_updates(DocumentInterface *doc_interface, GError * SPDesktop *desk = doc_interface->target.getDesktop(); g_return_if_fail(ensure_desktop_valid(desk, error)); doc_interface->updates = FALSE; - desk->canvas->drawing_disabled = 1; + desk->canvas->_drawing_disabled = 1; } void document_interface_resume_updates(DocumentInterface *doc_interface, GError ** error) @@ -1060,7 +1060,7 @@ void document_interface_resume_updates(DocumentInterface *doc_interface, GError SPDesktop *desk = doc_interface->target.getDesktop(); g_return_if_fail(ensure_desktop_valid(desk, error)); doc_interface->updates = TRUE; - desk->canvas->drawing_disabled = 0; + desk->canvas->_drawing_disabled = 0; //FIXME: use better verb than rect. Inkscape::DocumentUndo::done(doc_interface->target.getDocument(), SP_VERB_CONTEXT_RECT, "Multiple actions"); } diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 31491605b..d5c80f26e 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -128,7 +128,7 @@ ExecutionEnv::createWorkingDialog (void) { } SPDesktop *desktop = (SPDesktop *)_doc; - GtkWidget *toplevel = gtk_widget_get_toplevel(&(desktop->canvas->widget)); + GtkWidget *toplevel = gtk_widget_get_toplevel(GTK_WIDGET(desktop->canvas)); if (!toplevel || !gtk_widget_is_toplevel (toplevel)) return; Gtk::Window *window = Glib::wrap(GTK_WINDOW(toplevel), false); diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp index e96fd6437..57142bbdd 100644 --- a/src/extension/internal/image-resolution.cpp +++ b/src/extension/internal/image-resolution.cpp @@ -34,6 +34,18 @@ #include <Magick++.h> #endif +#define noIMAGE_RESOLUTION_DEBUG + +#ifdef IMAGE_RESOLUTION_DEBUG +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /* */ +#endif + namespace Inkscape { namespace Extension { namespace Internal { @@ -118,17 +130,38 @@ void ImageResolution::readpng(char const *fn) { png_read_info(png_ptr, info_ptr); png_uint_32 res_x, res_y; +#ifdef PNG_INCH_CONVERSIONS_SUPPORTED + debug("PNG_INCH_CONVERSIONS_SUPPORTED"); + res_x = png_get_x_pixels_per_inch(png_ptr, info_ptr); + res_y = png_get_y_pixels_per_inch(png_ptr, info_ptr); + if (res_x != 0 && res_y != 0) { + ok_ = true; + x_ = res_x * 1.0; // FIXME: implicit conversion of png_uint_32 to double ok? + y_ = res_y * 1.0; // FIXME: implicit conversion of png_uint_32 to double ok? + } +#else + debug("PNG_RESOLUTION_METER"); int unit_type; + // FIXME: png_get_pHYs() fails to return expected values + // with clang (based on LLVM 3.2svn) from Xcode 4.6.3 (OS X 10.7.5) png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, &unit_type); - png_destroy_read_struct(&png_ptr, &info_ptr, 0); - fclose(fp); - if (unit_type == PNG_RESOLUTION_METER) { ok_ = true; x_ = res_x * 2.54 / 100; y_ = res_y * 2.54 / 100; } +#endif + + png_destroy_read_struct(&png_ptr, &info_ptr, 0); + fclose(fp); + + if (ok_) { + debug("xdpi: %f", x_); + debug("ydpi: %f", y_); + } else { + debug("FAILED"); + } } #else @@ -206,6 +239,13 @@ void ImageResolution::readexif(char const *fn) { ok_ = true; } exif_data_free(ed); + + if (ok_) { + debug("xdpi: %f", x_); + debug("ydpi: %f", y_); + } else { + debug("FAILED"); + } } #else @@ -256,6 +296,13 @@ void ImageResolution::readexiv(char const *fn) { } } ok_ = havex && havey; + + if (ok_) { + debug("xdpi: %f", x_); + debug("ydpi: %f", y_); + } else { + debug("FAILED"); + } } #else @@ -312,6 +359,7 @@ void ImageResolution::readjfif(char const *fn) { jpeg_stdio_src(&cinfo, ifd); jpeg_read_header(&cinfo, TRUE); + debug("cinfo.[XY]_density"); if (cinfo.saw_JFIF_marker) { // JFIF APP0 marker was seen if ( cinfo.density_unit == 1 ) { // dots/inch x_ = cinfo.X_density; @@ -331,6 +379,13 @@ void ImageResolution::readjfif(char const *fn) { } jpeg_destroy_decompress(&cinfo); fclose(ifd); + + if (ok_) { + debug("xdpi: %f", x_); + debug("ydpi: %f", y_); + } else { + debug("FAILED"); + } } #else @@ -344,16 +399,17 @@ void ImageResolution::readjfif(char const *) { #ifdef WITH_IMAGE_MAGICK void ImageResolution::readmagick(char const *fn) { Magick::Image image; + debug("Trying image.read"); try { image.read(fn); } catch (Magick::Error & err) { - g_warning("ImageMagick error: %s", err.what()); + debug("ImageMagick error: %s", err.what()); return; - } catch (...) { - g_warning("ImageResolution::readmagick: Unknown error"); + } catch (std::exception & err) { + debug("ImageResolution::readmagick: %s", err.what()); return; } - + debug("image.[xy]Resolution"); std::string const type = image.magick(); x_ = image.xResolution(); y_ = image.yResolution(); @@ -367,6 +423,14 @@ void ImageResolution::readmagick(char const *fn) { if (x_ != 0 && y_ != 0) { ok_ = true; } + + if (ok_) { + debug("xdpi: %f", x_); + debug("ydpi: %f", y_); + } else { + debug("FAILED"); + debug("Using default Inkscape import resolution"); + } } #else |
