gtk2svg 0.3.13 → 0.3.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/gtk2svg.rb +75 -11
- data.tar.gz.sig +0 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b8368ad2e5d99ac4c5ae77f7ead08f89fc42314
|
4
|
+
data.tar.gz: a0b4d5f3ecd99a276bbbfe551b0eead008c94840
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f36401546b06f5234a39f62f6e4ca8022a32f3f195a607edd0c751bd56ee00cfedc295be1e0dafc7ac7a1f26a8bd26d92f82cee4d55b891a8957426a58e0eb9
|
7
|
+
data.tar.gz: 06667bdf893efce388aca9bc55b124f4cb09ab09a8b6b15bb21a5ebb012390467aec3256aea8619f3d60c94346be2341e276594877b40d237cf08dd8f403fd19
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/gtk2svg.rb
CHANGED
@@ -9,7 +9,6 @@ require 'svgle'
|
|
9
9
|
# Description: Experimental gem to render SVG within a GTK2 application.
|
10
10
|
|
11
11
|
|
12
|
-
|
13
12
|
module Gtk2SVG
|
14
13
|
|
15
14
|
class Render < DomRender
|
@@ -46,6 +45,17 @@ module Gtk2SVG
|
|
46
45
|
x1, y1, x2, y2 = %i(x1 y1 x2 y2).map{|x| attributes[x].to_i }
|
47
46
|
|
48
47
|
[:draw_line, [x1, y1, x2, y2], style, render_all(e)]
|
48
|
+
end
|
49
|
+
|
50
|
+
def image(e, attributes, raw_style)
|
51
|
+
|
52
|
+
style = style_filter(attributes).merge(raw_style)
|
53
|
+
h = attributes
|
54
|
+
|
55
|
+
x, y, width, height = %i(x y width height).map{|x| h[x] ? h[x].to_i : nil }
|
56
|
+
src = h[:'xlink:href']
|
57
|
+
|
58
|
+
[:draw_image, [x, y, width, height], src, style, render_all(e)]
|
49
59
|
end
|
50
60
|
|
51
61
|
def polygon(e, attributes, raw_style)
|
@@ -119,9 +129,10 @@ module Gtk2SVG
|
|
119
129
|
attr_accessor :area
|
120
130
|
|
121
131
|
|
122
|
-
def initialize(area=nil)
|
132
|
+
def initialize(area=nil, window=nil)
|
123
133
|
|
124
|
-
@area = area
|
134
|
+
@area = area
|
135
|
+
@window = window
|
125
136
|
|
126
137
|
end
|
127
138
|
|
@@ -135,6 +146,25 @@ module Gtk2SVG
|
|
135
146
|
@area.window.draw_arc(gc, 1, x, y, width, height, 0, 64 * 360)
|
136
147
|
end
|
137
148
|
|
149
|
+
def draw_image(args)
|
150
|
+
|
151
|
+
dimensions, src, style = args
|
152
|
+
|
153
|
+
x, y, width, height = dimensions
|
154
|
+
|
155
|
+
gc = gc_ini(fill: style[:fill] || :none)
|
156
|
+
img = GdkPixbuf::Pixbuf.new(file: src)
|
157
|
+
|
158
|
+
x ||= 0
|
159
|
+
y ||= 0
|
160
|
+
width ||= img.width
|
161
|
+
height ||= img.height
|
162
|
+
|
163
|
+
@area.window.draw_pixbuf(gc, img, 0, 0, x, y, width, height,
|
164
|
+
Gdk::RGB::DITHER_NONE, 0, 0)
|
165
|
+
|
166
|
+
end
|
167
|
+
|
138
168
|
def draw_line(args)
|
139
169
|
|
140
170
|
coords, style = args
|
@@ -167,6 +197,7 @@ module Gtk2SVG
|
|
167
197
|
Gdk::GC::CAP_NOT_LAST, Gdk::GC::JOIN_MITER)
|
168
198
|
@area.window.draw_lines(gc, points)
|
169
199
|
end
|
200
|
+
|
170
201
|
|
171
202
|
def draw_rectangle(args)
|
172
203
|
|
@@ -271,8 +302,18 @@ module Gtk2SVG
|
|
271
302
|
|
272
303
|
@svg = svg
|
273
304
|
@doc = Svgle.new(svg, callback: self)
|
274
|
-
|
305
|
+
|
275
306
|
@area = area = Gtk::DrawingArea.new
|
307
|
+
|
308
|
+
doc = @doc
|
309
|
+
|
310
|
+
def @doc.element_by_id(id)
|
311
|
+
self.root.element("//*[@id='#{id}']")
|
312
|
+
end
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
276
317
|
client_code = []
|
277
318
|
|
278
319
|
window = Gtk::Window.new
|
@@ -284,8 +325,13 @@ module Gtk2SVG
|
|
284
325
|
|
285
326
|
@dirty = true
|
286
327
|
|
287
|
-
|
328
|
+
@doc.root.xpath('//script').each {|x| eval x.text.unescape }
|
288
329
|
|
330
|
+
x1 = 150
|
331
|
+
|
332
|
+
area.signal_connect("expose_event") do
|
333
|
+
y1 = 30; x2 = 200; y2 = 70
|
334
|
+
area.window.draw_rectangle(area.style.fg_gc(area.state), 1, x1, y1, x2, y2)
|
289
335
|
if @dirty then
|
290
336
|
|
291
337
|
Thread.new { @doc.root.xpath('//script').each {|x| eval x.text.unescape } }
|
@@ -322,6 +368,20 @@ module Gtk2SVG
|
|
322
368
|
end
|
323
369
|
|
324
370
|
window.add(area).show_all
|
371
|
+
|
372
|
+
Thread.new do
|
373
|
+
@doc.root.xpath('//*[@onload]').each do |x|
|
374
|
+
|
375
|
+
eval x.onload()
|
376
|
+
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
#Thread.new do
|
381
|
+
# 3.times { x1 -= 1; @area.queue_draw; sleep 0.1}
|
382
|
+
#end
|
383
|
+
sleep 0.01
|
384
|
+
#@area.queue_draw; sleep 0.01
|
325
385
|
window.show_all.signal_connect("destroy"){Gtk.main_quit}
|
326
386
|
|
327
387
|
irb ? Thread.new {Gtk.main } : Gtk.main
|
@@ -329,18 +389,22 @@ module Gtk2SVG
|
|
329
389
|
|
330
390
|
def onmousemove(x,y)
|
331
391
|
|
332
|
-
end
|
333
|
-
|
334
|
-
def refresh()
|
335
|
-
@dirty = true
|
336
|
-
@area.queue_draw
|
337
|
-
end
|
392
|
+
end
|
338
393
|
|
339
394
|
def svg=(svg)
|
340
395
|
@svg = svg
|
341
396
|
@doc = Svgle.new(svg, callback: self)
|
342
397
|
end
|
343
398
|
|
399
|
+
def timeout(duration, loopx=true)
|
400
|
+
|
401
|
+
GLib::Timeout.add(duration) do
|
402
|
+
yield
|
403
|
+
loopx
|
404
|
+
end
|
405
|
+
|
406
|
+
end
|
407
|
+
|
344
408
|
end
|
345
409
|
end
|
346
410
|
|
data.tar.gz.sig
CHANGED
Binary file
|
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.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
S+VWAhfVm13yzrA556/5JtfZb/HMd97bm5U2ypMzi+hn2PRRxQ32RY58lYUVpxhE
|
32
32
|
QK5w9QJyQ1G9ag==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
34
|
+
date: 2017-01-26 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: gtk2
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: 0.4.0
|
96
96
|
description:
|
97
|
-
email: james@
|
97
|
+
email: james@jamesrobertson.eu
|
98
98
|
executables: []
|
99
99
|
extensions: []
|
100
100
|
extra_rdoc_files: []
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.8
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Renders SVG using GTK2
|
metadata.gz.sig
CHANGED
Binary file
|