epdfview-0.1.8-fixes-1.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. Submitted By: Ken Moffat <ken at linuxfromscratch dot org>
  2. Date: 2012-08-22
  3. Initial Package Version: 0.1.8
  4. Upstream Status: Varies
  5. Origin: Found at fedora.
  6. Description: Three fixes found at fedora. For the first (only glib.h
  7. can be included directly, with recent glib), we used to use a sed - but
  8. the other two fixes need patches so I've put them all together.
  9. Second part is from upstream and fixes trashed colours
  10. Upstream: http://trac.emma-soft.com/epdfview/changeset/367/trunk
  11. Fixes bug: https://bugzilla.redhat.com/show_bug.cgi?id=745483
  12. Third part is the most critical - from Jiri Popelka, found at
  13. https://bugzilla.redhat.com/show_bug.cgi?id=841880 - looks as if fedora
  14. haven't applied it yet. It solves building with cups-1.6.
  15. diff -Naur epdfview-0.1.8.orig/src/gtk/StockIcons.h epdfview-0.1.8/src/gtk/StockIcons.h
  16. --- epdfview-0.1.8.orig/src/gtk/StockIcons.h 2011-05-28 11:24:57.000000000 +0100
  17. +++ epdfview-0.1.8/src/gtk/StockIcons.h 2012-08-22 20:06:08.728195806 +0100
  18. @@ -18,7 +18,7 @@
  19. #if !defined (__STOCK_ICONS_H__)
  20. #define __STOCK_ICONS_H__
  21. -#include <glib/gmacros.h>
  22. +#include <glib.h>
  23. G_BEGIN_DECLS
  24. diff -Naur epdfview-0.1.8.orig/src/PDFDocument.cxx epdfview-0.1.8/src/PDFDocument.cxx
  25. --- epdfview-0.1.8.orig/src/PDFDocument.cxx 2011-05-28 11:25:01.000000000 +0100
  26. +++ epdfview-0.1.8/src/PDFDocument.cxx 2012-08-22 20:07:03.627913886 +0100
  27. @@ -20,6 +20,7 @@
  28. #include <time.h>
  29. #include <poppler.h>
  30. #include <unistd.h>
  31. +#include <algorithm>
  32. #include "epdfview.h"
  33. using namespace ePDFView;
  34. @@ -33,6 +34,24 @@
  35. static PageMode convertPageMode (gint pageMode);
  36. static gchar *getAbsoluteFileName (const gchar *fileName);
  37. +namespace
  38. +{
  39. + void
  40. + convert_bgra_to_rgba (guint8 *data, int width, int height)
  41. + {
  42. + using std::swap;
  43. +
  44. + for (int y = 0; y < height; y++)
  45. + {
  46. + for (int x = 0; x < width; x++)
  47. + {
  48. + swap(data[0], data[2]);
  49. + data += 4;
  50. + }
  51. + }
  52. + }
  53. +}
  54. +
  55. ///
  56. /// @brief Constructs a new PDFDocument object.
  57. ///
  58. @@ -650,6 +669,7 @@
  59. poppler_page_render (page, context);
  60. cairo_destroy(context);
  61. cairo_surface_destroy (surface);
  62. + convert_bgra_to_rgba(renderedPage->getData (), width, height);
  63. #else // !HAVE_POPPLER_0_17_0
  64. // Create the pixbuf from the data and render to it.
  65. GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data (renderedPage->getData (),
  66. diff -Naur epdfview-0.1.8.orig/src/PrintPter.cxx epdfview-0.1.8/src/PrintPter.cxx
  67. --- epdfview-0.1.8.orig/src/PrintPter.cxx 2011-05-28 11:25:01.000000000 +0100
  68. +++ epdfview-0.1.8/src/PrintPter.cxx 2012-08-22 20:11:46.362436859 +0100
  69. @@ -22,6 +22,40 @@
  70. #include <locale.h>
  71. #include "epdfview.h"
  72. +#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
  73. +#define HAVE_CUPS_1_6 1
  74. +#endif
  75. +
  76. +#ifndef HAVE_CUPS_1_6
  77. +inline int ippGetInteger (ipp_attribute_t *attr, int element)
  78. +{
  79. + return (attr->values[element].integer);
  80. +}
  81. +
  82. +inline const char * ippGetString (ipp_attribute_t *attr,
  83. + int element,
  84. + const char **language /*UNUSED*/)
  85. +{
  86. + return (attr->values[element].string.text);
  87. +}
  88. +
  89. +inline int ippSetOperation (ipp_t *ipp, ipp_op_t op)
  90. +{
  91. + if (!ipp)
  92. + return (0);
  93. + ipp->request.op.operation_id = op;
  94. + return (1);
  95. +}
  96. +
  97. +inline int ippSetRequestId (ipp_t *ipp, int request_id)
  98. +{
  99. + if (!ipp)
  100. + return (0);
  101. + ipp->request.any.request_id = request_id;
  102. + return (1);
  103. +}
  104. +#endif
  105. +
  106. using namespace ePDFView;
  107. // Structures
  108. @@ -380,8 +414,8 @@
  109. ipp_t *request = ippNew ();
  110. - request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
  111. - request->request.op.request_id = 1;
  112. + ippSetOperation(request, IPP_GET_PRINTER_ATTRIBUTES);
  113. + ippSetRequestId(request, 1);
  114. ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
  115. "attributes-charset", NULL, "utf-8");
  116. @@ -403,7 +437,7 @@
  117. ippFindAttribute (answer, "printer-state", IPP_TAG_ZERO);
  118. if ( NULL != state )
  119. {
  120. - switch (state->values[0].integer)
  121. + switch (ippGetInteger (state, 0))
  122. {
  123. case IPP_PRINTER_IDLE:
  124. attributes->state = g_strdup (_("Idle"));
  125. @@ -425,7 +459,7 @@
  126. ippFindAttribute (answer, "printer-location", IPP_TAG_ZERO);
  127. if ( NULL != location )
  128. {
  129. - attributes->location = g_strdup (location->values[0].string.text);
  130. + attributes->location = g_strdup (ippGetString (location, 0, NULL));
  131. }
  132. ippDelete (answer);