rsvg2 2.2.4-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README +35 -0
- data/Rakefile +69 -0
- data/ext/rsvg2/depend +6 -0
- data/ext/rsvg2/extconf.rb +89 -0
- data/ext/rsvg2/rbrsvg.c +206 -0
- data/ext/rsvg2/rbrsvgdimensiondata.c +194 -0
- data/ext/rsvg2/rbrsvghandle.c +496 -0
- data/ext/rsvg2/rsvg2.def +2 -0
- data/ext/rsvg2/rsvg2.h +70 -0
- data/extconf.rb +49 -0
- data/lib/2.0/rsvg2.so +0 -0
- data/lib/2.1/rsvg2.so +0 -0
- data/lib/2.2/rsvg2.so +0 -0
- data/lib/rsvg2.rb +33 -0
- data/sample/svg-viewer.rb +44 -0
- data/sample/svg2.rb +60 -0
- data/test/rsvg2-test-utils.rb +23 -0
- data/test/run-test.rb +49 -0
- data/test/test-handle.rb +91 -0
- data/vendor/local/bin/croco-0.6-config +87 -0
- data/vendor/local/bin/csslint-0.6.exe +0 -0
- data/vendor/local/bin/libcroco-0.6-3.dll +0 -0
- data/vendor/local/bin/librsvg-2-2.dll +0 -0
- data/vendor/local/bin/rsvg-convert.exe +0 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-additional-sel.h +98 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-attr-sel.h +74 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-cascade.h +74 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-declaration.h +136 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-doc-handler.h +298 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-enc-handler.h +94 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-fonts.h +315 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-input.h +174 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-num.h +127 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-om-parser.h +98 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-parser.h +128 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-parsing-location.h +70 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-prop-list.h +80 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-pseudo.h +64 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-rgb.h +94 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-sel-eng.h +110 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-selector.h +95 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-simple-sel.h +130 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-statement.h +440 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-string.h +76 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-style.h +339 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-stylesheet.h +102 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-term.h +190 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-tknzr.h +115 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-token.h +212 -0
- data/vendor/local/include/libcroco-0.6/libcroco/cr-utils.h +246 -0
- data/vendor/local/include/libcroco-0.6/libcroco/libcroco-config.h +17 -0
- data/vendor/local/include/libcroco-0.6/libcroco/libcroco.h +44 -0
- data/vendor/local/include/librsvg-2.0/librsvg/librsvg-enum-types.h +24 -0
- data/vendor/local/include/librsvg-2.0/librsvg/librsvg-features.h +28 -0
- data/vendor/local/include/librsvg-2.0/librsvg/rsvg-cairo.h +42 -0
- data/vendor/local/include/librsvg-2.0/librsvg/rsvg.h +264 -0
- data/vendor/local/lib/girepository-1.0/Rsvg-2.0.typelib +0 -0
- data/vendor/local/lib/libcroco-0.6.a +0 -0
- data/vendor/local/lib/libcroco-0.6.dll.a +0 -0
- data/vendor/local/lib/libcroco-0.6.la +41 -0
- data/vendor/local/lib/librsvg-2.a +0 -0
- data/vendor/local/lib/librsvg-2.dll.a +0 -0
- data/vendor/local/lib/librsvg-2.la +41 -0
- data/vendor/local/lib/pkgconfig/libcroco-0.6.pc +11 -0
- data/vendor/local/lib/pkgconfig/librsvg-2.0.pc +15 -0
- data/vendor/local/share/gir-1.0/Rsvg-2.0.gir +754 -0
- data/vendor/local/share/gtk-doc/html/libcroco/ch01.html +113 -0
- data/vendor/local/share/gtk-doc/html/libcroco/home.png +0 -0
- data/vendor/local/share/gtk-doc/html/libcroco/index.html +109 -0
- data/vendor/local/share/gtk-doc/html/libcroco/index.sgml +582 -0
- data/vendor/local/share/gtk-doc/html/libcroco/left.png +0 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-additional-sel.html +337 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-attr-sel.html +203 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-cascade.html +240 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-declaration.html +642 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-doc-handler.html +517 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-enc-handler.html +164 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-fonts.html +670 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-input.html +1102 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-num.html +265 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-om-parser.html +380 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-parser.html +913 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-parsing-location.html +205 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-prop-list.html +421 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-pseudo.html +141 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-rgb.html +503 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-sel-eng.html +346 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-selector.html +246 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-simple-sel.html +240 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-statement.html +1408 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-string.html +137 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-style.html +384 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-stylesheet.html +158 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-term.html +304 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-tknzr.html +312 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-token.html +428 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-cr-utils.html +334 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco-libcroco-config.html +80 -0
- data/vendor/local/share/gtk-doc/html/libcroco/libcroco.devhelp2 +511 -0
- data/vendor/local/share/gtk-doc/html/libcroco/right.png +0 -0
- data/vendor/local/share/gtk-doc/html/libcroco/style.css +266 -0
- data/vendor/local/share/gtk-doc/html/libcroco/up.png +0 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/RsvgHandle.html +1420 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/annotation-glossary.html +55 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/api-index-2-14.html +55 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/api-index-2-22.html +43 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/api-index-2-32.html +47 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/api-index-2-36.html +46 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/api-index-2-4.html +39 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/api-index-2-8.html +54 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/api-index-2-9.html +53 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/api-index-deprecated.html +100 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/api-index-full.html +323 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/home.png +0 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/index.html +88 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/index.sgml +106 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/left-insensitive.png +0 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/left.png +0 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/licence.html +57 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/object-tree.html +38 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/right-insensitive.png +0 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/right.png +0 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/rsvg-2.0.devhelp2 +94 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/rsvg-Using-RSVG-with-GIO.html +360 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/rsvg-Using-RSVG-with-GdkPixbuf.html +484 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/rsvg-Using-RSVG-with-cairo.html +154 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/rsvg-Version-check-and-feature-tests.html +142 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/rsvg.html +57 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/style.css +476 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/up-insensitive.png +0 -0
- data/vendor/local/share/gtk-doc/html/rsvg-2.0/up.png +0 -0
- data/vendor/local/share/license/libcroco/AUTHORS +13 -0
- data/vendor/local/share/license/libcroco/COPYING +481 -0
- data/vendor/local/share/license/libcroco/COPYING.LIB +481 -0
- data/vendor/local/share/license/librsvg/AUTHORS +1 -0
- data/vendor/local/share/license/librsvg/COPYING +340 -0
- data/vendor/local/share/license/librsvg/COPYING.LIB +482 -0
- data/vendor/local/share/man/man1/rsvg-convert.1 +55 -0
- metadata +209 -0
@@ -0,0 +1,496 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2005-2006 Ruby-GNOME2 Project Team
|
5
|
+
* Copyright (C) 2004 Kouhei Sutou <kou@cozmixng.org>
|
6
|
+
*
|
7
|
+
* This library is free software; you can redistribute it and/or
|
8
|
+
* modify it under the terms of the GNU Lesser General Public
|
9
|
+
* License as published by the Free Software Foundation; either
|
10
|
+
* version 2.1 of the License, or (at your option) any later version.
|
11
|
+
*
|
12
|
+
* This library is distributed in the hope that it will be useful,
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
* Lesser General Public License for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public
|
18
|
+
* License along with this library; if not, write to the Free Software
|
19
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
20
|
+
* MA 02110-1301 USA
|
21
|
+
*/
|
22
|
+
|
23
|
+
#include "rsvg2.h"
|
24
|
+
|
25
|
+
#define RG_TARGET_NAMESPACE cHandle
|
26
|
+
#ifdef RSVG_TYPE_HANDLE
|
27
|
+
# define _SELF(self) (RSVG_HANDLE(RVAL2GOBJ(self)))
|
28
|
+
#else
|
29
|
+
# define _SELF(self) ((RsvgHandle *)DATA_PTR(self))
|
30
|
+
#endif
|
31
|
+
|
32
|
+
static VALUE RG_TARGET_NAMESPACE;
|
33
|
+
|
34
|
+
static ID id_call;
|
35
|
+
static ID id_callback;
|
36
|
+
static ID id_closed;
|
37
|
+
|
38
|
+
static void
|
39
|
+
exec_callback(gint *width, gint *height, gpointer self)
|
40
|
+
{
|
41
|
+
VALUE result;
|
42
|
+
result = rb_funcall(rb_ivar_get((VALUE)self, id_callback),
|
43
|
+
id_call, 2, INT2NUM(*width), INT2NUM(*height));
|
44
|
+
if (T_ARRAY == TYPE(result)) {
|
45
|
+
VALUE w, h;
|
46
|
+
w = rb_ary_entry(result, 0);
|
47
|
+
h = rb_ary_entry(result, 1);
|
48
|
+
if (!NIL_P(w)) {
|
49
|
+
*width = NUM2INT(w);
|
50
|
+
}
|
51
|
+
if (!NIL_P(h)) {
|
52
|
+
*height = NUM2INT(h);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
static VALUE
|
58
|
+
rg_set_dpi(VALUE self, VALUE dpi)
|
59
|
+
{
|
60
|
+
#ifdef HAVE_RSVG_HANDLE_SET_DPI
|
61
|
+
rsvg_handle_set_dpi(_SELF(self), NUM2DBL(dpi));
|
62
|
+
#else
|
63
|
+
rb_warning("rsvg_handle_set_dpi isn't supported in your librsvg");
|
64
|
+
#endif
|
65
|
+
return self;
|
66
|
+
}
|
67
|
+
|
68
|
+
static VALUE
|
69
|
+
rg_set_dpi_x_y(VALUE self, VALUE dpi_x, VALUE dpi_y)
|
70
|
+
{
|
71
|
+
#ifdef HAVE_RSVG_HANDLE_SET_DPI_X_Y
|
72
|
+
rsvg_handle_set_dpi_x_y(_SELF(self), NUM2DBL(dpi_x), NUM2DBL(dpi_y));
|
73
|
+
#else
|
74
|
+
rb_warning("rsvg_handle_set_dpi_x_y isn't supported in your librsvg");
|
75
|
+
#endif
|
76
|
+
return self;
|
77
|
+
}
|
78
|
+
|
79
|
+
#ifndef RSVG_TYPE_HANDLE
|
80
|
+
static void
|
81
|
+
rb_rsvg_handle_free(RsvgHandle *handle)
|
82
|
+
{
|
83
|
+
if (handle) {
|
84
|
+
rsvg_handle_free(handle);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
static VALUE
|
89
|
+
rb_rsvg_handle_alloc(VALUE klass)
|
90
|
+
{
|
91
|
+
return Data_Wrap_Struct(klass, 0, rb_rsvg_handle_free, 0);
|
92
|
+
}
|
93
|
+
#endif
|
94
|
+
|
95
|
+
#if LIBRSVG_CHECK_VERSION(2, 14, 0)
|
96
|
+
static VALUE
|
97
|
+
rg_s_new_from_data(G_GNUC_UNUSED VALUE self, VALUE data)
|
98
|
+
{
|
99
|
+
GError *error = NULL;
|
100
|
+
RsvgHandle *handle;
|
101
|
+
|
102
|
+
handle = rsvg_handle_new_from_data((const guint8 *)RVAL2CSTR(data),
|
103
|
+
RSTRING_LEN(data), &error);
|
104
|
+
|
105
|
+
if (error)
|
106
|
+
RAISE_GERROR(error);
|
107
|
+
|
108
|
+
return GOBJ2RVAL(handle);
|
109
|
+
}
|
110
|
+
|
111
|
+
static VALUE
|
112
|
+
rg_s_new_from_file(int argc, VALUE *argv, VALUE self)
|
113
|
+
{
|
114
|
+
VALUE rb_file_path, rb_options, rb_flags;
|
115
|
+
GError *error = NULL;
|
116
|
+
RsvgHandle *handle;
|
117
|
+
|
118
|
+
rb_scan_args(argc, argv, "11", &rb_file_path, &rb_options);
|
119
|
+
rbg_scan_options(rb_options,
|
120
|
+
"flags", &rb_flags,
|
121
|
+
NULL);
|
122
|
+
|
123
|
+
#if LIBRSVG_CHECK_VERSION(2, 40, 3)
|
124
|
+
{
|
125
|
+
GFile *file;
|
126
|
+
GCancellable *cancellable = NULL;
|
127
|
+
RsvgHandleFlags flags = RSVG_HANDLE_FLAGS_NONE;
|
128
|
+
|
129
|
+
if (!NIL_P(rb_flags)) {
|
130
|
+
flags = RVAL2GFLAGS(rb_flags, RSVG_TYPE_HANDLE_FLAGS);
|
131
|
+
}
|
132
|
+
|
133
|
+
file = g_file_new_for_path((const char *)RVAL2CSTR(rb_file_path));
|
134
|
+
handle = rsvg_handle_new_from_gfile_sync(file, flags,
|
135
|
+
cancellable,
|
136
|
+
&error);
|
137
|
+
g_object_unref(file);
|
138
|
+
}
|
139
|
+
#else
|
140
|
+
if (!NIL_P(rb_flags)) {
|
141
|
+
rb_raise(rb_eArgError,
|
142
|
+
"librsvg 2.40.3 or later is required for :flags: <%d.%d.%d>",
|
143
|
+
LIBRSVG_MAJOR_VERSION,
|
144
|
+
LIBRSVG_MINOR_VERSION,
|
145
|
+
LIBRSVG_MICRO_VERSION);
|
146
|
+
}
|
147
|
+
handle = rsvg_handle_new_from_file((const gchar *)RVAL2CSTR(rb_file_path),
|
148
|
+
&error);
|
149
|
+
#endif
|
150
|
+
|
151
|
+
if (error)
|
152
|
+
RAISE_GERROR(error);
|
153
|
+
|
154
|
+
return GOBJ2RVAL(handle);
|
155
|
+
}
|
156
|
+
#endif
|
157
|
+
|
158
|
+
static VALUE
|
159
|
+
rg_initialize(int argc, VALUE *argv, VALUE self)
|
160
|
+
{
|
161
|
+
RsvgHandle *handle;
|
162
|
+
VALUE gz;
|
163
|
+
rb_scan_args(argc, argv, "01", &gz);
|
164
|
+
|
165
|
+
#if LIBRSVG_CHECK_VERSION(2, 11, 0)
|
166
|
+
handle = rsvg_handle_new();
|
167
|
+
#else
|
168
|
+
if (RVAL2CBOOL(gz)) {
|
169
|
+
# ifdef HAVE_LIBRSVG_RSVG_GZ_H
|
170
|
+
handle = rsvg_handle_new_gz();
|
171
|
+
# else
|
172
|
+
rb_warning("gz handling is not supported in your librsvg");
|
173
|
+
handle = rsvg_handle_new();
|
174
|
+
# endif
|
175
|
+
} else {
|
176
|
+
handle = rsvg_handle_new();
|
177
|
+
}
|
178
|
+
#endif
|
179
|
+
|
180
|
+
#ifdef RSVG_TYPE_HANDLE
|
181
|
+
G_INITIALIZE(self, handle);
|
182
|
+
#else
|
183
|
+
DATA_PTR(self) = handle;
|
184
|
+
#endif
|
185
|
+
|
186
|
+
rb_ivar_set(self, id_closed, Qfalse);
|
187
|
+
return Qnil;
|
188
|
+
}
|
189
|
+
|
190
|
+
static VALUE
|
191
|
+
rg_set_size_callback(VALUE self)
|
192
|
+
{
|
193
|
+
rb_ivar_set(self, id_callback, rb_block_proc());
|
194
|
+
rsvg_handle_set_size_callback(_SELF(self), exec_callback,
|
195
|
+
(gpointer)self, NULL);
|
196
|
+
return self;
|
197
|
+
}
|
198
|
+
|
199
|
+
static VALUE
|
200
|
+
rg_write(VALUE self, VALUE buf)
|
201
|
+
{
|
202
|
+
gboolean result;
|
203
|
+
GError *error = NULL;
|
204
|
+
|
205
|
+
result = rsvg_handle_write(_SELF(self), (const guchar*)RVAL2CSTR(buf),
|
206
|
+
RSTRING_LEN(buf), &error);
|
207
|
+
|
208
|
+
if (!result) RAISE_GERROR(error);
|
209
|
+
|
210
|
+
return CBOOL2RVAL(result);
|
211
|
+
}
|
212
|
+
|
213
|
+
static VALUE
|
214
|
+
rg_close(VALUE self)
|
215
|
+
{
|
216
|
+
gboolean result;
|
217
|
+
GError *error = NULL;
|
218
|
+
|
219
|
+
if (RVAL2CBOOL(rb_ivar_get(self, id_closed))) {
|
220
|
+
return Qnil;
|
221
|
+
}
|
222
|
+
|
223
|
+
result = rsvg_handle_close(_SELF(self), &error);
|
224
|
+
|
225
|
+
if (result) {
|
226
|
+
rb_ivar_set(self, id_closed, Qtrue);
|
227
|
+
} else {
|
228
|
+
RAISE_GERROR(error);
|
229
|
+
}
|
230
|
+
|
231
|
+
return CBOOL2RVAL(result);
|
232
|
+
}
|
233
|
+
|
234
|
+
static VALUE
|
235
|
+
rg_closed_p(VALUE self)
|
236
|
+
{
|
237
|
+
return rb_ivar_get(self, id_closed);
|
238
|
+
}
|
239
|
+
|
240
|
+
static VALUE
|
241
|
+
rg_pixbuf(int argc, VALUE *argv, VALUE self)
|
242
|
+
{
|
243
|
+
VALUE id;
|
244
|
+
VALUE rb_pixbuf;
|
245
|
+
GdkPixbuf *pixbuf = NULL;
|
246
|
+
|
247
|
+
rb_scan_args(argc, argv, "01", &id);
|
248
|
+
if (NIL_P(id)) {
|
249
|
+
pixbuf = rsvg_handle_get_pixbuf(_SELF(self));
|
250
|
+
} else {
|
251
|
+
#ifdef HAVE_RSVG_HANDLE_GET_PIXBUF_SUB
|
252
|
+
pixbuf = rsvg_handle_get_pixbuf_sub(_SELF(self),
|
253
|
+
(const char *)RVAL2CSTR(id));
|
254
|
+
#else
|
255
|
+
rb_warning("rsvg_handle_get_pixbuf_sub isn't "
|
256
|
+
"supported in your librsvg");
|
257
|
+
#endif
|
258
|
+
}
|
259
|
+
|
260
|
+
rb_pixbuf = GOBJ2RVAL(pixbuf);
|
261
|
+
if (pixbuf)
|
262
|
+
g_object_unref(pixbuf);
|
263
|
+
return rb_pixbuf;
|
264
|
+
}
|
265
|
+
|
266
|
+
#ifdef HAVE_TYPE_RSVGDIMENSIONDATA
|
267
|
+
static VALUE
|
268
|
+
rg_dimensions(VALUE self)
|
269
|
+
{
|
270
|
+
RsvgDimensionData dim;
|
271
|
+
VALUE args[4];
|
272
|
+
VALUE cDimensionData = rb_const_get(rb_const_get(rb_cObject,
|
273
|
+
rb_intern("RSVG")), rb_intern("DimensionData"));
|
274
|
+
|
275
|
+
rsvg_handle_get_dimensions(_SELF(self), &dim);
|
276
|
+
args[0] = INT2NUM(dim.width);
|
277
|
+
args[1] = INT2NUM(dim.height);
|
278
|
+
args[2] = rb_float_new(dim.em);
|
279
|
+
args[3] = rb_float_new(dim.ex);
|
280
|
+
return rb_class_new_instance(sizeof(args) / sizeof(VALUE),
|
281
|
+
args, cDimensionData);
|
282
|
+
}
|
283
|
+
#endif
|
284
|
+
|
285
|
+
#if !LIBRSVG_CHECK_VERSION(2, 36, 0)
|
286
|
+
/* Accessibility API */
|
287
|
+
static VALUE
|
288
|
+
rg_title(VALUE self)
|
289
|
+
{
|
290
|
+
return CSTR2RVAL(rsvg_handle_get_title(_SELF(self)));
|
291
|
+
}
|
292
|
+
|
293
|
+
static VALUE
|
294
|
+
rg_desc(VALUE self)
|
295
|
+
{
|
296
|
+
return CSTR2RVAL(rsvg_handle_get_desc(_SELF(self)));
|
297
|
+
}
|
298
|
+
|
299
|
+
# ifdef HAVE_RSVG_HANDLE_GET_METADATA
|
300
|
+
static VALUE
|
301
|
+
rg_metadata(VALUE self)
|
302
|
+
{
|
303
|
+
return CSTR2RVAL(rsvg_handle_get_metadata(_SELF(self)));
|
304
|
+
}
|
305
|
+
# endif
|
306
|
+
#endif
|
307
|
+
|
308
|
+
#if !LIBRSVG_CHECK_VERSION(2, 11, 0)
|
309
|
+
/* Extended Convenience API */
|
310
|
+
static VALUE
|
311
|
+
rg_pixbuf_from_file_at_size(VALUE self, VALUE file_name,
|
312
|
+
VALUE width, VALUE height)
|
313
|
+
{
|
314
|
+
VALUE rb_pixbuf;
|
315
|
+
GdkPixbuf *pixbuf;
|
316
|
+
GError *error = NULL;
|
317
|
+
|
318
|
+
pixbuf = rsvg_pixbuf_from_file_at_size_ex(_SELF(self),
|
319
|
+
RVAL2CSTR(file_name),
|
320
|
+
NUM2INT(width),
|
321
|
+
NUM2INT(height),
|
322
|
+
&error);
|
323
|
+
|
324
|
+
if (error) RAISE_GERROR(error);
|
325
|
+
|
326
|
+
rb_pixbuf = GOBJ2RVAL(pixbuf);
|
327
|
+
g_object_unref(pixbuf);
|
328
|
+
return rb_pixbuf;
|
329
|
+
}
|
330
|
+
|
331
|
+
static VALUE
|
332
|
+
rg_pixbuf_from_file(VALUE self, VALUE file_name)
|
333
|
+
{
|
334
|
+
VALUE rb_pixbuf;
|
335
|
+
GdkPixbuf *pixbuf;
|
336
|
+
GError *error = NULL;
|
337
|
+
|
338
|
+
pixbuf = rsvg_pixbuf_from_file_ex(_SELF(self),
|
339
|
+
RVAL2CSTR(file_name),
|
340
|
+
&error);
|
341
|
+
|
342
|
+
if (error) RAISE_GERROR(error);
|
343
|
+
|
344
|
+
rb_pixbuf = GOBJ2RVAL(pixbuf);
|
345
|
+
g_object_unref(pixbuf);
|
346
|
+
return rb_pixbuf;
|
347
|
+
}
|
348
|
+
|
349
|
+
static VALUE
|
350
|
+
rg_pixbuf_from_file_at_zoom(VALUE self, VALUE file_name,
|
351
|
+
VALUE x_zoom, VALUE y_zoom)
|
352
|
+
{
|
353
|
+
VALUE rb_pixbuf;
|
354
|
+
GdkPixbuf *pixbuf;
|
355
|
+
GError *error = NULL;
|
356
|
+
|
357
|
+
pixbuf = rsvg_pixbuf_from_file_at_zoom_ex(_SELF(self),
|
358
|
+
RVAL2CSTR(file_name),
|
359
|
+
NUM2DBL(x_zoom),
|
360
|
+
NUM2DBL(y_zoom),
|
361
|
+
&error);
|
362
|
+
|
363
|
+
if (error) RAISE_GERROR(error);
|
364
|
+
|
365
|
+
rb_pixbuf = GOBJ2RVAL(pixbuf);
|
366
|
+
g_object_unref(pixbuf);
|
367
|
+
return rb_pixbuf;
|
368
|
+
}
|
369
|
+
|
370
|
+
static VALUE
|
371
|
+
rg_pixbuf_from_file_at_max_size(VALUE self, VALUE file_name,
|
372
|
+
VALUE max_width, VALUE max_height)
|
373
|
+
{
|
374
|
+
VALUE rb_pixbuf;
|
375
|
+
GdkPixbuf *pixbuf;
|
376
|
+
GError *error = NULL;
|
377
|
+
|
378
|
+
pixbuf = rsvg_pixbuf_from_file_at_max_size_ex(_SELF(self),
|
379
|
+
RVAL2CSTR(file_name),
|
380
|
+
NUM2INT(max_width),
|
381
|
+
NUM2INT(max_height),
|
382
|
+
&error);
|
383
|
+
|
384
|
+
if (error) RAISE_GERROR(error);
|
385
|
+
|
386
|
+
rb_pixbuf = GOBJ2RVAL(pixbuf);
|
387
|
+
g_object_unref(pixbuf);
|
388
|
+
return rb_pixbuf;
|
389
|
+
}
|
390
|
+
|
391
|
+
static VALUE
|
392
|
+
rg_pixbuf_from_file_at_zoom_with_max(VALUE self,
|
393
|
+
VALUE file_name,
|
394
|
+
VALUE x_zoom,
|
395
|
+
VALUE y_zoom,
|
396
|
+
VALUE max_width,
|
397
|
+
VALUE max_height)
|
398
|
+
{
|
399
|
+
VALUE rb_pixbuf;
|
400
|
+
GdkPixbuf *pixbuf;
|
401
|
+
GError *error = NULL;
|
402
|
+
|
403
|
+
pixbuf = rsvg_pixbuf_from_file_at_zoom_with_max_ex(_SELF(self),
|
404
|
+
RVAL2CSTR(file_name),
|
405
|
+
NUM2DBL(x_zoom),
|
406
|
+
NUM2DBL(y_zoom),
|
407
|
+
NUM2INT(max_width),
|
408
|
+
NUM2INT(max_height),
|
409
|
+
&error);
|
410
|
+
|
411
|
+
if (error) RAISE_GERROR(error);
|
412
|
+
|
413
|
+
rb_pixbuf = GOBJ2RVAL(pixbuf);
|
414
|
+
g_object_unref(pixbuf);
|
415
|
+
return rb_pixbuf;
|
416
|
+
}
|
417
|
+
#endif
|
418
|
+
|
419
|
+
#ifdef HAVE_LIBRSVG_RSVG_CAIRO_H
|
420
|
+
static VALUE
|
421
|
+
rg_render_cairo(int argc, VALUE *argv, VALUE self)
|
422
|
+
{
|
423
|
+
VALUE cr, id;
|
424
|
+
rb_scan_args(argc, argv, "11", &cr, &id);
|
425
|
+
|
426
|
+
if (NIL_P(id)) {
|
427
|
+
rsvg_handle_render_cairo( _SELF(self), RVAL2CRCONTEXT(cr));
|
428
|
+
} else {
|
429
|
+
rsvg_handle_render_cairo_sub( _SELF(self), RVAL2CRCONTEXT(cr),
|
430
|
+
(const char *)RVAL2CSTR(id));
|
431
|
+
}
|
432
|
+
|
433
|
+
return Qnil;
|
434
|
+
}
|
435
|
+
#endif
|
436
|
+
|
437
|
+
void
|
438
|
+
Init_rsvg_handle(VALUE mRSVG)
|
439
|
+
{
|
440
|
+
id_call = rb_intern("call");
|
441
|
+
id_callback = rb_intern("callback");
|
442
|
+
id_closed = rb_intern("closed");
|
443
|
+
|
444
|
+
#ifdef RSVG_TYPE_HANDLE
|
445
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(RSVG_TYPE_HANDLE, "Handle", mRSVG);
|
446
|
+
#else
|
447
|
+
RG_TARGET_NAMESPACE = rb_define_class_under(mRSVG, "Handle", rb_cObject);
|
448
|
+
rb_define_alloc_func(RG_TARGET_NAMESPACE, rb_rsvg_handle_alloc);
|
449
|
+
#endif
|
450
|
+
|
451
|
+
#if LIBRSVG_CHECK_VERSION(2, 14, 0)
|
452
|
+
RG_DEF_SMETHOD(new_from_data, 1);
|
453
|
+
RG_DEF_SMETHOD(new_from_file, -1);
|
454
|
+
#endif
|
455
|
+
|
456
|
+
RG_DEF_METHOD(initialize, -1);
|
457
|
+
RG_DEF_METHOD(set_size_callback, 0);
|
458
|
+
RG_DEF_METHOD(set_dpi, 1);
|
459
|
+
RG_DEF_METHOD(set_dpi_x_y, 2);
|
460
|
+
RG_DEF_METHOD(write, 1);
|
461
|
+
RG_DEF_METHOD(close, 0);
|
462
|
+
RG_DEF_METHOD_P(closed, 0);
|
463
|
+
RG_DEF_METHOD(pixbuf, -1);
|
464
|
+
|
465
|
+
#ifdef HAVE_TYPE_RSVGDIMENSIONDATA
|
466
|
+
RG_DEF_METHOD(dimensions, 0);
|
467
|
+
#endif
|
468
|
+
|
469
|
+
#if !LIBRSVG_CHECK_VERSION(2, 36, 0)
|
470
|
+
/* Accessibility API */
|
471
|
+
RG_DEF_METHOD(title, 0);
|
472
|
+
RG_DEF_METHOD(desc, 0);
|
473
|
+
# ifdef HAVE_RSVG_HANDLE_GET_METADATA
|
474
|
+
RG_DEF_METHOD(metadata, 0);
|
475
|
+
# endif
|
476
|
+
#endif
|
477
|
+
|
478
|
+
#if !LIBRSVG_CHECK_VERSION(2, 11, 0)
|
479
|
+
/* Extended Convenience API */
|
480
|
+
RG_DEF_METHOD(pixbuf_from_file_at_size, 3);
|
481
|
+
RG_DEF_METHOD(pixbuf_from_file, 1);
|
482
|
+
RG_DEF_METHOD(pixbuf_from_file_at_zoom, 3);
|
483
|
+
RG_DEF_METHOD(pixbuf_from_file_at_max_size, 3);
|
484
|
+
RG_DEF_METHOD(pixbuf_from_file_at_zoom_with_max, 5);
|
485
|
+
#endif
|
486
|
+
|
487
|
+
#ifdef HAVE_LIBRSVG_RSVG_CAIRO_H
|
488
|
+
RG_DEF_METHOD(render_cairo, -1);
|
489
|
+
#endif
|
490
|
+
|
491
|
+
#if LIBRSVG_CHECK_VERSION(2, 40, 3)
|
492
|
+
/* RsvgHandleFlags */
|
493
|
+
G_DEF_CLASS(RSVG_TYPE_HANDLE_FLAGS, "Flags", RG_TARGET_NAMESPACE);
|
494
|
+
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, RSVG_TYPE_HANDLE_FLAGS, "RSVG_HANDLE_");
|
495
|
+
#endif
|
496
|
+
}
|