rsvg2 2.2.5 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -2
- data/ext/rsvg2/extconf.rb +1 -1
- data/ext/rsvg2/rbrsvg.c +2 -15
- data/ext/rsvg2/rbrsvghandle.c +44 -197
- data/ext/rsvg2/rsvg2.h +13 -19
- data/lib/rsvg2.rb +26 -11
- data/sample/svg-viewer.rb +2 -2
- data/test/rsvg2-test-utils.rb +11 -0
- data/test/test-handle.rb +4 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ee819e123fc5c50f97541c60dcee5a210bea040
|
4
|
+
data.tar.gz: ac4fcbe92dd99a1325ea3f5e3d381455ad4b34a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d622f55d2d3a7653a9dcb11a5849d7611b0b35eb0bed5fa81eff3edc8d6b48152facdd343899ed42380788ed53dd6150082cb40fa07cda5a0d75c3c734cae76
|
7
|
+
data.tar.gz: 523721a8779f9719b34d089ed1ddab7048df9ff25ba9097a8d2db564f5ac25a1dbb8c124e5eff2336fd255994353bf6968fa8a358a322ac67ce99de6b8e3e790
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2010-
|
3
|
+
# Copyright (C) 2010-2015 Ruby-GNOME2 Project Team
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -52,7 +52,7 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
|
|
52
52
|
:name => "librsvg",
|
53
53
|
:download_site => :gnome,
|
54
54
|
:label => "librsvg",
|
55
|
-
:version => "2.40.
|
55
|
+
:version => "2.40.9",
|
56
56
|
:compression_method => "xz",
|
57
57
|
:windows => {
|
58
58
|
:configure_args => [
|
data/ext/rsvg2/extconf.rb
CHANGED
data/ext/rsvg2/rbrsvg.c
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C)
|
4
|
-
* Copyright (C) 2005-2006 Ruby-GNOME2 Project Team
|
3
|
+
* Copyright (C) 2005-2015 Ruby-GNOME2 Project Team
|
5
4
|
* Copyright (C) 2004 Kouhei Sutou <kou@cozmixng.org>
|
6
5
|
*
|
7
6
|
* This library is free software; you can redistribute it and/or
|
@@ -155,22 +154,12 @@ rg_s_pixbuf_from_file_at_zoom_with_max(G_GNUC_UNUSED VALUE self,
|
|
155
154
|
return rb_pixbuf;
|
156
155
|
}
|
157
156
|
|
158
|
-
static VALUE
|
159
|
-
rg_s_cairo_available_p(G_GNUC_UNUSED VALUE self)
|
160
|
-
{
|
161
|
-
#ifdef HAVE_LIBRSVG_RSVG_CAIRO_H
|
162
|
-
return Qtrue;
|
163
|
-
#else
|
164
|
-
return Qfalse;
|
165
|
-
#endif
|
166
|
-
}
|
167
|
-
|
168
157
|
void
|
169
158
|
Init_rsvg2(void)
|
170
159
|
{
|
171
160
|
VALUE RG_TARGET_NAMESPACE = rb_define_module("RSVG");
|
172
161
|
|
173
|
-
#if LIBRSVG_CHECK_VERSION(2,
|
162
|
+
#if !LIBRSVG_CHECK_VERSION(2, 35, 0)
|
174
163
|
rsvg_init();
|
175
164
|
atexit(rsvg_term);
|
176
165
|
#endif
|
@@ -199,8 +188,6 @@ Init_rsvg2(void)
|
|
199
188
|
RG_DEF_SMETHOD(pixbuf_from_file_at_max_size, 3);
|
200
189
|
RG_DEF_SMETHOD(pixbuf_from_file_at_zoom_with_max, 5);
|
201
190
|
|
202
|
-
RG_DEF_SMETHOD_P(cairo_available, 0);
|
203
|
-
|
204
191
|
Init_rsvg_handle(RG_TARGET_NAMESPACE);
|
205
192
|
Init_rsvg_dimensiondata(RG_TARGET_NAMESPACE);
|
206
193
|
}
|
data/ext/rsvg2/rbrsvghandle.c
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C)
|
4
|
-
* Copyright (C) 2005-2006 Ruby-GNOME2 Project Team
|
3
|
+
* Copyright (C) 2005-2015 Ruby-GNOME2 Project Team
|
5
4
|
* Copyright (C) 2004 Kouhei Sutou <kou@cozmixng.org>
|
6
5
|
*
|
7
6
|
* This library is free software; you can redistribute it and/or
|
@@ -92,96 +91,73 @@ rb_rsvg_handle_alloc(VALUE klass)
|
|
92
91
|
}
|
93
92
|
#endif
|
94
93
|
|
95
|
-
#if LIBRSVG_CHECK_VERSION(2, 14, 0)
|
96
94
|
static VALUE
|
97
|
-
|
95
|
+
rg_initialize(int argc, VALUE *argv, VALUE self)
|
98
96
|
{
|
99
|
-
GError *error = NULL;
|
100
97
|
RsvgHandle *handle;
|
101
|
-
|
102
|
-
|
103
|
-
|
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;
|
98
|
+
VALUE rb_options;
|
99
|
+
const char *file_name = NULL;
|
100
|
+
const guint8 *data = NULL;
|
101
|
+
gsize data_size = 0;
|
115
102
|
GError *error = NULL;
|
116
|
-
|
103
|
+
#if LIBRSVG_CHECK_VERSION(2, 40, 3)
|
104
|
+
RsvgHandleFlags flags = RSVG_HANDLE_FLAGS_NONE;
|
105
|
+
#endif
|
117
106
|
|
118
|
-
rb_scan_args(argc, argv, "
|
119
|
-
rbg_scan_options(rb_options,
|
120
|
-
"flags", &rb_flags,
|
121
|
-
NULL);
|
107
|
+
rb_scan_args(argc, argv, "01", &rb_options);
|
122
108
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
RsvgHandleFlags flags = RSVG_HANDLE_FLAGS_NONE;
|
109
|
+
if (!NIL_P(rb_options)) {
|
110
|
+
VALUE rb_file_name;
|
111
|
+
VALUE rb_data;
|
112
|
+
VALUE rb_flags;
|
128
113
|
|
114
|
+
rbg_scan_options(rb_options,
|
115
|
+
"file_name", &rb_file_name,
|
116
|
+
"data", &rb_data,
|
117
|
+
"flags", &rb_flags,
|
118
|
+
NULL);
|
119
|
+
if (!NIL_P(rb_file_name)) {
|
120
|
+
file_name = RVAL2CSTRFILENAME(rb_file_name);
|
121
|
+
}
|
122
|
+
if (!NIL_P(rb_data)) {
|
123
|
+
data = (const guint8 *)RSTRING_PTR(rb_data);
|
124
|
+
data_size = RSTRING_LEN(rb_data);
|
125
|
+
}
|
129
126
|
if (!NIL_P(rb_flags)) {
|
127
|
+
#if LIBRSVG_CHECK_VERSION(2, 40, 3)
|
130
128
|
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
129
|
#else
|
140
|
-
if (!NIL_P(rb_flags)) {
|
141
130
|
rb_raise(rb_eArgError,
|
142
131
|
"librsvg 2.40.3 or later is required for :flags: <%d.%d.%d>",
|
143
132
|
LIBRSVG_MAJOR_VERSION,
|
144
133
|
LIBRSVG_MINOR_VERSION,
|
145
134
|
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
135
|
#endif
|
136
|
+
}
|
137
|
+
}
|
157
138
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
VALUE gz;
|
163
|
-
rb_scan_args(argc, argv, "01", &gz);
|
139
|
+
if (file_name) {
|
140
|
+
#if LIBRSVG_CHECK_VERSION(2, 40, 3)
|
141
|
+
GFile *file;
|
142
|
+
GCancellable *cancellable = NULL;
|
164
143
|
|
165
|
-
|
166
|
-
|
144
|
+
file = g_file_new_for_path(file_name);
|
145
|
+
handle = rsvg_handle_new_from_gfile_sync(file, flags, cancellable,
|
146
|
+
&error);
|
147
|
+
g_object_unref(file);
|
167
148
|
#else
|
168
|
-
|
169
|
-
#
|
170
|
-
|
171
|
-
|
172
|
-
rb_warning("gz handling is not supported in your librsvg");
|
173
|
-
handle = rsvg_handle_new();
|
174
|
-
# endif
|
149
|
+
handle = rsvg_handle_new_from_file(file_name, &error);
|
150
|
+
#endif
|
151
|
+
} else if (data) {
|
152
|
+
handle = rsvg_handle_new_from_data(data, data_size, &error);
|
175
153
|
} else {
|
176
154
|
handle = rsvg_handle_new();
|
177
155
|
}
|
178
|
-
#endif
|
179
156
|
|
180
|
-
|
157
|
+
if (error)
|
158
|
+
RAISE_GERROR(error);
|
159
|
+
|
181
160
|
G_INITIALIZE(self, handle);
|
182
|
-
#else
|
183
|
-
DATA_PTR(self) = handle;
|
184
|
-
#endif
|
185
161
|
|
186
162
|
rb_ivar_set(self, id_closed, Qfalse);
|
187
163
|
return Qnil;
|
@@ -305,118 +281,6 @@ rg_metadata(VALUE self)
|
|
305
281
|
# endif
|
306
282
|
#endif
|
307
283
|
|
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
284
|
static VALUE
|
421
285
|
rg_render_cairo(int argc, VALUE *argv, VALUE self)
|
422
286
|
{
|
@@ -432,7 +296,6 @@ rg_render_cairo(int argc, VALUE *argv, VALUE self)
|
|
432
296
|
|
433
297
|
return Qnil;
|
434
298
|
}
|
435
|
-
#endif
|
436
299
|
|
437
300
|
void
|
438
301
|
Init_rsvg_handle(VALUE mRSVG)
|
@@ -448,11 +311,6 @@ Init_rsvg_handle(VALUE mRSVG)
|
|
448
311
|
rb_define_alloc_func(RG_TARGET_NAMESPACE, rb_rsvg_handle_alloc);
|
449
312
|
#endif
|
450
313
|
|
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
314
|
RG_DEF_METHOD(initialize, -1);
|
457
315
|
RG_DEF_METHOD(set_size_callback, 0);
|
458
316
|
RG_DEF_METHOD(set_dpi, 1);
|
@@ -475,18 +333,7 @@ Init_rsvg_handle(VALUE mRSVG)
|
|
475
333
|
# endif
|
476
334
|
#endif
|
477
335
|
|
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
336
|
RG_DEF_METHOD(render_cairo, -1);
|
489
|
-
#endif
|
490
337
|
|
491
338
|
#if LIBRSVG_CHECK_VERSION(2, 40, 3)
|
492
339
|
/* RsvgHandleFlags */
|
data/ext/rsvg2/rsvg2.h
CHANGED
@@ -31,32 +31,26 @@ extern "C" {
|
|
31
31
|
|
32
32
|
#include <rbglib.h>
|
33
33
|
#include <rbgobject.h>
|
34
|
+
#include <rb_cairo.h>
|
34
35
|
|
35
|
-
#
|
36
|
-
# include <librsvg/rsvg-gz.h>
|
37
|
-
#else
|
38
|
-
# include <librsvg/rsvg.h>
|
39
|
-
#endif
|
40
|
-
|
41
|
-
#ifdef HAVE_RB_CAIRO_H
|
42
|
-
# include <rb_cairo.h>
|
43
|
-
# include <librsvg/rsvg-cairo.h>
|
44
|
-
#endif
|
45
|
-
|
46
|
-
#ifdef HAVE_LIBRSVG_LIBRSVG_ENUM_TYPES_H
|
47
|
-
# include <librsvg/librsvg-enum-types.h>
|
48
|
-
#else
|
49
|
-
# include "librsvg-enum-types.h"
|
50
|
-
#endif
|
36
|
+
#include <librsvg/rsvg.h>
|
51
37
|
|
52
|
-
#
|
53
|
-
|
38
|
+
#ifndef LIBRSVG_CHECK_VERSION
|
39
|
+
# include <librsvg/librsvg-features.h>
|
40
|
+
# define LIBRSVG_CHECK_VERSION(major, minor, micro) \
|
41
|
+
(LIBRSVG_MAJOR_VERSION > (major) || \
|
54
42
|
(LIBRSVG_MAJOR_VERSION == (major) && LIBRSVG_MINOR_VERSION > (minor)) || \
|
55
43
|
(LIBRSVG_MAJOR_VERSION == (major) && LIBRSVG_MINOR_VERSION == (minor) && \
|
56
44
|
LIBRSVG_MICRO_VERSION >= (micro)))
|
45
|
+
#endif
|
57
46
|
|
58
47
|
#if !LIBRSVG_CHECK_VERSION(2, 36, 2)
|
59
|
-
# include <librsvg/
|
48
|
+
# include <librsvg/rsvg-cairo.h>
|
49
|
+
# ifdef HAVE_LIBRSVG_LIBRSVG_ENUM_TYPES_H
|
50
|
+
# include <librsvg/librsvg-enum-types.h>
|
51
|
+
# else
|
52
|
+
# include "librsvg-enum-types.h"
|
53
|
+
# endif
|
60
54
|
#endif
|
61
55
|
|
62
56
|
|
data/lib/rsvg2.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
require "glib2"
|
2
2
|
require "gdk_pixbuf2"
|
3
|
-
|
4
|
-
require "cairo"
|
5
|
-
rescue LoadError
|
6
|
-
end
|
3
|
+
require "cairo"
|
7
4
|
|
8
5
|
base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path
|
9
6
|
vendor_dir = base_dir + "vendor" + "local"
|
10
7
|
vendor_bin_dir = vendor_dir + "bin"
|
11
8
|
GLib.prepend_dll_path(vendor_bin_dir)
|
12
9
|
begin
|
13
|
-
major, minor,
|
10
|
+
major, minor, = RUBY_VERSION.split(/\./)
|
14
11
|
require "#{major}.#{minor}/rsvg2.so"
|
15
12
|
rescue LoadError
|
16
13
|
require "rsvg2.so"
|
@@ -18,14 +15,32 @@ end
|
|
18
15
|
|
19
16
|
module RSVG
|
20
17
|
LOG_DOMAIN = "librsvg"
|
21
|
-
end
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
class << self
|
20
|
+
def cairo_available?
|
21
|
+
true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Handle
|
26
|
+
class << self
|
27
|
+
# For backward compatibility
|
28
|
+
def new_from_data(data)
|
29
|
+
new(:data => data)
|
28
30
|
end
|
31
|
+
|
32
|
+
# For backward compatibility
|
33
|
+
def new_from_file(file_name, options={})
|
34
|
+
new(options.merge(:file_name => file_name))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
module Cairo
|
41
|
+
class Context
|
42
|
+
def render_rsvg_handle(handle, *args, &block)
|
43
|
+
handle.render_cairo(self, *args, &block)
|
29
44
|
end
|
30
45
|
end
|
31
46
|
end
|
data/sample/svg-viewer.rb
CHANGED
@@ -27,11 +27,11 @@ window = Gtk::Window.new
|
|
27
27
|
window.set_default_size(width, height)
|
28
28
|
area = Gtk::DrawingArea.new
|
29
29
|
|
30
|
-
window.signal_connect(
|
30
|
+
window.signal_connect(:destroy) do
|
31
31
|
Gtk.main_quit
|
32
32
|
end
|
33
33
|
|
34
|
-
area.signal_connect(
|
34
|
+
area.signal_connect(:expose_event) do |widget, event|
|
35
35
|
context = widget.window.create_cairo_context
|
36
36
|
window_width, window_height = widget.window.size
|
37
37
|
context.scale(window_width.to_f / width, window_height.to_f / height)
|
data/test/rsvg2-test-utils.rb
CHANGED
@@ -20,4 +20,15 @@ require "test/unit/notify"
|
|
20
20
|
require "fileutils"
|
21
21
|
|
22
22
|
module RSVG2TestUtils
|
23
|
+
def later_version?(major, minor, micro=nil)
|
24
|
+
micro ||= 0
|
25
|
+
(RSVG::BUILD_VERSION <=> [major, minor, micro]) >= 0
|
26
|
+
end
|
27
|
+
|
28
|
+
def only_rsvg_version(major, minor, micro=nil)
|
29
|
+
micro ||= 0
|
30
|
+
unless later_version?(major, minor, micro)
|
31
|
+
omit("Require librsvg >= #{major}.#{minor}.#{micro}")
|
32
|
+
end
|
33
|
+
end
|
23
34
|
end
|
data/test/test-handle.rb
CHANGED
@@ -15,6 +15,8 @@
|
|
15
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
16
|
|
17
17
|
class TestHandle < Test::Unit::TestCase
|
18
|
+
include RSVG2TestUtils
|
19
|
+
|
18
20
|
sub_test_case ".new_from_file" do
|
19
21
|
sub_test_case "options" do
|
20
22
|
def setup
|
@@ -68,12 +70,14 @@ class TestHandle < Test::Unit::TestCase
|
|
68
70
|
end
|
69
71
|
|
70
72
|
def test_no_option
|
73
|
+
only_rsvg_version(2, 40, 3)
|
71
74
|
assert_raise(RSVG::Error::Failed) do
|
72
75
|
RSVG::Handle.new_from_file(@large_svg_path)
|
73
76
|
end
|
74
77
|
end
|
75
78
|
|
76
79
|
def test_unlimited
|
80
|
+
only_rsvg_version(2, 40, 3)
|
77
81
|
handle = RSVG::Handle.new_from_file(@large_svg_path,
|
78
82
|
:flags => :flag_unlimited)
|
79
83
|
assert_equal([0, 0, 0.0, 0.0],
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsvg2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Ruby-GNOME2 Project Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cairo
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 3.0.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 3.0.1
|
41
41
|
description: Ruby/RSVG is a Ruby binding of librsvg-2.x.
|
42
42
|
email: ruby-gnome2-devel-en@lists.sourceforge.net
|
43
43
|
executables: []
|