gtk2svg 0.3.5 → 0.3.6
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/gtk2svg.rb +34 -13
- metadata +8 -8
- 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: baf3f4e66c486dd4add79ab6ba11251f89719e2e
|
4
|
+
data.tar.gz: a3e8456c3f352399c71c1042fe1609f4b14893f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e61d1ff7313ef58af73bee4d69a4f770c25150342c677a83dc03092b7faa4c0da2beceafccbd4215f020a77036abe87b1fe11be7bbc5b252880540195559697d
|
7
|
+
data.tar.gz: 480ef78d9cb337c5ffaa21a6179f598ccb7675ee27295bfbb5f4b84490d9167992e9a29a6805b0656650664e4b52f2bfbd759a657fe5effdf9564dae056b003d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/gtk2svg.rb
CHANGED
@@ -164,17 +164,17 @@ module Gtk2SVG
|
|
164
164
|
|
165
165
|
end
|
166
166
|
|
167
|
-
def set_colour(
|
167
|
+
def set_colour(c)
|
168
168
|
|
169
|
-
colour = case
|
169
|
+
colour = case c
|
170
170
|
when /^rgb/
|
171
171
|
regex = /rgb\((\d{1,3}), *(\d{1,3}), *(\d{1,3})\)$/
|
172
|
-
r, g, b =
|
172
|
+
r, g, b = c.match(regex).captures.map {|x| x.to_i * 257}
|
173
173
|
colour = Gdk::Color.new(r, g, b)
|
174
174
|
when /^#/
|
175
|
-
Gdk::Color.parse(
|
175
|
+
Gdk::Color.parse(c)
|
176
176
|
else
|
177
|
-
Gdk::Color.parse(
|
177
|
+
Gdk::Color.parse(c)
|
178
178
|
end
|
179
179
|
|
180
180
|
colormap = Gdk::Colormap.system
|
@@ -199,7 +199,7 @@ module Gtk2SVG
|
|
199
199
|
attr_accessor :doc, :svg
|
200
200
|
attr_reader :width, :height
|
201
201
|
|
202
|
-
def initialize(svg)
|
202
|
+
def initialize(svg, irb: false)
|
203
203
|
|
204
204
|
@svg = svg
|
205
205
|
@doc = Svgle.new(svg, callback: self)
|
@@ -207,14 +207,22 @@ module Gtk2SVG
|
|
207
207
|
client_code = []
|
208
208
|
|
209
209
|
window = Gtk::Window.new
|
210
|
-
width, height = %i(width height).map{|x| @doc.root.attributes[x] }
|
210
|
+
@width, @height = %i(width height).map{|x| @doc.root.attributes[x].to_i }
|
211
211
|
|
212
|
-
if width and height then
|
213
|
-
@width, @height = width.to_i, height.to_i
|
212
|
+
if @width and @height then
|
214
213
|
window.set_default_size(@width, @height)
|
215
214
|
end
|
216
215
|
|
217
216
|
area.signal_connect("expose_event") do
|
217
|
+
|
218
|
+
Thread.new do
|
219
|
+
|
220
|
+
@doc.root.each_recursive do |x|
|
221
|
+
eval x.text.unescape if x.name == 'script'
|
222
|
+
end
|
223
|
+
|
224
|
+
end
|
225
|
+
|
218
226
|
a = Render.new(@doc).to_a
|
219
227
|
drawing = DrawingInstructions.new area
|
220
228
|
drawing.render a
|
@@ -225,21 +233,34 @@ module Gtk2SVG
|
|
225
233
|
area.signal_connect('motion_notify_event') do |item, event|
|
226
234
|
|
227
235
|
@doc.root.each_recursive do |x|
|
228
|
-
|
229
|
-
eval x.text.unescape if x.name == 'script'
|
230
|
-
|
236
|
+
|
231
237
|
if x.attributes[:onmousemove] and x.hotspot? event.x, event.y then
|
232
238
|
#onmousemove(event.x,event.y)
|
233
239
|
eval x.onmousemove()
|
234
240
|
end
|
235
241
|
|
236
242
|
end
|
243
|
+
end
|
244
|
+
|
245
|
+
area.add_events(Gdk::Event::BUTTON_PRESS_MASK)
|
246
|
+
|
247
|
+
area.signal_connect "button_press_event" do |item,event|
|
248
|
+
|
249
|
+
@doc.root.each_recursive do |x|
|
250
|
+
|
251
|
+
if x.attributes[:onmousedown] and x.hotspot? event.x, event.y then
|
252
|
+
|
253
|
+
eval x.onmousedown()
|
254
|
+
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
237
258
|
end
|
238
259
|
|
239
260
|
window.add(area).show_all
|
240
261
|
window.show_all.signal_connect("destroy"){Gtk.main_quit}
|
241
262
|
|
242
|
-
Thread.new {Gtk.main }
|
263
|
+
irb ? Thread.new {Gtk.main } : Gtk.main
|
243
264
|
end
|
244
265
|
|
245
266
|
def onmousemove(x,y)
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -62,7 +62,7 @@ dependencies:
|
|
62
62
|
version: '0.2'
|
63
63
|
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0.2.
|
65
|
+
version: 0.2.1
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -72,27 +72,27 @@ dependencies:
|
|
72
72
|
version: '0.2'
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.2.
|
75
|
+
version: 0.2.1
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: svgle
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
82
|
+
version: '0.2'
|
83
83
|
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 0.1
|
85
|
+
version: 0.2.1
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
90
|
- - "~>"
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: '0.
|
92
|
+
version: '0.2'
|
93
93
|
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: 0.1
|
95
|
+
version: 0.2.1
|
96
96
|
description:
|
97
97
|
email: james@r0bertson.co.uk
|
98
98
|
executables: []
|
@@ -123,5 +123,5 @@ rubyforge_project:
|
|
123
123
|
rubygems_version: 2.4.8
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
|
-
summary:
|
126
|
+
summary: Renders SVG using GTK2
|
127
127
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|