goocanvas 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This sample code is a port of
4
+ # goocanvas/demo/demo-focus.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
+ class CanvasSampleFocus < Gtk::Box
25
+ def initialize
26
+ super(:vertical, 4)
27
+ set_border_width(4)
28
+ show
29
+ create_focus_page(self)
30
+ end
31
+
32
+ private
33
+ def create_focus_page(vbox)
34
+ label = Gtk::Label.new(<<-EOT)
35
+ Use Tab, Shift+Tab or the arrow keys to move the keyboard focus between the canvas items.
36
+ EOT
37
+ vbox.pack_start(label, :expand => false,
38
+ :fill => false,
39
+ :padding => 0)
40
+ label.show
41
+
42
+ scrolled_win = Gtk::ScrolledWindow.new
43
+ scrolled_win.shadow_type = :in
44
+ scrolled_win.show
45
+ vbox.pack_start(scrolled_win, :expand => true,
46
+ :fill => true,
47
+ :padding => 0)
48
+
49
+ canvas = Goo::Canvas.new
50
+ canvas.can_focus = true
51
+ canvas.set_size_request(600, 450)
52
+ canvas.set_bounds(0, 0, 1000, 1000)
53
+ canvas.show
54
+ scrolled_win.add(canvas)
55
+
56
+ setup_canvas(canvas)
57
+ end
58
+
59
+ def setup_canvas(canvas)
60
+ create_focus_box(canvas, 109, 80, 50, 30, "red")
61
+ create_focus_box(canvas, 300, 160, 50, 30, "orange")
62
+ create_focus_box(canvas, 500, 50, 50, 30, "yellow")
63
+ create_focus_box(canvas, 70, 400, 50, 30, "blue")
64
+ create_focus_box(canvas, 130, 200, 50, 30, "magenta")
65
+ create_focus_box(canvas, 200, 160, 50, 30, "green")
66
+ create_focus_box(canvas, 450, 450, 50, 30, "cyan")
67
+ create_focus_box(canvas, 300, 350, 50, 30, "grey")
68
+ create_focus_box(canvas, 900, 900, 50, 30, "gold")
69
+ create_focus_box(canvas, 800, 150, 50, 30, "thistle")
70
+ create_focus_box(canvas, 600, 800, 50, 30, "azure")
71
+ create_focus_box(canvas, 700, 250, 50, 30, "moccasin")
72
+ create_focus_box(canvas, 500, 100, 50, 30, "cornsilk")
73
+ create_focus_box(canvas, 200, 750, 50, 30, "plum")
74
+ create_focus_box(canvas, 400, 800, 50, 30, "orchid")
75
+ end
76
+
77
+ def create_focus_box(canvas, x, y, width, height, color)
78
+ root = canvas.root_item
79
+ item = Goo::CanvasRect.new(:parent => root,
80
+ :x => x,
81
+ :y => y,
82
+ :width => width,
83
+ :height => height,
84
+ :stroke_pattern => nil,
85
+ :fill_color => color,
86
+ :line_width => 5.0,
87
+ :can_focus => true)
88
+
89
+ item.signal_connect("focus-in-event") do |widget|
90
+ on_focus_in(widget, color)
91
+ end
92
+ item.signal_connect("focus-out-event") do |widget|
93
+ on_focus_out(widget, color)
94
+ end
95
+
96
+ item.signal_connect("button-press-event") do |widget|
97
+ on_button_press(widget, color)
98
+ end
99
+
100
+ item.signal_connect("key-press-event") do
101
+ on_key_press(color)
102
+ end
103
+ end
104
+
105
+ def on_focus_in (item, color)
106
+ puts "#{color} received focus-in event"
107
+
108
+ # Note that this is only for testing. Setting item properties to indicate
109
+ # focus isn't a good idea for real apps, as there may be multiple views.
110
+ item.stroke_color = "black"
111
+
112
+ false
113
+ end
114
+
115
+ def on_focus_out(item, color)
116
+ puts "#{color} received focus-out event"
117
+
118
+ # Note that this is only for testing. Setting item properties to indicate
119
+ # focus isn't a good idea for real apps, as there may be multiple views.
120
+ item.stroke_pattern = nil
121
+
122
+ false
123
+ end
124
+
125
+ def on_button_press(item, color)
126
+ puts "#{color} received button-press event"
127
+ item.canvas.grab_focus(item)
128
+ false
129
+ end
130
+
131
+ def on_key_press(color)
132
+ puts "#{color} received key-press event"
133
+ false
134
+ end
135
+ end
@@ -20,10 +20,9 @@ Original Copyright:
20
20
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
21
  GNU General Public License for more details.
22
22
 
23
- You should have received a copy of the GNU General Public License
24
- along with this program; if not, write to the Free Software
25
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26
- 02111-1307, USA.
23
+ You should have received a copy of the GNU General Public License along
24
+ with this program; if not, write to the Free Software Foundation, Inc.,
25
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27
26
 
28
27
  =end
29
28
  class CanvasSamplePrimitives < Gtk::VBox
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env ruby
1
2
  # -*- indent-tabs-mode: nil -*-
2
3
  =begin header
3
4
 
@@ -21,10 +22,9 @@ Original Copyright:
21
22
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
23
  GNU General Public License for more details.
23
24
 
24
- You should have received a copy of the GNU General Public License
25
- along with this program; if not, write to the Free Software
26
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27
- 02111-1307, USA.
25
+ You should have received a copy of the GNU General Public License along
26
+ with this program; if not, write to the Free Software Foundation, Inc.,
27
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28
28
 
29
29
  =end
30
30
 
@@ -40,10 +40,14 @@ require 'goocanvas'
40
40
  require 'demo-primitives'
41
41
  require 'demo-arrowhead'
42
42
  require 'demo-fifteen'
43
+ require 'demo-features'
44
+ require 'demo-events'
45
+ require 'demo-focus'
46
+ require 'demo-animation'
43
47
 
44
48
  class GooCanvasSample < Gtk::Window
45
49
  def initialize
46
- super(Gtk::Window::TOPLEVEL)
50
+ super(:toplevel)
47
51
 
48
52
  signal_connect("destroy") do |widget, event|
49
53
  Gtk::main_quit()
@@ -69,8 +73,14 @@ class GooCanvasSample < Gtk::Window
69
73
  Gtk::Label.new("Arrowhead"))
70
74
  notebook.append_page(CanvasSampleFifteen.new,
71
75
  Gtk::Label.new("Fifteen"))
72
- # notebook.append_page(CanvasSampleFeatures.new,
73
- # Gtk::Label.new("Feature"))
76
+ notebook.append_page(CanvasSampleFeatures.new,
77
+ Gtk::Label.new("Reparent"))
78
+ notebook.append_page(CanvasSampleEvents.new,
79
+ Gtk::Label.new("Events"))
80
+ notebook.append_page(CanvasSampleFocus.new,
81
+ Gtk::Label.new("Focus"))
82
+ notebook.append_page(CanvasSampleAnimation.new,
83
+ Gtk::Label.new("Animation"))
74
84
  # notebook.append_page(CanvasSampleRichText.new,
75
85
  # Gtk::Label.new("Rich Text"))
76
86
  # notebook.append_page(CanvasSampleBezierCurve.new,
metadata CHANGED
@@ -1,32 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goocanvas
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
5
- prerelease:
4
+ version: 2.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - The Ruby-GNOME2 Project Team
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-26 00:00:00.000000000 Z
11
+ date: 2013-12-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: gtk2
14
+ name: gtk3
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - '='
20
18
  - !ruby/object:Gem::Version
21
- version: 2.0.2
19
+ version: 2.0.3
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - '='
28
25
  - !ruby/object:Gem::Version
29
- version: 2.0.2
26
+ version: 2.0.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: gobject-introspection
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.3
30
41
  description: Ruby/GooCanvas is a Ruby binding of GooCanvas.
31
42
  email: ruby-gnome2-devel-en@lists.sourceforge.net
32
43
  executables: []
@@ -44,8 +55,12 @@ files:
44
55
  - ext/goocanvas/goocanvas.def
45
56
  - ext/goocanvas/rbgoocanvas.c
46
57
  - ext/goocanvas/rbgoocanvas.h
58
+ - sample/demo-animation.rb
47
59
  - sample/demo-arrowhead.rb
60
+ - sample/demo-events.rb
61
+ - sample/demo-features.rb
48
62
  - sample/demo-fifteen.rb
63
+ - sample/demo-focus.rb
49
64
  - sample/demo-primitives.rb
50
65
  - sample/demo.rb
51
66
  - sample/flower.png
@@ -57,26 +72,25 @@ files:
57
72
  - sample/widgets-demo.rb
58
73
  homepage: http://ruby-gnome2.sourceforge.jp/
59
74
  licenses: []
75
+ metadata: {}
60
76
  post_install_message:
61
77
  rdoc_options: []
62
78
  require_paths:
63
79
  - lib
64
80
  required_ruby_version: !ruby/object:Gem::Requirement
65
- none: false
66
81
  requirements:
67
- - - ! '>='
82
+ - - '>='
68
83
  - !ruby/object:Gem::Version
69
- version: 1.8.5
84
+ version: 1.9.3
70
85
  required_rubygems_version: !ruby/object:Gem::Requirement
71
- none: false
72
86
  requirements:
73
- - - ! '>='
87
+ - - '>='
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0'
76
90
  requirements: []
77
91
  rubyforge_project:
78
- rubygems_version: 1.8.23
92
+ rubygems_version: 2.0.14
79
93
  signing_key:
80
- specification_version: 3
94
+ specification_version: 4
81
95
  summary: Ruby/GooCanvas is a Ruby binding of GooCanvas.
82
96
  test_files: []