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
@@ -1,15 +1,32 @@
1
- require 'erb'
2
- require 'fileutils'
1
+ # Copyright (C) 2005-2018 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 "erb"
18
+ require "fileutils"
3
19
 
4
20
  begin
5
- require 'rss/maker'
21
+ require "rss/maker"
6
22
  rescue LoadError
7
23
  end
8
24
 
9
- require 'rabbit/rabbit'
10
- require 'rabbit/front'
11
- require 'rabbit/utils'
12
- require 'rabbit/keys'
25
+ require "rabbit/filename"
26
+ require "rabbit/front"
27
+ require "rabbit/keys"
28
+ require "rabbit/rabbit"
29
+ require "rabbit/utils"
13
30
 
14
31
  module Rabbit
15
32
  module HTML
@@ -21,7 +38,14 @@ module Rabbit
21
38
  path = ["rabbit", "html", "template.erb"]
22
39
  template_path = Utils.find_path_in_load_path(*path)
23
40
  raise CantFindHTMLTemplate.new(File.join(*path)) if template_path.nil?
24
- erb = File.open(template_path) {|f| ERB.new(f.read, nil, "-")}
41
+ erb = File.open(template_path) do |f|
42
+ parameters = ERB.instance_method(:initialize).parameters
43
+ if parameters.include?([:key, :trim_mode])
44
+ ERB.new(f.read, trim_mode: "-")
45
+ else
46
+ ERB.new(f.read, nil, "-")
47
+ end
48
+ end
25
49
  erb.def_method(self, "to_html", template_path)
26
50
 
27
51
  attr_accessor :pdf_filename, :source_filename
@@ -40,7 +64,7 @@ module Rabbit
40
64
  @output_index_html = output_index_html
41
65
  @pdf_filename = nil
42
66
  @source_filename = nil
43
- FileUtils.mkdir_p(to_filename_encoding(@base_dir))
67
+ FileUtils.mkdir_p(Filename.new(@base_dir).encode)
44
68
  end
45
69
 
46
70
  def save
@@ -193,7 +217,7 @@ module Rabbit
193
217
  if Object.const_defined?(:RSS)
194
218
  rss = make_rss
195
219
  name = File.join(@base_dir, @rss_filename)
196
- File.open(to_filename_encoding(name), "w") do |f|
220
+ File.open(Filename.new(name).encode, "w") do |f|
197
221
  f.print(rss.to_s)
198
222
  end
199
223
  true
@@ -209,31 +233,15 @@ module Rabbit
209
233
  format << "-%0#{number_of_places(slide_size)}d%s.%s"
210
234
  end
211
235
 
212
- def to_filename_encoding(utf8_filename)
213
- if GLib.const_defined?(:Win32)
214
- GLib::Win32.locale_filename_from_utf8(utf8_filename)
215
- else
216
- if Utils.windows?
217
- GLib.locale_from_utf8(utf8_filename)
218
- else
219
- GLib.filename_from_utf8(utf8_filename)
220
- end
221
- end
222
- end
223
-
224
- def make_filename(slide_number, suffix, optional=nil, convert=true)
236
+ def make_filename(slide_number, suffix, optional=nil)
225
237
  optional = "-#{optional}" if optional
226
238
  name = filename_format % [slide_number, optional || '', suffix]
227
- if convert
228
- to_filename_encoding(name)
229
- else
230
- name
231
- end
239
+ Filename.new(name).encode
232
240
  end
233
241
 
234
242
  def slide_filename(slide_number=@slide_number)
235
243
  if !outputting_index? and slide_number.zero?
236
- File.join(to_filename_encoding(@base_dir), "index.#{@suffix}")
244
+ Filename.new(File.join(@base_dir, "index.#{@suffix}")).encode
237
245
  else
238
246
  make_filename(slide_number, @suffix)
239
247
  end
@@ -244,7 +252,7 @@ module Rabbit
244
252
  end
245
253
 
246
254
  def pixbuf_filename(slide_number=@slide_number, optional=nil)
247
- make_filename(slide_number, @image_type, optional, !Utils.windows?)
255
+ make_filename(slide_number, @image_type, optional)
248
256
  end
249
257
 
250
258
  def output_html(filename)
@@ -18,11 +18,15 @@ require "gdk_pixbuf2"
18
18
 
19
19
  module Rabbit
20
20
  class ImageDataLoader
21
- attr_reader :width, :height, :pixbuf
21
+ attr_reader :width
22
+ attr_reader :height
23
+ attr_reader :pixbuf
24
+ attr_reader :animation
22
25
  def initialize(data)
23
26
  @width = 0
24
27
  @height = 0
25
28
  @pixbuf = nil
29
+ @animation = nil
26
30
  @data = data
27
31
  end
28
32
 
@@ -40,6 +44,7 @@ module Rabbit
40
44
  end
41
45
  loader.signal_handler_disconnect(id)
42
46
  @pixbuf = loader.pixbuf
47
+ @animation = loader.animation
43
48
  @pixbuf
44
49
  end
45
50
  end
@@ -1,11 +1,29 @@
1
+ # Copyright (C) 2004-2017 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 "forwardable"
2
18
  require "tempfile"
3
19
  require 'thread'
4
20
 
5
- require 'rabbit/utils'
6
-
7
- dir = File.join("rabbit", "image")
8
- Rabbit::Utils.require_files_under_directory_in_load_path(dir)
21
+ require "rabbit/image/default"
22
+ require "rabbit/image/dia"
23
+ require "rabbit/image/eps"
24
+ require "rabbit/image/gimp"
25
+ require "rabbit/image/pdf"
26
+ require "rabbit/image/svg"
9
27
 
10
28
  module Rabbit
11
29
  module ImageManipulable
@@ -10,10 +10,14 @@ module Rabbit
10
10
  extend ModuleLoader
11
11
 
12
12
  attr_reader :width, :height, :original_width, :original_height
13
+ attr_reader :animation
13
14
 
14
15
  def initialize(filename, props)
15
16
  @filename = filename
16
17
  @props = normalize_props(props)
18
+ @animation = nil
19
+ @animation_iterator = nil
20
+ @animation_timeout = nil
17
21
  update_size
18
22
  @original_width = @width
19
23
  @original_height = @height
@@ -65,7 +69,13 @@ module Rabbit
65
69
  :width => width,
66
70
  :height => height,
67
71
  }
68
- canvas.draw_pixbuf(pixbuf, x, y, default_params.merge(params))
72
+ target_pixbuf = pixbuf
73
+ if @animation_iterator
74
+ @animation_iterator.advance
75
+ target_pixbuf = @animation_iterator.pixbuf
76
+ update_animation_timeout(canvas)
77
+ end
78
+ canvas.draw_pixbuf(target_pixbuf, x, y, default_params.merge(params))
69
79
  end
70
80
 
71
81
  private
@@ -95,7 +105,29 @@ module Rabbit
95
105
 
96
106
  @width = loader.width
97
107
  @height = loader.height
98
- loader.pixbuf
108
+ @pixbuf = loader.pixbuf
109
+ @animation = loader.animation
110
+ if @animation and not @animation.static_image?
111
+ @animation_iterator = @animation.get_iter
112
+ else
113
+ @animation_iterator = nil
114
+ end
115
+ if @animation_timeout
116
+ GLib::Source.remove(@animation_timeout)
117
+ @animation_timeout = nil
118
+ end
119
+ end
120
+
121
+ def update_animation_timeout(canvas)
122
+ delay_time = @animation_iterator.delay_time
123
+ if delay_time > 0 and @animation_timeout.nil?
124
+ @animation_timeout = GLib::Timeout.add(delay_time) do
125
+ canvas.redraw
126
+ @animation_timeout = nil
127
+ # update_animation_timeout(canvas)
128
+ GLib::Source::REMOVE
129
+ end
130
+ end
99
131
  end
100
132
  end
101
133
  end
@@ -17,7 +17,7 @@ module Rabbit
17
17
  def update_size
18
18
  File.open(@filename, "rb") do |file|
19
19
  Dir.chdir(File.dirname(@filename)) do
20
- @pixbuf = load_data(file.read)
20
+ load_data(file.read)
21
21
  end
22
22
  end
23
23
  end
@@ -36,7 +36,7 @@ module Rabbit
36
36
 
37
37
  private
38
38
  def update_size
39
- @pixbuf = load_image
39
+ load_image
40
40
  end
41
41
 
42
42
  def load_image(width=nil, height=nil)
@@ -41,7 +41,7 @@ EOC
41
41
  if GIMP_COMMANDS.any? {|gimp| run(gimp, *args); File.exist?(png_path)}
42
42
  png_file.open
43
43
  png_file.binmode
44
- @pixbuf = load_data(png_file.read)
44
+ load_data(png_file.read)
45
45
  else
46
46
  raise GIMPCanNotHandleError.new("gimp #{args.join(' ')}",
47
47
  GIMP_COMMANDS)
@@ -1,4 +1,18 @@
1
- require 'erb'
1
+ # Copyright (C) 2006-2018 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.
2
16
 
3
17
  require 'rabbit/gtk'
4
18
  require 'rabbit/dependency-canvas'
@@ -11,7 +25,6 @@ require 'rabbit/renderer/display/menu'
11
25
 
12
26
  module Rabbit
13
27
  class InfoWindow
14
- include ERB::Util
15
28
  include GetText
16
29
 
17
30
  include Renderer::Display::HookHandler
@@ -191,17 +204,9 @@ module Rabbit
191
204
 
192
205
  def init_note_area
193
206
  @note_area = Gtk::DrawingArea.new
194
- if @note_area.class.signals.include?("expose-event")
195
- @note_area.signal_connect("expose-event") do |area, event|
196
- context = area.window.create_cairo_context
197
- draw_text_as_large_as_possible(area, context, note_text)
198
- Gdk::Event::PROPAGATE
199
- end
200
- else
201
- @note_area.signal_connect("draw") do |area, context|
202
- draw_text_as_large_as_possible(area, context, note_text)
203
- Gdk::Event::PROPAGATE
204
- end
207
+ @note_area.signal_connect("draw") do |area, context|
208
+ draw_text_as_large_as_possible(area, context, note_text)
209
+ Gdk::Event::PROPAGATE
205
210
  end
206
211
  end
207
212
 
@@ -271,7 +276,7 @@ module Rabbit
271
276
  attrs["font_desc"] = ((height * font_size) / Pango::SCALE).to_s
272
277
  rest_time = @canvas.rest_time
273
278
  attrs["foreground"] = "red" if rest_time and rest_time < 0
274
- "<span #{@canvas.to_attrs(attrs)}>#{h timer_label}</span>"
279
+ PangoMarkup.new("span", attrs, timer_label).to_s
275
280
  end
276
281
 
277
282
  def timer_label
@@ -292,7 +297,7 @@ module Rabbit
292
297
  end
293
298
  attrs = {}
294
299
  attrs["font_desc"] = ((height * 40) / Pango::SCALE).to_s
295
- "<span #{@canvas.to_attrs(attrs)}>#{text}</span>"
300
+ PangoMarkup.new("span", attrs, text).to_s
296
301
  end
297
302
 
298
303
  def update_source
@@ -307,6 +312,13 @@ module Rabbit
307
312
  end
308
313
  end
309
314
 
315
+ def reload_theme
316
+ @canvas.reload_theme
317
+ each do |canvas|
318
+ canvas.reload_theme
319
+ end
320
+ end
321
+
310
322
  def adjust_slide(base_index=nil)
311
323
  base_index ||= @canvas.current_index
312
324
  @previous_canvas.move_to_if_can([base_index - 1, 0].max)
@@ -11,7 +11,6 @@ module Rabbit
11
11
 
12
12
  attr_accessor :start_gui_main_loop_automatically
13
13
  def initialize(level=nil, width=450, height=400)
14
- Gtk.init
15
14
  super(*[level].compact)
16
15
  @width = width
17
16
  @height = height
@@ -61,8 +60,8 @@ module Rabbit
61
60
  end
62
61
 
63
62
  def append(text, *tags)
64
- iter = @buffer.get_iter_at_offset(-1)
65
- @buffer.insert_with_tags(iter, text.encode("UTF-8"), *tags)
63
+ iter = @buffer.get_iter_at(offset: -1)
64
+ @buffer.insert(iter, text.encode("UTF-8"), tags: tags)
66
65
  end
67
66
 
68
67
  def title
@@ -70,13 +69,12 @@ module Rabbit
70
69
  end
71
70
 
72
71
  def init_dialog(width=@width, height=@height)
73
- flags = 0
74
- buttons = [
75
- [Gtk::Stock::CLEAR, Gtk::Dialog::RESPONSE_CANCEL],
76
- [Gtk::Stock::CLOSE, Gtk::Dialog::RESPONSE_CLOSE],
77
- ]
78
- @dialog = Gtk::Dialog.new(title, nil, flags, *buttons)
79
- @dialog.vbox.add(init_buffer)
72
+ @dialog = Gtk::Dialog.new(title: title,
73
+ buttons: [
74
+ [Gtk::Stock::CLEAR, :cancel],
75
+ [Gtk::Stock::CLOSE, :close],
76
+ ])
77
+ @dialog.child.add(init_buffer)
80
78
  @dialog.set_default_size(width, height)
81
79
  @dialog.title = title
82
80
  set_dialog_delete
@@ -86,7 +84,7 @@ module Rabbit
86
84
 
87
85
  def set_dialog_delete
88
86
  @dialog.signal_connect("destroy") do |widget, event|
89
- exit if @current_severity >= Severity::FATAL
87
+ exit(false) if @current_severity >= Severity::FATAL
90
88
  true
91
89
  end
92
90
  end
@@ -94,9 +92,9 @@ module Rabbit
94
92
  def set_dialog_response
95
93
  @dialog.signal_connect("response") do |widget, event|
96
94
  case event
97
- when Gtk::Dialog::RESPONSE_CANCEL
95
+ when Gtk::ResponseType::CANCEL
98
96
  clear_buffer
99
- when Gtk::Dialog::RESPONSE_CLOSE
97
+ when Gtk::ResponseType::CLOSE
100
98
  quit
101
99
  end
102
100
  true
@@ -109,7 +107,7 @@ module Rabbit
109
107
  flags = Gtk::AccelFlags::VISIBLE
110
108
  Keys::QUIT_KEYS.each do |val|
111
109
  accel_group.connect(val, mod, flags) do
112
- @dialog.signal_emit("response", Gtk::Dialog::RESPONSE_CLOSE)
110
+ @dialog.signal_emit("response", Gtk::ResponseType::CLOSE)
113
111
  true
114
112
  end
115
113
  end
@@ -119,39 +117,39 @@ module Rabbit
119
117
  def init_buffer
120
118
  textview = Gtk::TextView.new
121
119
  textview.set_editable(false)
122
- textview.set_wrap_mode(Gtk::TextTag::WrapMode::WORD)
120
+ textview.set_wrap_mode(:word)
123
121
  @buffer = textview.buffer
124
122
  create_tags
125
123
  scrolled_window = Gtk::ScrolledWindow.new
126
- scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
124
+ scrolled_window.set_policy(:automatic, :automatic)
127
125
  scrolled_window.add(textview)
128
126
  scrolled_window
129
127
  end
130
128
 
131
129
  def create_tags
132
130
  @buffer.create_tag("DEBUG",
133
- "weight" => Pango::FontDescription::WEIGHT_BOLD,
131
+ "weight" => :bold,
134
132
  "foreground" => "blue")
135
133
  @buffer.create_tag("INFO", "foreground" => "blue")
136
- @buffer.create_tag("WARN", "foreground" => "red")
134
+ @buffer.create_tag("WARNING", "foreground" => "red")
137
135
  @buffer.create_tag("ERROR",
138
- "weight" => Pango::FontDescription::WEIGHT_BOLD,
136
+ "weight" => :bold,
139
137
  "foreground" => "red")
140
138
  @buffer.create_tag("FATAL",
141
139
  "foreground" => "yellow",
142
140
  "background" => "black")
143
141
  @buffer.create_tag("UNKNOWN",
144
- "weight" => Pango::FontDescription::WEIGHT_BOLD,
142
+ "weight" => :bold,
145
143
  "foreground" => "yellow",
146
144
  "background" => "black")
147
145
  @buffer.create_tag("ANY",
148
- "weight" => Pango::FontDescription::WEIGHT_BOLD)
146
+ "weight" => :bold)
149
147
  @buffer.create_tag("prog_name",
150
- "weight" => Pango::FontDescription::WEIGHT_BOLD,
148
+ "weight" => :bold,
151
149
  "foreground" => "blue",
152
150
  "left_margin" => 10)
153
151
  @buffer.create_tag("message",
154
- "weight" => Pango::FontDescription::WEIGHT_BOLD,
152
+ "weight" => :bold,
155
153
  "left_margin" => 10,
156
154
  "right_margin" => 10)
157
155
  end