clutter 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ # -*- ruby -*-
2
+ #
3
+ # Copyright (C) 2012 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-raketask"
21
+
22
+ package = GNOME2Package.new do |_package|
23
+ _package.summary = "Ruby/Clutter is a Ruby binding of Clutter."
24
+ _package.description = "Ruby/Clutter is a Ruby binding of Clutter."
25
+ _package.dependency.gem.runtime = ["cairo-gobject", "gobject-introspection"]
26
+ _package.dependency.gem.development = ["test-unit-notify"]
27
+ _package.win32.packages = []
28
+ _package.win32.dependencies = []
29
+ _package.win32.build_dependencies = ["glib2", "gobject-introspection"]
30
+ _package.win32.build_packages = []
31
+ end
32
+ package.define_tasks
33
+
34
+ namespace :dependency do
35
+ desc "Install depenencies"
36
+ task :install do
37
+ # TODO: Install gir1.2-clutter-1.0 on Debian.
38
+ end
39
+ end
40
+
41
+ task :build => "dependency:install"
data/lib/clutter.rb ADDED
@@ -0,0 +1,135 @@
1
+ # Copyright (C) 2012-2013 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 "gobject-introspection"
18
+ require "cairo-gobject"
19
+
20
+ base_dir = Pathname.new(__FILE__).dirname.dirname.dirname.expand_path
21
+ vendor_dir = base_dir + "vendor" + "local"
22
+ vendor_bin_dir = vendor_dir + "bin"
23
+ GLib.prepend_environment_path(vendor_bin_dir)
24
+
25
+ module Clutter
26
+ LOG_DOMAIN = "Clutter"
27
+ GLib::Log.set_log_domain(LOG_DOMAIN)
28
+
29
+ class << self
30
+ @initialized = false
31
+ def init(argv=ARGV)
32
+ return if @initialized
33
+ @initialized = true
34
+ loader = Loader.new(self, argv)
35
+ loader.load("Clutter")
36
+ require "clutter/actor"
37
+ require "clutter/actor-iter"
38
+ require "clutter/animatable"
39
+ require "clutter/cairo"
40
+ require "clutter/color"
41
+ require "clutter/event"
42
+ require "clutter/point"
43
+ require "clutter/text"
44
+ require "clutter/threads"
45
+ end
46
+ end
47
+
48
+ class Loader < GObjectIntrospection::Loader
49
+ class InitError < StandardError
50
+ end
51
+
52
+ def initialize(base_module, init_arguments)
53
+ super(base_module)
54
+ @init_arguments = init_arguments
55
+ @key_constants = {}
56
+ @other_constant_infos = []
57
+ @event_infos = []
58
+ end
59
+
60
+ private
61
+ def pre_load(repository, namespace)
62
+ init = repository.find(namespace, "init")
63
+ error, argc, argv = init.invoke(1 + @init_arguments.size,
64
+ [$0] + @init_arguments)
65
+ @init_arguments.replace(argv)
66
+ if error.to_i <= 0
67
+ raise InitError, "failed to initialize Clutter: #{error.name}"
68
+ end
69
+ @keys_module = Module.new
70
+ @base_module.const_set("Keys", @keys_module)
71
+ @threads_module = Module.new
72
+ @base_module.const_set("Threads", @threads_module)
73
+ end
74
+
75
+ def post_load(repository, namespace)
76
+ @other_constant_infos.each do |constant_info|
77
+ name = constant_info.name
78
+ next if @key_constants.has_key?("KEY_#{name}")
79
+ @base_module.const_set(name, constant_info.value)
80
+ end
81
+ load_events
82
+ end
83
+
84
+ def load_events
85
+ @event_infos.each do |event_info|
86
+ define_struct(event_info, :parent => Event)
87
+ end
88
+ event_map = {
89
+ EventType::KEY_PRESS => KeyEvent,
90
+ EventType::KEY_RELEASE => KeyEvent,
91
+ EventType::MOTION => MotionEvent,
92
+ EventType::ENTER => CrossingEvent,
93
+ EventType::LEAVE => CrossingEvent,
94
+ EventType::BUTTON_PRESS => ButtonEvent,
95
+ EventType::BUTTON_RELEASE => ButtonEvent,
96
+ EventType::SCROLL => ScrollEvent,
97
+ EventType::STAGE_STATE => StageStateEvent,
98
+ EventType::TOUCH_UPDATE => TouchEvent,
99
+ EventType::TOUCH_END => TouchEvent,
100
+ EventType::TOUCH_CANCEL => TouchEvent,
101
+ }
102
+ self.class.register_boxed_class_converter(Event.gtype) do |event|
103
+ event_map[event.type] || Event
104
+ end
105
+ end
106
+
107
+ def load_struct_info(info)
108
+ if info.name.end_with?("Event")
109
+ @event_infos << info
110
+ else
111
+ super
112
+ end
113
+ end
114
+
115
+ def load_function_info(info)
116
+ name = info.name
117
+ case name
118
+ when /\Athreads_/
119
+ define_module_function(@threads_module, $POSTMATCH, info)
120
+ else
121
+ super
122
+ end
123
+ end
124
+
125
+ def load_constant_info(info)
126
+ case info.name
127
+ when /\AKEY_/
128
+ @key_constants[info.name] = true
129
+ @keys_module.const_set(info.name, info.value)
130
+ else
131
+ @other_constant_infos << info
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,33 @@
1
+ # Copyright (C) 2013 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
+ module Clutter
18
+ class ActorIter
19
+ private :init
20
+ def initialize(root)
21
+ super()
22
+ init(root)
23
+ end
24
+
25
+ def each
26
+ loop do
27
+ have_next, child = self.next
28
+ break unless have_next
29
+ yield(child)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ # Copyright (C) 2012 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
+ module Clutter
18
+ class Actor
19
+ # TODO: use prepend after Ruby 1.9 support is dropped.
20
+ alias_method :save_easing_state_without_block, :save_easing_state
21
+ def save_easing_state
22
+ if block_given?
23
+ save_easing_state_without_block
24
+ begin
25
+ yield
26
+ ensure
27
+ restore_easing_state
28
+ end
29
+ else
30
+ save_easing_state_without_block
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,26 @@
1
+ # Copyright (C) 2013 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
+ module Clutter
18
+ module Animatable
19
+ alias_method :set_final_state_without_conversion, :set_final_state
20
+ def set_final_state(property_name, value)
21
+ property = self.class.property(property_name)
22
+ value = GLib::Value.new(property.value_type, value)
23
+ set_final_state_without_conversion(property_name, value)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ # Copyright (C) 2013 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
+ module Cairo
18
+ class Context
19
+ def set_source_clutter_color(color)
20
+ Clutter.cairo_set_source_color(self, color)
21
+ end
22
+ alias_method :source_clutter_color=, :set_source_clutter_color
23
+ end
24
+ end
@@ -0,0 +1,55 @@
1
+ # Copyright (C) 2013 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
+ module Clutter
18
+ class Color
19
+ class << self
20
+ def new(*args)
21
+ if [Symbol] == args.collect(&:class)
22
+ name = args[0]
23
+ get_static(name)
24
+ else
25
+ super
26
+ end
27
+ end
28
+
29
+ def rgb(red, green, blue, alpha=255)
30
+ rgba(red, green, blue, alpha)
31
+ end
32
+
33
+ def rgba(red, green, blue, alpha)
34
+ new(red, green, blue, alpha)
35
+ end
36
+
37
+ def hls(hue, luminance, saturation, alpha=255)
38
+ hlsa(hue, luminance, saturation, alpha)
39
+ end
40
+
41
+ def hlsa(hue, luminance, saturation, alpha)
42
+ color = new
43
+ color.from_hls(hue, luminance, saturation)
44
+ color.alpha = alpha
45
+ color
46
+ end
47
+
48
+ def pixel(pixel)
49
+ color = new
50
+ color.from_pixel(pixel)
51
+ color
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,21 @@
1
+ # Copyright (C) 2013 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
+ module Clutter
18
+ class Event
19
+ STOP = true
20
+ end
21
+ end
@@ -0,0 +1,25 @@
1
+ # Copyright (C) 2013 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
+ module Clutter
18
+ class Point
19
+ alias_method :initialize_original, :initialize
20
+ def initialize(x=nil, y=nil)
21
+ initialize_original
22
+ init(x, y) if x and y
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ # Copyright (C) 2013 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
+ module Clutter
18
+ class Text
19
+ # Remove deprecated property accessors
20
+ remove_method :position
21
+ remove_method :set_position
22
+ end
23
+ end
@@ -0,0 +1,38 @@
1
+ # Copyright (C) 2013 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
+ module Clutter
18
+ module Threads
19
+ class << self
20
+ alias_method :add_timeout_full, :add_timeout
21
+ def add_timeout(interval_or_priority, interval=nil, &block)
22
+ if interval.nil?
23
+ priority, interval = GLib::PRIORITY_DEFAULT, interval_or_priority
24
+ add_timeout_full(priority, interval, &block)
25
+ else
26
+ priority = interval_or_priority
27
+ add_timeout_full(priority, interval, &block)
28
+ end
29
+ end
30
+
31
+ alias_method :add_idle_full, :add_idle
32
+ def add_idle(priority=nil, &block)
33
+ priority ||= GLib::PRIORITY_DEFAULT_IDLE
34
+ add_idle_full(priority, &block)
35
+ end
36
+ end
37
+ end
38
+ end