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
@@ -21,7 +21,7 @@ module Rabbit
21
21
  $stderr.puts(format_severity(severity))
22
22
  $stderr.print("[#{prog_name}]: ") if prog_name
23
23
  $stderr.puts(message)
24
- exit if severity >= Severity::FATAL
24
+ exit(false) if severity >= Severity::FATAL
25
25
  end
26
26
  end
27
27
  end
@@ -0,0 +1,44 @@
1
+ # Copyright (C) 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 "cgi/util"
18
+
19
+ module Rabbit
20
+ class PangoMarkup
21
+ def initialize(name, attributes, content=nil)
22
+ @name = name
23
+ @attributes = attributes
24
+ @content = content
25
+ end
26
+
27
+ def to_s
28
+ tag = "<#{@name}"
29
+ @attributes.each do |name, value|
30
+ next if value.nil?
31
+ formatter_name = Utils.to_class_name(name)
32
+ if Format.const_defined?(formatter_name)
33
+ formatter = Format.const_get(formatter_name).new(value)
34
+ value = formatter.pango_value
35
+ end
36
+ tag << " #{CGI.escapeHTML(name.to_s)}='#{CGI.escapeHTML(value.to_s)}'"
37
+ end
38
+ tag << ">"
39
+ tag << @content.to_s if @content
40
+ tag << "</#{@name}>"
41
+ tag
42
+ end
43
+ end
44
+ end
@@ -1,7 +1,24 @@
1
- require "rabbit/utils"
1
+ # Copyright (C) 2007-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.
2
16
 
3
- dir = File.join("rabbit", "parser")
4
- Rabbit::Utils.require_files_under_directory_in_load_path(dir)
17
+ require "rabbit/parser/image"
18
+ require "rabbit/parser/markdown"
19
+ require "rabbit/parser/pdf"
20
+ require "rabbit/parser/rd"
21
+ require "rabbit/parser/wiki"
5
22
 
6
23
  module Rabbit
7
24
  module Parser
@@ -1,9 +1,26 @@
1
- require 'uri'
2
- require 'cgi'
3
- require 'open-uri'
4
- require 'fileutils'
1
+ # Copyright (C) 2007-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.
5
16
 
6
- require 'rabbit/element'
17
+ require "uri"
18
+ require "cgi"
19
+ require "open-uri"
20
+ require "fileutils"
21
+
22
+ require "rabbit/element"
23
+ require "rabbit/filename"
7
24
 
8
25
  module Rabbit
9
26
  module Parser
@@ -39,7 +56,7 @@ module Rabbit
39
56
  end
40
57
 
41
58
  module Private
42
- ALLOWED_IMG_URL_SCHEME = ['http', 'https', 'file']
59
+ ALLOWED_IMG_URL_SCHEME = ["http", "https", "file"]
43
60
 
44
61
  module_function
45
62
  def uri_string_to_image_filename(canvas, uri_string)
@@ -58,7 +75,7 @@ module Rabbit
58
75
  def uri_to_image_filename(canvas, uri)
59
76
  case uri.scheme.to_s.downcase
60
77
  when "file"
61
- GLib.filename_from_utf8(uri.path)
78
+ Filename.new(uri.path).encode
62
79
  when "http", "https", "ftp"
63
80
  other_uri_filename(canvas, uri)
64
81
  else
@@ -67,7 +84,7 @@ module Rabbit
67
84
  end
68
85
 
69
86
  def local_path_to_image_filename(canvas, path)
70
- path = Pathname.new(GLib.filename_from_utf8(path))
87
+ path = Pathname.new(Filename.new(path).encode)
71
88
  return path.to_s if path.absolute?
72
89
 
73
90
  expanded_path = canvas.full_path(path.to_s)
@@ -1,10 +1,29 @@
1
- require 'rabbit/element'
1
+ # Copyright (C) 2012 Narihiro Nakamura <authornari@gmail.com>
2
+ # Copyright (C) 2018 Kouhei Sutou <kou@cozmixng.org>
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this program; if not, write to the Free Software Foundation, Inc.,
16
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
+
18
+ require "rabbit/element"
19
+ require "rabbit/parser/ext/image"
2
20
 
3
21
  module Rabbit
4
22
  module Parser
5
23
  module Ext
6
24
  module Video
7
- def make_video(canvas, path, prop)
25
+ def make_video(canvas, uri_str, prop)
26
+ path = Image::Private.uri_string_to_image_filename(canvas, uri_str)
8
27
  begin
9
28
  Element::Video.new(path, prop)
10
29
  rescue Error
@@ -1,6 +1,5 @@
1
1
  require "kramdown"
2
- require "kramdown/parser/kramdown"
3
- require "kramdown/parser/gfm"
2
+ require "kramdown-parser-gfm"
4
3
 
5
4
  require "rabbit/parser/base"
6
5
 
@@ -1,3 +1,19 @@
1
+ # Copyright (C) 2007-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
+
1
17
  require "tempfile"
2
18
 
3
19
  require "poppler"
@@ -26,13 +42,13 @@ module Rabbit
26
42
 
27
43
  include Element
28
44
  def parse
29
- doc = Poppler::Document.new(@source.read)
30
-
31
- title_page, *rest = doc.to_a
32
-
33
- @canvas << PopplerTitleSlide.new(title_page, doc)
34
- rest.each do |page|
35
- @canvas << PopplerSlide.new(page)
45
+ doc = Poppler::Document.new(:data => @source.read)
46
+ doc.each_with_index do |page, i|
47
+ if i.zero?
48
+ @canvas << PopplerTitleSlide.new(page, doc)
49
+ else
50
+ @canvas << PopplerSlide.new(page)
51
+ end
36
52
  end
37
53
  end
38
54
  end
@@ -8,6 +8,26 @@ require "rabbit/parser/rd/ext/refer"
8
8
  require "rabbit/parser/rd/ext/inline-verbatim"
9
9
  require "rabbit/parser/rd/ext/block-verbatim"
10
10
 
11
+ module Rabbit
12
+ module Parser
13
+ class RD
14
+ module NoURLMark
15
+ def to_reference_content
16
+ [::RD::StringElement.new(url)]
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ module RD
24
+ class Reference
25
+ class URL
26
+ prepend Rabbit::Parser::RD::NoURLMark
27
+ end
28
+ end
29
+ end
30
+
11
31
  module Rabbit
12
32
  module Parser
13
33
  class RD
@@ -4,6 +4,8 @@ module Rabbit
4
4
  class Progress
5
5
  attr_reader :window, :foreground, :background
6
6
  def initialize
7
+ @width = 100
8
+ @height = 20
7
9
  @foreground = nil
8
10
  @background = nil
9
11
  end
@@ -27,8 +29,8 @@ module Rabbit
27
29
  @window = Gtk::Window.new(:popup)
28
30
  @window.transient_for = parent
29
31
  @window.app_paintable = true
32
+ @window.set_default_size(@width, @height)
30
33
  @bar = Gtk::ProgressBar.new
31
- @bar.show_text = true
32
34
  @window.add(@bar)
33
35
  @window.show_all
34
36
  @bar.fraction = @current = 0
@@ -52,6 +54,7 @@ module Rabbit
52
54
  end
53
55
 
54
56
  def hide
57
+ @max = nil
55
58
  @window.destroy
56
59
  @bar = nil
57
60
  @window = nil
@@ -59,29 +62,37 @@ module Rabbit
59
62
 
60
63
  private
61
64
  def setup_progress_color
62
- if Gtk.const_defined?(:CssProvider)
63
- css = "progressbar {\n"
64
- if @foreground
65
- css << " color: #{@foreground.to_css_rgba};\n"
66
- end
67
- if @background
68
- css << " background-color: #{@background.to_css_rgba};\n"
69
- end
70
- css << "}\n"
71
- provider = Gtk::CssProvider.default
72
- provider.load(:data => css)
73
- else
74
- style = @bar.style.copy
75
- if @foreground
76
- rgb = @foreground.to_gdk_rgb
77
- style.set_bg(Gtk::STATE_PRELIGHT, *rgb)
78
- end
79
- if @background
80
- rgb = @background.to_gdk_rgb
81
- style.set_bg(Gtk::STATE_NORMAL, *rgb)
82
- end
83
- @bar.style = style
65
+ css = <<-CSS
66
+ progress {
67
+ padding: 0px;
68
+ padding-top: #{@height}px;
69
+ padding-bottom: #{@height}px;
70
+ }
71
+
72
+ trough {
73
+ border-width: 0px;
74
+ }
75
+ CSS
76
+ if @foreground
77
+ css << <<-CSS
78
+ progress {
79
+ background-color: #{@foreground.to_css_rgba};
80
+ border-color: #{@foreground.to_css_rgba};
81
+ }
82
+ CSS
83
+ end
84
+ if @background
85
+ css << <<-CSS
86
+ progressbar,
87
+ trough {
88
+ background-color: #{@background.to_css_rgba};
89
+ }
90
+ CSS
84
91
  end
92
+ provider = Gtk::CssProvider.new
93
+ provider.load(:data => css)
94
+ @bar.style_context.add_provider(provider,
95
+ Gtk::StyleProvider::PRIORITY_USER)
85
96
  end
86
97
  end
87
98
  end
@@ -1,27 +1,21 @@
1
- require "rabbit/utils"
1
+ # Copyright (C) 2004-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/renderer/color"
4
18
  require "rabbit/renderer/display"
5
19
  require "rabbit/renderer/offscreen"
6
- require "rabbit/renderer/print"
7
-
8
- module Rabbit
9
- module Renderer
10
- extend Utils
11
-
12
- class << self
13
- def printable?
14
- Print.printable?
15
- end
16
-
17
- def printable_renderer(slides_per_page)
18
- raise NoPrintSupportError unless printable?
19
- if slides_per_page > 1
20
- Print::Multiple
21
- else
22
- Print
23
- end
24
- end
25
- end
26
- end
27
- end
20
+ require "rabbit/renderer/printer"
21
+ require "rabbit/renderer/screen"
@@ -1,3 +1,19 @@
1
+ # Copyright (C) 2004-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 "forwardable"
2
18
  require "erb"
3
19
  require "rabbit/gtk"
@@ -18,6 +34,8 @@ module Rabbit
18
34
  def_delegators(:@canvas, :reload_source)
19
35
 
20
36
  attr_reader :x_dpi, :y_dpi
37
+ attr_accessor :base_width
38
+ attr_accessor :base_height
21
39
  attr_accessor :paper_width, :paper_height, :slides_per_page
22
40
  attr_accessor :margin_left, :margin_right
23
41
  attr_accessor :margin_top, :margin_bottom
@@ -34,9 +52,11 @@ module Rabbit
34
52
  super()
35
53
  @canvas = canvas
36
54
  @font_families = nil
55
+ @base_width = nil
56
+ @base_height = nil
37
57
  @paper_width = nil
38
58
  @paper_height = nil
39
- @slides_per_page = nil
59
+ @slides_per_page = 1
40
60
  @margin_left = nil
41
61
  @margin_right = nil
42
62
  @margin_top = nil
@@ -156,16 +176,6 @@ module Rabbit
156
176
  def setup_event(area)
157
177
  end
158
178
 
159
- def to_attrs(hash)
160
- hash.collect do |key, value|
161
- if value
162
- "#{h key}='#{h value}'"
163
- else
164
- nil
165
- end
166
- end.compact.join(" ")
167
- end
168
-
169
179
  def clean
170
180
  dirty_count_clean
171
181
  end
@@ -290,9 +300,10 @@ module Rabbit
290
300
  end
291
301
 
292
302
  def make_canvas_with_printable_renderer
293
- renderer = Renderer.printable_renderer(@canvas.slides_per_page)
303
+ renderer = Renderer::Printer
294
304
  make_canvas_with_renderer(renderer) do |canvas|
295
305
  canvas.filename = @canvas.filename
306
+ setup_size(canvas)
296
307
  setup_margin(canvas)
297
308
  setup_page_margin(canvas)
298
309
  setup_paper_size(canvas)
@@ -303,12 +314,16 @@ module Rabbit
303
314
 
304
315
  def make_canvas_with_offscreen_renderer
305
316
  make_canvas_with_renderer(Offscreen) do |canvas|
306
- canvas.width = @canvas.width
307
- canvas.height = @canvas.height
317
+ setup_size(canvas)
308
318
  setup_3d(canvas)
309
319
  end
310
320
  end
311
321
 
322
+ def setup_size(canvas)
323
+ canvas.width = @canvas.width
324
+ canvas.height = @canvas.height
325
+ end
326
+
312
327
  def setup_margin(canvas)
313
328
  canvas.margin_left = @canvas.margin_left
314
329
  canvas.margin_right = @canvas.margin_right
@@ -324,55 +339,14 @@ module Rabbit
324
339
  end
325
340
 
326
341
  def setup_paper_size(canvas)
327
- if @canvas.paper_width and @canvas.paper_height
328
- canvas.paper_width = @canvas.paper_width
329
- canvas.paper_height = @canvas.paper_height
330
- else
331
- canvas.paper_width = @canvas.width
332
- canvas.paper_height = @canvas.height
333
- end
342
+ canvas.paper_width = @canvas.paper_width
343
+ canvas.paper_height = @canvas.paper_height
334
344
  end
335
345
 
336
346
  def setup_3d(canvas)
337
347
  canvas.use_gl = @canvas.use_gl?
338
348
  end
339
349
 
340
- def setup_flag_params(pole_height, default_flag_width_ratio, params)
341
- params = params.dup
342
-
343
- text = params["text"]
344
- text_attrs = params["text_attributes"] || {}
345
- if text
346
- markupped_text = "<span #{to_attrs(text_attrs)}>#{text}</span>"
347
- layout = make_layout(markupped_text)
348
- text_width, text_height = layout.pixel_size
349
- params["layout"] = layout
350
- params["text_width"] = text_width
351
- params["text_height"] = text_height
352
- flag_width_default = [
353
- text_width * default_flag_width_ratio,
354
- pole_height / 2
355
- ].max
356
- flag_height_default = [text_height, flag_width_default].max
357
- else
358
- params["layout"] = nil
359
- flag_width_default = flag_height_default = nil
360
- end
361
-
362
- params["pole_width"] = params["pole_width"] || 2
363
- params["pole_color"] ||= "black"
364
- flag_height = params["flag_height"] ||
365
- flag_height_default || pole_height / 2
366
- flag_height = [flag_height, pole_height].min
367
- params["flag_height"] = flag_height
368
- params["flag_width"] ||= flag_width_default || flag_height
369
- params["flag_color"] ||= "red"
370
- params["flag_frame_width"] ||= params["pole_width"]
371
- params["flag_frame_color"] ||= params["pole_color"]
372
-
373
- params
374
- end
375
-
376
350
  def not_support_method(name)
377
351
  format = _("%s does not support: %s")
378
352
  msg = format % [self.class.name, name]