goocanvas 1.2.5 → 1.2.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.
Files changed (2) hide show
  1. data/sample/units-demo.rb +78 -27
  2. metadata +4 -4
@@ -1,11 +1,35 @@
1
1
  #!/usr/bin/env ruby
2
- require 'goocanvas'
2
+ #
3
+ # This sample code is a port of
4
+ # goocanvas/demo/units-demo.c. It is licensed
5
+ # under the terms of the GNU Library General Public License, version
6
+ # 2 or (at your option) later.
7
+ #
8
+ # Copyright (C) 2013 Ruby-GNOME2 Project Team
9
+ #
10
+ # This library is free software; you can redistribute it and/or
11
+ # modify it under the terms of the GNU Lesser General Public
12
+ # License as published by the Free Software Foundation; either
13
+ # version 2.1 of the License, or (at your option) any later version.
14
+ #
15
+ # This library is distributed in the hope that it will be useful,
16
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
+ # Lesser General Public License for more details.
19
+ #
20
+ # You should have received a copy of the GNU Lesser General Public
21
+ # License along with this library; if not, write to the Free Software
22
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
+
24
+ require 'goocanvas-gi'
25
+
26
+ Goo.init
3
27
 
4
28
  DATA = {
5
- Gtk::PaperSize::UNIT_PIXEL => [ 100, 100, 200, 20, 10, 200, 310, 24 ],
6
- Gtk::PaperSize::UNIT_POINTS => [ 100, 100, 200, 20, 10, 200, 310, 24 ],
7
- Gtk::PaperSize::UNIT_INCH => [ 1, 1, 3, 0.5, 0.16, 3, 4, 0.3 ],
8
- Gtk::PaperSize::UNIT_MM => [ 30, 30, 100, 10, 5, 80, 60, 10 ],
29
+ :pixel => [ 100, 100, 200, 20, 10, 200, 310, 24 ],
30
+ :points => [ 100, 100, 200, 20, 10, 200, 310, 24 ],
31
+ :inch => [ 1, 1, 3, 0.5, 0.16, 3, 4, 0.3 ],
32
+ :mm => [ 30, 30, 100, 10, 5, 80, 60, 10 ],
9
33
  }
10
34
 
11
35
  def setup_canvas(canvas, units, units_name)
@@ -13,40 +37,67 @@ def setup_canvas(canvas, units, units_name)
13
37
 
14
38
  root = canvas.root_item
15
39
 
16
- item = Goo::CanvasRect.new(root, d[0], d[1], d[2], d[3])
17
- item.signal_connect('motion_notify_event') { puts "received 'motion-notify' signal" }
18
-
19
- item = Goo::CanvasText.new(root, "This box is #{d[2]}x#{d[3]} #{units_name}",
20
- d[0] + d[2] / 2.0, d[1] + d[3] / 2.0, -1, Gtk::ANCHOR_CENTER, :font => "Sans #{d[4]}px")
21
-
22
- item = Goo::CanvasText.new(root, "This font is #{d[7]} #{units_name} high",
23
- d[5], d[6], -1, Gtk::ANCHOR_CENTER, :font => "Sans #{d[7]}px")
40
+ item = Goo::CanvasRect.new(:parent => root,
41
+ :x => d[0],
42
+ :y => d[1],
43
+ :width => d[2],
44
+ :height => d[3])
45
+
46
+ item.signal_connect('motion_notify_event') do
47
+ puts("item received 'motion-notify' signal")
48
+ end
49
+
50
+ item = Goo::CanvasText.new(:parent => root,
51
+ :text => "This box is #{d[2]}x#{d[3]} #{units_name}",
52
+ :x => d[0] + d[2] / 2.0,
53
+ :y => d[1] + d[3] / 2.0,
54
+ :width => -1,
55
+ :anchor => :center,
56
+ :font => "Sans #{d[4]}px")
57
+
58
+ item = Goo::CanvasText.new(:parent => root,
59
+ :text => "This font is #{d[7]} #{units_name} high",
60
+ :x => d[5],
61
+ :y => d[6],
62
+ :width => -1,
63
+ :anchor => :center,
64
+ :font => "Sans #{d[7]}px")
24
65
  end
25
66
 
26
67
  def create_canvas(units, units_name)
27
- vbox = Gtk::VBox.new(false, 4)
68
+ vbox = Gtk::Box.new(:vertical, 4)
28
69
  vbox.show
29
70
 
30
- hbox = Gtk::HBox.new(false, 4)
31
- vbox.pack_start(hbox, false, false, 0)
71
+ hbox = Gtk::Box.new(:horizontal, 4)
72
+ vbox.pack_start(hbox, :expand => false,
73
+ :fill => false,
74
+ :padding => 0)
32
75
  hbox.show
33
76
 
34
77
  canvas = Goo::Canvas.new
35
78
 
36
79
  w = Gtk::Label.new('Zoom:')
37
- hbox.pack_start(w, false, false, 0)
80
+ hbox.pack_start(w, :expand => false,
81
+ :fill => false,
82
+ :padding => 0)
38
83
  w.show
39
84
 
40
85
  adj = Gtk::Adjustment.new(1, 0.05, 100, 0.05, 0.5, 0.5)
41
86
  w = Gtk::SpinButton.new(adj, 0, 2)
42
- adj.signal_connect('value_changed') { |new_adj| canvas.scale = new_adj.value }
87
+ adj.signal_connect('value_changed') do |new_adj|
88
+ canvas.scale = new_adj.value
89
+ end
43
90
 
44
91
  w.set_size_request(50, -1)
45
- hbox.pack_start(w, false, false, 0)
92
+ hbox.pack_start(w, :expand => false,
93
+ :fill => false,
94
+ :padding => 0)
46
95
  w.show
47
96
 
48
97
  scrolled_win = Gtk::ScrolledWindow.new
49
- vbox.pack_start(scrolled_win, true, true, 0)
98
+ vbox.pack_start(scrolled_win, :expand => true,
99
+ :fill => true,
100
+ :padding => 0)
50
101
  scrolled_win.show
51
102
 
52
103
  # Create the canvas.
@@ -55,7 +106,7 @@ def create_canvas(units, units_name)
55
106
 
56
107
  canvas.set_bounds(0, 0, 1000, 1000)
57
108
  canvas.units = units
58
- canvas.anchor = Gtk::ANCHOR_CENTER
109
+ canvas.anchor = :center
59
110
  canvas.show
60
111
 
61
112
  scrolled_win.add(canvas)
@@ -63,7 +114,7 @@ def create_canvas(units, units_name)
63
114
  vbox
64
115
  end
65
116
 
66
- window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
117
+ window = Gtk::Window.new(:toplevel)
67
118
  window.set_default_size(640, 600)
68
119
  window.show
69
120
  window.signal_connect('delete_event') { Gtk.main_quit }
@@ -72,9 +123,9 @@ notebook = Gtk::Notebook.new
72
123
  notebook.show
73
124
  window.add(notebook)
74
125
 
75
- notebook.append_page(create_canvas(Gtk::PaperSize::UNIT_PIXEL, 'pixels'), Gtk::Label.new('Pixels'))
76
- notebook.append_page(create_canvas(Gtk::PaperSize::UNIT_POINTS, 'points'), Gtk::Label.new('Points'))
77
- notebook.append_page(create_canvas(Gtk::PaperSize::UNIT_INCH, 'inches'), Gtk::Label.new('Inches'))
78
- notebook.append_page(create_canvas(Gtk::PaperSize::UNIT_MM, 'millimeters'), Gtk::Label.new('Millimeters'))
126
+ notebook.append_page(create_canvas(:pixel, 'pixels'), Gtk::Label.new('Pixels'))
127
+ notebook.append_page(create_canvas(:points, 'points'), Gtk::Label.new('Points'))
128
+ notebook.append_page(create_canvas(:inch, 'inches'), Gtk::Label.new('Inches'))
129
+ notebook.append_page(create_canvas(:mm, 'millimeters'), Gtk::Label.new('Millimeters'))
79
130
 
80
- Gtk.main
131
+ Gtk.main
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goocanvas
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-27 00:00:00.000000000 Z
12
+ date: 2013-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gtk2
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.2.5
21
+ version: 1.2.6
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 1.2.5
29
+ version: 1.2.6
30
30
  description: Ruby/GooCanvas is a Ruby binding of GooCanvas.
31
31
  email: ruby-gnome2-devel-en@lists.sourceforge.net
32
32
  executables: []