rsvg2 1.0.3-x86-mingw32 → 1.1.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/rsvg2/rbrsvg.c +47 -687
- data/ext/rsvg2/rbrsvgdimensiondata.c +196 -0
- data/ext/rsvg2/rbrsvghandle.c +477 -0
- data/ext/rsvg2/rsvg2.h +68 -0
- data/lib/1.8/rsvg2.so +0 -0
- data/lib/1.9/rsvg2.so +0 -0
- metadata +12 -10
- data/ChangeLog +0 -209
@@ -0,0 +1,196 @@
|
|
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
|
+
#ifdef HAVE_TYPE_RSVGDIMENSIONDATA
|
26
|
+
|
27
|
+
#define RG_TARGET_NAMESPACE cDimensionData
|
28
|
+
|
29
|
+
#define RVAL2DIM(obj) ((RsvgDimensionData *)DATA_PTR(obj))
|
30
|
+
|
31
|
+
static VALUE RG_TARGET_NAMESPACE;
|
32
|
+
|
33
|
+
static ID id_closed;
|
34
|
+
static ID id_to_s;
|
35
|
+
|
36
|
+
static VALUE
|
37
|
+
to_s(VALUE obj)
|
38
|
+
{
|
39
|
+
return rb_funcall(obj, id_to_s, 0);
|
40
|
+
}
|
41
|
+
|
42
|
+
static void
|
43
|
+
rb_rsvg_dim_free(RsvgDimensionData *dimp)
|
44
|
+
{
|
45
|
+
if (dimp) {
|
46
|
+
free(dimp);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
static VALUE
|
51
|
+
rb_rsvg_dim_alloc(VALUE klass)
|
52
|
+
{
|
53
|
+
RsvgDimensionData *dimp;
|
54
|
+
return Data_Make_Struct(klass, RsvgDimensionData, 0,
|
55
|
+
rb_rsvg_dim_free, dimp);
|
56
|
+
}
|
57
|
+
|
58
|
+
static VALUE
|
59
|
+
rg_initialize(int argc, VALUE *argv, VALUE self)
|
60
|
+
{
|
61
|
+
VALUE width, height, em, ex;
|
62
|
+
RsvgDimensionData *dimp;
|
63
|
+
|
64
|
+
dimp = RVAL2DIM(self);
|
65
|
+
rb_scan_args(argc, argv, "04", &width, &height, &em, &ex);
|
66
|
+
|
67
|
+
if (!NIL_P(width))
|
68
|
+
dimp->width = NUM2INT(width);
|
69
|
+
if (!NIL_P(height))
|
70
|
+
dimp->height = NUM2INT(height);
|
71
|
+
if (!NIL_P(em))
|
72
|
+
dimp->em = NUM2DBL(em);
|
73
|
+
if (!NIL_P(ex))
|
74
|
+
dimp->ex = NUM2DBL(ex);
|
75
|
+
|
76
|
+
return Qnil;
|
77
|
+
}
|
78
|
+
|
79
|
+
static VALUE
|
80
|
+
rg_width(VALUE self)
|
81
|
+
{
|
82
|
+
return INT2NUM(RVAL2DIM(self)->width);
|
83
|
+
}
|
84
|
+
|
85
|
+
static VALUE
|
86
|
+
rg_set_width(VALUE self, VALUE width)
|
87
|
+
{
|
88
|
+
RVAL2DIM(self)->width = NUM2INT(width);
|
89
|
+
return Qnil;
|
90
|
+
}
|
91
|
+
|
92
|
+
static VALUE
|
93
|
+
rg_height(VALUE self)
|
94
|
+
{
|
95
|
+
return INT2NUM(RVAL2DIM(self)->height);
|
96
|
+
}
|
97
|
+
|
98
|
+
static VALUE
|
99
|
+
rg_set_height(VALUE self, VALUE height)
|
100
|
+
{
|
101
|
+
RVAL2DIM(self)->height = NUM2INT(height);
|
102
|
+
return Qnil;
|
103
|
+
}
|
104
|
+
|
105
|
+
static VALUE
|
106
|
+
rg_em(VALUE self)
|
107
|
+
{
|
108
|
+
return rb_float_new(RVAL2DIM(self)->em);
|
109
|
+
}
|
110
|
+
|
111
|
+
static VALUE
|
112
|
+
rg_set_em(VALUE self, VALUE em)
|
113
|
+
{
|
114
|
+
RVAL2DIM(self)->em = NUM2DBL(em);
|
115
|
+
return Qnil;
|
116
|
+
}
|
117
|
+
|
118
|
+
static VALUE
|
119
|
+
rg_ex(VALUE self)
|
120
|
+
{
|
121
|
+
return rb_float_new(RVAL2DIM(self)->ex);
|
122
|
+
}
|
123
|
+
|
124
|
+
static VALUE
|
125
|
+
rg_set_ex(VALUE self, VALUE ex)
|
126
|
+
{
|
127
|
+
RVAL2DIM(self)->ex = NUM2DBL(ex);
|
128
|
+
return Qnil;
|
129
|
+
}
|
130
|
+
|
131
|
+
static VALUE
|
132
|
+
rg_to_a(VALUE self)
|
133
|
+
{
|
134
|
+
return rb_ary_new3(4,
|
135
|
+
rg_width(self),
|
136
|
+
rg_height(self),
|
137
|
+
rg_em(self),
|
138
|
+
rg_ex(self));
|
139
|
+
}
|
140
|
+
|
141
|
+
static VALUE
|
142
|
+
rg_to_s(VALUE self)
|
143
|
+
{
|
144
|
+
VALUE ret;
|
145
|
+
|
146
|
+
ret = rb_str_new2("#<");
|
147
|
+
rb_str_cat2(ret, rb_obj_classname(self));
|
148
|
+
rb_str_cat2(ret, ":");
|
149
|
+
rb_str_concat(ret, rb_funcall(INT2NUM(self), id_to_s, 0));
|
150
|
+
rb_str_cat2(ret, " ");
|
151
|
+
|
152
|
+
rb_str_cat2(ret, "width=");
|
153
|
+
rb_str_concat(ret, to_s(rg_width(self)));
|
154
|
+
rb_str_cat2(ret, ", ");
|
155
|
+
rb_str_cat2(ret, "height=");
|
156
|
+
rb_str_concat(ret, to_s(rg_height(self)));
|
157
|
+
rb_str_cat2(ret, ", ");
|
158
|
+
rb_str_cat2(ret, "em=");
|
159
|
+
rb_str_concat(ret, to_s(rg_em(self)));
|
160
|
+
rb_str_cat2(ret, ", ");
|
161
|
+
rb_str_cat2(ret, "ex=");
|
162
|
+
rb_str_concat(ret, to_s(rg_ex(self)));
|
163
|
+
rb_str_cat2(ret, ">");
|
164
|
+
|
165
|
+
return ret;
|
166
|
+
}
|
167
|
+
#endif
|
168
|
+
|
169
|
+
void
|
170
|
+
Init_rsvg_dimensiondata(VALUE mRSVG)
|
171
|
+
{
|
172
|
+
#ifdef HAVE_TYPE_RSVGDIMENSIONDATA
|
173
|
+
id_closed = rb_intern("closed");
|
174
|
+
id_to_s = rb_intern("to_s");
|
175
|
+
|
176
|
+
RG_TARGET_NAMESPACE = rb_define_class_under(mRSVG, "DimensionData", rb_cObject);
|
177
|
+
|
178
|
+
rb_define_alloc_func(RG_TARGET_NAMESPACE, rb_rsvg_dim_alloc);
|
179
|
+
RG_DEF_METHOD(initialize, -1);
|
180
|
+
|
181
|
+
RG_DEF_METHOD(width, 0);
|
182
|
+
RG_DEF_METHOD(set_width, 1);
|
183
|
+
RG_DEF_METHOD(height, 0);
|
184
|
+
RG_DEF_METHOD(set_height, 1);
|
185
|
+
RG_DEF_METHOD(em, 0);
|
186
|
+
RG_DEF_METHOD(set_em, 1);
|
187
|
+
RG_DEF_METHOD(ex, 0);
|
188
|
+
RG_DEF_METHOD(set_ex, 1);
|
189
|
+
|
190
|
+
RG_DEF_METHOD(to_s, 0);
|
191
|
+
RG_DEF_METHOD(to_a, 0);
|
192
|
+
RG_DEF_ALIAS("to_ary", "to_a");
|
193
|
+
|
194
|
+
G_DEF_SETTERS(RG_TARGET_NAMESPACE);
|
195
|
+
#endif
|
196
|
+
}
|
@@ -0,0 +1,477 @@
|
|
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_m_new_from_data(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_m_new_from_file(VALUE self, VALUE file)
|
113
|
+
{
|
114
|
+
GError *error = NULL;
|
115
|
+
RsvgHandle *handle;
|
116
|
+
|
117
|
+
handle = rsvg_handle_new_from_file((const gchar *)RVAL2CSTR(file),
|
118
|
+
&error);
|
119
|
+
|
120
|
+
if (error)
|
121
|
+
RAISE_GERROR(error);
|
122
|
+
|
123
|
+
return GOBJ2RVAL(handle);
|
124
|
+
}
|
125
|
+
#endif
|
126
|
+
|
127
|
+
static VALUE
|
128
|
+
rg_initialize(int argc, VALUE *argv, VALUE self)
|
129
|
+
{
|
130
|
+
RsvgHandle *handle;
|
131
|
+
VALUE gz;
|
132
|
+
rb_scan_args(argc, argv, "01", &gz);
|
133
|
+
|
134
|
+
#if LIBRSVG_CHECK_VERSION(2, 11, 0)
|
135
|
+
handle = rsvg_handle_new();
|
136
|
+
#else
|
137
|
+
if (RVAL2CBOOL(gz)) {
|
138
|
+
# ifdef HAVE_LIBRSVG_RSVG_GZ_H
|
139
|
+
handle = rsvg_handle_new_gz();
|
140
|
+
# else
|
141
|
+
rb_warning("gz handling is not supported in your librsvg");
|
142
|
+
handle = rsvg_handle_new();
|
143
|
+
# endif
|
144
|
+
} else {
|
145
|
+
handle = rsvg_handle_new();
|
146
|
+
}
|
147
|
+
#endif
|
148
|
+
|
149
|
+
#ifdef RSVG_TYPE_HANDLE
|
150
|
+
G_INITIALIZE(self, handle);
|
151
|
+
#else
|
152
|
+
DATA_PTR(self) = handle;
|
153
|
+
#endif
|
154
|
+
|
155
|
+
rb_ivar_set(self, id_closed, Qfalse);
|
156
|
+
return Qnil;
|
157
|
+
}
|
158
|
+
|
159
|
+
static VALUE
|
160
|
+
rg_set_size_callback(VALUE self)
|
161
|
+
{
|
162
|
+
rb_ivar_set(self, id_callback, rb_block_proc());
|
163
|
+
rsvg_handle_set_size_callback(_SELF(self), exec_callback,
|
164
|
+
(gpointer)self, NULL);
|
165
|
+
return self;
|
166
|
+
}
|
167
|
+
|
168
|
+
static VALUE
|
169
|
+
rg_write(VALUE self, VALUE buf)
|
170
|
+
{
|
171
|
+
gboolean result;
|
172
|
+
GError *error = NULL;
|
173
|
+
|
174
|
+
result = rsvg_handle_write(_SELF(self), (const guchar*)RVAL2CSTR(buf),
|
175
|
+
RSTRING_LEN(buf), &error);
|
176
|
+
|
177
|
+
if (!result) RAISE_GERROR(error);
|
178
|
+
|
179
|
+
return CBOOL2RVAL(result);
|
180
|
+
}
|
181
|
+
|
182
|
+
static VALUE
|
183
|
+
rg_close(VALUE self)
|
184
|
+
{
|
185
|
+
gboolean result;
|
186
|
+
GError *error = NULL;
|
187
|
+
|
188
|
+
if (RVAL2CBOOL(rb_ivar_get(self, id_closed))) {
|
189
|
+
return Qnil;
|
190
|
+
}
|
191
|
+
|
192
|
+
result = rsvg_handle_close(_SELF(self), &error);
|
193
|
+
|
194
|
+
if (result) {
|
195
|
+
rb_ivar_set(self, id_closed, Qtrue);
|
196
|
+
} else {
|
197
|
+
RAISE_GERROR(error);
|
198
|
+
}
|
199
|
+
|
200
|
+
return CBOOL2RVAL(result);
|
201
|
+
}
|
202
|
+
|
203
|
+
static VALUE
|
204
|
+
rg_closed_p(VALUE self)
|
205
|
+
{
|
206
|
+
return rb_ivar_get(self, id_closed);
|
207
|
+
}
|
208
|
+
|
209
|
+
static VALUE
|
210
|
+
rg_pixbuf(int argc, VALUE *argv, VALUE self)
|
211
|
+
{
|
212
|
+
VALUE id;
|
213
|
+
VALUE rb_pixbuf;
|
214
|
+
GdkPixbuf *pixbuf = NULL;
|
215
|
+
|
216
|
+
rb_scan_args(argc, argv, "01", &id);
|
217
|
+
if (NIL_P(id)) {
|
218
|
+
pixbuf = rsvg_handle_get_pixbuf(_SELF(self));
|
219
|
+
} else {
|
220
|
+
#ifdef HAVE_RSVG_HANDLE_GET_PIXBUF_SUB
|
221
|
+
pixbuf = rsvg_handle_get_pixbuf_sub(_SELF(self),
|
222
|
+
(const char *)RVAL2CSTR(id));
|
223
|
+
#else
|
224
|
+
rb_warning("rsvg_handle_get_pixbuf_sub isn't "
|
225
|
+
"supported in your librsvg");
|
226
|
+
#endif
|
227
|
+
}
|
228
|
+
|
229
|
+
rb_pixbuf = GOBJ2RVAL(pixbuf);
|
230
|
+
if (pixbuf)
|
231
|
+
g_object_unref(pixbuf);
|
232
|
+
return rb_pixbuf;
|
233
|
+
}
|
234
|
+
|
235
|
+
#if LIBRSVG_CHECK_VERSION(2, 9, 0)
|
236
|
+
static VALUE
|
237
|
+
rg_base_uri(VALUE self)
|
238
|
+
{
|
239
|
+
return CSTR2RVAL(rsvg_handle_get_base_uri(_SELF(self)));
|
240
|
+
}
|
241
|
+
|
242
|
+
static VALUE
|
243
|
+
rg_set_base_uri(VALUE self, VALUE base_uri)
|
244
|
+
{
|
245
|
+
rsvg_handle_set_base_uri(_SELF(self), RVAL2CSTR(base_uri));
|
246
|
+
return self;
|
247
|
+
}
|
248
|
+
#endif
|
249
|
+
|
250
|
+
#ifdef HAVE_TYPE_RSVGDIMENSIONDATA
|
251
|
+
static VALUE
|
252
|
+
rg_dimensions(VALUE self)
|
253
|
+
{
|
254
|
+
RsvgDimensionData dim;
|
255
|
+
VALUE args[4];
|
256
|
+
VALUE cDimensionData = rb_const_get(rb_const_get(rb_cObject,
|
257
|
+
rb_intern("RSVG")), rb_intern("DimensionData"));
|
258
|
+
|
259
|
+
rsvg_handle_get_dimensions(_SELF(self), &dim);
|
260
|
+
args[0] = INT2NUM(dim.width);
|
261
|
+
args[1] = INT2NUM(dim.height);
|
262
|
+
args[2] = rb_float_new(dim.em);
|
263
|
+
args[3] = rb_float_new(dim.ex);
|
264
|
+
return rb_class_new_instance(sizeof(args) / sizeof(VALUE),
|
265
|
+
args, cDimensionData);
|
266
|
+
}
|
267
|
+
#endif
|
268
|
+
|
269
|
+
/* Accessibility API */
|
270
|
+
static VALUE
|
271
|
+
rg_title(VALUE self)
|
272
|
+
{
|
273
|
+
return CSTR2RVAL(rsvg_handle_get_title(_SELF(self)));
|
274
|
+
}
|
275
|
+
|
276
|
+
static VALUE
|
277
|
+
rg_desc(VALUE self)
|
278
|
+
{
|
279
|
+
return CSTR2RVAL(rsvg_handle_get_desc(_SELF(self)));
|
280
|
+
}
|
281
|
+
|
282
|
+
#ifdef HAVE_RSVG_HANDLE_GET_METADATA
|
283
|
+
static VALUE
|
284
|
+
rg_metadata(VALUE self)
|
285
|
+
{
|
286
|
+
return CSTR2RVAL(rsvg_handle_get_metadata(_SELF(self)));
|
287
|
+
}
|
288
|
+
#endif
|
289
|
+
|
290
|
+
#if !LIBRSVG_CHECK_VERSION(2, 11, 0)
|
291
|
+
/* Extended Convenience API */
|
292
|
+
static VALUE
|
293
|
+
rg_pixbuf_from_file_at_size(VALUE self, VALUE file_name,
|
294
|
+
VALUE width, VALUE height)
|
295
|
+
{
|
296
|
+
VALUE rb_pixbuf;
|
297
|
+
GdkPixbuf *pixbuf;
|
298
|
+
GError *error = NULL;
|
299
|
+
|
300
|
+
pixbuf = rsvg_pixbuf_from_file_at_size_ex(_SELF(self),
|
301
|
+
RVAL2CSTR(file_name),
|
302
|
+
NUM2INT(width),
|
303
|
+
NUM2INT(height),
|
304
|
+
&error);
|
305
|
+
|
306
|
+
if (error) RAISE_GERROR(error);
|
307
|
+
|
308
|
+
rb_pixbuf = GOBJ2RVAL(pixbuf);
|
309
|
+
g_object_unref(pixbuf);
|
310
|
+
return rb_pixbuf;
|
311
|
+
}
|
312
|
+
|
313
|
+
static VALUE
|
314
|
+
rg_pixbuf_from_file(VALUE self, VALUE file_name)
|
315
|
+
{
|
316
|
+
VALUE rb_pixbuf;
|
317
|
+
GdkPixbuf *pixbuf;
|
318
|
+
GError *error = NULL;
|
319
|
+
|
320
|
+
pixbuf = rsvg_pixbuf_from_file_ex(_SELF(self),
|
321
|
+
RVAL2CSTR(file_name),
|
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_at_zoom(VALUE self, VALUE file_name,
|
333
|
+
VALUE x_zoom, VALUE y_zoom)
|
334
|
+
{
|
335
|
+
VALUE rb_pixbuf;
|
336
|
+
GdkPixbuf *pixbuf;
|
337
|
+
GError *error = NULL;
|
338
|
+
|
339
|
+
pixbuf = rsvg_pixbuf_from_file_at_zoom_ex(_SELF(self),
|
340
|
+
RVAL2CSTR(file_name),
|
341
|
+
NUM2DBL(x_zoom),
|
342
|
+
NUM2DBL(y_zoom),
|
343
|
+
&error);
|
344
|
+
|
345
|
+
if (error) RAISE_GERROR(error);
|
346
|
+
|
347
|
+
rb_pixbuf = GOBJ2RVAL(pixbuf);
|
348
|
+
g_object_unref(pixbuf);
|
349
|
+
return rb_pixbuf;
|
350
|
+
}
|
351
|
+
|
352
|
+
static VALUE
|
353
|
+
rg_pixbuf_from_file_at_max_size(VALUE self, VALUE file_name,
|
354
|
+
VALUE max_width, VALUE max_height)
|
355
|
+
{
|
356
|
+
VALUE rb_pixbuf;
|
357
|
+
GdkPixbuf *pixbuf;
|
358
|
+
GError *error = NULL;
|
359
|
+
|
360
|
+
pixbuf = rsvg_pixbuf_from_file_at_max_size_ex(_SELF(self),
|
361
|
+
RVAL2CSTR(file_name),
|
362
|
+
NUM2INT(max_width),
|
363
|
+
NUM2INT(max_height),
|
364
|
+
&error);
|
365
|
+
|
366
|
+
if (error) RAISE_GERROR(error);
|
367
|
+
|
368
|
+
rb_pixbuf = GOBJ2RVAL(pixbuf);
|
369
|
+
g_object_unref(pixbuf);
|
370
|
+
return rb_pixbuf;
|
371
|
+
}
|
372
|
+
|
373
|
+
static VALUE
|
374
|
+
rg_pixbuf_from_file_at_zoom_with_max(VALUE self,
|
375
|
+
VALUE file_name,
|
376
|
+
VALUE x_zoom,
|
377
|
+
VALUE y_zoom,
|
378
|
+
VALUE max_width,
|
379
|
+
VALUE max_height)
|
380
|
+
{
|
381
|
+
VALUE rb_pixbuf;
|
382
|
+
GdkPixbuf *pixbuf;
|
383
|
+
GError *error = NULL;
|
384
|
+
|
385
|
+
pixbuf = rsvg_pixbuf_from_file_at_zoom_with_max_ex(_SELF(self),
|
386
|
+
RVAL2CSTR(file_name),
|
387
|
+
NUM2DBL(x_zoom),
|
388
|
+
NUM2DBL(y_zoom),
|
389
|
+
NUM2INT(max_width),
|
390
|
+
NUM2INT(max_height),
|
391
|
+
&error);
|
392
|
+
|
393
|
+
if (error) RAISE_GERROR(error);
|
394
|
+
|
395
|
+
rb_pixbuf = GOBJ2RVAL(pixbuf);
|
396
|
+
g_object_unref(pixbuf);
|
397
|
+
return rb_pixbuf;
|
398
|
+
}
|
399
|
+
#endif
|
400
|
+
|
401
|
+
#ifdef HAVE_LIBRSVG_RSVG_CAIRO_H
|
402
|
+
static VALUE
|
403
|
+
rg_render_cairo(int argc, VALUE *argv, VALUE self)
|
404
|
+
{
|
405
|
+
VALUE cr, id;
|
406
|
+
rb_scan_args(argc, argv, "11", &cr, &id);
|
407
|
+
|
408
|
+
if (NIL_P(id)) {
|
409
|
+
rsvg_handle_render_cairo( _SELF(self), RVAL2CRCONTEXT(cr));
|
410
|
+
} else {
|
411
|
+
rsvg_handle_render_cairo_sub( _SELF(self), RVAL2CRCONTEXT(cr),
|
412
|
+
(const char *)RVAL2CSTR(id));
|
413
|
+
}
|
414
|
+
|
415
|
+
return Qnil;
|
416
|
+
}
|
417
|
+
#endif
|
418
|
+
|
419
|
+
void
|
420
|
+
Init_rsvg_handle(VALUE mRSVG)
|
421
|
+
{
|
422
|
+
id_call = rb_intern("call");
|
423
|
+
id_callback = rb_intern("callback");
|
424
|
+
id_closed = rb_intern("closed");
|
425
|
+
|
426
|
+
#ifdef RSVG_TYPE_HANDLE
|
427
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(RSVG_TYPE_HANDLE, "Handle", mRSVG);
|
428
|
+
#else
|
429
|
+
RG_TARGET_NAMESPACE = rb_define_class_under(mRSVG, "Handle", rb_cObject);
|
430
|
+
rb_define_alloc_func(RG_TARGET_NAMESPACE, rb_rsvg_handle_alloc);
|
431
|
+
#endif
|
432
|
+
|
433
|
+
#if LIBRSVG_CHECK_VERSION(2, 14, 0)
|
434
|
+
RG_DEF_MODFUNC(new_from_data, 1);
|
435
|
+
RG_DEF_MODFUNC(new_from_file, 1);
|
436
|
+
#endif
|
437
|
+
|
438
|
+
RG_DEF_METHOD(initialize, -1);
|
439
|
+
RG_DEF_METHOD(set_size_callback, 0);
|
440
|
+
RG_DEF_METHOD(set_dpi, 1);
|
441
|
+
RG_DEF_METHOD(set_dpi_x_y, 2);
|
442
|
+
RG_DEF_METHOD(write, 1);
|
443
|
+
RG_DEF_METHOD(close, 0);
|
444
|
+
RG_DEF_METHOD_P(closed, 0);
|
445
|
+
RG_DEF_METHOD(pixbuf, -1);
|
446
|
+
|
447
|
+
#if LIBRSVG_CHECK_VERSION(2, 9, 0)
|
448
|
+
RG_DEF_METHOD(base_uri, 0);
|
449
|
+
RG_DEF_METHOD(set_base_uri, 1);
|
450
|
+
#endif
|
451
|
+
|
452
|
+
#ifdef HAVE_TYPE_RSVGDIMENSIONDATA
|
453
|
+
RG_DEF_METHOD(dimensions, 0);
|
454
|
+
#endif
|
455
|
+
|
456
|
+
/* Accessibility API */
|
457
|
+
RG_DEF_METHOD(title, 0);
|
458
|
+
RG_DEF_METHOD(desc, 0);
|
459
|
+
#ifdef HAVE_RSVG_HANDLE_GET_METADATA
|
460
|
+
RG_DEF_METHOD(metadata, 0);
|
461
|
+
#endif
|
462
|
+
|
463
|
+
#if !LIBRSVG_CHECK_VERSION(2, 11, 0)
|
464
|
+
/* Extended Convenience API */
|
465
|
+
RG_DEF_METHOD(pixbuf_from_file_at_size, 3);
|
466
|
+
RG_DEF_METHOD(pixbuf_from_file, 1);
|
467
|
+
RG_DEF_METHOD(pixbuf_from_file_at_zoom, 3);
|
468
|
+
RG_DEF_METHOD(pixbuf_from_file_at_max_size, 3);
|
469
|
+
RG_DEF_METHOD(pixbuf_from_file_at_zoom_with_max, 5);
|
470
|
+
#endif
|
471
|
+
|
472
|
+
#ifdef HAVE_LIBRSVG_RSVG_CAIRO_H
|
473
|
+
RG_DEF_METHOD(render_cairo, -1);
|
474
|
+
#endif
|
475
|
+
|
476
|
+
G_DEF_SETTERS(RG_TARGET_NAMESPACE);
|
477
|
+
}
|