rabbit 2.2.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. checksums.yaml +5 -5
  2. data/data/locale/ja/LC_MESSAGES/rabbit.mo +0 -0
  3. data/doc/_config.yml +2 -2
  4. data/doc/_layouts/en.html +1 -1
  5. data/doc/_layouts/ja.html +1 -1
  6. data/doc/en/news.rd +140 -0
  7. data/doc/en/sample/hiki/rabbit.hiki +2 -2
  8. data/doc/en/sample/markdown/rabbit.md +1 -1
  9. data/doc/en/sample/rd/rabbit.rd +1 -1
  10. data/doc/en/usage/rabbit-slide.rd +3 -3
  11. data/doc/images/screenshots/en/blue-circle-raw.png +0 -0
  12. data/doc/images/screenshots/en/blue-circle.png +0 -0
  13. data/doc/images/screenshots/en/clear-blue-raw.png +0 -0
  14. data/doc/images/screenshots/en/clear-blue.png +0 -0
  15. data/doc/images/screenshots/en/cozmixng-raw.png +0 -0
  16. data/doc/images/screenshots/en/cozmixng.png +0 -0
  17. data/doc/images/screenshots/en/dark-gradation-raw.png +0 -0
  18. data/doc/images/screenshots/en/dark-gradation.png +0 -0
  19. data/doc/images/screenshots/en/day-white-raw.png +0 -0
  20. data/doc/images/screenshots/en/day-white.png +0 -0
  21. data/doc/images/screenshots/en/debian-raw.png +0 -0
  22. data/doc/images/screenshots/en/debian.png +0 -0
  23. data/doc/images/screenshots/en/green-circle-raw.png +0 -0
  24. data/doc/images/screenshots/en/green-circle.png +0 -0
  25. data/doc/images/screenshots/en/night-black-raw.png +0 -0
  26. data/doc/images/screenshots/en/night-black.png +0 -0
  27. data/doc/images/screenshots/en/rabbit-raw.png +0 -0
  28. data/doc/images/screenshots/en/rabbit.png +0 -0
  29. data/doc/images/screenshots/en/ranguba-raw.png +0 -0
  30. data/doc/images/screenshots/en/ranguba.png +0 -0
  31. data/doc/images/screenshots/en/red-frame-raw.png +0 -0
  32. data/doc/images/screenshots/en/red-frame.png +0 -0
  33. data/doc/images/screenshots/en/ruby-gnome2-raw.png +0 -0
  34. data/doc/images/screenshots/en/ruby-gnome2.png +0 -0
  35. data/doc/images/screenshots/en/rubykaigi2011-raw.png +0 -0
  36. data/doc/images/screenshots/en/rubykaigi2011.png +0 -0
  37. data/doc/images/screenshots/ja/blue-circle-raw.png +0 -0
  38. data/doc/images/screenshots/ja/blue-circle.png +0 -0
  39. data/doc/images/screenshots/ja/clear-blue-raw.png +0 -0
  40. data/doc/images/screenshots/ja/clear-blue.png +0 -0
  41. data/doc/images/screenshots/ja/cozmixng-raw.png +0 -0
  42. data/doc/images/screenshots/ja/cozmixng.png +0 -0
  43. data/doc/images/screenshots/ja/dark-gradation-raw.png +0 -0
  44. data/doc/images/screenshots/ja/dark-gradation.png +0 -0
  45. data/doc/images/screenshots/ja/day-white-raw.png +0 -0
  46. data/doc/images/screenshots/ja/day-white.png +0 -0
  47. data/doc/images/screenshots/ja/debian-raw.png +0 -0
  48. data/doc/images/screenshots/ja/debian.png +0 -0
  49. data/doc/images/screenshots/ja/green-circle-raw.png +0 -0
  50. data/doc/images/screenshots/ja/green-circle.png +0 -0
  51. data/doc/images/screenshots/ja/night-black-raw.png +0 -0
  52. data/doc/images/screenshots/ja/night-black.png +0 -0
  53. data/doc/images/screenshots/ja/rabbit-raw.png +0 -0
  54. data/doc/images/screenshots/ja/rabbit.png +0 -0
  55. data/doc/images/screenshots/ja/ranguba-raw.png +0 -0
  56. data/doc/images/screenshots/ja/ranguba.png +0 -0
  57. data/doc/images/screenshots/ja/red-frame-raw.png +0 -0
  58. data/doc/images/screenshots/ja/red-frame.png +0 -0
  59. data/doc/images/screenshots/ja/ruby-gnome2-raw.png +0 -0
  60. data/doc/images/screenshots/ja/ruby-gnome2.png +0 -0
  61. data/doc/images/screenshots/ja/rubykaigi2011-raw.png +0 -0
  62. data/doc/images/screenshots/ja/rubykaigi2011.png +0 -0
  63. data/doc/ja/how-to-make/index.rd +1 -1
  64. data/doc/ja/news.rd +143 -0
  65. data/doc/ja/sample/hiki/rabbit.hiki +2 -2
  66. data/doc/ja/sample/markdown/rabbit.md +1 -1
  67. data/doc/ja/sample/rd/rabbit.rd +1 -1
  68. data/doc/ja/slides.rd +1 -1
  69. data/doc/ja/usage/rabbit-slide.rd +3 -3
  70. data/doc/ja/users.rd +1 -1
  71. data/lib/rabbit/action.rb +23 -4
  72. data/lib/rabbit/canvas.rb +70 -14
  73. data/lib/rabbit/command/rabbit-slide.rb +252 -67
  74. data/lib/rabbit/command/rabbit-slide.ui +180 -0
  75. data/lib/rabbit/command/rabbit.rb +14 -20
  76. data/lib/rabbit/console.rb +9 -3
  77. data/lib/rabbit/dependency-canvas.rb +19 -1
  78. data/lib/rabbit/element.rb +34 -7
  79. data/lib/rabbit/element/poppler-page.rb +1 -2
  80. data/lib/rabbit/element/text-container-element.rb +2 -2
  81. data/lib/rabbit/element/text-renderer.rb +5 -4
  82. data/lib/rabbit/element/title-slide.rb +8 -0
  83. data/lib/rabbit/element/video.rb +1 -2
  84. data/lib/rabbit/filename.rb +39 -0
  85. data/lib/rabbit/formatter.rb +61 -30
  86. data/lib/rabbit/frame.rb +1 -19
  87. data/lib/rabbit/front.rb +23 -2
  88. data/lib/rabbit/gesture/handler.rb +21 -2
  89. data/lib/rabbit/graffiti/config-dialog.rb +15 -18
  90. data/lib/rabbit/gtk.rb +2 -191
  91. data/lib/rabbit/html/generator.rb +38 -30
  92. data/lib/rabbit/image-data-loader.rb +6 -1
  93. data/lib/rabbit/image.rb +22 -4
  94. data/lib/rabbit/image/base.rb +34 -2
  95. data/lib/rabbit/image/default.rb +1 -1
  96. data/lib/rabbit/image/eps.rb +1 -1
  97. data/lib/rabbit/image/gimp.rb +1 -1
  98. data/lib/rabbit/info-window.rb +27 -15
  99. data/lib/rabbit/logger/gui.rb +21 -23
  100. data/lib/rabbit/logger/stderr.rb +1 -1
  101. data/lib/rabbit/pango-markup.rb +44 -0
  102. data/lib/rabbit/parser.rb +20 -3
  103. data/lib/rabbit/parser/ext/image.rb +25 -8
  104. data/lib/rabbit/parser/ext/video.rb +21 -2
  105. data/lib/rabbit/parser/markdown.rb +1 -2
  106. data/lib/rabbit/parser/pdf.rb +23 -7
  107. data/lib/rabbit/parser/rd/rd2rabbit-lib.rb +20 -0
  108. data/lib/rabbit/progress.rb +34 -23
  109. data/lib/rabbit/renderer.rb +17 -23
  110. data/lib/rabbit/renderer/base.rb +31 -57
  111. data/lib/rabbit/renderer/color.rb +46 -53
  112. data/lib/rabbit/renderer/display/base.rb +71 -62
  113. data/lib/rabbit/renderer/display/button-handler.rb +2 -1
  114. data/lib/rabbit/renderer/display/clutter-embed.rb +60 -26
  115. data/lib/rabbit/renderer/display/drawing-area-base.rb +1 -1
  116. data/lib/rabbit/renderer/display/drawing-area-primitive.rb +34 -21
  117. data/lib/rabbit/renderer/display/graffiti.rb +1 -3
  118. data/lib/rabbit/renderer/display/hook-handler.rb +8 -4
  119. data/lib/rabbit/renderer/display/key-handler.rb +7 -2
  120. data/lib/rabbit/renderer/display/magnifier.rb +2 -2
  121. data/lib/rabbit/renderer/display/progress.rb +10 -2
  122. data/lib/rabbit/renderer/display/spotlight.rb +2 -2
  123. data/lib/rabbit/renderer/engine/cairo.rb +0 -3
  124. data/lib/rabbit/renderer/kernel.rb +54 -0
  125. data/lib/rabbit/renderer/offscreen.rb +14 -6
  126. data/lib/rabbit/renderer/print-layout.rb +150 -0
  127. data/lib/rabbit/renderer/printer.rb +236 -0
  128. data/lib/rabbit/renderer/screen.rb +288 -0
  129. data/lib/rabbit/renderer/widget/drawing-area.rb +93 -0
  130. data/lib/rabbit/size.rb +52 -25
  131. data/lib/rabbit/slide-configuration.rb +56 -12
  132. data/lib/rabbit/source.rb +24 -8
  133. data/lib/rabbit/task/slide.rb +1 -1
  134. data/lib/rabbit/theme/applier.rb +26 -9
  135. data/lib/rabbit/theme/base/base.rb +7 -7
  136. data/lib/rabbit/theme/clear-blue/clear-blue.rb +1 -1
  137. data/lib/rabbit/theme/image-timer/image-timer.rb +3 -1
  138. data/lib/rabbit/theme/image-viewer/image-viewer.rb +13 -1
  139. data/lib/rabbit/theme/image/image.rb +4 -4
  140. data/lib/rabbit/theme/lightning-talk-toolkit/lightning-talk-toolkit.rb +3 -1
  141. data/lib/rabbit/theme/tag/tag.rb +12 -4
  142. data/lib/rabbit/version.rb +2 -2
  143. data/lib/rabbit/video-window.rb +75 -89
  144. data/misc/emacs/rabbit-mode.el +11 -7
  145. data/po/en/rabbit.edit.po +189 -185
  146. data/po/en/rabbit.po +15 -12
  147. data/po/fr/rabbit.edit.po +189 -185
  148. data/po/fr/rabbit.po +15 -12
  149. data/po/ja/rabbit.edit.po +190 -186
  150. data/po/ja/rabbit.po +16 -13
  151. data/rabbit.gemspec +34 -16
  152. data/test/command/test-rabbit.rb +100 -0
  153. data/test/{rabbit-test-utils.rb → helper.rb} +7 -4
  154. data/test/{rabbit-test-utils → helper}/fixture.rb +2 -2
  155. data/test/{rabbit-test-utils → helper}/parser.rb +2 -2
  156. data/test/image/test-dia.rb +2 -2
  157. data/test/image/test-eps.rb +2 -2
  158. data/test/parser/test-markdown.rb +3 -5
  159. data/test/parser/test-rd.rb +1 -3
  160. data/test/parser/test-wiki.rb +3 -5
  161. data/test/run-test.rb +3 -3
  162. data/test/test-applier.rb +60 -29
  163. data/test/test-canvas.rb +70 -0
  164. data/test/test-color.rb +18 -9
  165. data/test/test-element.rb +15 -3
  166. data/test/test-size.rb +25 -22
  167. data/test/test-slide-configuration.rb +16 -6
  168. data/test/test-source.rb +15 -5
  169. data/test/test-utils.rb +15 -1
  170. metadata +55 -84
  171. data/lib/rabbit/renderer/print.rb +0 -31
  172. data/lib/rabbit/renderer/print/base.rb +0 -78
  173. data/lib/rabbit/renderer/print/cairo.rb +0 -122
  174. data/lib/rabbit/renderer/print/layout.rb +0 -123
  175. data/lib/rabbit/renderer/print/multiple.rb +0 -202
  176. data/lib/rabbit/source/hiki.rb +0 -36
  177. data/lib/rabbit/source/slide-share.rb +0 -53
@@ -4,75 +4,41 @@ require "rabbit/rabbit"
4
4
 
5
5
  module Rabbit
6
6
  module Renderer
7
- Color = Struct.new(:red, :green, :blue, :alpha, :have_alpha)
8
- class Color
9
- GDK_COLOR_NORMALIZE = 65535.0
10
-
7
+ class Color < Struct.new(:red, :green, :blue, :alpha)
11
8
  class << self
12
- def new_from_gdk_color(color, have_alpha=false)
13
- red = color.red / GDK_COLOR_NORMALIZE
14
- green = color.green / GDK_COLOR_NORMALIZE
15
- blue = color.blue / GDK_COLOR_NORMALIZE
16
- alpha = 1.0
17
- new(red, green, blue, alpha, have_alpha)
18
- end
19
-
20
- HEX = "(?i:[a-z0-9])"
21
- def parse(spec)
22
- case spec
23
- when Array
24
- new(*spec)
25
- when /\A\#(#{HEX})(#{HEX})(#{HEX})(#{HEX})?\z/
26
- new(*normalize($1, $2, $3, $4, 16 ** 1 - 1))
27
- when /\A\#(#{HEX}{2})(#{HEX}{2})(#{HEX}{2})(#{HEX}{2})?\z/
28
- new(*normalize($1, $2, $3, $4, 16 ** 2 - 1))
29
- when /\A\#(#{HEX}{4})(#{HEX}{4})(#{HEX}{4})(#{HEX}{4})?\z/
30
- new(*normalize($1, $2, $3, $4, 16 ** 4 - 1))
31
- else
32
- new_from_gdk_color(Gdk::Color.parse(spec))
33
- end
9
+ def parse(*args)
10
+ new(*args)
34
11
  end
12
+ end
35
13
 
36
- def normalize(r, g, b, a, max)
37
- red = r.hex / max.to_f
38
- green = g.hex / max.to_f
39
- blue = b.hex / max.to_f
40
- have_alpha = !a.nil?
41
- alpha = have_alpha ? a.hex / max.to_f : 1.0
42
- [red, green, blue, alpha, have_alpha]
14
+ def initialize(*args)
15
+ case args.collect(&:class)
16
+ when [Gdk::RGBA]
17
+ rgba = args[0]
18
+ super(*rgba.to_a)
19
+ when [String]
20
+ rgba = parse(args[0])
21
+ super(*rgba)
22
+ else
23
+ super(*args)
43
24
  end
44
25
  end
45
26
 
46
- alias have_alpha? have_alpha
47
-
48
27
  def to_s
49
- "#%04X%04X%04X%04X" % to_gdk_rgba
28
+ values = to_a.collect {|x| (x * 65535).ceil}
29
+ "#%04X%04X%04X%04X" % values
50
30
  end
51
31
 
52
32
  def to_a
53
- if have_alpha?
54
- [red, green, blue, alpha]
55
- else
56
- [red, green, blue]
57
- end
58
- end
59
-
60
- def to_gdk_rgb
61
- to_gdk_rgba[0..-2]
33
+ [red, green, blue, alpha]
62
34
  end
63
35
 
64
36
  def to_gdk_rgba
65
- [red, green, blue, alpha || 1.0].collect do |color|
66
- (color * GDK_COLOR_NORMALIZE).truncate
67
- end
37
+ Gdk::RGBA.new(*to_a)
68
38
  end
69
39
 
70
40
  def to_gdk_format
71
- to_s.gsub(/[a-z0-9]{4}\z/i, '')
72
- end
73
-
74
- def to_gdk_color
75
- Gdk::Color.new(*to_gdk_rgb)
41
+ to_s
76
42
  end
77
43
 
78
44
  def to_css_rgba
@@ -82,6 +48,33 @@ module Rabbit
82
48
  a = alpha || 1.0
83
49
  "rgba(#{red_percent}%, #{green_percent}%, #{blue_percent}%, #{a})"
84
50
  end
51
+
52
+ private
53
+ HEX = "(?i:[a-z0-9])"
54
+ def parse(text)
55
+ case text
56
+ when /\A\#(#{HEX})(#{HEX})(#{HEX})(#{HEX})?\z/
57
+ normalize_rgba($1, $2, $3, $4, 16 ** 1 - 1)
58
+ when /\A\#(#{HEX}{2})(#{HEX}{2})(#{HEX}{2})(#{HEX}{2})?\z/
59
+ normalize_rgba($1, $2, $3, $4, 16 ** 2 - 1)
60
+ when /\A\#(#{HEX}{4})(#{HEX}{4})(#{HEX}{4})(#{HEX}{4})?\z/
61
+ normalize_rgba($1, $2, $3, $4, 16 ** 4 - 1)
62
+ else
63
+ Gdk::RGBA.parse(text).to_a
64
+ end
65
+ end
66
+
67
+ def normalize_rgba(r, g, b, a, max)
68
+ red = r.hex / max.to_f
69
+ green = g.hex / max.to_f
70
+ blue = b.hex / max.to_f
71
+ if a
72
+ alpha = a.hex / max.to_f
73
+ else
74
+ alpha = 1.0
75
+ end
76
+ [red, green, blue, alpha]
77
+ end
85
78
  end
86
79
  end
87
80
  end
@@ -1,3 +1,19 @@
1
+ # Copyright (C) 2006-2019 Kouhei Sutou <kou@cozmixng.org>
2
+ #
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program 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
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along
14
+ # with this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
+
1
17
  require "rabbit/renderer/base"
2
18
  require "rabbit/renderer/display/hook-handler"
3
19
 
@@ -12,8 +28,6 @@ module Rabbit
12
28
  @drawable = nil
13
29
  @size = nil
14
30
  @size_dirty = true
15
- @default_size_ratio = nil
16
- @size_ratio = nil
17
31
  super
18
32
  end
19
33
 
@@ -47,16 +61,9 @@ module Rabbit
47
61
  def attach_to(window, container=nil)
48
62
  @window = window
49
63
  @container = container || @window
50
-
51
- set_configure_event
52
64
  end
53
65
 
54
66
  def detach
55
- if !@window.destroyed? and @configure_signal_id
56
- @window.signal_handler_disconnect(@configure_signal_id)
57
- @configure_signal_id = nil
58
- end
59
-
60
67
  @window = nil
61
68
  @container = nil
62
69
  end
@@ -95,12 +102,13 @@ module Rabbit
95
102
  end
96
103
 
97
104
  def draw_slide(slide, simulation)
98
- set_size_ratio(slide.size_ratio || @default_size_ratio)
105
+ set_size_ratio(slide.size_ratio)
99
106
 
100
107
  if simulation
101
108
  super
102
109
  else
103
110
  save_context do
111
+ scale_context(*@size.logical_scale)
104
112
  translate_context(@size.logical_margin_left,
105
113
  @size.logical_margin_top)
106
114
  super
@@ -111,33 +119,36 @@ module Rabbit
111
119
  end
112
120
 
113
121
  margin_background = make_color("black")
114
- if @size.have_logical_margin_x?
115
- draw_rectangle(true,
116
- 0,
117
- 0,
118
- @size.logical_margin_left,
119
- @size.real_height,
120
- margin_background)
121
- draw_rectangle(true,
122
- @size.real_width - @size.logical_margin_right,
123
- 0,
124
- @size.logical_margin_right,
125
- @size.real_height,
126
- margin_background)
127
- end
128
- if @size.have_logical_margin_y?
129
- draw_rectangle(true,
130
- 0,
131
- 0,
132
- @size.real_width,
133
- @size.logical_margin_top,
134
- margin_background)
135
- draw_rectangle(true,
136
- 0,
137
- @size.real_height - @size.logical_margin_bottom,
138
- @size.real_width,
139
- @size.logical_margin_bottom,
140
- margin_background)
122
+ save_context do
123
+ scale_context(*@size.logical_scale)
124
+ if @size.have_logical_margin_x?
125
+ draw_rectangle(true,
126
+ 0,
127
+ 0,
128
+ @size.logical_margin_left,
129
+ @size.logical_height,
130
+ margin_background)
131
+ draw_rectangle(true,
132
+ @size.logical_margin_left + @size.logical_width,
133
+ 0,
134
+ @size.logical_margin_right,
135
+ @size.logical_height,
136
+ margin_background)
137
+ end
138
+ if @size.have_logical_margin_y?
139
+ draw_rectangle(true,
140
+ 0,
141
+ 0,
142
+ @size.logical_width,
143
+ @size.logical_margin_top,
144
+ margin_background)
145
+ draw_rectangle(true,
146
+ 0,
147
+ @size.logical_margin_top + @size.logical_height,
148
+ @size.logical_width,
149
+ @size.logical_margin_bottom,
150
+ margin_background)
151
+ end
141
152
  end
142
153
  end
143
154
  end
@@ -145,47 +156,45 @@ module Rabbit
145
156
  private
146
157
  def set_drawable(drawable)
147
158
  @drawable = drawable
148
- w = @drawable.width
149
- h = @drawable.height
150
- @default_size_ratio = w.to_f / h.to_f
151
- @size_ratio = @default_size_ratio
152
- set_size(w, h)
159
+ set_default_size(@drawable.width, @drawable.height)
160
+ end
161
+
162
+ def set_default_size(w, h)
163
+ @real_width = w
164
+ @real_height = h
165
+ ratio = @base_width.to_f / @base_height.to_f
166
+ set_size(w, h, ratio)
167
+ end
168
+
169
+ def set_size(w, h, ratio)
170
+ @size = Size.new(@base_width,
171
+ @base_height,
172
+ w,
173
+ h,
174
+ ratio)
153
175
  end
154
176
 
155
- def set_size(w, h)
156
- @size = Size.new(w, h, @size_ratio)
177
+ def update_size(w, h)
178
+ @real_width = w
179
+ @real_height = h
180
+ @size_dirty = true
157
181
  end
158
182
 
159
183
  def set_size_ratio(ratio)
184
+ ratio ||= @base_width.to_f / @base_height.to_f
160
185
  return if @size.ratio == ratio
161
186
 
162
187
  w = @size.real_width
163
188
  h = @size.real_height
164
- @size_ratio = ratio
165
- @size = Size.new(w, h, @size_ratio)
189
+ set_size(w, h, ratio)
166
190
  end
167
191
 
168
192
  def refresh_size
169
193
  return unless @size_dirty
170
-
171
- @size = Size.new(@drawable.width,
172
- @drawable.height,
173
- @size.ratio)
194
+ set_size(@real_width, @real_height, @size.ratio)
174
195
  @size_dirty = false
175
196
  end
176
197
 
177
- def set_configure_event
178
- id = @window.signal_connect("configure_event") do |widget, event|
179
- configured(event.x, event.y, event.width, event.height)
180
- false
181
- end
182
- @configure_signal_id = id
183
- end
184
-
185
- def configured(x, y, w, h)
186
- @size_dirty = true
187
- end
188
-
189
198
  def queue_draw
190
199
  widget.queue_draw
191
200
  end
@@ -113,7 +113,8 @@ module Rabbit
113
113
  end
114
114
  end
115
115
 
116
- def add_button_handler(handler=Proc.new)
116
+ def add_button_handler(handler=nil, &block)
117
+ handler ||= Proc.new(&block)
117
118
  @button_handler.push(handler)
118
119
  end
119
120
 
@@ -1,5 +1,20 @@
1
- require 'clutter_gtk'
2
- require 'clutter_cairo'
1
+ # Copyright (C) 2008-2019 Kouhei Sutou <kou@cozmixng.org>
2
+ #
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program 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
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along
14
+ # with this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
+
17
+ require "clutter-gtk"
3
18
 
4
19
  require "rabbit/utils"
5
20
  require "rabbit/renderer/engine"
@@ -18,10 +33,6 @@ require "rabbit/renderer/display/spotlight"
18
33
  require "rabbit/renderer/display/magnifier"
19
34
 
20
35
  module Rabbit
21
- add_gui_init_proc do
22
- Clutter::Gtk.init
23
- end
24
-
25
36
  module Renderer
26
37
  module Display
27
38
  class ClutterEmbed
@@ -31,6 +42,8 @@ module Rabbit
31
42
  end
32
43
  end
33
44
 
45
+ include Renderer::Engine::Cairo
46
+
34
47
  include Base
35
48
 
36
49
  include Cursor
@@ -46,8 +59,6 @@ module Rabbit
46
59
  include Spotlight
47
60
  include Magnifier
48
61
 
49
- include Renderer::Engine::Cairo
50
-
51
62
  attr_accessor :filename
52
63
  def initialize(canvas)
53
64
  @recreate_id = nil
@@ -61,6 +72,13 @@ module Rabbit
61
72
  @embed
62
73
  end
63
74
 
75
+ def redraw
76
+ actor = current_actor
77
+ # TODO: We need more work for periodical redraw
78
+ actor.content.invalidate if actor
79
+ widget.queue_draw
80
+ end
81
+
64
82
  def clear_slide
65
83
  super
66
84
  redraw
@@ -90,6 +108,7 @@ module Rabbit
90
108
  old_actor.hide if old_actor
91
109
  actor = retrieve_actor(index)
92
110
  if actor and !hiding?
111
+ actor.content.set_size(actor.width, actor.height)
93
112
  actor.show
94
113
  actor.raise_top
95
114
  if old_actor
@@ -107,6 +126,7 @@ module Rabbit
107
126
  actor.hide if actor
108
127
  actor = retrieve_actor(nil, index)
109
128
  if actor and !hiding?
129
+ actor.content.set_size(actor.width, actor.height)
110
130
  actor.show
111
131
  actor.raise_top
112
132
  end
@@ -246,12 +266,12 @@ module Rabbit
246
266
  end
247
267
 
248
268
  def init_clutter_embed
249
- @embed = Clutter::GtkEmbed.new
269
+ @embed = ClutterGtk::Embed.new
250
270
  @embed.can_focus = true
251
271
  @stage = @embed.stage
252
272
  reset_stage_color
253
273
  set_map
254
- set_expose_event
274
+ set_draw
255
275
  set_configure_event_after
256
276
 
257
277
  event_mask = Gdk::EventMask::BUTTON_PRESS_MASK
@@ -296,8 +316,8 @@ module Rabbit
296
316
  end
297
317
  end
298
318
 
299
- def set_expose_event
300
- @embed.signal_connect("expose-event") do |widget, event|
319
+ def set_draw
320
+ @embed.signal_connect("draw") do |widget, context|
301
321
  reload_source
302
322
  false
303
323
  end
@@ -315,6 +335,9 @@ module Rabbit
315
335
  end
316
336
 
317
337
  def configured_after(widget, event)
338
+ @real_width = event.width
339
+ @real_height = event.height
340
+ @size_dirty = true
318
341
  reload_theme if @drawable
319
342
  false
320
343
  end
@@ -415,9 +438,9 @@ module Rabbit
415
438
  unless handled
416
439
  handled = true
417
440
  case event.direction
418
- when Gdk::EventScroll::Direction::UP
441
+ when Gdk::ScrollDirection::UP
419
442
  @canvas.activate("PreviousSlide")
420
- when Gdk::EventScroll::Direction::DOWN
443
+ when Gdk::ScrollDirection::DOWN
421
444
  @canvas.activate("NextSlide")
422
445
  else
423
446
  handled = false
@@ -431,8 +454,13 @@ module Rabbit
431
454
  index ||= index || @canvas.current_index
432
455
  slide_actors = @actors[index]
433
456
  return nil if slide_actors.nil?
434
- slide = @canvas.slides[index]
435
- slide_actors[index_in_slide || slide.drawing_index]
457
+
458
+ if index_in_slide.nil?
459
+ slide = @canvas.slides[index]
460
+ return nil if slide.nil?
461
+ index_in_slide = slide.drawing_index
462
+ end
463
+ slide_actors[index_in_slide]
436
464
  end
437
465
 
438
466
  def current_actor
@@ -455,16 +483,22 @@ module Rabbit
455
483
  actor = slide_actors[index_in_slide]
456
484
  slide = @canvas.slides[i]
457
485
  if actor.nil?
458
- actor = Clutter::Cairo.new(width, height)
459
- context = actor.create
460
- init_context(context)
461
- draw_nth_slide(i, index_in_slide)
462
- finish_context
486
+ canvas = Clutter::Canvas.new
487
+ canvas.signal_connect(:draw, i, index_in_slide) do |_, context, _width, _height, _i, _index_in_slide|
488
+ init_context(context)
489
+ draw_nth_slide(_i, _index_in_slide)
490
+ finish_context
491
+ end
492
+ actor = Clutter::Actor.new
493
+ actor.instance_variable_set(:@c, canvas)
494
+ actor.content = canvas
495
+ actor.set_size(@real_width, @real_height)
463
496
  @actors[i] ||= []
464
497
  @actors[i][index_in_slide] = actor
465
- @stage.add(actor)
498
+ @stage.add_child(actor)
466
499
  current_index_in_slide = index_in_slide == slide.drawing_index
467
500
  if index.nil? and current_index_in_slide and !hiding?
501
+ canvas.set_size(@real_width, @real_height)
468
502
  actor.show
469
503
  actor.raise_top
470
504
  Utils.process_pending_events_proc.call
@@ -492,19 +526,19 @@ module Rabbit
492
526
  end
493
527
 
494
528
  def grab
495
- Gtk.grab_add(@embed)
529
+ @embed.grab_add
496
530
  Gdk.pointer_grab(@embed.window, false,
497
531
  Gdk::EventMask::BUTTON_PRESS_MASK |
498
532
  Gdk::EventMask::BUTTON_RELEASE_MASK |
499
533
  Gdk::EventMask::SCROLL_MASK |
500
534
  Gdk::EventMask::POINTER_MOTION_MASK,
501
535
  nil, nil,
502
- Gdk::Event::CURRENT_TIME)
536
+ Gdk::CURRENT_TIME)
503
537
  end
504
538
 
505
539
  def ungrab
506
- Gtk.grab_remove(@embed)
507
- Gdk.pointer_ungrab(Gdk::Event::CURRENT_TIME)
540
+ @embed.grab_remove
541
+ Gdk.pointer_ungrab(Gdk::CURRENT_TIME)
508
542
  end
509
543
 
510
544
  def pointer