clutter-gtk 2.2.4-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +75 -0
  3. data/lib/clutter-gtk.rb +77 -0
  4. data/sample/events.rb +176 -0
  5. data/sample/multistage.rb +78 -0
  6. data/sample/redhand.png +0 -0
  7. data/sample/test-actor.rb +163 -0
  8. data/sample/test-scroll.rb +174 -0
  9. data/sample/test.rb +169 -0
  10. data/sample/window-test.rb +113 -0
  11. data/sample/window-test2.rb +132 -0
  12. data/test/clutter-gtk-test-utils.rb +21 -0
  13. data/test/run-test.rb +73 -0
  14. data/test/test-clutter-gtk-embed.rb +21 -0
  15. data/vendor/local/bin/libclutter-gtk-1.0-0.dll +0 -0
  16. data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/clutter-gtk.h +17 -0
  17. data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/gtk-clutter-actor.h +87 -0
  18. data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/gtk-clutter-embed.h +94 -0
  19. data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/gtk-clutter-texture.h +115 -0
  20. data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/gtk-clutter-util.h +46 -0
  21. data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/gtk-clutter-version.h +111 -0
  22. data/vendor/local/include/clutter-gtk-1.0/clutter-gtk/gtk-clutter-window.h +90 -0
  23. data/vendor/local/lib/girepository-1.0/GtkClutter-1.0.typelib +0 -0
  24. data/vendor/local/lib/libclutter-gtk-1.0.dll.a +0 -0
  25. data/vendor/local/lib/libclutter-gtk-1.0.la +41 -0
  26. data/vendor/local/lib/pkgconfig/clutter-gtk-1.0.pc +13 -0
  27. data/vendor/local/share/gir-1.0/GtkClutter-1.0.gir +696 -0
  28. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/GtkClutterActor.html +307 -0
  29. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/GtkClutterEmbed.html +305 -0
  30. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/GtkClutterWindow.html +179 -0
  31. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/annotation-glossary.html +48 -0
  32. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ch01.html +36 -0
  33. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ch02.html +42 -0
  34. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ch03.html +34 -0
  35. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/clutter-gtk-1.0-Utility-Functions.html +258 -0
  36. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/clutter-gtk-1.0.devhelp2 +50 -0
  37. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/cluttergtk-glossary.html +35 -0
  38. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/cluttergtk-object-hierarchy.html +45 -0
  39. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/cluttergtk-object-index.html +60 -0
  40. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/cluttergtk-objects.html +38 -0
  41. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/home.png +0 -0
  42. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/index.html +83 -0
  43. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/index.sgml +60 -0
  44. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ix01.html +100 -0
  45. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ix02.html +198 -0
  46. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ix03.html +66 -0
  47. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/ix04.html +32 -0
  48. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/left-insensitive.png +0 -0
  49. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/left.png +0 -0
  50. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/license.html +59 -0
  51. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/right-insensitive.png +0 -0
  52. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/right.png +0 -0
  53. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/style.css +476 -0
  54. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/up-insensitive.png +0 -0
  55. data/vendor/local/share/gtk-doc/html/clutter-gtk-1.0/up.png +0 -0
  56. data/vendor/local/share/license/clutter-gtk/COPYING +504 -0
  57. data/vendor/local/share/locale/ja/LC_MESSAGES/cluttergtk-1.0.mo +0 -0
  58. data/vendor/local/share/locale/pl/LC_MESSAGES/cluttergtk-1.0.mo +0 -0
  59. data/vendor/local/share/locale/zh_CN/LC_MESSAGES/cluttergtk-1.0.mo +0 -0
  60. metadata +143 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 080fe6ef1e678ec04ecc3bca95279bcb7eae3387
4
+ data.tar.gz: 6e86f37e8c8e14f98dcb3ab00cbef0fdc09b7785
5
+ SHA512:
6
+ metadata.gz: 5a90d7c4ebccd9a4dbea8c34a4d474414a5547b802201d36bfba828131052c3dba1135a684ee0e214343c6e69d77306bbb1e8ad503703b6da9d35f84e009789e
7
+ data.tar.gz: 04cd81f03deb7a302a312b672ecad4dd719cd3f857c48f47494442e69d7afcf24beb126a9efa64246cf1aa834d945555bd1c492734a7286e08e26f6e2f2fde57
data/Rakefile ADDED
@@ -0,0 +1,75 @@
1
+ # -*- ruby -*-
2
+ #
3
+ # Copyright (C) 2013-2014 Ruby-GNOME2 Project Team
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ $LOAD_PATH.unshift("./../glib2/lib")
20
+ require "gnome2/rake/package-task"
21
+
22
+ package_task = GNOME2::Rake::PackageTask.new do |package|
23
+ package.summary = "Ruby/ClutterGTK is a Ruby binding of Clutter-GTK."
24
+ package.description = "Ruby/ClutterGTK is a Ruby binding of Clutter-GTK."
25
+ package.dependency.gem.runtime = ["clutter", "gtk3"]
26
+ package.dependency.gem.development = ["test-unit-notify"]
27
+ package.windows.packages = []
28
+ package.windows.dependencies = []
29
+ package.windows.build_dependencies = [
30
+ "glib2",
31
+ "atk",
32
+ "pango",
33
+ "gdk_pixbuf2",
34
+ "gobject-introspection",
35
+ "clutter",
36
+ "gdk3",
37
+ ]
38
+ package.windows.gobject_introspection_dependencies = [
39
+ "atk",
40
+ "pango",
41
+ "gdk_pixbuf2",
42
+ "clutter",
43
+ "gdk3",
44
+ ]
45
+ package.external_packages = [
46
+ {
47
+ :name => "clutter-gtk",
48
+ :download_site => :gnome,
49
+ :label => "Clutter-GTK",
50
+ :version => "1.6.0",
51
+ :compression_method => "xz",
52
+ :windows => {
53
+ :configure_args => [
54
+ "--enable-introspection",
55
+ ],
56
+ :patches => [
57
+ "0001-actor-fix-clutter-win32.h-include-path.patch",
58
+ "0001-Use-no-undefined-ld-flag.patch",
59
+ ],
60
+ :need_autoreconf => true,
61
+ :built_file => "bin/libclutter-gtk-1.0-0.dll",
62
+ },
63
+ }
64
+ ]
65
+ end
66
+ package_task.define
67
+
68
+ namespace :dependency do
69
+ desc "Install depenencies"
70
+ task :install do
71
+ # TODO: Install gir1.2-gtkclutter-1.0 on Debian.
72
+ end
73
+ end
74
+
75
+ task :build => "dependency:install"
@@ -0,0 +1,77 @@
1
+ # Copyright (C) 2013-2014 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ require "clutter"
18
+ require "gtk3"
19
+
20
+ base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path
21
+ vendor_dir = base_dir + "vendor" + "local"
22
+ vendor_bin_dir = vendor_dir + "bin"
23
+ GLib.prepend_dll_path(vendor_bin_dir)
24
+ vendor_girepository_dir = vendor_dir + "lib" + "girepository-1.0"
25
+ GObjectIntrospection.prepend_typelib_path(vendor_girepository_dir)
26
+
27
+ module ClutterGtk
28
+ LOG_DOMAIN = "Clutter-Gtk"
29
+ GLib::Log.set_log_domain(LOG_DOMAIN)
30
+
31
+ class << self
32
+ def const_missing(name)
33
+ init()
34
+ if const_defined?(name)
35
+ const_get(name)
36
+ else
37
+ super
38
+ end
39
+ end
40
+
41
+ def init(argv=[])
42
+ class << self
43
+ remove_method(:init)
44
+ remove_method(:const_missing)
45
+ end
46
+ loader = Loader.new(self, argv)
47
+ loader.load("GtkClutter")
48
+ Clutter.init(argv) if Clutter.respond_to?(:init)
49
+ end
50
+ end
51
+
52
+ class Loader < GObjectIntrospection::Loader
53
+ class InitError < StandardError
54
+ end
55
+
56
+ def initialize(base_module, init_arguments)
57
+ super(base_module)
58
+ @init_arguments = init_arguments
59
+ end
60
+
61
+ private
62
+ def pre_load(repository, namespace)
63
+ init = repository.find(namespace, "init")
64
+ arguments = [
65
+ [$0] + @init_arguments,
66
+ ]
67
+ error, returned_arguments = init.invoke(:arguments => arguments)
68
+ @init_arguments.replace(returned_arguments[1..-1])
69
+ if error.to_i <= 0
70
+ raise InitError, "failed to initialize Clutter-GTK: #{error.name}"
71
+ end
72
+ end
73
+
74
+ def post_load(repository, namespace)
75
+ end
76
+ end
77
+ end
data/sample/events.rb ADDED
@@ -0,0 +1,176 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This sample code is a port of
4
+ # clutter-gtk/examples/gtk-clutter-events.c. The image file used in
5
+ # this sample code is copied from
6
+ # clutter-gtk/examples/redhand.png. They are licensed under the terms
7
+ # of the GNU Lesser General Public License, version 2.1 or (at your
8
+ # option) later.
9
+ #
10
+ # Copyright (C) 2013 Ruby-GNOME2 Project Team
11
+ #
12
+ # This library is free software; you can redistribute it and/or
13
+ # modify it under the terms of the GNU Lesser General Public
14
+ # License as published by the Free Software Foundation; either
15
+ # version 2.1 of the License, or (at your option) any later version.
16
+ #
17
+ # This library is distributed in the hope that it will be useful,
18
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
+ # Lesser General Public License for more details.
21
+ #
22
+ # You should have received a copy of the GNU Lesser General Public
23
+ # License along with this library; if not, write to the Free Software
24
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25
+
26
+ require "clutter-gtk"
27
+ require "gdk_pixbuf2"
28
+
29
+ window = Gtk::Window.new
30
+ window.title = "Gtk-Clutter Interaction demo"
31
+ window.set_default_size(800, 600)
32
+ window.resizable = false
33
+ window.border_width = 12
34
+ window.signal_connect("destroy") do
35
+ Gtk.main_quit
36
+ end
37
+
38
+ vbox = Gtk::Box.new(:vertical, 12)
39
+ window.add(vbox)
40
+
41
+ clutter_entry = nil
42
+ gtk_entry = Gtk::Entry.new
43
+ gtk_entry.text = "Enter some text"
44
+ vbox.pack_start(gtk_entry, :expand => false, :fill => false, :padding => 0)
45
+ gtk_entry.signal_connect("changed") do |editable|
46
+ clutter_entry.text = editable.text
47
+ end
48
+
49
+ hbox = Gtk::Box.new(:horizontal, 12)
50
+ vbox.pack_start(hbox, :expand => true, :fill => true, :padding => 0)
51
+
52
+ # Set up clutter & create our stage
53
+ clutter_embed = ClutterGtk::Embed.new
54
+ hbox.pack_start(clutter_embed, :expand => true, :fill => true, :padding => 0)
55
+ clutter_embed.grab_focus
56
+ stage = clutter_embed.stage
57
+ clutter_embed.set_size_request(640, 480)
58
+ stage.signal_connect("captured-event") do |_stage, event|
59
+ case event
60
+ when Clutter::ButtonEvent
61
+ puts("#{event.type.nick} captured at (#{event.x}, #{event.y})");
62
+ when Clutter::CrossingEvent
63
+ if event.source == _stage and not event.related.nil?
64
+ if event.type == Clutter::EventType::ENTER
65
+ stage_action = "Entering"
66
+ actor_action = "leaving"
67
+ else
68
+ stage_action = "Leaving"
69
+ actor_action = "entering"
70
+ end
71
+ puts("#{stage_action} the stage and #{actor_action} '#{event.related.name}'")
72
+ end
73
+ when Clutter::KeyEvent
74
+ if event.type == Clutter::EventType::KEY_PRESS
75
+ format = "the stage got a key press: '%s' (symbol: %d, unicode: 0x%x)"
76
+ unicode = [event.key_unicode].pack("U")
77
+ puts(format % [unicode, event.key_symbol, event.key_unicode])
78
+ end
79
+ end
80
+
81
+ not Clutter::Event::STOP
82
+ end
83
+
84
+ clutter_embed.signal_connect("enter-notify-event") do |widget|
85
+ puts("Entering widget '#{widget.class.name}'")
86
+ false
87
+ end
88
+ clutter_embed.signal_connect("leave-notify-event") do |widget|
89
+ puts("Leaving widget '#{widget.class.name}'")
90
+ end
91
+
92
+ # Create the main texture that the spin buttons manipulate
93
+ pixbuf = Gdk::Pixbuf.new(File.expand_path("redhand.png", File.dirname(__FILE__)));
94
+ hand = ClutterGtk::Texture.new
95
+ hand.from_pixbuf = pixbuf
96
+ stage.add_child(hand)
97
+ hand.anchor_point_from_gravity = :center
98
+ hand.set_position(stage.width / 2, stage.height / 2)
99
+ hand.reactive = true
100
+ hand.name = "Red Hand"
101
+ hand.signal_connect("button-press-event") do |actor, event|
102
+ puts("Button press on hand ('#{actor.class.name}')")
103
+ not Clutter::Event::STOP
104
+ end
105
+
106
+ # Setup the clutter entry
107
+ clutter_entry = Clutter::Text.new
108
+ clutter_entry.color = Clutter::Color.new(:black)
109
+ stage.add_child(clutter_entry)
110
+ clutter_entry.set_position(0, 0)
111
+ clutter_entry.set_size(500, 20)
112
+
113
+ # Create our adjustment widgets
114
+ vbox = Gtk::Box.new(:vertical, 6)
115
+ hbox.pack_start(vbox, :expand => false, :fill => false, :padding => 0)
116
+
117
+ box = Gtk::Box.new(:horizontal, 6)
118
+ vbox.pack_start(box, :expand => false, :fill => true, :padding => 0)
119
+ label = Gtk::Label.new("Rotate x-axis")
120
+ box.pack_start(label, :expand => true, :fill => true, :padding => 0)
121
+ button = Gtk::SpinButton.new(0, 360, 1)
122
+ box.pack_start(button, :expand => true, :fill => true, :padding => 0)
123
+ button.signal_connect("value-changed") do |_button|
124
+ hand.set_rotation(:x_axis,
125
+ _button.value,
126
+ 0,
127
+ hand.height / 2,
128
+ 0)
129
+ end
130
+
131
+ box = Gtk::Box.new(:horizontal, 6)
132
+ vbox.pack_start(box, :expand => false, :fill => true, :padding => 0)
133
+ label = Gtk::Label.new("Rotate y-axis")
134
+ box.pack_start(label, :expand => true, :fill => true, :padding => 0)
135
+ button = Gtk::SpinButton.new(0, 360, 1)
136
+ box.pack_start(button, :expand => true, :fill => true, :padding => 0)
137
+ button.signal_connect("value-changed") do |_button|
138
+ hand.set_rotation(:y_axis,
139
+ _button.value,
140
+ hand.width / 2,
141
+ 0,
142
+ 0)
143
+ end
144
+
145
+ box = Gtk::Box.new(:horizontal, 6)
146
+ vbox.pack_start(box, :expand => false, :fill => true, :padding => 0)
147
+ label = Gtk::Label.new("Rotate z-axis")
148
+ box.pack_start(label, :expand => true, :fill => true, :padding => 0)
149
+ button = Gtk::SpinButton.new(0, 360, 1)
150
+ box.pack_start(button, :expand => true, :fill => true, :padding => 0)
151
+ button.signal_connect("value-changed") do |_button|
152
+ hand.set_rotation(:z_axis,
153
+ _button.value,
154
+ hand.width / 2,
155
+ hand.height / 2,
156
+ 0)
157
+ end
158
+
159
+ box = Gtk::Box.new(:horizontal, 6)
160
+ vbox.pack_start(box, :expand => false, :fill => true, :padding => 0)
161
+ label = Gtk::Label.new("Adjust opacity")
162
+ box.pack_start(label, :expand => true, :fill => true, :padding => 0)
163
+ button = Gtk::SpinButton.new(0, 255, 1)
164
+ button.value = 255
165
+ box.pack_start(button, :expand => true, :fill => true, :padding => 0)
166
+ button.signal_connect("value-changed") do |_button|
167
+ hand.opacity = _button.value
168
+ end
169
+
170
+ window.show_all
171
+
172
+ # Only show/show_all the stage after parent show. widget_show will call
173
+ # show on the stage.
174
+ stage.show
175
+
176
+ Gtk.main
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This sample code is a port of clutter-gtk/examples/gtk-clutter-multistage.c.
4
+ # It is licensed under the terms of the GNU Lesser General Public
5
+ # License, version 2.1 or (at your option) later.
6
+ #
7
+ # Copyright (C) 2013 Ruby-GNOME2 Project Team
8
+ #
9
+ # This library is free software; you can redistribute it and/or
10
+ # modify it under the terms of the GNU Lesser General Public
11
+ # License as published by the Free Software Foundation; either
12
+ # version 2.1 of the License, or (at your option) any later version.
13
+ #
14
+ # This library is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ # Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public
20
+ # License along with this library; if not, write to the Free Software
21
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
+
23
+ require "clutter-gtk"
24
+ require "gdk_pixbuf2"
25
+
26
+ window = Gtk::Window.new
27
+ window.set_default_size(600, 400)
28
+ window.title = "Multiple GtkClutterEmbed"
29
+ window.signal_connect("destroy") do
30
+ Gtk.main_quit
31
+ end
32
+
33
+ notebook = Gtk::Notebook.new
34
+ window.add(notebook)
35
+
36
+ clutter0 = ClutterGtk::Embed.new
37
+ notebook.append_page(clutter0, Gtk::Label.new("One stage"))
38
+ stage0 = clutter0.stage
39
+ stage0.background_color = Clutter::Color.new(0xdd, 0xff, 0xdd, 0xff)
40
+
41
+ vbox = Gtk::Box.new(:vertical, 6)
42
+ notebook.append_page(vbox, Gtk::Label.new("Two stages"))
43
+
44
+ clutter1 = ClutterGtk::Embed.new
45
+ clutter1.set_size_request(320, 240)
46
+ stage1 = clutter1.stage
47
+ stage1.background_color = Clutter::Color.new(0xff, 0xff, 0xff, 0xff)
48
+ texture1 = ClutterGtk::Texture.new
49
+ texture1.set_from_stock(clutter1, Gtk::Stock::DIALOG_INFO.to_s, :dialog)
50
+ texture1.set_anchor_point(texture1.width / 2,
51
+ texture1.height / 2)
52
+ texture1.set_position(160, 120)
53
+ stage1.add_child(texture1)
54
+ texture1.show
55
+
56
+ vbox.add(clutter1)
57
+
58
+ clutter2 = ClutterGtk::Embed.new
59
+ clutter2.set_size_request(320, 120)
60
+ stage2 = clutter2.stage
61
+ stage2.background_color = Clutter::Color.new(0x00, 0x00, 0x00, 0xff)
62
+ texture2 = ClutterGtk::Texture.new
63
+ texture2.set_from_icon_name(clutter1, "user-info", :button)
64
+ texture2.set_anchor_point(texture2.width / 2,
65
+ texture2.height / 2)
66
+ texture2.set_position(160, 60)
67
+ stage2.add_child(texture2)
68
+
69
+ vbox.add(clutter2)
70
+
71
+ stage2.signal_connect("allocation-changed") do |actor, allocation, flags|
72
+ texture2.set_position((allocation.x2 - allocation.x1) / 2,
73
+ (allocation.y2 - allocation.y1) / 2)
74
+ end
75
+
76
+ window.show_all
77
+
78
+ Gtk.main
Binary file
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This sample code is a port of clutter-gtk/examples/gtk-clutter-test-actor.c.
4
+ # It is licensed under the terms of the GNU Lesser General Public
5
+ # License, version 2.1 or (at your option) later.
6
+ #
7
+ # Copyright (C) 2013 Ruby-GNOME2 Project Team
8
+ #
9
+ # This library is free software; you can redistribute it and/or
10
+ # modify it under the terms of the GNU Lesser General Public
11
+ # License as published by the Free Software Foundation; either
12
+ # version 2.1 of the License, or (at your option) any later version.
13
+ #
14
+ # This library is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ # Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public
20
+ # License along with this library; if not, write to the Free Software
21
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
+
23
+ require "clutter-gtk"
24
+
25
+ MAX_N_WIDGETS = 4
26
+ WINDOW_WIDTH = 400
27
+ WINDOW_HEIGHT = 400
28
+ RADIUS = 80
29
+
30
+ do_rotate_p = true
31
+
32
+ window = Gtk::Window.new
33
+ window.signal_connect("destroy") do
34
+ Gtk.main_quit
35
+ end
36
+
37
+ vbox = Gtk::Box.new(:vertical, 6)
38
+ window.add(vbox)
39
+
40
+ clutter = ClutterGtk::Embed.new
41
+ clutter.set_size_request(WINDOW_WIDTH, WINDOW_HEIGHT)
42
+
43
+ vbox.pack_start(clutter, :expand => true, :fill => true, :padding => 0)
44
+
45
+ stage = clutter.stage
46
+
47
+ button = Gtk::Button.new(:stock_id => Gtk::Stock::QUIT)
48
+ button.signal_connect("clicked") do |_button|
49
+ window.destroy
50
+ end
51
+ vbox.pack_end(button, :expand => false, :fill => false, :padding => 0)
52
+
53
+ stage.background_color = Clutter::Color.new(0x61, 0x64, 0x8c, 0xff)
54
+
55
+ widgets = []
56
+
57
+ # create a new group to hold multiple actors in a group
58
+ group = Clutter::Actor.new
59
+
60
+ create_gtk_actor = lambda do
61
+ gtk_actor = ClutterGtk::Actor.new
62
+ bin = gtk_actor.widget
63
+
64
+ vbox = Gtk::Box.new(:vertical, 6)
65
+ bin.add(vbox)
66
+
67
+ button = Gtk::Button.new(:label => "A Button")
68
+ vbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
69
+
70
+ button.signal_connect("clicked") do |_button|
71
+ puts("button clicked")
72
+ label = Gtk::Label.new("A new label")
73
+ label.show
74
+ vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
75
+ end
76
+
77
+ button = Gtk::CheckButton.new("Another button")
78
+ vbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
79
+
80
+ entry = Gtk::Entry.new
81
+ vbox.pack_start(entry, :expand => false, :fill => false, :padding => 0)
82
+
83
+ bin.show_all
84
+
85
+ gtk_actor
86
+ end
87
+
88
+ add_clutter_actor = lambda do |actor, container, i|
89
+ container.add_child(actor)
90
+
91
+ # Place around a circle
92
+ w = widgets.first.width
93
+ h = widgets.first.height
94
+
95
+ x = WINDOW_WIDTH / 2 +
96
+ RADIUS * Math.cos(i * 2 * Math::PI / (MAX_N_WIDGETS)) - w / 2
97
+ y = WINDOW_HEIGHT / 2 +
98
+ RADIUS * Math.sin(i * 2 * Math::PI / (MAX_N_WIDGETS)) - h / 2
99
+
100
+ actor.set_position(x, y)
101
+ end
102
+
103
+ MAX_N_WIDGETS.times do |i|
104
+ widget = create_gtk_actor.call
105
+ widgets[i] = widget
106
+ add_clutter_actor.call(widget, group, i)
107
+ end
108
+
109
+ # Add the group to the stage and center it
110
+ stage.add_child(group)
111
+ group.add_constraint(Clutter::AlignConstraint.new(stage, :x_axis, 0.5))
112
+ group.add_constraint(Clutter::AlignConstraint.new(stage, :y_axis, 0.5))
113
+
114
+ window.show_all
115
+
116
+ # Create a timeline to manage animation
117
+ timeline = Clutter::Timeline.new(6000)
118
+ timeline.repeat_count = -1
119
+
120
+ # fire a callback for frame change
121
+ timeline.signal_connect("new-frame") do |_timeline, m_secs|
122
+ rotation = _timeline.progress * 360.0
123
+ if do_rotate_p
124
+ # Rotate everything clockwise about stage center
125
+ group.set_rotation(:z_axis,
126
+ rotation,
127
+ WINDOW_WIDTH / 2,
128
+ WINDOW_HEIGHT / 2,
129
+ 0)
130
+
131
+ widgets.each do |widget|
132
+ # rotate each widget around its center
133
+ w = widget.width
134
+ h = widget.height
135
+
136
+ widget.set_rotation(:z_axis,
137
+ -(2 * rotation),
138
+ w / 2,
139
+ h / 2,
140
+ 0)
141
+ widget.opacity = 50 * Math.sin(2 * Math::PI * rotation / 360) + (255 - 50)
142
+ end
143
+ end
144
+ end
145
+
146
+ # and start it
147
+ timeline.start
148
+
149
+ GLib::Timeout.add_seconds(3) do
150
+ if MAX_N_WIDGETS == widgets.size
151
+ # Removing an item
152
+ group.remove_child(widgets.pop)
153
+ else
154
+ # Adding an item
155
+ widget = create_gtk_actor.call
156
+ widgets << widget
157
+ add_clutter_actor.call(widget, group, MAX_N_WIDGETS - 1)
158
+ end
159
+ keep_callback = true
160
+ keep_callback
161
+ end
162
+
163
+ Gtk.main