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.
Files changed (6) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/gtk2svg.rb +68 -74
  5. metadata +35 -32
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: aebb344b15aad397ada0ee76af5603b0f2123fcc
4
- data.tar.gz: 4d32b93c7e71541ca69a461e2af590cce620c987
2
+ SHA256:
3
+ metadata.gz: 8b5a118c0868c06925d3a913ddc70520252cf750417619386a0861c15a9b18dc
4
+ data.tar.gz: 767e84933875bebbeaa06ba7e4b46895d5cdcb174b2488d07b1f271feb46f54f
5
5
  SHA512:
6
- metadata.gz: 8a96c8f6ebd2f0365db719ca704bd9668e696664e10f4d92693ddc1da5c457f59df433f69cc47835b6215de016b72e945128db7f52b2782bd023b5e06ec5f930
7
- data.tar.gz: 404061b26b759dab2dc14b8ea692b12414cf5695adc457a470443b5b7f4692f6060e9e9bad0277f22b2c5f1c10e2f441ac87a129e61fc64afba187ce046e7b82
6
+ metadata.gz: 9aff8130ed2d5422e8f4119f2bc813631fe350a7d29daef0778283f23547e0205111f9a0b546ea55832442a96d5ea2bfa370d1896a31180308de620243b882d8
7
+ data.tar.gz: ad7e9921a4be4257cff93f79227cb000480a411759efdfce0495356d8562b8e5a020303f7ca0d176f8bcd3bc4da28095dbd288ac979780f6e1c52e7842c7f0c4
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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, raw_style)
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], style, render_all(e)]
25
+ [:draw_arc, [x, y, radius, radius], attributes, render_all(e)]
27
26
  end
28
27
 
29
- def ellipse(e, attributes, raw_style)
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], style, render_all(e)]
36
+ [:draw_arc, [x, y, width, height], attributes, render_all(e)]
39
37
  end
40
38
 
41
- def line(e, attributes, raw_style)
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], style, render_all(e)]
44
+ [:draw_line, [x1, y1, x2, y2], attributes, render_all(e)]
48
45
  end
49
46
 
50
- def image(e, attributes, raw_style)
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, style, render_all(e)]
54
+ [:draw_image, [x, y, width, height], src, attributes, render_all(e)]
59
55
  end
60
56
 
61
- def polygon(e, attributes, raw_style)
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, style, render_all(e)]
62
+ [:draw_polygon, points, attributes, render_all(e)]
68
63
  end
69
64
 
70
- def polyline(e, attributes, raw_style)
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, style, render_all(e)]
70
+ [:draw_lines, points, attributes, render_all(e)]
77
71
  end
78
72
 
79
- def rect(e, attributes, raw_style)
73
+ def rect(e, attributes)
80
74
 
81
- style = style_filter(attributes).merge(raw_style)
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], style, render_all(e)]
81
+ [:draw_rectangle, [x1, y1, x2, y2], attributes, render_all(e)]
88
82
  end
89
83
 
90
- def script(e, attributes, style)
84
+ def script(e, attributes)
91
85
  [:script]
92
86
  end
93
87
 
94
- def svg(e, attributes, raw_style)
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], style, render_all(e)]
95
+ [:draw_rectangle, [0, 0, width, height], attributes, render_all(e)]
103
96
  end
104
97
 
105
- def text(e, attributes, raw_style)
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, style, render_all(e)]
102
+ [:draw_layout, [x, y], e.text, attributes, render_all(e)]
113
103
  end
114
104
 
115
- private
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
- x ||= 0
159
- y ||= 0
160
- width ||= img.width
161
- height ||= img.height
139
+ if File.exists? src then
140
+ img = GdkPixbuf::Pixbuf.new(file: src)
162
141
 
163
- @area.window.draw_pixbuf(gc, img, 0, 0, x, y, width, height,
164
- Gdk::RGB::DITHER_NONE, 0, 0)
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
- coords, style = args
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
- window = Gtk::Window.new
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
- y1 = 30; x2 = 200; y2 = 70
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
- Thread.new do
373
- @doc.root.xpath('//*[@onload]').each do |x|
374
-
375
- eval x.onload()
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
- sleep 0.01
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.15
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
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE2MTIwNTA5NTAzN1oXDTE3MTIwNTA5NTAzN1owSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAMt/Q8jwR4DPPfNHkKKuSIelyHmzHnD3uiYwXx4UJaAg02izoHoP3slhRY6s
19
- KmiQik/EurFyE3zVz2nm5HcixAz+IoA27NeNxvd+hGNVAggkGDmhuNRxyIiKnQM1
20
- vEDLK8NOHAzjOxgQcFEtCaUD+Byg0WHhVrT95LckFYm/0BwoTzo0DQvGQBuDkOvh
21
- Om09wmX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f6DNOsbm/pFQmJ04V5AIoEixNjeZ
33
+ /0gRFIHa6KaTLBTDlD56Vp/KxVAKa4lpIgJd8meNWibAl3URscgQTcKOUpKU0YSU
34
+ +tP3l68P25LjOVqb36q+te45SjB8ATohHZ2kCFc4e5jDB+HX1lwYKqDLTfSd/cuh
35
+ 5C/ULWUz63TixmnPQiXfUV5DTAb+U7xkR+IoF9PZXNzriqakqL6/kvguqZSDiG5K
36
+ C+3upURGHZLC1bs5uIZirvk+
33
37
  -----END CERTIFICATE-----
34
- date: 2017-01-26 00:00:00.000000000 Z
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.0'
46
+ version: '3.3'
43
47
  - - ">="
44
48
  - !ruby/object:Gem::Version
45
- version: 3.0.7
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.0'
56
+ version: '3.3'
53
57
  - - ">="
54
58
  - !ruby/object:Gem::Version
55
- version: 3.0.7
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.1
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.1
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.0
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.0
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
- rubyforge_project:
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