[gloobus-preview] Workaround missing function

mkasik mkasik at fedoraproject.org
Mon Aug 8 15:55:36 UTC 2011


commit 634be9fe2777e4db7cf4ef3491016a441c065b20
Author: Marek Kasik <mkasik at redhat.com>
Date:   Mon Aug 8 17:54:37 2011 +0200

    Workaround missing function
    
    Resolves: #698159

 gloobus-page-render-to-pixbuf.patch |  254 +++++++++++++++++++++++++++++++++++
 gloobus-preview.spec                |    8 +-
 2 files changed, 261 insertions(+), 1 deletions(-)
---
diff --git a/gloobus-page-render-to-pixbuf.patch b/gloobus-page-render-to-pixbuf.patch
new file mode 100644
index 0000000..6935867
--- /dev/null
+++ b/gloobus-page-render-to-pixbuf.patch
@@ -0,0 +1,254 @@
+--- gloobus-preview-0.4.1/src/plugin-openoffice/plugin-openoffice.cpp	2009-10-30 13:45:32.000000000 +0100
++++ gloobus-preview-0.4.1/src/plugin-openoffice/plugin-openoffice.cpp	2011-08-08 15:26:49.000000000 +0200
+@@ -79,6 +79,114 @@ int	iOO::get_page_height_unscaled ( void
+ 	return y;	
+ }
+ //====================== GET PAGES PIXBUF =======================//
++#if POPPLER_CHECK_VERSION(0, 17, 0)
++static void
++copy_cairo_surface_to_pixbuf (cairo_surface_t *surface,
++			      GdkPixbuf       *pixbuf)
++{
++  int cairo_width, cairo_height, cairo_rowstride;
++  unsigned char *pixbuf_data, *dst, *cairo_data;
++  int pixbuf_rowstride, pixbuf_n_channels;
++  unsigned int *src;
++  int x, y;
++
++  cairo_width = cairo_image_surface_get_width (surface);
++  cairo_height = cairo_image_surface_get_height (surface);
++  cairo_rowstride = cairo_image_surface_get_stride (surface);
++  cairo_data = cairo_image_surface_get_data (surface);
++
++  pixbuf_data = gdk_pixbuf_get_pixels (pixbuf);
++  pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
++  pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
++
++  if (cairo_width > gdk_pixbuf_get_width (pixbuf))
++    cairo_width = gdk_pixbuf_get_width (pixbuf);
++  if (cairo_height > gdk_pixbuf_get_height (pixbuf))
++    cairo_height = gdk_pixbuf_get_height (pixbuf);
++  for (y = 0; y < cairo_height; y++)
++    {
++      src = (unsigned int *) (cairo_data + y * cairo_rowstride);
++      dst = pixbuf_data + y * pixbuf_rowstride;
++      for (x = 0; x < cairo_width; x++) 
++	{
++	  dst[0] = (*src >> 16) & 0xff;
++	  dst[1] = (*src >> 8) & 0xff; 
++	  dst[2] = (*src >> 0) & 0xff;
++	  if (pixbuf_n_channels == 4)
++	      dst[3] = (*src >> 24) & 0xff;
++	  dst += pixbuf_n_channels;
++	  src++;
++	}
++    }
++}
++
++static void
++_poppler_page_render_to_pixbuf (PopplerPage *page,
++				int src_x, int src_y,
++				int src_width, int src_height,
++				double scale,
++				int rotation,
++				GdkPixbuf *pixbuf)
++{
++  cairo_t *cr;
++  cairo_surface_t *surface;
++
++  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
++					src_width, src_height);
++  cr = cairo_create (surface);
++  cairo_save (cr);
++  switch (rotation) {
++  case 90:
++	  cairo_translate (cr, src_x + src_width, -src_y);
++	  break;
++  case 180:
++	  cairo_translate (cr, src_x + src_width, src_y + src_height);
++	  break;
++  case 270:
++	  cairo_translate (cr, -src_x, src_y + src_height);
++	  break;
++  default:
++	  cairo_translate (cr, -src_x, -src_y);
++  }
++
++  if (scale != 1.0)
++	  cairo_scale (cr, scale, scale);
++
++  if (rotation != 0)
++	  cairo_rotate (cr, rotation * G_PI / 180.0);
++
++  poppler_page_render (page, cr);
++  cairo_restore (cr);
++
++  cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
++  cairo_set_source_rgb (cr, 1., 1., 1.);
++  cairo_paint (cr);
++
++  cairo_destroy (cr);
++
++  copy_cairo_surface_to_pixbuf (surface, pixbuf);
++  cairo_surface_destroy (surface);
++}
++
++void
++poppler_page_render_to_pixbuf (PopplerPage *page,
++			       int src_x, int src_y,
++			       int src_width, int src_height,
++			       double scale,
++			       int rotation,
++			       GdkPixbuf *pixbuf)
++{
++  g_return_if_fail (POPPLER_IS_PAGE (page));
++  g_return_if_fail (scale > 0.0);
++  g_return_if_fail (pixbuf != NULL);
++
++  _poppler_page_render_to_pixbuf (page, src_x, src_y,
++				  src_width, src_height,
++				  scale, rotation,
++				  pixbuf);
++}
++#endif
++
+ GdkPixbuf* iOO::get_page_pixbuf ( int n_page )
+ {
+ 	GdkPixbuf* temp;
+--- gloobus-preview-0.4.1/src/plugin-openoffice/plugin-openoffice.h	2009-09-14 15:51:19.000000000 +0200
++++ gloobus-preview-0.4.1/src/plugin-openoffice/plugin-openoffice.h	2011-08-08 15:24:39.000000000 +0200
+@@ -7,6 +7,7 @@
+ #include "../gloobus-preview-interface-document.h"
+ 
+ #include <poppler.h>
++#include <glib/poppler-features.h>
+ 
+ 
+ class iOO : public iDocument
+--- gloobus-preview-0.4.1/src/plugin-pdf/plugin-pdf.cpp	2011-08-08 15:39:51.000000000 +0200
++++ gloobus-preview-0.4.1/src/plugin-pdf/plugin-pdf.cpp	2011-08-08 15:39:21.000000000 +0200
+@@ -61,6 +61,114 @@ int	iPdf::get_page_height_unscaled ( voi
+ 	return y;	
+ }
+ //====================== GET PAGE PIXBUF =======================//
++#if POPPLER_CHECK_VERSION(0, 17, 0)
++static void
++copy_cairo_surface_to_pixbuf (cairo_surface_t *surface,
++			      GdkPixbuf       *pixbuf)
++{
++  int cairo_width, cairo_height, cairo_rowstride;
++  unsigned char *pixbuf_data, *dst, *cairo_data;
++  int pixbuf_rowstride, pixbuf_n_channels;
++  unsigned int *src;
++  int x, y;
++
++  cairo_width = cairo_image_surface_get_width (surface);
++  cairo_height = cairo_image_surface_get_height (surface);
++  cairo_rowstride = cairo_image_surface_get_stride (surface);
++  cairo_data = cairo_image_surface_get_data (surface);
++
++  pixbuf_data = gdk_pixbuf_get_pixels (pixbuf);
++  pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
++  pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
++
++  if (cairo_width > gdk_pixbuf_get_width (pixbuf))
++    cairo_width = gdk_pixbuf_get_width (pixbuf);
++  if (cairo_height > gdk_pixbuf_get_height (pixbuf))
++    cairo_height = gdk_pixbuf_get_height (pixbuf);
++  for (y = 0; y < cairo_height; y++)
++    {
++      src = (unsigned int *) (cairo_data + y * cairo_rowstride);
++      dst = pixbuf_data + y * pixbuf_rowstride;
++      for (x = 0; x < cairo_width; x++) 
++	{
++	  dst[0] = (*src >> 16) & 0xff;
++	  dst[1] = (*src >> 8) & 0xff; 
++	  dst[2] = (*src >> 0) & 0xff;
++	  if (pixbuf_n_channels == 4)
++	      dst[3] = (*src >> 24) & 0xff;
++	  dst += pixbuf_n_channels;
++	  src++;
++	}
++    }
++}
++
++static void
++_poppler_page_render_to_pixbuf (PopplerPage *page,
++				int src_x, int src_y,
++				int src_width, int src_height,
++				double scale,
++				int rotation,
++				GdkPixbuf *pixbuf)
++{
++  cairo_t *cr;
++  cairo_surface_t *surface;
++
++  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
++					src_width, src_height);
++  cr = cairo_create (surface);
++  cairo_save (cr);
++  switch (rotation) {
++  case 90:
++	  cairo_translate (cr, src_x + src_width, -src_y);
++	  break;
++  case 180:
++	  cairo_translate (cr, src_x + src_width, src_y + src_height);
++	  break;
++  case 270:
++	  cairo_translate (cr, -src_x, src_y + src_height);
++	  break;
++  default:
++	  cairo_translate (cr, -src_x, -src_y);
++  }
++
++  if (scale != 1.0)
++	  cairo_scale (cr, scale, scale);
++
++  if (rotation != 0)
++	  cairo_rotate (cr, rotation * G_PI / 180.0);
++
++  poppler_page_render (page, cr);
++  cairo_restore (cr);
++
++  cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
++  cairo_set_source_rgb (cr, 1., 1., 1.);
++  cairo_paint (cr);
++
++  cairo_destroy (cr);
++
++  copy_cairo_surface_to_pixbuf (surface, pixbuf);
++  cairo_surface_destroy (surface);
++}
++
++void
++poppler_page_render_to_pixbuf (PopplerPage *page,
++			       int src_x, int src_y,
++			       int src_width, int src_height,
++			       double scale,
++			       int rotation,
++			       GdkPixbuf *pixbuf)
++{
++  g_return_if_fail (POPPLER_IS_PAGE (page));
++  g_return_if_fail (scale > 0.0);
++  g_return_if_fail (pixbuf != NULL);
++
++  _poppler_page_render_to_pixbuf (page, src_x, src_y,
++				  src_width, src_height,
++				  scale, rotation,
++				  pixbuf);
++}
++#endif
++
+ GdkPixbuf* iPdf::get_page_pixbuf ( int n_page )
+ {
+ 	GdkPixbuf* temp;
+--- gloobus-preview-0.4.1/src/plugin-pdf/plugin-pdf.h	2009-09-14 15:51:19.000000000 +0200
++++ gloobus-preview-0.4.1/src/plugin-pdf/plugin-pdf.h	2011-08-08 15:40:00.000000000 +0200
+@@ -7,6 +7,7 @@
+ #include "../gloobus-preview-interface-document.h"
+ 
+ #include <poppler.h>
++#include <glib/poppler-features.h>
+ 
+ 
+ class iPdf : public iDocument
diff --git a/gloobus-preview.spec b/gloobus-preview.spec
index 2e3531d..39cc29b 100644
--- a/gloobus-preview.spec
+++ b/gloobus-preview.spec
@@ -1,6 +1,6 @@
 Name:           gloobus-preview
 Version:        0.4.1
-Release:        14%{?dist}
+Release:        15%{?dist}
 Summary:        A Gnome extension to enable previews for any kind of file
 
 Group:          Applications/File          
@@ -12,6 +12,7 @@ Source1:        README.fedora.tar.gz
 # This patch fixes problems with autotools not respecting install directories
 # it also includes the rebuild of the autotools scripts required
 Patch0:         gloobus-location-prereconf.patch
+Patch1:         gloobus-page-render-to-pixbuf.patch
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -38,6 +39,7 @@ need to open their default applications.
 %setup -q
 %setup -q -D -T -a 1
 %patch0 -p1
+%patch1 -p1
 find . -name '*.cpp' -exec chmod -x {} \;
 find . -name '*.h' -exec chmod -x {} \;
 libtoolize
@@ -82,6 +84,10 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 %doc README AUTHORS COPYING THANKS README.fedora
 
 %changelog
+* Mon Aug  8 2011 Marek Kasik <mkasik at redhat.com> - 0.4.1-15
+- Workaround missing function
+- Resolves: #698159
+
 * Sun Jul 17 2011 Rex Dieter <rdieter at fedoraproject.org> - 0.4.1-14
 - rebuild (poppler)
 


More information about the scm-commits mailing list