gtk2svg 0.2.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c328f57948ea7c88a00d4435e4ea49fea7bd0359
4
- data.tar.gz: b2e125a43197eb912201b301e824648c921bb328
3
+ metadata.gz: f33931e9f61d6c9e991b3ee225314749df9da2f3
4
+ data.tar.gz: 5286219c0ef5102a35d1924081f76ce14dbc9119
5
5
  SHA512:
6
- metadata.gz: 0f8d8769120799c24f0d8f44ef9ce19f21a6974929f4e4962c1ba307108932630bb6b35968d77dd0a4bf63faf733639488e0fbce225849b1c4656fb8374299f0
7
- data.tar.gz: eaa49e1baa8623bb57e13deef433a4e11aba0db50935f286abf65c99ef4a7301f22d77df872f33feecfb5483af81b05002c8d72b21e68c201d798cfcbbfeaa30
6
+ metadata.gz: 577683577cedfc3c4a092aa0cbaaddcc21c1899001c1dd414832ecc1b428c57fce4bf077b75fa327608efcb23aa49493b9113ac66d0994e7cec535db61696c5c
7
+ data.tar.gz: 01688463c05b3af1bc7b7b04c32346a1ba5d478b1e9930ef61c9e25fc700c2c77fc4698d6bde7e9f1ca953df444e4efc5adebb2b4f3bd28dea8931f942015aa7
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/gtk2svg.rb CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  require 'gtk2'
6
6
  require 'dom_render'
7
+ require 'svgle'
7
8
 
8
9
 
9
10
  # Description: Experimental gem to render SVG within an GTK2 application.
@@ -60,7 +61,7 @@ module Gtk2SVG
60
61
  style = e2.style
61
62
  style[:stroke_width] = style.delete(:'stroke-width') || '3'
62
63
 
63
- x1, y1, x2, y2 = %i(x y x2 y2).map{|x| h[x].to_i }
64
+ x1, y1, x2, y2 = %i(x1 y1 x2 y2).map{|x| h[x].to_i }
64
65
 
65
66
  [:draw_line, [x1, y1, x2, y2], style, render_all(e)]
66
67
  end
@@ -209,20 +210,32 @@ module Gtk2SVG
209
210
 
210
211
  class Main
211
212
 
212
- attr_accessor :svg
213
+ attr_accessor :doc, :svg
214
+ attr_reader :width, :height
213
215
 
214
216
  def initialize(svg)
215
217
 
216
218
  @svg = svg
219
+ @doc = Svgle.new(svg)
217
220
  @area = area = Gtk::DrawingArea.new
218
221
 
222
+ window = Gtk::Window.new
223
+ width, height = %i(width height).map{|x| @doc.root.attributes[x] }
224
+
225
+ if width and height then
226
+ @width, @height = width.to_i, height.to_i
227
+ window.set_default_size(@width, @height)
228
+ end
229
+
219
230
  area.signal_connect("expose_event") do
220
- a = Render.new(@svg).to_a
231
+ a = Render.new(@doc).to_a
221
232
  drawing = DrawingInstructions.new area
222
233
  drawing.render a
223
234
  end
224
235
 
225
- Gtk::Window.new.add(area).show_all
236
+ window.add(area).show_all
237
+ window.show_all.signal_connect("destroy"){Gtk.main_quit}
238
+
226
239
  Thread.new {Gtk.main }
227
240
  end
228
241
 
@@ -230,6 +243,11 @@ module Gtk2SVG
230
243
  @area.queue_draw
231
244
  end
232
245
 
246
+ def svg=(svg)
247
+ @svg = svg
248
+ @doc = Svgle.new(svg)
249
+ end
250
+
233
251
  end
234
252
  end
235
253
 
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.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -73,6 +73,26 @@ dependencies:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.2.0
76
+ - !ruby/object:Gem::Dependency
77
+ name: svgle
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.1'
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 0.1.0
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '0.1'
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 0.1.0
76
96
  description:
77
97
  email: james@r0bertson.co.uk
78
98
  executables: []
metadata.gz.sig CHANGED
Binary file