1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
Index: ruby-gnome2-0.16.0/poppler/ChangeLog
===================================================================
--- ruby-gnome2-0.16.0.orig/poppler/ChangeLog 2008-05-29 17:13:17.000000000 +0200
+++ ruby-gnome2-0.16.0/poppler/ChangeLog 2008-05-29 17:13:46.000000000 +0200
@@ -1,3 +1,8 @@
+2008-03-20 Kouhei Sutou <kou@cozmixng.org>
+
+ * src/rbpoppler.[ch], src/rbpoppler-page.c: just buildable with
+ poppler-glib 0.7.3.
+
2007-11-11 Kouhei Sutou <kou@cozmixng.org>
* README: updated supported poppler-glib version: 0.5.2 - 0.6.2.
Index: ruby-gnome2-0.16.0/poppler/src/rbpoppler-page.c
===================================================================
--- ruby-gnome2-0.16.0.orig/poppler/src/rbpoppler-page.c 2008-05-29 17:13:16.000000000 +0200
+++ ruby-gnome2-0.16.0/poppler/src/rbpoppler-page.c 2008-05-29 17:13:25.000000000 +0200
@@ -39,6 +39,33 @@
VALUE cUnknownField, cTextField, cButtonField, cChoiceField, cSignatureField;
#endif
+#ifdef POPPLER_TYPE_COLOR
+extern VALUE mGdk;
+VALUE rb_cPopplerColor;
+
+PopplerColor *
+rb_poppler_ruby_object_to_color(VALUE color)
+{
+ static VALUE rb_cGdkColor = Qnil;
+
+ if (NIL_P(rb_cGdkColor)) {
+ rb_cGdkColor = rb_const_get(mGdk, rb_intern("Color"));
+ }
+
+ if (RTEST(rb_obj_is_kind_of(color, rb_cGdkColor))) {
+ GdkColor *gdk_color;
+ gdk_color = RVAL2GDKCOLOR(color);
+ color = rb_funcall(rb_cPopplerColor, rb_intern("new"),
+ 3,
+ UINT2NUM(gdk_color->red),
+ UINT2NUM(gdk_color->green),
+ UINT2NUM(gdk_color->blue));
+ }
+
+ return RVAL2BOXED(color, POPPLER_TYPE_COLOR);
+}
+#endif
+
static VALUE
page_render_to_pixbuf(VALUE self, VALUE src_x, VALUE src_y, VALUE src_width,
VALUE src_height, VALUE scale, VALUE rotation,
@@ -293,8 +320,8 @@
#ifdef HAVE_POPPLER_PAGE_RENDER_SELECTION_TO_PIXBUF
RVAL2SELSTYLE(style),
#endif
- RVAL2COLOR(glyph_color),
- RVAL2COLOR(background_color));
+ RVAL2GDKCOLOR(glyph_color),
+ RVAL2GDKCOLOR(background_color));
return Qnil;
}
@@ -415,6 +442,55 @@
}
+#ifdef POPPLER_TYPE_COLOR
+/* A color in RGB */
+static VALUE
+color_initialize(VALUE self, VALUE red, VALUE green, VALUE blue)
+{
+ PopplerColor color;
+
+ color.red = NUM2UINT(red);
+ color.green = NUM2UINT(green);
+ color.blue = NUM2UINT(blue);
+
+ G_INITIALIZE(self, &color);
+ return Qnil;
+}
+
+DEF_ACCESSOR(color, red, RVAL2COLOR, UINT2NUM, NUM2UINT)
+DEF_ACCESSOR(color, green, RVAL2COLOR, UINT2NUM, NUM2UINT)
+DEF_ACCESSOR(color, blue, RVAL2COLOR, UINT2NUM, NUM2UINT)
+
+static VALUE
+color_to_a(VALUE self)
+{
+ PopplerColor *color;
+ color = RVAL2COLOR(self);
+ return rb_ary_new3(3,
+ UINT2NUM(color->red),
+ UINT2NUM(color->green),
+ UINT2NUM(color->blue));
+}
+
+static VALUE
+color_inspect(VALUE self)
+{
+ VALUE inspected;
+ gchar *rgb;
+ PopplerColor *color;
+
+ color = RVAL2COLOR(self);
+ inspected = rb_call_super(0, NULL);
+ rb_str_resize(inspected, RSTRING_LEN(inspected) - 1);
+ rgb = g_strdup_printf(": [%u, %u, %u]>",
+ color->red, color->green, color->blue);
+ rb_str_cat2(inspected, rgb);
+ g_free(rgb);
+ return inspected;
+}
+#endif
+
+
/* Mapping between areas on the current page and PopplerActions */
#define RECT_ENTITY2RVAL(rect) RECT2RVAL(&(rect))
#define RECT_ENTITY_SET(rect, rb_rect) rectangle_set(&(rect), rb_rect)
@@ -443,7 +519,11 @@
/* Mapping between areas on the current page and images */
DEF_ACCESSOR_WITH_SETTER(image_mapping, area,
RVAL2IM, RECT_ENTITY2RVAL, RECT_ENTITY_SET)
+#ifdef HAVE_ST_IMAGE_ID
+DEF_ACCESSOR(image_mapping, image_id, RVAL2IM, INT2NUM, NUM2INT)
+#else
DEF_ACCESSOR(image_mapping, image, RVAL2IM, GOBJ2RVAL, RVAL2GDK_PIXBUF)
+#endif
/* Mapping between areas on the current page and form fields */
@@ -668,6 +748,9 @@
cPage = G_DEF_CLASS(POPPLER_TYPE_PAGE, "Page", mPoppler);
cRectangle = G_DEF_CLASS(POPPLER_TYPE_RECTANGLE, "Rectangle", mPoppler);
+#ifdef POPPLER_TYPE_COLOR
+ rb_cPopplerColor = G_DEF_CLASS(POPPLER_TYPE_COLOR, "Color", mPoppler);
+#endif
cLinkMapping = G_DEF_CLASS(POPPLER_TYPE_LINK_MAPPING, "LinkMapping",
mPoppler);
#if POPPLER_CHECK_VERSION(0, 6, 0)
@@ -729,6 +812,21 @@
G_DEF_SETTERS(cRectangle);
+#ifdef POPPLER_TYPE_COLOR
+/* A color in RGB */
+ rb_define_method(rb_cPopplerColor, "initialize", color_initialize, 3);
+ rb_define_method(rb_cPopplerColor, "red", color_get_red, 0);
+ rb_define_method(rb_cPopplerColor, "green", color_get_green, 0);
+ rb_define_method(rb_cPopplerColor, "blue", color_get_blue, 0);
+ rb_define_method(rb_cPopplerColor, "set_red", color_set_red, 1);
+ rb_define_method(rb_cPopplerColor, "set_green", color_set_green, 1);
+ rb_define_method(rb_cPopplerColor, "set_blue", color_set_blue, 1);
+ rb_define_method(rb_cPopplerColor, "to_a", color_to_a, 0);
+ rb_define_method(rb_cPopplerColor, "inspect", color_inspect, 0);
+
+ G_DEF_SETTERS(rb_cPopplerColor);
+#endif
+
/* Mapping between areas on the current page and PopplerActions */
rb_define_method(cLinkMapping, "area", link_mapping_get_area, 0);
rb_define_method(cLinkMapping, "action", link_mapping_get_action, 0);
@@ -766,10 +864,19 @@
/* Mapping between areas on the current page and images */
rb_define_method(cImageMapping, "area", image_mapping_get_area, 0);
+#ifdef HAVE_ST_IMAGE_ID
+ rb_define_method(cImageMapping, "image_id", image_mapping_get_image_id, 0);
+#else
rb_define_method(cImageMapping, "image", image_mapping_get_image, 0);
+#endif
rb_define_method(cImageMapping, "set_area", image_mapping_set_area, 1);
+#ifdef HAVE_ST_IMAGE_ID
+ rb_define_method(cImageMapping, "set_image_id",
+ image_mapping_set_image_id, 1);
+#else
rb_define_method(cImageMapping, "set_image", image_mapping_set_image, 1);
+#endif
G_DEF_SETTERS(cImageMapping);
Index: ruby-gnome2-0.16.0/poppler/src/rbpoppler.c
===================================================================
--- ruby-gnome2-0.16.0.orig/poppler/src/rbpoppler.c 2008-05-29 17:13:16.000000000 +0200
+++ ruby-gnome2-0.16.0/poppler/src/rbpoppler.c 2008-05-29 17:13:25.000000000 +0200
@@ -50,6 +50,7 @@
G_DEF_CLASS(POPPLER_TYPE_ERROR, "Error", mPoppler);
G_DEF_CLASS(POPPLER_TYPE_ORIENTATION, "Orientation", mPoppler);
+
#if POPPLER_CHECK_VERSION(0, 6, 0)
G_DEF_CLASS(POPPLER_TYPE_PAGE_TRANSITION_TYPE,
"PageTransitionType", mPoppler);
@@ -61,8 +62,24 @@
G_DEF_CLASS(POPPLER_TYPE_FORM_BUTTON_TYPE, "FormButtonType", mPoppler);
G_DEF_CLASS(POPPLER_TYPE_FORM_TEXT_TYPE, "FormTextType", mPoppler);
G_DEF_CLASS(POPPLER_TYPE_FORM_CHOICE_TYPE, "FormChoiceType", mPoppler);
+#endif
+#if POPPLER_CHECK_VERSION(0, 7, 2)
+ G_RENAME_NICK("3D", "TYPE_3D");
+ G_DEF_CLASS(POPPLER_TYPE_ANNOT_TYPE, "AnnotationType", mPoppler);
+ G_DEF_CLASS(POPPLER_TYPE_ANNOT_FLAG, "AnnotationFlag", mPoppler);
+ G_DEF_CLASS(POPPLER_TYPE_ANNOT_MARKUP_REPLY_TYPE,
+ "AnnotationMarkupReplyType", mPoppler);
+ G_RENAME_NICK("3D", "TYPE_3D");
+ G_DEF_CLASS(POPPLER_TYPE_ANNOT_EXTERNAL_DATA_TYPE,
+ "AnnotationExternalDataType", mPoppler);
+ G_DEF_CLASS(POPPLER_TYPE_ANNOT_TEXT_ICON, "AnnotationTextIcon", mPoppler);
+ G_DEF_CLASS(POPPLER_TYPE_ANNOT_TEXT_STATE, "AnnotationTextState", mPoppler);
+ G_DEF_CLASS(POPPLER_TYPE_ANNOT_FREE_TEXT_QUADDING,
+ "AnnotationFreeTextQuadding", mPoppler);
#endif
+
+
G_DEF_CLASS(POPPLER_TYPE_BACKEND, "Backend", mPoppler);
rb_define_module_function(mPoppler, "backend", get_backend, 0);
Index: ruby-gnome2-0.16.0/poppler/src/rbpoppler.h
===================================================================
--- ruby-gnome2-0.16.0.orig/poppler/src/rbpoppler.h 2008-05-29 17:13:16.000000000 +0200
+++ ruby-gnome2-0.16.0/poppler/src/rbpoppler.h 2008-05-29 17:13:25.000000000 +0200
@@ -46,7 +46,14 @@
#define RVAL2ACTIONTYPE(obj) (RVAL2GENUM(obj, POPPLER_TYPE_ACTION_TYPE))
#define SELSTYLE2RVAL(obj) (GENUM2RVAL(obj, POPPLER_TYPE_SELECTION_STYLE))
#define RVAL2SELSTYLE(obj) (RVAL2GENUM(obj, POPPLER_TYPE_SELECTION_STYLE))
-#define RVAL2COLOR(obj) ((GdkColor *)RVAL2BOXED(obj, GDK_TYPE_COLOR))
+#define RVAL2GDKCOLOR(obj) ((GdkColor *)RVAL2BOXED(obj, GDK_TYPE_COLOR))
+
+#ifdef POPPLER_TYPE_COLOR
+extern PopplerColor *rb_poppler_ruby_object_to_color(VALUE color);
+# define RVAL2COLOR(obj) (rb_poppler_ruby_object_to_color(obj))
+#else
+# define RVAL2COLOR(obj) (RVAL2GDKCOLOR(obj))
+#endif
#define ACTION2RVAL(obj) (rb_poppler_ruby_object_from_action(obj))
#define RVAL2ACTION(obj) (rb_poppler_action_from_ruby_object(obj))
Index: ruby-gnome2-0.16.0/poppler/extconf.rb
===================================================================
--- ruby-gnome2-0.16.0.orig/poppler/extconf.rb 2008-05-29 17:13:17.000000000 +0200
+++ ruby-gnome2-0.16.0/poppler/extconf.rb 2008-05-29 17:13:25.000000000 +0200
@@ -31,6 +31,7 @@
make_version_header("POPPLER", PACKAGE_ID)
have_func("poppler_page_render_selection_to_pixbuf")
+have_struct_member("PopplerImageMapping", "image_id", ["poppler.h"])
create_makefile_at_srcdir(PACKAGE_NAME, SRCDIR, "-DRUBY_POPPLER_COMPILATION")
create_top_makefile
|