rabbit 3.0.5 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. checksums.yaml +4 -4
  2. data/data/locale/ja/LC_MESSAGES/rabbit.mo +0 -0
  3. data/doc/_config.yml +2 -2
  4. data/doc/en/news.rd +54 -0
  5. data/doc/ja/news.rd +54 -0
  6. data/lib/rabbit/actions.rb +446 -0
  7. data/lib/rabbit/author-configuration.rb +7 -10
  8. data/lib/rabbit/canvas.rb +74 -42
  9. data/lib/rabbit/command/rabbit-slide.rb +11 -13
  10. data/lib/rabbit/command/rabbit-theme.rb +10 -12
  11. data/lib/rabbit/command/rabbit.rb +31 -43
  12. data/lib/rabbit/console.rb +20 -22
  13. data/lib/rabbit/dependency-canvas.rb +2 -2
  14. data/lib/rabbit/element/base.rb +93 -6
  15. data/lib/rabbit/element/block-element.rb +17 -1
  16. data/lib/rabbit/element/block.rb +17 -1
  17. data/lib/rabbit/element/container-element.rb +59 -3
  18. data/lib/rabbit/element/description-list.rb +18 -2
  19. data/lib/rabbit/element/enum-list.rb +18 -2
  20. data/lib/rabbit/element/footnote.rb +18 -2
  21. data/lib/rabbit/element/image-title-slide.rb +17 -1
  22. data/lib/rabbit/element/image.rb +32 -2
  23. data/lib/rabbit/element/index-slide.rb +29 -13
  24. data/lib/rabbit/element/item-list.rb +18 -2
  25. data/lib/rabbit/element/method-list.rb +18 -2
  26. data/lib/rabbit/element/poppler-page.rb +17 -1
  27. data/lib/rabbit/element/poppler-slide.rb +18 -2
  28. data/lib/rabbit/element/poppler-title-slide.rb +18 -2
  29. data/lib/rabbit/element/preformatted.rb +18 -2
  30. data/lib/rabbit/element/slide-element.rb +29 -2
  31. data/lib/rabbit/element/slide.rb +18 -2
  32. data/lib/rabbit/element/syntax-highlighting.rb +17 -1
  33. data/lib/rabbit/element/table.rb +19 -3
  34. data/lib/rabbit/element/tag.rb +18 -2
  35. data/lib/rabbit/element/text-block-element.rb +18 -2
  36. data/lib/rabbit/element/text-container-element.rb +41 -2
  37. data/lib/rabbit/element/text-element.rb +17 -1
  38. data/lib/rabbit/element/text-renderer.rb +17 -1
  39. data/lib/rabbit/element/text.rb +4 -4
  40. data/lib/rabbit/element/title-slide.rb +19 -3
  41. data/lib/rabbit/element/video.rb +157 -56
  42. data/lib/rabbit/element.rb +20 -20
  43. data/lib/rabbit/formatter.rb +18 -1
  44. data/lib/rabbit/frame.rb +102 -90
  45. data/lib/rabbit/front.rb +11 -4
  46. data/lib/rabbit/gem-finder.rb +4 -8
  47. data/lib/rabbit/gem-pusher.rb +4 -4
  48. data/lib/rabbit/gesture/handler.rb +26 -21
  49. data/lib/rabbit/graffiti/config-dialog.rb +18 -2
  50. data/lib/rabbit/graffiti/processor.rb +20 -4
  51. data/lib/rabbit/gtk.rb +48 -14
  52. data/lib/rabbit/html/generator.rb +18 -18
  53. data/{test/helper/fixture.rb → lib/rabbit/icon.rb} +16 -6
  54. data/lib/rabbit/image/base.rb +7 -6
  55. data/lib/rabbit/image/default.rb +17 -1
  56. data/lib/rabbit/image/dia.rb +2 -2
  57. data/lib/rabbit/image/eps.rb +16 -2
  58. data/lib/rabbit/image/gimp.rb +28 -11
  59. data/lib/rabbit/image/mermaid.rb +3 -3
  60. data/lib/rabbit/image/pdf.rb +3 -3
  61. data/lib/rabbit/image/svg.rb +2 -2
  62. data/lib/rabbit/image.rb +8 -8
  63. data/lib/rabbit/info-window.rb +55 -18
  64. data/lib/rabbit/key-handler.rb +381 -0
  65. data/lib/rabbit/keys.rb +31 -2
  66. data/lib/rabbit/logger/base.rb +17 -1
  67. data/lib/rabbit/logger/gui.rb +20 -4
  68. data/lib/rabbit/logger/stderr.rb +16 -2
  69. data/lib/rabbit/logger.rb +4 -4
  70. data/lib/rabbit/menu.rb +200 -220
  71. data/lib/rabbit/parser/base.rb +17 -1
  72. data/lib/rabbit/parser/ext/aafigure.rb +17 -1
  73. data/lib/rabbit/parser/ext/blockdiag.rb +17 -1
  74. data/lib/rabbit/parser/ext/charty.rb +2 -2
  75. data/lib/rabbit/parser/ext/coderay.rb +20 -4
  76. data/lib/rabbit/parser/ext/enscript.rb +31 -15
  77. data/lib/rabbit/parser/ext/entity.rb +17 -1
  78. data/lib/rabbit/parser/ext/image.rb +6 -6
  79. data/lib/rabbit/parser/ext/inline.rb +17 -1
  80. data/lib/rabbit/parser/ext/rouge.rb +7 -4
  81. data/lib/rabbit/parser/ext/tex.rb +18 -2
  82. data/lib/rabbit/parser/ext/video.rb +4 -4
  83. data/lib/rabbit/parser/image.rb +20 -4
  84. data/lib/rabbit/parser/markdown/converter.rb +12 -13
  85. data/lib/rabbit/parser/markdown.rb +18 -2
  86. data/lib/rabbit/parser/pause-support.rb +1 -0
  87. data/lib/rabbit/parser/pdf.rb +3 -3
  88. data/lib/rabbit/parser/rd/ext/base.rb +20 -4
  89. data/lib/rabbit/parser/rd/ext/block-verbatim.rb +24 -28
  90. data/lib/rabbit/parser/rd/ext/character-reference.rb +18 -2
  91. data/lib/rabbit/parser/rd/ext/image.rb +3 -3
  92. data/lib/rabbit/parser/rd/ext/inline-verbatim.rb +6 -6
  93. data/lib/rabbit/parser/rd/ext/refer.rb +18 -2
  94. data/lib/rabbit/parser/rd/ext/video.rb +19 -2
  95. data/lib/rabbit/parser/rd/rd2rabbit-lib.rb +24 -8
  96. data/lib/rabbit/parser/rd/rt/rt2rabbit-lib.rb +18 -2
  97. data/lib/rabbit/parser/rd/visitor.rb +18 -2
  98. data/lib/rabbit/parser/rd.rb +18 -2
  99. data/lib/rabbit/parser/wiki/output.rb +25 -28
  100. data/lib/rabbit/parser/wiki.rb +18 -2
  101. data/lib/rabbit/parser.rb +6 -6
  102. data/lib/rabbit/path-manipulatable.rb +4 -4
  103. data/lib/rabbit/progress.rb +17 -1
  104. data/lib/rabbit/properties.rb +3 -3
  105. data/lib/rabbit/rabbit.rb +15 -7
  106. data/lib/rabbit/readme-parser.rb +4 -6
  107. data/lib/rabbit/renderer/base.rb +44 -36
  108. data/lib/rabbit/renderer/color.rb +18 -2
  109. data/lib/rabbit/renderer/display/base.rb +10 -12
  110. data/lib/rabbit/renderer/display/button-handler.rb +141 -60
  111. data/lib/rabbit/renderer/display/cursor.rb +4 -5
  112. data/lib/rabbit/renderer/display/drawing-area-base.rb +32 -48
  113. data/lib/rabbit/renderer/display/drawing-area-primitive.rb +10 -61
  114. data/lib/rabbit/renderer/display/drawing-area-view-only.rb +19 -8
  115. data/lib/rabbit/renderer/display/drawing-area.rb +19 -15
  116. data/lib/rabbit/renderer/display/gesture.rb +9 -9
  117. data/lib/rabbit/renderer/display/graffiti.rb +22 -13
  118. data/lib/rabbit/renderer/display/info.rb +22 -2
  119. data/lib/rabbit/renderer/display/magnifier.rb +30 -17
  120. data/lib/rabbit/renderer/display/mask.rb +17 -1
  121. data/lib/rabbit/renderer/display/menu.rb +27 -3
  122. data/lib/rabbit/renderer/display/motion-handler.rb +45 -0
  123. data/lib/rabbit/renderer/display/progress.rb +17 -2
  124. data/lib/rabbit/renderer/display/scroll-handler.rb +60 -13
  125. data/lib/rabbit/renderer/display/search.rb +19 -2
  126. data/lib/rabbit/renderer/display/spotlight.rb +39 -25
  127. data/lib/rabbit/renderer/display.rb +16 -36
  128. data/lib/rabbit/renderer/engine/cairo.rb +4 -11
  129. data/lib/rabbit/renderer/engine.rb +17 -1
  130. data/lib/rabbit/renderer/kernel.rb +2 -20
  131. data/lib/rabbit/renderer/offscreen.rb +8 -14
  132. data/lib/rabbit/renderer/print-layout.rb +2 -2
  133. data/lib/rabbit/renderer/printer.rb +9 -16
  134. data/lib/rabbit/renderer/scene-background-widget.rb +95 -0
  135. data/lib/rabbit/renderer/scene-node-widget.rb +63 -0
  136. data/lib/rabbit/renderer/scene.rb +508 -0
  137. data/lib/rabbit/renderer.rb +6 -6
  138. data/lib/rabbit/search-window.rb +18 -2
  139. data/lib/rabbit/searcher.rb +15 -1
  140. data/lib/rabbit/size.rb +9 -1
  141. data/lib/rabbit/slide-configuration.rb +11 -14
  142. data/lib/rabbit/soap/driver.rb +20 -4
  143. data/lib/rabbit/soap/server.rb +17 -1
  144. data/lib/rabbit/source/argf.rb +5 -5
  145. data/lib/rabbit/source/base.rb +5 -6
  146. data/lib/rabbit/source/file.rb +5 -5
  147. data/lib/rabbit/source/memory.rb +20 -4
  148. data/lib/rabbit/source/uri.rb +9 -11
  149. data/lib/rabbit/source-generator/hiki.rb +2 -7
  150. data/lib/rabbit/source-generator/markdown.rb +2 -7
  151. data/lib/rabbit/source-generator/rd.rb +2 -7
  152. data/lib/rabbit/source-generator.rb +4 -4
  153. data/lib/rabbit/source.rb +5 -5
  154. data/lib/rabbit/task/slide.rb +13 -11
  155. data/lib/rabbit/task/theme.rb +8 -11
  156. data/lib/rabbit/task.rb +3 -3
  157. data/lib/rabbit/theme/applier.rb +27 -11
  158. data/lib/rabbit/theme/clear-blue/clear-blue.rb +1 -1
  159. data/lib/rabbit/theme/color-circle/color-circle.rb +18 -1
  160. data/lib/rabbit/theme/cozmixng/cozmixng.rb +1 -1
  161. data/lib/rabbit/theme/default/default.rb +1 -0
  162. data/lib/rabbit/theme/default-icon/default-icon.rb +1 -1
  163. data/lib/rabbit/theme/default-item-mark-setup/default-item-mark-setup.rb +17 -1
  164. data/lib/rabbit/theme/default-preformatted/default-preformatted.rb +9 -1
  165. data/lib/rabbit/theme/enishi-green/enishi-green.rb +1 -1
  166. data/lib/rabbit/theme/entry.rb +10 -12
  167. data/lib/rabbit/theme/icon/icon.rb +3 -8
  168. data/lib/rabbit/theme/image-slide-number/image-slide-number.rb +5 -5
  169. data/lib/rabbit/theme/image-timer/image-timer.rb +3 -3
  170. data/lib/rabbit/theme/lightning-simple/lightning-simple.rb +1 -0
  171. data/lib/rabbit/theme/lightning-talk/lightning-talk.rb +1 -0
  172. data/lib/rabbit/theme/manager.rb +19 -9
  173. data/lib/rabbit/theme/rabbit-icon/rabbit-icon.rb +1 -1
  174. data/lib/rabbit/theme/ranguba/ranguba.rb +1 -1
  175. data/lib/rabbit/theme/red-frame/red-frame.rb +6 -2
  176. data/lib/rabbit/theme/ruby-gnome2/ruby-gnome2.rb +1 -0
  177. data/lib/rabbit/theme/ruby-gnome2-icon/ruby-gnome2-icon.rb +1 -1
  178. data/lib/rabbit/theme/searcher.rb +23 -7
  179. data/lib/rabbit/theme/slide-number/slide-number.rb +1 -1
  180. data/lib/rabbit/theme/slide-show/slide-show.rb +1 -1
  181. data/lib/rabbit/theme/table/table.rb +2 -2
  182. data/lib/rabbit/theme/video/property.rb +3 -0
  183. data/lib/rabbit/theme/video/video.rb +5 -0
  184. data/lib/rabbit/theme-configuration.rb +9 -11
  185. data/lib/rabbit/utils.rb +12 -94
  186. data/lib/rabbit/version.rb +1 -1
  187. data/lib/rabbit/xmlrpc/client.rb +17 -1
  188. data/lib/rabbit/xmlrpc/server.rb +17 -1
  189. data/po/en/rabbit.edit.po +324 -316
  190. data/po/en/rabbit.po +61 -55
  191. data/po/fr/rabbit.edit.po +324 -316
  192. data/po/fr/rabbit.po +61 -55
  193. data/po/ja/rabbit.edit.po +345 -370
  194. data/po/ja/rabbit.po +83 -80
  195. data/rabbit.gemspec +4 -2
  196. data/sample/block-quote.rab +13 -0
  197. data/sample/description-list.rab +17 -0
  198. data/sample/mermaid.rab +16 -0
  199. data/sample/rabbit-en.hiki +0 -1
  200. data/sample/rabbit-en.md +0 -1
  201. data/sample/rabbit-en.rd +0 -1
  202. data/sample/rabbit.hiki +0 -1
  203. data/sample/rabbit.md +0 -1
  204. data/sample/rabbit.rd +0 -1
  205. data/sample/video.rab +17 -0
  206. metadata +33 -65
  207. data/lib/rabbit/action/basic.rb +0 -304
  208. data/lib/rabbit/action/radio.rb +0 -78
  209. data/lib/rabbit/action/toggle.rb +0 -82
  210. data/lib/rabbit/action.rb +0 -140
  211. data/lib/rabbit/renderer/display/gl.rb +0 -98
  212. data/lib/rabbit/renderer/display/key-handler.rb +0 -321
  213. data/lib/rabbit/renderer/gl.rb +0 -95
  214. data/lib/rabbit/renderer/screen.rb +0 -286
  215. data/lib/rabbit/renderer/widget/drawing-area.rb +0 -93
  216. data/lib/rabbit/stock.rb +0 -31
  217. data/lib/rabbit/trackball.rb +0 -228
  218. data/lib/rabbit/video-window.rb +0 -123
  219. data/test/command/test-rabbit.rb +0 -101
  220. data/test/helper/parser.rb +0 -48
  221. data/test/helper.rb +0 -24
  222. data/test/image/test-dia.rb +0 -54
  223. data/test/image/test-eps.rb +0 -41
  224. data/test/parser/test-markdown.rb +0 -360
  225. data/test/parser/test-rd.rb +0 -43
  226. data/test/parser/test-wiki.rb +0 -71
  227. data/test/run-test.rb +0 -27
  228. data/test/source-generator/test-hiki.rb +0 -68
  229. data/test/source-generator/test-markdown.rb +0 -67
  230. data/test/source-generator/test-rd.rb +0 -69
  231. data/test/test-applier.rb +0 -73
  232. data/test/test-author-configuration.rb +0 -37
  233. data/test/test-canvas.rb +0 -70
  234. data/test/test-color.rb +0 -51
  235. data/test/test-element.rb +0 -103
  236. data/test/test-readme-parser.rb +0 -160
  237. data/test/test-size.rb +0 -155
  238. data/test/test-slide-configuration.rb +0 -74
  239. data/test/test-source.rb +0 -122
  240. data/test/test-theme-configuration.rb +0 -47
  241. data/test/test-utils.rb +0 -64
data/lib/rabbit/front.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2005-2019 Kouhei Sutou <kou@cozmixng.org>
1
+ # Copyright (C) 2005-2025 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,8 +16,8 @@
16
16
 
17
17
  require "monitor"
18
18
 
19
- require "rabbit/rabbit"
20
- require "rabbit/utils"
19
+ require_relative "rabbit"
20
+ require_relative "utils"
21
21
 
22
22
  module Rabbit
23
23
 
@@ -109,8 +109,15 @@ module Rabbit
109
109
  @canvas.slide_title
110
110
  end
111
111
 
112
+ def n_slides
113
+ @canvas.n_slides
114
+ end
115
+
112
116
  def total_slide_number
113
- @canvas.slide_size
117
+ warn("#{self.class.name}\##{__method__} is deprecated. " +
118
+ "Use \#n_slides instead.",
119
+ category: :deprecated)
120
+ n_slides
114
121
  end
115
122
 
116
123
  def current_slide_number
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012 Kouhei Sutou <kou@cozmixng.org>
1
+ # Copyright (C) 2012-2025 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
@@ -14,16 +14,12 @@
14
14
  # with this program; if not, write to the Free Software Foundation, Inc.,
15
15
  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
16
 
17
- require "rabbit/gettext"
17
+ require_relative "gettext"
18
18
 
19
19
  module Rabbit
20
20
  class GemFinder
21
21
  include GetText
22
22
 
23
- def initialize(logger=nil)
24
- @logger = logger || Logger.default
25
- end
26
-
27
23
  def find(name, prefix)
28
24
  normalized_name = name.downcase
29
25
  unless normalized_name.start_with?(prefix)
@@ -43,11 +39,11 @@ module Rabbit
43
39
  require "rubygems/dependency_installer"
44
40
  options = {}
45
41
  if File.writable?(Gem.dir)
46
- @logger.info(_("Installing gem: %s") % normalized_name)
42
+ Rabbit.logger.info(_("Installing gem: %s") % normalized_name)
47
43
  else
48
44
  options[:user_install] = true
49
45
  format = _("Installing gem in user install mode: %s")
50
- @logger.info(format % normalized_name)
46
+ Rabbit.logger.info(format % normalized_name)
51
47
  end
52
48
  installer = Gem::DependencyInstaller.new(options)
53
49
  installer.install(normalized_name, Gem::Requirement.default)
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016-2023 Sutou Kouhei <kou@cozmixng.org>
1
+ # Copyright (C) 2016-2025 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
@@ -17,9 +17,9 @@
17
17
  require "rake"
18
18
  require "open-uri"
19
19
 
20
- require "rabbit/gettext"
21
- require "rabbit/password-reader"
22
- require "rabbit/yaml-loader"
20
+ require_relative "gettext"
21
+ require_relative "password-reader"
22
+ require_relative "yaml-loader"
23
23
 
24
24
  module Rabbit
25
25
  class GemPusher
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2006-2024 Sutou Kouhei <kou@cozmixng.org>
1
+ # Copyright (C) 2006-2025 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
@@ -14,11 +14,11 @@
14
14
  # with this program; if not, write to the Free Software Foundation, Inc.,
15
15
  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
16
 
17
- require 'rabbit/gtk'
17
+ require_relative "../gtk"
18
18
 
19
- require 'rabbit/rabbit'
20
- require 'rabbit/renderer/engine'
21
- require 'rabbit/gesture/processor'
19
+ require_relative "../rabbit"
20
+ require_relative "../renderer/engine"
21
+ require_relative "processor"
22
22
 
23
23
  module Rabbit
24
24
  module Gesture
@@ -35,6 +35,7 @@ module Rabbit
35
35
  attr_accessor :line_width, :next_width
36
36
  def initialize(conf={})
37
37
  super()
38
+ @icon_theme = Gtk::IconTheme.default
38
39
  conf ||= {}
39
40
  @back_color = conf[:back_color] || DEFAULT_BACK_COLOR
40
41
  @line_color = conf[:line_color] || DEFAULT_LINE_COLOR
@@ -56,12 +57,12 @@ module Rabbit
56
57
  @actions.clear
57
58
  end
58
59
 
59
- def add_action(sequence, action, &block)
60
+ def add_action(sequence, action)
60
61
  invalid_motion = sequence.find do |motion|
61
62
  not @processor.available_motion?(motion)
62
63
  end
63
64
  raise InvalidMotionError.new(invalid_motion) if invalid_motion
64
- @actions << [sequence, action, block]
65
+ @actions << [sequence, action]
65
66
  end
66
67
 
67
68
  def start(button, x, y, base_x, base_y)
@@ -100,7 +101,7 @@ module Rabbit
100
101
 
101
102
  draw_available_marks(renderer, next_available_motions)
102
103
 
103
- act, = action
104
+ act = action
104
105
  draw_mark(renderer, act, *@processor.position) if act
105
106
 
106
107
  draw_locus(renderer)
@@ -117,11 +118,11 @@ module Rabbit
117
118
 
118
119
  private
119
120
  def perform_action
120
- act, block = action
121
+ act = action
121
122
  @processor.reset
122
123
  @locus.clear
123
124
  if act
124
- act.activate(&block)
125
+ act.gaction.activate
125
126
  true
126
127
  else
127
128
  false
@@ -130,16 +131,16 @@ module Rabbit
130
131
 
131
132
  def action
132
133
  motions = @processor.motions
133
- @actions.each do |sequence, act, block|
134
- return [act, block] if sequence == motions and act.sensitive?
134
+ @actions.each do |sequence, act|
135
+ return act if sequence == motions and act.gaction.enabled?
135
136
  end
136
137
  nil
137
138
  end
138
139
 
139
140
  def available_motions
140
141
  motions = @processor.motions
141
- @actions.collect do |sequence, act, block|
142
- if sequence == motions and act.sensitive?
142
+ @actions.collect do |sequence, act|
143
+ if sequence == motions and act.gaction.enabled?
143
144
  [sequence.last, act]
144
145
  else
145
146
  nil
@@ -149,8 +150,8 @@ module Rabbit
149
150
 
150
151
  def next_available_motions
151
152
  motions = @processor.motions
152
- @actions.collect do |sequence, act, block|
153
- if sequence[0..-2] == motions and act.sensitive?
153
+ @actions.collect do |sequence, act|
154
+ if sequence[0..-2] == motions and act.gaction.enabled?
154
155
  [sequence.last, act]
155
156
  else
156
157
  nil
@@ -171,12 +172,16 @@ module Rabbit
171
172
  end
172
173
 
173
174
  def draw_action_image(renderer, act, x, y)
174
- icon = nil
175
- icon = act.create_icon(Gtk::IconSize::DIALOG) if act
175
+ icon = act&.icon
176
176
  if icon
177
- stock, = icon.stock
178
- icon_size = icon.icon_size
179
- pixbuf = icon.render_icon_pixbuf(stock, icon_size)
177
+ if icon.respond_to?(:bytes)
178
+ loader = GdkPixbuf::PixbufLoader.new
179
+ loader.set_size(48, 48)
180
+ loader.last_write(icon.bytes.to_s)
181
+ pixbuf = loader.pixbuf
182
+ else
183
+ pixbuf = @icon_theme.load_icon(icon.names[0], 48, 0)
184
+ end
180
185
  x -= pixbuf.width / 2.0
181
186
  y -= pixbuf.height / 2.0
182
187
  renderer.draw_pixbuf(pixbuf, x, y)
@@ -1,6 +1,22 @@
1
- require 'rabbit/gtk'
1
+ # Copyright (C) 2006-2025 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.
2
16
 
3
- require 'rabbit/renderer/color'
17
+ require_relative "../gtk"
18
+
19
+ require_relative "../renderer/color"
4
20
 
5
21
  module Rabbit
6
22
  module Graffiti
@@ -1,7 +1,23 @@
1
- require 'rabbit/gtk'
2
-
3
- require 'rabbit/renderer/engine'
4
- require 'rabbit/graffiti/config-dialog'
1
+ # Copyright (C) 2006-2025 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_relative "../gtk"
18
+
19
+ require_relative "../renderer/engine"
20
+ require_relative "config-dialog"
5
21
 
6
22
  module Rabbit
7
23
  module Graffiti
data/lib/rabbit/gtk.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2024 Sutou Kouhei <kou@cozmixng.org>
1
+ # Copyright (C) 2014-2025 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
@@ -23,27 +23,49 @@ end
23
23
 
24
24
  Gtk.init if Gtk.respond_to?(:init)
25
25
 
26
- module Gtk
27
- if const_defined?(:Action)
28
- class Action
29
- alias _activate activate
30
- def activate(&block)
31
- @block = block
32
- _activate
33
- ensure
34
- @block = nil
26
+ module Gdk
27
+ class ModifierType
28
+ ALT_MASK = MOD1_MASK unless const_defined?(:ALT_MASK)
29
+ alias_method :alt_mask?, :mod1_mask? unless method_defined?(:alt_mask?)
30
+ end
31
+
32
+ if const_defined?(:Paintable)
33
+ class PixbufAnimationPaintable < GLib::Object
34
+ type_register
35
+
36
+ include Paintable
37
+
38
+ def initialize(animation)
39
+ super()
40
+ @animation = animation
41
+ @iter = @animation.get_iter
42
+ end
43
+
44
+ def virtual_do_snapshot(snapshot, width, height)
45
+ @iter.advance
46
+ texture = Texture.new(@iter.pixbuf)
47
+ snapshot.append_texture(texture, [0, 0, width, height])
48
+ delay_time = @iter.delay_time
49
+ if delay_time != -1
50
+ GLib::Timeout.add(@iter.delay_time) do
51
+ invalidate_contents
52
+ GLib::Source::REMOVE
53
+ end
54
+ end
35
55
  end
36
56
 
37
- def block_given?
38
- not @block.nil?
57
+ def virtual_do_get_intrinsic_width
58
+ @animation.width
39
59
  end
40
60
 
41
- def call(*args, &block)
42
- @block.call(*args, &block)
61
+ def virtual_do_get_intrinsic_height
62
+ @animation.height
43
63
  end
44
64
  end
45
65
  end
66
+ end
46
67
 
68
+ module Gtk
47
69
  unless const_defined?(:Native)
48
70
  # For GTK 3
49
71
  #
@@ -56,4 +78,16 @@ module Gtk
56
78
  alias_method :surface, :window
57
79
  end
58
80
  end
81
+
82
+ unless const_defined?(:StackTransitionType)
83
+ StackTransitionType = Stack::TransitionType
84
+ end
85
+ end
86
+
87
+ unless Gtk.const_defined?(:MediaFile)
88
+ # For video
89
+ begin
90
+ require "gst"
91
+ rescue LoadError
92
+ end
59
93
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2005-2018 Kouhei Sutou <kou@cozmixng.org>
1
+ # Copyright (C) 2005-2025 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
@@ -22,11 +22,11 @@ begin
22
22
  rescue LoadError
23
23
  end
24
24
 
25
- require "rabbit/filename"
26
- require "rabbit/front"
27
- require "rabbit/keys"
28
- require "rabbit/rabbit"
29
- require "rabbit/utils"
25
+ require_relative "../filename"
26
+ require_relative "../front"
27
+ require_relative "../keys"
28
+ require_relative "../rabbit"
29
+ require_relative "../utils"
30
30
 
31
31
  module Rabbit
32
32
  module HTML
@@ -72,7 +72,7 @@ module Rabbit
72
72
  @outputting_index = false
73
73
  @canvas.each_slide_pixbuf do |slide, pixbuf, slide_number|
74
74
  message = _("Creating a image for the %dth page") % slide_number
75
- @canvas.logger.info(message)
75
+ Rabbit.logger.info(message)
76
76
  save_slide(slide, pixbuf, slide_number)
77
77
  true
78
78
  end
@@ -84,7 +84,7 @@ module Rabbit
84
84
  end
85
85
  end
86
86
  unless save_rss
87
- @canvas.logger.warn(_("can't generate RSS"))
87
+ Rabbit.logger.warn(_("can't generate RSS"))
88
88
  end
89
89
  end
90
90
  end
@@ -160,18 +160,18 @@ module Rabbit
160
160
  private
161
161
  def save_environment
162
162
  @index_mode = @canvas.index_mode?
163
- @slide_size = @canvas.slide_size
164
- @index_slide_size = 0
163
+ @n_slides = @canvas.n_slides
164
+ @index_n_slides = 0
165
165
  if output_index_html?
166
166
  @canvas.with_index_mode(true) do
167
- @index_slide_size = @canvas.slide_size
167
+ @index_n_slides = @canvas.n_slides
168
168
  end
169
169
  end
170
170
  yield
171
171
  ensure
172
172
  @index_mode = nil
173
- @slide_size = nil
174
- @index_slide_size = nil
173
+ @n_slides = nil
174
+ @index_n_slides = nil
175
175
  end
176
176
 
177
177
  def save_html(slide, slide_number)
@@ -229,8 +229,8 @@ module Rabbit
229
229
  def filename_format
230
230
  format = @base_name.dup
231
231
  format << "-index" if outputting_index?
232
- slide_size = outputting_index? ? @index_slide_size : @slide_size
233
- format << "-%0#{number_of_places(slide_size)}d%s.%s"
232
+ n_slides = outputting_index? ? @index_n_slides : @n_slides
233
+ format << "-%0#{number_of_places(n_slides)}d%s.%s"
234
234
  end
235
235
 
236
236
  def make_filename(slide_number, suffix, optional=nil)
@@ -290,7 +290,7 @@ module Rabbit
290
290
 
291
291
  def image_title(slide_number=@slide_number)
292
292
  title = h(slide_title(slide_number))
293
- title << "(#{slide_number}/#{@canvas.slide_size - 1})"
293
+ title << "(#{slide_number}/#{@canvas.n_slides - 1})"
294
294
  title
295
295
  end
296
296
 
@@ -315,7 +315,7 @@ module Rabbit
315
315
  end
316
316
 
317
317
  def last_slide?(slide_number=@slide_number)
318
- @canvas.slide_size.zero? or slide_number == @canvas.slide_size - 1
318
+ @canvas.n_slides.zero? or slide_number == @canvas.n_slides - 1
319
319
  end
320
320
 
321
321
  def first_index(slide_number=@slide_number)
@@ -331,7 +331,7 @@ module Rabbit
331
331
  end
332
332
 
333
333
  def last_index(slide_number=@slide_number)
334
- @canvas.slide_size - 1
334
+ @canvas.n_slides - 1
335
335
  end
336
336
 
337
337
  def first_link(slide_number=@slide_number)
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2019 Kouhei Sutou <kou@cozmixng.org>
1
+ # Copyright (C) 2025 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
@@ -14,11 +14,21 @@
14
14
  # with this program; if not, write to the Free Software Foundation, Inc.,
15
15
  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
16
 
17
- module Helper
18
- module Fixture
19
- private
20
- def fixture_path(*components)
21
- File.join(File.dirname(__FILE__), "..", "fixtures", *components)
17
+ require_relative "gtk"
18
+
19
+ require_relative "image"
20
+ require_relative "theme/searcher"
21
+
22
+ module Rabbit
23
+ module Icon
24
+ module_function
25
+ def rabbit
26
+ image_theme = Theme::Searcher.find_theme("rabbit-images", true)
27
+ file = Theme::Searcher.find_file("lavie-icon.png", [image_theme])
28
+ loader = ImageLoader.new(file)
29
+ loader.resize(32, 32)
30
+ bytes = GLib::Bytes.new(loader.pixbuf.save("png"))
31
+ Gio::BytesIcon.new(bytes)
22
32
  end
23
33
  end
24
34
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2004-2022 Sutou Kouhei <kou@cozmixng.org>
1
+ # Copyright (C) 2004-2025 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
@@ -19,8 +19,9 @@ require "digest/sha2"
19
19
 
20
20
  require "gdk_pixbuf2"
21
21
 
22
- require "rabbit/image-data-loader"
23
- require "rabbit/properties"
22
+ require_relative "../image-data-loader"
23
+ require_relative "../properties"
24
+ require_relative "../utils"
24
25
 
25
26
  module Rabbit
26
27
  module ImageManipulable
@@ -116,9 +117,9 @@ module Rabbit
116
117
  end
117
118
 
118
119
  def resize(w, h)
119
- if w.nil? and h.nil?
120
- return
121
- elsif keep_ratio?
120
+ return if w.nil? and h.nil?
121
+
122
+ if keep_ratio?
122
123
  if w and h.nil?
123
124
  h = (original_height * w.to_f / original_width).ceil
124
125
  elsif w.nil? and h
@@ -1,4 +1,20 @@
1
- require "rabbit/image/base"
1
+ # Copyright (C) 2004-2025 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_relative "base"
2
18
 
3
19
  module Rabbit
4
20
  module ImageManipulable
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2004-2022 Sutou Kouhei <kou@cozmixng.org>
1
+ # Copyright (C) 2004-2025 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
@@ -14,7 +14,7 @@
14
14
  # with this program; if not, write to the Free Software Foundation, Inc.,
15
15
  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
16
 
17
- require "rabbit/image/base"
17
+ require_relative "base"
18
18
 
19
19
  module Rabbit
20
20
  module ImageManipulable
@@ -1,6 +1,20 @@
1
- require "rabbit/utils"
1
+ # Copyright (C) 2004-2025 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.
2
16
 
3
- require "rabbit/image/base"
17
+ require_relative "base"
4
18
 
5
19
  module Rabbit
6
20
  module ImageManipulable
@@ -1,5 +1,21 @@
1
- require "rabbit/utils"
2
- require "rabbit/image/base"
1
+ # Copyright (C) 2006-2025 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_relative "../utils"
18
+ require_relative "base"
3
19
 
4
20
  module Rabbit
5
21
  module ImageManipulable
@@ -23,21 +39,22 @@ module Rabbit
23
39
 
24
40
  private
25
41
  def update_size
26
- png_file = Tempfile.new("rabbit-loader-gimp-png")
42
+ png_file = Tempfile.new(["rabbit-loader-gimp-png", ".png"])
27
43
  png_path = png_file.path
28
44
  clip_to_image = 1
29
45
  merge_type = clip_to_image
30
- command = <<-EOC
46
+ command = <<-COMMAND
31
47
  (let ((image (car (gimp-file-load RUN-NONINTERACTIVE
32
48
  "#{@filename}" "#{@filename}"))))
33
- (let ((layer (car (gimp-image-merge-visible-layers image #{merge_type}))))
34
- (file-png-save-defaults RUN-NONINTERACTIVE image layer
35
- "#{png_path}" "#{png_path}"))
49
+ (gimp-file-save RUN-NONINTERACTIVE image "#{png_path}")
36
50
  (gimp-image-delete image))
37
- EOC
38
- args = %w(-i)
39
- args.concat(["-b", command])
40
- args.concat(["-b", "(gimp-quit TRUE)"])
51
+ COMMAND
52
+ args = [
53
+ "--no-interface",
54
+ "--batch-interpreter", "plug-in-script-fu-eval",
55
+ "--batch", command,
56
+ "--batch", "(gimp-quit TRUE)",
57
+ ]
41
58
  if GIMP_COMMANDS.any? {|gimp| run(gimp, *args); File.exist?(png_path)}
42
59
  png_file.open
43
60
  png_file.binmode
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2022 Sutou Kouhei <kou@cozmixng.org>
1
+ # Copyright (C) 2022-2025 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
@@ -14,8 +14,8 @@
14
14
  # with this program; if not, write to the Free Software Foundation, Inc.,
15
15
  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
16
 
17
- require "rabbit/gettext"
18
- require "rabbit/image/pdf"
17
+ require_relative "../gettext"
18
+ require_relative "pdf"
19
19
 
20
20
  module Rabbit
21
21
  module ImageManipulable
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2006-2022 Sutou Kouhei <kou@cozmixng.org>
1
+ # Copyright (C) 2006-2025 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,8 +16,8 @@
16
16
 
17
17
  require "poppler"
18
18
 
19
- require "rabbit/gettext"
20
- require "rabbit/image/base"
19
+ require_relative "../gettext"
20
+ require_relative "base"
21
21
 
22
22
  module Rabbit
23
23
  module ImageManipulable