rabbit 3.0.0 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -1
  3. data/data/locale/en/LC_MESSAGES/rabbit.mo +0 -0
  4. data/data/locale/ja/LC_MESSAGES/rabbit.mo +0 -0
  5. data/doc/_config.yml +2 -2
  6. data/doc/_layouts/skeleton.html +0 -7
  7. data/doc/en/faq.rd +4 -2
  8. data/doc/en/install/homebrew.rd +8 -13
  9. data/doc/en/news.rd +158 -0
  10. data/doc/en/sample/hiki/rabbit.hiki +0 -4
  11. data/doc/en/sample/rd/rabbit.rd +0 -4
  12. data/doc/en/usage/rabbit-slide.rd +3 -3
  13. data/doc/images/screenshots/en/blue-circle-raw.png +0 -0
  14. data/doc/images/screenshots/en/blue-circle.png +0 -0
  15. data/doc/images/screenshots/en/clear-blue-raw.png +0 -0
  16. data/doc/images/screenshots/en/clear-blue.png +0 -0
  17. data/doc/images/screenshots/en/cozmixng-raw.png +0 -0
  18. data/doc/images/screenshots/en/cozmixng.png +0 -0
  19. data/doc/images/screenshots/en/dark-gradation-raw.png +0 -0
  20. data/doc/images/screenshots/en/dark-gradation.png +0 -0
  21. data/doc/images/screenshots/en/day-white-raw.png +0 -0
  22. data/doc/images/screenshots/en/day-white.png +0 -0
  23. data/doc/images/screenshots/en/debian-raw.png +0 -0
  24. data/doc/images/screenshots/en/debian.png +0 -0
  25. data/doc/images/screenshots/en/green-circle-raw.png +0 -0
  26. data/doc/images/screenshots/en/green-circle.png +0 -0
  27. data/doc/images/screenshots/en/night-black-raw.png +0 -0
  28. data/doc/images/screenshots/en/night-black.png +0 -0
  29. data/doc/images/screenshots/en/rabbit-raw.png +0 -0
  30. data/doc/images/screenshots/en/rabbit.png +0 -0
  31. data/doc/images/screenshots/en/ranguba-raw.png +0 -0
  32. data/doc/images/screenshots/en/ranguba.png +0 -0
  33. data/doc/images/screenshots/en/red-frame-raw.png +0 -0
  34. data/doc/images/screenshots/en/red-frame.png +0 -0
  35. data/doc/images/screenshots/en/ruby-gnome2-raw.png +0 -0
  36. data/doc/images/screenshots/en/ruby-gnome2.png +0 -0
  37. data/doc/images/screenshots/en/rubykaigi2011-raw.png +0 -0
  38. data/doc/images/screenshots/en/rubykaigi2011.png +0 -0
  39. data/doc/images/screenshots/ja/blue-circle-raw.png +0 -0
  40. data/doc/images/screenshots/ja/blue-circle.png +0 -0
  41. data/doc/images/screenshots/ja/clear-blue-raw.png +0 -0
  42. data/doc/images/screenshots/ja/clear-blue.png +0 -0
  43. data/doc/images/screenshots/ja/cozmixng-raw.png +0 -0
  44. data/doc/images/screenshots/ja/cozmixng.png +0 -0
  45. data/doc/images/screenshots/ja/dark-gradation-raw.png +0 -0
  46. data/doc/images/screenshots/ja/dark-gradation.png +0 -0
  47. data/doc/images/screenshots/ja/day-white-raw.png +0 -0
  48. data/doc/images/screenshots/ja/day-white.png +0 -0
  49. data/doc/images/screenshots/ja/debian-raw.png +0 -0
  50. data/doc/images/screenshots/ja/debian.png +0 -0
  51. data/doc/images/screenshots/ja/green-circle-raw.png +0 -0
  52. data/doc/images/screenshots/ja/green-circle.png +0 -0
  53. data/doc/images/screenshots/ja/night-black-raw.png +0 -0
  54. data/doc/images/screenshots/ja/night-black.png +0 -0
  55. data/doc/images/screenshots/ja/rabbit-raw.png +0 -0
  56. data/doc/images/screenshots/ja/rabbit.png +0 -0
  57. data/doc/images/screenshots/ja/ranguba-raw.png +0 -0
  58. data/doc/images/screenshots/ja/ranguba.png +0 -0
  59. data/doc/images/screenshots/ja/red-frame-raw.png +0 -0
  60. data/doc/images/screenshots/ja/red-frame.png +0 -0
  61. data/doc/images/screenshots/ja/ruby-gnome2-raw.png +0 -0
  62. data/doc/images/screenshots/ja/ruby-gnome2.png +0 -0
  63. data/doc/images/screenshots/ja/rubykaigi2011-raw.png +0 -0
  64. data/doc/images/screenshots/ja/rubykaigi2011.png +0 -0
  65. data/doc/index.html.en +1 -1
  66. data/doc/ja/faq.rd +2 -0
  67. data/doc/ja/install/homebrew.rd +8 -12
  68. data/doc/ja/news.rd +157 -0
  69. data/doc/ja/sample/hiki/rabbit.hiki +0 -4
  70. data/doc/ja/sample/rd/rabbit.rd +0 -4
  71. data/doc/ja/usage/rabbit-slide.rd +3 -3
  72. data/doc/ja/users.rd +7 -0
  73. data/lib/rabbit/action/toggle.rb +7 -0
  74. data/lib/rabbit/author-configuration.rb +3 -4
  75. data/lib/rabbit/canvas.rb +18 -6
  76. data/lib/rabbit/command/rabbit-slide.rb +59 -1
  77. data/lib/rabbit/command/rabbit-slide.ui +127 -49
  78. data/lib/rabbit/command/rabbit.rb +5 -9
  79. data/lib/rabbit/element/base.rb +1 -5
  80. data/lib/rabbit/element/image.rb +139 -89
  81. data/lib/rabbit/element/video.rb +3 -11
  82. data/lib/rabbit/error.rb +9 -3
  83. data/lib/rabbit/formatter.rb +1 -1
  84. data/lib/rabbit/frame.rb +102 -4
  85. data/lib/rabbit/gem-pusher.rb +29 -6
  86. data/lib/rabbit/image/base.rb +163 -28
  87. data/lib/rabbit/image/dia.rb +21 -14
  88. data/lib/rabbit/image/mermaid.rb +73 -0
  89. data/lib/rabbit/image/pdf.rb +22 -9
  90. data/lib/rabbit/image/svg.rb +1 -4
  91. data/lib/rabbit/image.rb +6 -6
  92. data/lib/rabbit/info-window.rb +106 -80
  93. data/lib/rabbit/keys.rb +6 -0
  94. data/lib/rabbit/menu.rb +2 -0
  95. data/lib/rabbit/parser/base.rb +2 -1
  96. data/lib/rabbit/parser/ext/blockdiag.rb +16 -14
  97. data/lib/rabbit/parser/ext/charty.rb +58 -0
  98. data/lib/rabbit/parser/ext/image.rb +38 -10
  99. data/lib/rabbit/parser/markdown/converter.rb +36 -30
  100. data/lib/rabbit/parser/rd/ext/block-verbatim.rb +33 -35
  101. data/lib/rabbit/parser/rd/ext/image.rb +23 -4
  102. data/lib/rabbit/parser/rd/rd2rabbit-lib.rb +3 -1
  103. data/lib/rabbit/parser/rd.rb +1 -1
  104. data/lib/rabbit/parser/wiki/output.rb +9 -9
  105. data/lib/rabbit/parser.rb +2 -2
  106. data/lib/rabbit/progress.rb +1 -1
  107. data/lib/rabbit/properties.rb +154 -0
  108. data/lib/rabbit/rabbit.rb +3 -1
  109. data/lib/rabbit/relative-size.rb +28 -0
  110. data/lib/rabbit/renderer/base.rb +6 -0
  111. data/lib/rabbit/renderer/display/drawing-area-base.rb +1 -2
  112. data/lib/rabbit/renderer/display/drawing-area-primitive.rb +1 -0
  113. data/lib/rabbit/renderer/display/info.rb +6 -1
  114. data/lib/rabbit/renderer/display/key-handler.rb +27 -2
  115. data/lib/rabbit/renderer/engine/cairo.rb +24 -3
  116. data/lib/rabbit/renderer/screen.rb +0 -1
  117. data/lib/rabbit/slide-configuration.rb +16 -8
  118. data/lib/rabbit/task/slide.rb +6 -33
  119. data/lib/rabbit/theme/background-image-toolkit/background-image-toolkit.rb +38 -0
  120. data/lib/rabbit/theme/clear-blue/clear-blue.rb +4 -2
  121. data/lib/rabbit/theme/edge-info-toolkit/edge-info-toolkit.rb +12 -2
  122. data/lib/rabbit/theme/image/image.rb +3 -0
  123. data/lib/rabbit/theme/image-slide-number/image-slide-number.rb +8 -3
  124. data/lib/rabbit/theme/image-timer/image-timer.rb +8 -3
  125. data/lib/rabbit/theme/pdf/pdf.rb +1 -1
  126. data/lib/rabbit/theme/slide-footer-info/slide-footer-info.rb +2 -0
  127. data/lib/rabbit/theme/tag/tag.rb +9 -2
  128. data/lib/rabbit/theme-configuration.rb +3 -4
  129. data/lib/rabbit/utils.rb +25 -2
  130. data/lib/rabbit/version.rb +2 -2
  131. data/lib/rabbit/video-window.rb +14 -3
  132. data/{test/test-slideshare.rb → lib/rabbit/yaml-loader.rb} +20 -15
  133. data/po/en/rabbit.edit.po +123 -121
  134. data/po/en/rabbit.po +28 -26
  135. data/po/fr/rabbit.edit.po +122 -120
  136. data/po/fr/rabbit.po +27 -25
  137. data/po/ja/rabbit.edit.po +156 -125
  138. data/po/ja/rabbit.po +34 -30
  139. data/rabbit.gemspec +0 -1
  140. data/sample/can_rabbit.rd +0 -24
  141. data/sample/rabbit-en.hiki +0 -4
  142. data/sample/rabbit-en.md +13 -0
  143. data/sample/rabbit-en.rd +10 -4
  144. data/sample/rabbit.hiki +0 -4
  145. data/sample/rabbit.md +21 -0
  146. data/sample/rabbit.rd +20 -4
  147. data/test/command/test-rabbit.rb +1 -0
  148. data/test/parser/test-markdown.rb +2 -2
  149. data/test/test-slide-configuration.rb +4 -2
  150. metadata +30 -46
  151. data/doc/css/jquery-ui/themes/ui-lightness.css +0 -573
  152. data/doc/javascripts/jquery-ui.js +0 -11544
  153. data/doc/javascripts/jquery.js +0 -7179
  154. data/lib/rabbit/slideshare.rb +0 -192
@@ -0,0 +1,73 @@
1
+ # Copyright (C) 2022 Sutou Kouhei <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 "rabbit/image/pdf"
18
+
19
+ module Rabbit
20
+ module ImageManipulable
21
+ class Mermaid < Base
22
+
23
+ unshift_loader(self)
24
+
25
+ include SystemRunner
26
+
27
+ class << self
28
+ def match?(filename)
29
+ File.extname(filename).downcase.end_with?(".mmd")
30
+ end
31
+ end
32
+
33
+ delegate
34
+
35
+ def initialize(filename, props, canvas: nil)
36
+ init_delegated_loader(filename, props, canvas)
37
+ super
38
+ end
39
+
40
+ private
41
+ def init_delegated_loader(filename, props, canvas)
42
+ background_color = props["background_color"] || "transparent"
43
+ pdf_path = File.open(filename, "rb") do |source|
44
+ cache_processed_data(canvas, [source, background_color], "pdf") do
45
+ @pdf_file = Tempfile.new(["rabbit-image-loader-mermaid", ".pdf"])
46
+ command_line = [
47
+ "npx",
48
+ "--yes",
49
+ "--package=@mermaid-js/mermaid-cli",
50
+ "mmdc",
51
+ "--backgroundColor", background_color,
52
+ "--input", filename,
53
+ "--output", @pdf_file.path,
54
+ "--pdfFit",
55
+ ]
56
+ unless SystemRunner.run(*command_line)
57
+ format = _("tried mermaid command: %s")
58
+ additional_info = format % command_line.inspect
59
+ raise MermaidCanNotHandleError.new(command_line.join(' '),
60
+ additional_info)
61
+ end
62
+ @pdf_file.path
63
+ end
64
+ end
65
+ @delegated_loader = PDF.new(pdf_path, props)
66
+ end
67
+
68
+ def load_image
69
+ # do nothing
70
+ end
71
+ end
72
+ end
73
+ end
@@ -1,3 +1,19 @@
1
+ # Copyright (C) 2006-2022 Sutou Kouhei <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 "poppler"
2
18
 
3
19
  require "rabbit/gettext"
@@ -25,10 +41,7 @@ module Rabbit
25
41
 
26
42
  def draw(canvas, x, y, params={})
27
43
  if @document
28
- default_params = {
29
- :width => width,
30
- :height => height,
31
- }
44
+ default_params = default_draw_params(x, y)
32
45
  canvas.draw_poppler_page(page, x, y, default_params.merge(params))
33
46
  else
34
47
  super
@@ -39,6 +52,11 @@ module Rabbit
39
52
  @pixbuf ||= to_pixbuf
40
53
  end
41
54
 
55
+ def update_size
56
+ @document = Poppler::Document.new(uri)
57
+ @width, @height = page.size
58
+ end
59
+
42
60
  private
43
61
  def page
44
62
  index = self["page"] || 1
@@ -56,11 +74,6 @@ module Rabbit
56
74
  _page
57
75
  end
58
76
 
59
- def update_size
60
- @document = Poppler::Document.new(uri)
61
- @width, @height = page.size
62
- end
63
-
64
77
  def filename
65
78
  File.expand_path(@filename)
66
79
  end
@@ -42,10 +42,7 @@ module Rabbit
42
42
 
43
43
  def draw(canvas, x, y, params={})
44
44
  if @handle
45
- default_params = {
46
- :width => width,
47
- :height => height,
48
- }
45
+ default_params = default_draw_params(x, y)
49
46
  canvas.draw_rsvg_handle(@handle, x, y, default_params.merge(params))
50
47
  else
51
48
  super
data/lib/rabbit/image.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2004-2017 Kouhei Sutou <kou@cozmixng.org>
1
+ # Copyright (C) 2004-2020 Sutou Kouhei <kou@cozmixng.org>
2
2
  #
3
3
  # This program is free software; you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
@@ -16,12 +16,12 @@
16
16
 
17
17
  require "forwardable"
18
18
  require "tempfile"
19
- require 'thread'
20
19
 
21
20
  require "rabbit/image/default"
22
21
  require "rabbit/image/dia"
23
22
  require "rabbit/image/eps"
24
23
  require "rabbit/image/gimp"
24
+ require "rabbit/image/mermaid"
25
25
  require "rabbit/image/pdf"
26
26
  require "rabbit/image/svg"
27
27
 
@@ -29,21 +29,21 @@ module Rabbit
29
29
  module ImageManipulable
30
30
  extend Forwardable
31
31
 
32
- def_delegators(:@loader, :keep_ratio, :keep_ratio=)
32
+ def_delegators(:@loader, :keep_ratio, :keep_ratio?, :keep_ratio=)
33
33
  def_delegators(:@loader, :x_aspect_ratio, :y_aspect_ratio)
34
34
  def_delegators(:@loader, :pixbuf, :width, :height)
35
35
  def_delegators(:@loader, :original_width, :original_height)
36
36
  def_delegators(:@loader, :resize, :draw)
37
37
  def_delegators(:@loader, :[], :[]=)
38
+ def_delegators(:@loader, :properties)
38
39
  alias_method :scale, :resize
39
40
 
40
- def initialize(filename, props=nil, *args, &block)
41
+ def initialize(filename, props=nil, *args, canvas: nil, &block)
41
42
  unless File.exist?(filename)
42
43
  raise ImageFileDoesNotExistError.new(filename)
43
44
  end
44
45
  super(*args, &block)
45
- props = Utils.stringify_hash_key(props) if props
46
- @loader = Base.find_loader(filename).new(filename, props)
46
+ @loader = Base.find_loader(filename).new(filename, props, canvas: canvas)
47
47
  end
48
48
  end
49
49
 
@@ -62,7 +62,7 @@ module Rabbit
62
62
  @window.signal_handler_disconnect(@window_destroy_id)
63
63
  @window.destroy
64
64
  @window = @window_destroy_id = nil
65
- @canvas_widgets = @outer_box = nil
65
+ @canvas_widgets = @grid = nil
66
66
  GLib::Source.remove(@timer_id) if @timer_id
67
67
  @timer_id = nil
68
68
  @previous_canvas = @current_canvas = @next_canvas = nil
@@ -72,9 +72,9 @@ module Rabbit
72
72
  !@window.nil?
73
73
  end
74
74
 
75
- def moved(index)
75
+ def moved
76
76
  return unless showing?
77
- update(index)
77
+ update
78
78
  end
79
79
 
80
80
  def parsed
@@ -114,13 +114,14 @@ module Rabbit
114
114
  @window = Gtk::Window.new
115
115
  @window_destroy_id = @window.signal_connect("destroy") do
116
116
  @canvas.activate("ToggleInfoWindow")
117
+ Gdk::Event::PROPAGATE
117
118
  end
118
119
  @window.title = _("%s: Information window") % @canvas.title
119
120
  @window.set_default_size(width, height) if width and height
120
121
  if on_note_mode?
121
- init_widgets_on_note_mode(width, height)
122
+ init_widgets_on_note_mode
122
123
  else
123
- init_widgets(width, height)
124
+ init_widgets
124
125
  end
125
126
  init_menu
126
127
  attach_key(@window)
@@ -133,61 +134,91 @@ module Rabbit
133
134
  @window.add_events(event_mask)
134
135
  set_button_event(@window)
135
136
  set_scroll_event(@window)
136
- @window.add(@outer_box)
137
+ @window.add(@grid)
137
138
  end
138
139
 
139
- def init_widgets(width, height)
140
- init_timer_label(width * (1.0 / 3.0), height * (1.0 / 3.0))
141
- @outer_box = Gtk::Box.new(:vertical)
142
-
143
- current_box = Gtk::Box.new(:horizontal)
144
- @current_canvas.attach_to(nil, @window, current_box) do |container, widget|
145
- widget.set_size_request(width * (2.0 / 3.0), height * (2.0 / 3.0))
146
- container.pack_start(widget, :expand => true, :fill => false)
140
+ def init_widgets
141
+ init_timer_area
142
+ @grid = Gtk::Grid.new
143
+ @grid.column_homogeneous = true
144
+ @grid.row_homogeneous = true
145
+
146
+ base_width = 1
147
+ base_height = 1
148
+ @current_canvas.attach_to(nil, @window, @grid) do |container, widget|
149
+ container.attach(widget,
150
+ base_width,
151
+ 0,
152
+ base_width * 2,
153
+ base_height * 2)
147
154
  end
148
- @outer_box.pack_start(current_box, :expand => true, :fill => false)
149
155
 
150
- bottom_box = Gtk::Box.new(:horizontal)
151
- @previous_canvas.attach_to(nil, @window, bottom_box) do |container, widget|
152
- widget.set_size_request(width * (1.0 / 3.0), height * (1.0 / 3.0))
153
- container.pack_start(widget, :expand => false, :fill => false)
156
+ @previous_canvas.attach_to(nil, @window, @grid) do |container, widget|
157
+ container.attach(widget,
158
+ 0,
159
+ base_height * 2,
160
+ base_width,
161
+ base_height)
154
162
  end
155
- bottom_box.pack_start(@timer_label, :expand => true, :fill => false)
156
- @next_canvas.attach_to(nil, @window, bottom_box) do |container, widget|
157
- widget.set_size_request(width * (1.0 / 3.0), height * (1.0 / 3.0))
158
- container.pack_end(widget, :expand => false, :fill => false)
163
+ @next_canvas.attach_to(nil, @window, @grid) do |container, widget|
164
+ container.attach(widget,
165
+ base_width * 3,
166
+ base_height * 2,
167
+ base_width,
168
+ base_height)
159
169
  end
160
- @outer_box.pack_end(bottom_box, :expand => false, :fill => false)
161
170
 
162
- @outer_box.show
171
+ @grid.attach(@timer_area,
172
+ base_width,
173
+ base_height * 2,
174
+ base_width * 2,
175
+ base_height)
176
+
177
+ @grid.show
163
178
  end
164
179
 
165
- def init_widgets_on_note_mode(width, height)
166
- init_timer_label(width * (1.0 / 5.0), height * (2.0 / 5.0))
180
+ def init_widgets_on_note_mode
181
+ init_timer_area
167
182
  init_note_area
168
- @outer_box = Gtk::Box.new(:vertical)
169
-
170
- current_box = Gtk::Box.new(:horizontal)
171
- current_box.pack_start(@timer_label, :expand => false, :fill => false)
172
- @previous_canvas.attach_to(nil, @window, current_box) do |container, widget|
173
- widget.set_size_request(width * (1.0 / 5.0), height * (2.0 / 5.0))
174
- container.pack_start(widget, :expand => true, :fill => true, :padding => 10)
183
+ @grid = Gtk::Grid.new
184
+ @grid.column_homogeneous = true
185
+ @grid.row_homogeneous = true
186
+
187
+ base_width = 1
188
+ base_height = 4
189
+ @previous_canvas.attach_to(nil, @window, @grid) do |container, widget|
190
+ container.attach(widget,
191
+ 0,
192
+ 0,
193
+ base_width,
194
+ base_height)
175
195
  end
176
- @current_canvas.attach_to(nil, @window, current_box) do |container, widget|
177
- widget.set_size_request(width * (2.0 / 5.0), height * (2.0 / 5.0))
178
- container.pack_start(widget, :expand => true, :fill => true)
196
+ @current_canvas.attach_to(nil, @window, @grid) do |container, widget|
197
+ container.attach(widget,
198
+ base_width,
199
+ 0,
200
+ base_width * 2,
201
+ base_height)
179
202
  end
180
- @next_canvas.attach_to(nil, @window, current_box) do |container, widget|
181
- widget.set_size_request(width * (1.0 / 5.0), height * (2.0 / 5.0))
182
- container.pack_end(widget, :expand => true, :fill => true, :padding => 10)
203
+ @next_canvas.attach_to(nil, @window, @grid) do |container, widget|
204
+ container.attach(widget,
205
+ base_width * 3,
206
+ 0,
207
+ base_width,
208
+ base_height)
183
209
  end
184
- @outer_box.pack_start(current_box, :expand => false, :fill => false)
185
-
186
- bottom_box = Gtk::Box.new(:horizontal)
187
- bottom_box.pack_start(@note_area, :expand => true, :fill => true, :padding => 20)
188
- @outer_box.pack_start(bottom_box, :expand => true, :fill => true, :padding => 20)
189
210
 
190
- @outer_box.show
211
+ @grid.attach(@note_area,
212
+ 0,
213
+ base_height,
214
+ base_width * 4,
215
+ base_height)
216
+ @grid.attach(@timer_area,
217
+ 0,
218
+ base_height * 2,
219
+ base_width * 4,
220
+ 1)
221
+ @grid.show
191
222
  end
192
223
 
193
224
  def init_canvas_widgets
@@ -196,10 +227,16 @@ module Rabbit
196
227
  @next_canvas.attach_to(nil, @window, @canvas_widgets)
197
228
  end
198
229
 
199
- def init_timer_label(width, height)
200
- @timer_label = Gtk::Label.new
201
- @timer_label.justify = :center
202
- @timer_label.markup = markupped_timer_label(width, height)
230
+ def init_timer_area
231
+ @timer_area = Gtk::DrawingArea.new
232
+ @timer_area.signal_connect("draw") do |area, context|
233
+ context.set_source_rgb(1, 0, 0) if rest_time and rest_time < 0
234
+ draw_text_as_large_as_possible(area,
235
+ context,
236
+ timer_text,
237
+ alignment: :center)
238
+ Gdk::Event::PROPAGATE
239
+ end
203
240
  end
204
241
 
205
242
  def init_note_area
@@ -210,10 +247,10 @@ module Rabbit
210
247
  end
211
248
  end
212
249
 
213
- def update(index=nil)
250
+ def update
214
251
  start_timer if @timer_id.nil?
215
252
  @note_area.queue_draw if @note_area
216
- adjust_slide(index)
253
+ adjust_slide
217
254
  end
218
255
 
219
256
  def note_text
@@ -222,10 +259,14 @@ module Rabbit
222
259
  note.gsub(/\\n/, "\n")
223
260
  end
224
261
 
225
- def draw_text_as_large_as_possible(area, context, markupped_text)
262
+ def draw_text_as_large_as_possible(area,
263
+ context,
264
+ markupped_text,
265
+ options={})
226
266
  return if markupped_text.nil?
227
267
 
228
- area_width, area_height = area.window.size
268
+ area_width = area.window.width
269
+ area_height = area.window.height
229
270
 
230
271
  layout = context.create_pango_layout
231
272
  layout.context.resolution = @canvas.font_resolution
@@ -234,6 +275,9 @@ module Rabbit
234
275
  layout.attributes = attributes
235
276
  layout.width = area_width * Pango::SCALE
236
277
  layout.wrap = :word_char
278
+ layout.alignment = options[:alignment] if options.key?(:alignment)
279
+
280
+ layout.justify = options[:justify] if options.key?(:justify)
237
281
  set_as_large_as_font_description(layout, area_height)
238
282
 
239
283
  context.update_pango_layout(layout)
@@ -258,8 +302,8 @@ module Rabbit
258
302
 
259
303
  def start_timer
260
304
  @timer_id = GLib::Timeout.add(1000) do
261
- @timer_label.markup = markupped_timer_label if showing?
262
305
  if showing? and @canvas.rest_time
306
+ @timer_area.queue_draw
263
307
  GLib::Source::CONTINUE
264
308
  else
265
309
  @timer_id = nil
@@ -268,19 +312,11 @@ module Rabbit
268
312
  end
269
313
  end
270
314
 
271
- def markupped_timer_label(width=nil, height=nil)
272
- width ||= @window.size[0] * (1.0 / 3.0)
273
- height ||= @window.size[1] * (1.0 / 3.0)
274
- attrs = {}
275
- font_size = on_note_mode? ? 100 : 200
276
- attrs["font_desc"] = ((height * font_size) / Pango::SCALE).to_s
277
- rest_time = @canvas.rest_time
278
- attrs["foreground"] = "red" if rest_time and rest_time < 0
279
- PangoMarkup.new("span", attrs, timer_label).to_s
315
+ def rest_time
316
+ @canvas.rest_time || @canvas.allotted_time
280
317
  end
281
318
 
282
- def timer_label
283
- rest_time = @canvas.rest_time || @canvas.allotted_time
319
+ def timer_text
284
320
  if rest_time
285
321
  "%s%02d:%02d" % Utils.split_number_to_minute_and_second(rest_time)
286
322
  else
@@ -288,18 +324,6 @@ module Rabbit
288
324
  end
289
325
  end
290
326
 
291
- def markupped_note_text(width=nil, height=nil)
292
- height ||= @window.size[1] * (3.0 / 5.0)
293
- if @canvas.current_slide["note"]
294
- text = @canvas.current_slide["note"].gsub(/\\n/, "\n")
295
- else
296
- text = ""
297
- end
298
- attrs = {}
299
- attrs["font_desc"] = ((height * 40) / Pango::SCALE).to_s
300
- PangoMarkup.new("span", attrs, text).to_s
301
- end
302
-
303
327
  def update_source
304
328
  each do |canvas|
305
329
  source = Source::Memory.new("UTF-8", @canvas.logger)
@@ -319,10 +343,12 @@ module Rabbit
319
343
  end
320
344
  end
321
345
 
322
- def adjust_slide(base_index=nil)
323
- base_index ||= @canvas.current_index
346
+ def adjust_slide
347
+ base_index = @canvas.current_index
324
348
  @previous_canvas.move_to_if_can([base_index - 1, 0].max)
325
349
  @current_canvas.move_to_if_can(base_index)
350
+ @current_canvas.current_slide.drawing_index =
351
+ @canvas.current_slide.drawing_index
326
352
  @next_canvas.move_to_if_can([base_index + 1, @canvas.slide_size - 1].min)
327
353
  end
328
354
 
data/lib/rabbit/keys.rb CHANGED
@@ -178,5 +178,11 @@ module Rabbit
178
178
  Gdk::Keyval::KEY_t,
179
179
  ]
180
180
  end
181
+
182
+ module ShiftControlAlt
183
+ TOGGLE_TERMINAL_KEYS = [
184
+ Gdk::Keyval::KEY_t,
185
+ ]
186
+ end
181
187
  end
182
188
  end
data/lib/rabbit/menu.rb CHANGED
@@ -260,6 +260,8 @@ module Rabbit
260
260
  [:item, "ToggleSpotlight"],
261
261
  [:item, "ToggleMagnifier"],
262
262
  [:separator],
263
+ [:item, "ToggleTerminal"],
264
+ [:separator],
263
265
  [:menu, "JumpTo"],
264
266
  [:separator],
265
267
  [:item, "Previous"],
@@ -5,9 +5,10 @@ module Rabbit
5
5
  class Base
6
6
  extend ModuleLoader
7
7
 
8
- def initialize(canvas, source)
8
+ def initialize(canvas, source, progress: nil)
9
9
  @canvas = canvas
10
10
  @source = source
11
+ @progress = progress
11
12
  end
12
13
  end
13
14
  end
@@ -9,29 +9,31 @@ module Rabbit
9
9
  # "font" is treated as specially.
10
10
  AVAILABLE_VALUE_OPTIONS = []
11
11
  def make_image(path, prop, logger)
12
- image_file = Tempfile.new("rabbit-image-blockdiag")
13
- command = [
14
- "blockdiag",
12
+ image_file = Tempfile.new(["rabbit-image-blockdiag", ".svg"])
13
+ command_line = [
15
14
  "-T", "svg",
16
15
  "-o", image_file.path,
17
16
  ]
18
17
  font = find_font(prop)
19
- command.concat(["-f", font]) if font
18
+ command_line.concat(["-f", font]) if font
20
19
  AVAILABLE_FLAG_OPTIONS.each do |name|
21
- command << "--#{name}" if /\A(?:true|yes)\z/i =~ prop[name].to_s
20
+ command_line << "--#{name}" if /\A(?:true|yes)\z/i =~ prop[name].to_s
22
21
  end
23
22
  AVAILABLE_VALUE_OPTIONS.each do |name|
24
- command.concat(["--#{name}", prop[name]]) if prop.has_key?(name)
23
+ command_line.concat(["--#{name}", prop[name]]) if prop.has_key?(name)
25
24
  end
26
- command << path
27
- if SystemRunner.run(*command)
28
- image_file
29
- else
30
- format = _("tried blockdiag command: %s")
31
- additional_info = format % command.inspect
32
- raise BlockDiagCanNotHandleError.new(command.join(' '),
33
- additional_info)
25
+ command_line << path
26
+ blockdiag_commands = ["blockdiag3", "blockdiag"]
27
+ blockdiag_commands.each do |blockdiag|
28
+ if SystemRunner.run(blockdiag, *command_line)
29
+ return image_file
30
+ end
34
31
  end
32
+ command_line.unshift(blockdiag_commands.first)
33
+ format = _("tried blockdiag command: %s")
34
+ additional_info = format % command_line
35
+ raise BlockDiagCanNotHandleError.new(command_line.join(' '),
36
+ additional_info)
35
37
  end
36
38
 
37
39
  def find_font(prop)
@@ -0,0 +1,58 @@
1
+ # Copyright (C) 2021 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 "csv"
18
+
19
+ module Rabbit
20
+ module Parser
21
+ module Ext
22
+ module Charty
23
+ include GetText
24
+
25
+ module_function
26
+ def make_image(path, prop, logger)
27
+ require "charty"
28
+ backend = prop["backend"]
29
+ ::Charty::Backends.use(backend) if backend
30
+ data = CSV.read(path, headers: true, converters: :all)
31
+ type = prop["type"]
32
+ case type
33
+ when "bar"
34
+ plotter = ::Charty.bar_plot(data: data,
35
+ x: prop["x"],
36
+ y: prop["y"],
37
+ color: prop["color"])
38
+ when "line"
39
+ plotter = ::Charty.line_plot(data: data,
40
+ x: prop["x"],
41
+ y: prop["y"],
42
+ color: prop["color"])
43
+ when "scatter"
44
+ plotter = ::Charty.scatter_plot(data: data,
45
+ x: prop["x"],
46
+ y: prop["y"],
47
+ color: prop["color"])
48
+ else
49
+ raise ArgumentError, "charty: unsupported type: #{type.inspect}"
50
+ end
51
+ image_file = Tempfile.new(["rabbit-image-charty", ".svg"])
52
+ plotter.save(image_file.path)
53
+ image_file
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end