gtk2svg 0.3.15 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/gtk2svg.rb +68 -74
- metadata +35 -32
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8b5a118c0868c06925d3a913ddc70520252cf750417619386a0861c15a9b18dc
|
4
|
+
data.tar.gz: 767e84933875bebbeaa06ba7e4b46895d5cdcb174b2488d07b1f271feb46f54f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9aff8130ed2d5422e8f4119f2bc813631fe350a7d29daef0778283f23547e0205111f9a0b546ea55832442a96d5ea2bfa370d1896a31180308de620243b882d8
|
7
|
+
data.tar.gz: ad7e9921a4be4257cff93f79227cb000480a411759efdfce0495356d8562b8e5a020303f7ca0d176f8bcd3bc4da28095dbd288ac979780f6e1c52e7842c7f0c4
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/gtk2svg.rb
CHANGED
@@ -9,130 +9,112 @@ require 'svgle'
|
|
9
9
|
# Description: Experimental gem to render SVG within a GTK2 application.
|
10
10
|
|
11
11
|
|
12
|
+
|
12
13
|
module Gtk2SVG
|
13
14
|
|
14
15
|
class Render < DomRender
|
15
16
|
|
16
17
|
|
17
|
-
def circle(e, attributes
|
18
|
-
|
19
|
-
style = style_filter(attributes).merge(raw_style)
|
18
|
+
def circle(e, attributes)
|
20
19
|
|
21
20
|
h = attributes
|
22
21
|
|
23
22
|
x, y= %i(cx cy).map{|x| h[x].to_i }
|
24
23
|
radius = h[:r].to_i * 2
|
25
24
|
|
26
|
-
[:draw_arc, [x, y, radius, radius],
|
25
|
+
[:draw_arc, [x, y, radius, radius], attributes, render_all(e)]
|
27
26
|
end
|
28
27
|
|
29
|
-
def ellipse(e, attributes
|
28
|
+
def ellipse(e, attributes)
|
30
29
|
|
31
|
-
style = style_filter(attributes).merge(raw_style)
|
32
30
|
h = attributes
|
33
31
|
|
34
32
|
x, y= %i(cx cy).map{|x| h[x].to_i }
|
35
33
|
width = h[:rx].to_i * 2
|
36
34
|
height = h[:ry].to_i * 2
|
37
35
|
|
38
|
-
[:draw_arc, [x, y, width, height],
|
36
|
+
[:draw_arc, [x, y, width, height], attributes, render_all(e)]
|
39
37
|
end
|
40
38
|
|
41
|
-
def line(e, attributes
|
39
|
+
def line(e, attributes)
|
42
40
|
|
43
|
-
style = style_filter(attributes).merge(raw_style)
|
44
41
|
|
45
42
|
x1, y1, x2, y2 = %i(x1 y1 x2 y2).map{|x| attributes[x].to_i }
|
46
43
|
|
47
|
-
[:draw_line, [x1, y1, x2, y2],
|
44
|
+
[:draw_line, [x1, y1, x2, y2], attributes, render_all(e)]
|
48
45
|
end
|
49
46
|
|
50
|
-
def image(e, attributes
|
47
|
+
def image(e, attributes)
|
51
48
|
|
52
|
-
style = style_filter(attributes).merge(raw_style)
|
53
49
|
h = attributes
|
54
50
|
|
55
51
|
x, y, width, height = %i(x y width height).map{|x| h[x] ? h[x].to_i : nil }
|
56
52
|
src = h[:'xlink:href']
|
57
53
|
|
58
|
-
[:draw_image, [x, y, width, height], src,
|
54
|
+
[:draw_image, [x, y, width, height], src, attributes, render_all(e)]
|
59
55
|
end
|
60
56
|
|
61
|
-
def polygon(e, attributes
|
57
|
+
def polygon(e, attributes)
|
62
58
|
|
63
|
-
style = style_filter(attributes).merge(raw_style)
|
64
59
|
points = attributes[:points].split(/\s+/). \
|
65
60
|
map {|x| x.split(/\s*,\s*/).map(&:to_i)}
|
66
61
|
|
67
|
-
[:draw_polygon, points,
|
62
|
+
[:draw_polygon, points, attributes, render_all(e)]
|
68
63
|
end
|
69
64
|
|
70
|
-
def polyline(e, attributes
|
65
|
+
def polyline(e, attributes)
|
71
66
|
|
72
|
-
style = style_filter(attributes).merge(raw_style)
|
73
67
|
points = attributes[:points].split(/\s+/). \
|
74
68
|
map {|x| x.split(/\s*,\s*/).map(&:to_i)}
|
75
69
|
|
76
|
-
[:draw_lines, points,
|
70
|
+
[:draw_lines, points, attributes, render_all(e)]
|
77
71
|
end
|
78
72
|
|
79
|
-
def rect(e, attributes
|
73
|
+
def rect(e, attributes)
|
80
74
|
|
81
|
-
|
75
|
+
puts 'inside rect'
|
82
76
|
h = attributes
|
83
77
|
|
84
78
|
x1, y1, width, height = %i(x y width height).map{|x| h[x].to_i }
|
85
79
|
x2, y2, = x1 + width, y1 + height
|
86
80
|
|
87
|
-
[:draw_rectangle, [x1, y1, x2, y2],
|
81
|
+
[:draw_rectangle, [x1, y1, x2, y2], attributes, render_all(e)]
|
88
82
|
end
|
89
83
|
|
90
|
-
def script(e, attributes
|
84
|
+
def script(e, attributes)
|
91
85
|
[:script]
|
92
86
|
end
|
93
87
|
|
94
|
-
def svg(e, attributes
|
88
|
+
def svg(e, attributes)
|
95
89
|
|
96
|
-
style = style_filter(attributes).merge(raw_style)
|
97
90
|
|
98
91
|
# jr051216 style[:fill] = style.delete :'background-color'
|
99
92
|
h = attributes
|
100
93
|
width, height = %i(width height).map{|x| h[x].to_i }
|
101
94
|
|
102
|
-
[:draw_rectangle, [0, 0, width, height],
|
95
|
+
[:draw_rectangle, [0, 0, width, height], attributes, render_all(e)]
|
103
96
|
end
|
104
97
|
|
105
|
-
def text(e, attributes
|
106
|
-
|
107
|
-
style = style_filter(attributes).merge(raw_style)
|
108
|
-
style.merge!({font_size: '20'})
|
98
|
+
def text(e, attributes)
|
109
99
|
|
110
100
|
x, y = %i(x y).map{|x| attributes[x].to_i }
|
111
101
|
|
112
|
-
[:draw_layout, [x, y], e.text,
|
102
|
+
[:draw_layout, [x, y], e.text, attributes, render_all(e)]
|
113
103
|
end
|
114
104
|
|
115
|
-
|
116
|
-
|
117
|
-
def style_filter(attributes)
|
118
|
-
|
119
|
-
%i(stroke stroke-width fill).inject({}) do |r,x|
|
120
|
-
attributes.has_key?(x) ? r.merge(x => attributes[x]) : r
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
105
|
+
|
124
106
|
|
125
107
|
end
|
126
108
|
|
127
109
|
class DrawingInstructions
|
128
|
-
|
110
|
+
using ColouredText
|
111
|
+
|
129
112
|
attr_accessor :area
|
130
113
|
|
131
114
|
|
132
|
-
def initialize(area=nil, window=nil)
|
115
|
+
def initialize(area=nil, window=nil, debug: false)
|
133
116
|
|
134
|
-
@area = area
|
135
|
-
@window = window
|
117
|
+
@area, @window, @debug = area, window, debug
|
136
118
|
|
137
119
|
end
|
138
120
|
|
@@ -153,16 +135,18 @@ module Gtk2SVG
|
|
153
135
|
x, y, width, height = dimensions
|
154
136
|
|
155
137
|
gc = gc_ini(fill: style[:fill] || :none)
|
156
|
-
img = GdkPixbuf::Pixbuf.new(file: src)
|
157
138
|
|
158
|
-
|
159
|
-
|
160
|
-
width ||= img.width
|
161
|
-
height ||= img.height
|
139
|
+
if File.exists? src then
|
140
|
+
img = GdkPixbuf::Pixbuf.new(file: src)
|
162
141
|
|
163
|
-
|
164
|
-
|
165
|
-
|
142
|
+
x ||= 0
|
143
|
+
y ||= 0
|
144
|
+
width ||= img.width
|
145
|
+
height ||= img.height
|
146
|
+
|
147
|
+
@area.window.draw_pixbuf(gc, img, 0, 0, x, y, width, height,
|
148
|
+
Gdk::RGB::DITHER_NONE, 0, 0)
|
149
|
+
end
|
166
150
|
end
|
167
151
|
|
168
152
|
def draw_line(args)
|
@@ -201,7 +185,9 @@ module Gtk2SVG
|
|
201
185
|
|
202
186
|
def draw_rectangle(args)
|
203
187
|
|
204
|
-
|
188
|
+
puts 'inside draw_rectangle' if @debug
|
189
|
+
|
190
|
+
coords, style, e = args
|
205
191
|
|
206
192
|
x1, y1, x2, y2 = coords
|
207
193
|
|
@@ -229,7 +215,16 @@ module Gtk2SVG
|
|
229
215
|
end
|
230
216
|
|
231
217
|
def render(a)
|
218
|
+
|
219
|
+
if @debug then
|
220
|
+
puts 'inside gtk2svg render '.info
|
221
|
+
puts 'a: ' + a.inspect
|
222
|
+
end
|
223
|
+
|
232
224
|
method(a[0]).call(args=a[1..2])
|
225
|
+
puts 'after method' if @debug
|
226
|
+
return unless a[3].any?
|
227
|
+
|
233
228
|
draw a[3]
|
234
229
|
end
|
235
230
|
|
@@ -293,15 +288,15 @@ module Gtk2SVG
|
|
293
288
|
end
|
294
289
|
|
295
290
|
class Main
|
296
|
-
|
291
|
+
using ColouredText
|
297
292
|
|
298
293
|
attr_accessor :doc, :svg
|
299
294
|
attr_reader :width, :height
|
300
295
|
|
301
|
-
def initialize(svg, irb: false)
|
296
|
+
def initialize(svg, irb: false, title: 'window', debug: @debug)
|
302
297
|
|
303
|
-
@svg = svg
|
304
|
-
@doc = Svgle.new(svg, callback: self)
|
298
|
+
@svg, @debug = svg, debug
|
299
|
+
@doc = Svgle.new(svg, callback: self, debug: debug)
|
305
300
|
|
306
301
|
@area = area = Gtk::DrawingArea.new
|
307
302
|
|
@@ -316,7 +311,8 @@ module Gtk2SVG
|
|
316
311
|
|
317
312
|
client_code = []
|
318
313
|
|
319
|
-
|
314
|
+
puts ('title: ' + title.inspect).debug if @debug
|
315
|
+
window = Gtk::Window.new title
|
320
316
|
@width, @height = %i(width height).map{|x| @doc.root.attributes[x].to_i }
|
321
317
|
|
322
318
|
if @width and @height then
|
@@ -326,20 +322,17 @@ module Gtk2SVG
|
|
326
322
|
@dirty = true
|
327
323
|
|
328
324
|
@doc.root.xpath('//script').each {|x| eval x.text.unescape }
|
329
|
-
|
330
|
-
x1 = 150
|
331
325
|
|
332
326
|
area.signal_connect("expose_event") do
|
333
|
-
|
334
|
-
area.window.draw_rectangle(area.style.fg_gc(area.state), 1, x1, y1, x2, y2)
|
327
|
+
|
335
328
|
if @dirty then
|
336
329
|
|
337
330
|
Thread.new { @doc.root.xpath('//script').each {|x| eval x.text.unescape } }
|
338
331
|
|
339
|
-
@instructions = Gtk2SVG::Render.new(@doc).to_a
|
332
|
+
@instructions = Gtk2SVG::Render.new(@doc, debug: debug).to_a
|
340
333
|
end
|
341
334
|
|
342
|
-
drawing = DrawingInstructions.new area
|
335
|
+
drawing = DrawingInstructions.new area, debug: debug
|
343
336
|
drawing.render @instructions
|
344
337
|
@dirty = false
|
345
338
|
|
@@ -369,19 +362,17 @@ module Gtk2SVG
|
|
369
362
|
|
370
363
|
window.add(area).show_all
|
371
364
|
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
end
|
365
|
+
|
366
|
+
@doc.root.xpath('//*[@onload]').each do |x|
|
367
|
+
|
368
|
+
eval x.onload()
|
369
|
+
|
378
370
|
end
|
379
371
|
|
380
372
|
#Thread.new do
|
381
373
|
# 3.times { x1 -= 1; @area.queue_draw; sleep 0.1}
|
382
374
|
#end
|
383
|
-
|
384
|
-
#@area.queue_draw; sleep 0.01
|
375
|
+
|
385
376
|
window.show_all.signal_connect("destroy"){Gtk.main_quit}
|
386
377
|
|
387
378
|
irb ? Thread.new {Gtk.main } : Gtk.main
|
@@ -389,7 +380,10 @@ module Gtk2SVG
|
|
389
380
|
|
390
381
|
def onmousemove(x,y)
|
391
382
|
|
392
|
-
end
|
383
|
+
end
|
384
|
+
|
385
|
+
def refresh()
|
386
|
+
end
|
393
387
|
|
394
388
|
def svg=(svg)
|
395
389
|
@svg = svg
|
@@ -417,4 +411,4 @@ if __FILE__ == $0 then
|
|
417
411
|
|
418
412
|
app = Gtk2SVG::Main.new svg
|
419
413
|
|
420
|
-
end
|
414
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gtk2svg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,28 +10,32 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAwODI1MDkyMzE5WhcN
|
15
|
+
MjEwODI1MDkyMzE5WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDZipRF
|
17
|
+
PddOhSJWjA5AU0enpeQuWI33p2Vxr5nzmqFw1v8L9et4dEfwf8jrvGQCFKVrLkOF
|
18
|
+
V16DPS7aB4CRyqysrT3Wcx7PRcAcU8PM/60x5VjlHkOoIGyDBS19FeEXSxnCL37P
|
19
|
+
qpN3IR32F3MnhQgi/Q75MGeT7EdG1QF0hfnUSvdWcfhMu85RppIrfMx8KBXNoOya
|
20
|
+
9rmsFHLiGZMvkCVQ/slMRTPy2FdZi9+KbkvoEll4wZgw5CyYDTlW/eu43bg2+5uZ
|
21
|
+
hZYkPajmyP31OfXXoITEuZBuwShJBvXh3hr4pRJ/WZEwbCzQxV7GnW8nS0+cVv9i
|
22
|
+
HVsUrX/J47s1vZsCVBOaExiAfO2fJv67DR99PzK2fKcvPw5YmLWoBm6yaMNQ361p
|
23
|
+
usLtsag3TqrqIsG8rOY6QZactnoFGtW9bSFqXOqaO4FKbwgCcdTJELte9XX4mMvJ
|
24
|
+
Epal/e/KUDQFTKIB367qZ5lG7I8SvQrI87PkQ0LShHf80/QSpEqcgf2A4zUCAwEA
|
25
|
+
AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU5/XXpoSY
|
26
|
+
0jQsP2JR2vU5b7uMJhYwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
27
|
+
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAj4Dp4hBFi30D7gviksCLr+eMB3XD+YiZ9kbMi3P3
|
29
|
+
WJXH9gkELeKX9kzMRJDgZ3fJNcpAt3dT7pMKNGLfMhzXr4S0K9oNIfmq+5y4eUQ3
|
30
|
+
/eZnDrhLdLN0CfLaT1taKTbnh98wroE44fvW34KOzHEhPx4IL3Bd5jxuztqJRaZW
|
31
|
+
NsUP3kOGU/DUK+0/r96bPELVaXYq8AFuQGK13Z/Cr2tM3uX6bLj+tmKx0zOHRBBf
|
32
|
+
8YSz4LRUsv2LMkhdxyQKXEmIgsu9EE1DPu0Jf6DNOsbm/pFQmJ04V5AIoEixNjeZ
|
33
|
+
/0gRFIHa6KaTLBTDlD56Vp/KxVAKa4lpIgJd8meNWibAl3URscgQTcKOUpKU0YSU
|
34
|
+
+tP3l68P25LjOVqb36q+te45SjB8ATohHZ2kCFc4e5jDB+HX1lwYKqDLTfSd/cuh
|
35
|
+
5C/ULWUz63TixmnPQiXfUV5DTAb+U7xkR+IoF9PZXNzriqakqL6/kvguqZSDiG5K
|
36
|
+
C+3upURGHZLC1bs5uIZirvk+
|
33
37
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
38
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
35
39
|
dependencies:
|
36
40
|
- !ruby/object:Gem::Dependency
|
37
41
|
name: gtk2
|
@@ -39,20 +43,20 @@ dependencies:
|
|
39
43
|
requirements:
|
40
44
|
- - "~>"
|
41
45
|
- !ruby/object:Gem::Version
|
42
|
-
version: '3.
|
46
|
+
version: '3.3'
|
43
47
|
- - ">="
|
44
48
|
- !ruby/object:Gem::Version
|
45
|
-
version: 3.
|
49
|
+
version: 3.3.2
|
46
50
|
type: :runtime
|
47
51
|
prerelease: false
|
48
52
|
version_requirements: !ruby/object:Gem::Requirement
|
49
53
|
requirements:
|
50
54
|
- - "~>"
|
51
55
|
- !ruby/object:Gem::Version
|
52
|
-
version: '3.
|
56
|
+
version: '3.3'
|
53
57
|
- - ">="
|
54
58
|
- !ruby/object:Gem::Version
|
55
|
-
version: 3.
|
59
|
+
version: 3.3.2
|
56
60
|
- !ruby/object:Gem::Dependency
|
57
61
|
name: dom_render
|
58
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,7 +66,7 @@ dependencies:
|
|
62
66
|
version: '0.3'
|
63
67
|
- - ">="
|
64
68
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0.3.
|
69
|
+
version: 0.3.2
|
66
70
|
type: :runtime
|
67
71
|
prerelease: false
|
68
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -72,7 +76,7 @@ dependencies:
|
|
72
76
|
version: '0.3'
|
73
77
|
- - ">="
|
74
78
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.3.
|
79
|
+
version: 0.3.2
|
76
80
|
- !ruby/object:Gem::Dependency
|
77
81
|
name: svgle
|
78
82
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +86,7 @@ dependencies:
|
|
82
86
|
version: '0.4'
|
83
87
|
- - ">="
|
84
88
|
- !ruby/object:Gem::Version
|
85
|
-
version: 0.4.
|
89
|
+
version: 0.4.4
|
86
90
|
type: :runtime
|
87
91
|
prerelease: false
|
88
92
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -92,7 +96,7 @@ dependencies:
|
|
92
96
|
version: '0.4'
|
93
97
|
- - ">="
|
94
98
|
- !ruby/object:Gem::Version
|
95
|
-
version: 0.4.
|
99
|
+
version: 0.4.4
|
96
100
|
description:
|
97
101
|
email: james@jamesrobertson.eu
|
98
102
|
executables: []
|
@@ -119,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
123
|
- !ruby/object:Gem::Version
|
120
124
|
version: '0'
|
121
125
|
requirements: []
|
122
|
-
|
123
|
-
rubygems_version: 2.6.8
|
126
|
+
rubygems_version: 3.0.3
|
124
127
|
signing_key:
|
125
128
|
specification_version: 4
|
126
129
|
summary: Renders SVG using GTK2
|
metadata.gz.sig
CHANGED
Binary file
|