rabbit 2.2.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/data/locale/ja/LC_MESSAGES/rabbit.mo +0 -0
- data/doc/_config.yml +2 -2
- data/doc/_layouts/en.html +1 -1
- data/doc/_layouts/ja.html +1 -1
- data/doc/en/news.rd +140 -0
- data/doc/en/sample/hiki/rabbit.hiki +2 -2
- data/doc/en/sample/markdown/rabbit.md +1 -1
- data/doc/en/sample/rd/rabbit.rd +1 -1
- data/doc/en/usage/rabbit-slide.rd +3 -3
- data/doc/images/screenshots/en/blue-circle-raw.png +0 -0
- data/doc/images/screenshots/en/blue-circle.png +0 -0
- data/doc/images/screenshots/en/clear-blue-raw.png +0 -0
- data/doc/images/screenshots/en/clear-blue.png +0 -0
- data/doc/images/screenshots/en/cozmixng-raw.png +0 -0
- data/doc/images/screenshots/en/cozmixng.png +0 -0
- data/doc/images/screenshots/en/dark-gradation-raw.png +0 -0
- data/doc/images/screenshots/en/dark-gradation.png +0 -0
- data/doc/images/screenshots/en/day-white-raw.png +0 -0
- data/doc/images/screenshots/en/day-white.png +0 -0
- data/doc/images/screenshots/en/debian-raw.png +0 -0
- data/doc/images/screenshots/en/debian.png +0 -0
- data/doc/images/screenshots/en/green-circle-raw.png +0 -0
- data/doc/images/screenshots/en/green-circle.png +0 -0
- data/doc/images/screenshots/en/night-black-raw.png +0 -0
- data/doc/images/screenshots/en/night-black.png +0 -0
- data/doc/images/screenshots/en/rabbit-raw.png +0 -0
- data/doc/images/screenshots/en/rabbit.png +0 -0
- data/doc/images/screenshots/en/ranguba-raw.png +0 -0
- data/doc/images/screenshots/en/ranguba.png +0 -0
- data/doc/images/screenshots/en/red-frame-raw.png +0 -0
- data/doc/images/screenshots/en/red-frame.png +0 -0
- data/doc/images/screenshots/en/ruby-gnome2-raw.png +0 -0
- data/doc/images/screenshots/en/ruby-gnome2.png +0 -0
- data/doc/images/screenshots/en/rubykaigi2011-raw.png +0 -0
- data/doc/images/screenshots/en/rubykaigi2011.png +0 -0
- data/doc/images/screenshots/ja/blue-circle-raw.png +0 -0
- data/doc/images/screenshots/ja/blue-circle.png +0 -0
- data/doc/images/screenshots/ja/clear-blue-raw.png +0 -0
- data/doc/images/screenshots/ja/clear-blue.png +0 -0
- data/doc/images/screenshots/ja/cozmixng-raw.png +0 -0
- data/doc/images/screenshots/ja/cozmixng.png +0 -0
- data/doc/images/screenshots/ja/dark-gradation-raw.png +0 -0
- data/doc/images/screenshots/ja/dark-gradation.png +0 -0
- data/doc/images/screenshots/ja/day-white-raw.png +0 -0
- data/doc/images/screenshots/ja/day-white.png +0 -0
- data/doc/images/screenshots/ja/debian-raw.png +0 -0
- data/doc/images/screenshots/ja/debian.png +0 -0
- data/doc/images/screenshots/ja/green-circle-raw.png +0 -0
- data/doc/images/screenshots/ja/green-circle.png +0 -0
- data/doc/images/screenshots/ja/night-black-raw.png +0 -0
- data/doc/images/screenshots/ja/night-black.png +0 -0
- data/doc/images/screenshots/ja/rabbit-raw.png +0 -0
- data/doc/images/screenshots/ja/rabbit.png +0 -0
- data/doc/images/screenshots/ja/ranguba-raw.png +0 -0
- data/doc/images/screenshots/ja/ranguba.png +0 -0
- data/doc/images/screenshots/ja/red-frame-raw.png +0 -0
- data/doc/images/screenshots/ja/red-frame.png +0 -0
- data/doc/images/screenshots/ja/ruby-gnome2-raw.png +0 -0
- data/doc/images/screenshots/ja/ruby-gnome2.png +0 -0
- data/doc/images/screenshots/ja/rubykaigi2011-raw.png +0 -0
- data/doc/images/screenshots/ja/rubykaigi2011.png +0 -0
- data/doc/ja/how-to-make/index.rd +1 -1
- data/doc/ja/news.rd +143 -0
- data/doc/ja/sample/hiki/rabbit.hiki +2 -2
- data/doc/ja/sample/markdown/rabbit.md +1 -1
- data/doc/ja/sample/rd/rabbit.rd +1 -1
- data/doc/ja/slides.rd +1 -1
- data/doc/ja/usage/rabbit-slide.rd +3 -3
- data/doc/ja/users.rd +1 -1
- data/lib/rabbit/action.rb +23 -4
- data/lib/rabbit/canvas.rb +70 -14
- data/lib/rabbit/command/rabbit-slide.rb +252 -67
- data/lib/rabbit/command/rabbit-slide.ui +180 -0
- data/lib/rabbit/command/rabbit.rb +14 -20
- data/lib/rabbit/console.rb +9 -3
- data/lib/rabbit/dependency-canvas.rb +19 -1
- data/lib/rabbit/element.rb +34 -7
- data/lib/rabbit/element/poppler-page.rb +1 -2
- data/lib/rabbit/element/text-container-element.rb +2 -2
- data/lib/rabbit/element/text-renderer.rb +5 -4
- data/lib/rabbit/element/title-slide.rb +8 -0
- data/lib/rabbit/element/video.rb +1 -2
- data/lib/rabbit/filename.rb +39 -0
- data/lib/rabbit/formatter.rb +61 -30
- data/lib/rabbit/frame.rb +1 -19
- data/lib/rabbit/front.rb +23 -2
- data/lib/rabbit/gesture/handler.rb +21 -2
- data/lib/rabbit/graffiti/config-dialog.rb +15 -18
- data/lib/rabbit/gtk.rb +2 -191
- data/lib/rabbit/html/generator.rb +38 -30
- data/lib/rabbit/image-data-loader.rb +6 -1
- data/lib/rabbit/image.rb +22 -4
- data/lib/rabbit/image/base.rb +34 -2
- data/lib/rabbit/image/default.rb +1 -1
- data/lib/rabbit/image/eps.rb +1 -1
- data/lib/rabbit/image/gimp.rb +1 -1
- data/lib/rabbit/info-window.rb +27 -15
- data/lib/rabbit/logger/gui.rb +21 -23
- data/lib/rabbit/logger/stderr.rb +1 -1
- data/lib/rabbit/pango-markup.rb +44 -0
- data/lib/rabbit/parser.rb +20 -3
- data/lib/rabbit/parser/ext/image.rb +25 -8
- data/lib/rabbit/parser/ext/video.rb +21 -2
- data/lib/rabbit/parser/markdown.rb +1 -2
- data/lib/rabbit/parser/pdf.rb +23 -7
- data/lib/rabbit/parser/rd/rd2rabbit-lib.rb +20 -0
- data/lib/rabbit/progress.rb +34 -23
- data/lib/rabbit/renderer.rb +17 -23
- data/lib/rabbit/renderer/base.rb +31 -57
- data/lib/rabbit/renderer/color.rb +46 -53
- data/lib/rabbit/renderer/display/base.rb +71 -62
- data/lib/rabbit/renderer/display/button-handler.rb +2 -1
- data/lib/rabbit/renderer/display/clutter-embed.rb +60 -26
- data/lib/rabbit/renderer/display/drawing-area-base.rb +1 -1
- data/lib/rabbit/renderer/display/drawing-area-primitive.rb +34 -21
- data/lib/rabbit/renderer/display/graffiti.rb +1 -3
- data/lib/rabbit/renderer/display/hook-handler.rb +8 -4
- data/lib/rabbit/renderer/display/key-handler.rb +7 -2
- data/lib/rabbit/renderer/display/magnifier.rb +2 -2
- data/lib/rabbit/renderer/display/progress.rb +10 -2
- data/lib/rabbit/renderer/display/spotlight.rb +2 -2
- data/lib/rabbit/renderer/engine/cairo.rb +0 -3
- data/lib/rabbit/renderer/kernel.rb +54 -0
- data/lib/rabbit/renderer/offscreen.rb +14 -6
- data/lib/rabbit/renderer/print-layout.rb +150 -0
- data/lib/rabbit/renderer/printer.rb +236 -0
- data/lib/rabbit/renderer/screen.rb +288 -0
- data/lib/rabbit/renderer/widget/drawing-area.rb +93 -0
- data/lib/rabbit/size.rb +52 -25
- data/lib/rabbit/slide-configuration.rb +56 -12
- data/lib/rabbit/source.rb +24 -8
- data/lib/rabbit/task/slide.rb +1 -1
- data/lib/rabbit/theme/applier.rb +26 -9
- data/lib/rabbit/theme/base/base.rb +7 -7
- data/lib/rabbit/theme/clear-blue/clear-blue.rb +1 -1
- data/lib/rabbit/theme/image-timer/image-timer.rb +3 -1
- data/lib/rabbit/theme/image-viewer/image-viewer.rb +13 -1
- data/lib/rabbit/theme/image/image.rb +4 -4
- data/lib/rabbit/theme/lightning-talk-toolkit/lightning-talk-toolkit.rb +3 -1
- data/lib/rabbit/theme/tag/tag.rb +12 -4
- data/lib/rabbit/version.rb +2 -2
- data/lib/rabbit/video-window.rb +75 -89
- data/misc/emacs/rabbit-mode.el +11 -7
- data/po/en/rabbit.edit.po +189 -185
- data/po/en/rabbit.po +15 -12
- data/po/fr/rabbit.edit.po +189 -185
- data/po/fr/rabbit.po +15 -12
- data/po/ja/rabbit.edit.po +190 -186
- data/po/ja/rabbit.po +16 -13
- data/rabbit.gemspec +34 -16
- data/test/command/test-rabbit.rb +100 -0
- data/test/{rabbit-test-utils.rb → helper.rb} +7 -4
- data/test/{rabbit-test-utils → helper}/fixture.rb +2 -2
- data/test/{rabbit-test-utils → helper}/parser.rb +2 -2
- data/test/image/test-dia.rb +2 -2
- data/test/image/test-eps.rb +2 -2
- data/test/parser/test-markdown.rb +3 -5
- data/test/parser/test-rd.rb +1 -3
- data/test/parser/test-wiki.rb +3 -5
- data/test/run-test.rb +3 -3
- data/test/test-applier.rb +60 -29
- data/test/test-canvas.rb +70 -0
- data/test/test-color.rb +18 -9
- data/test/test-element.rb +15 -3
- data/test/test-size.rb +25 -22
- data/test/test-slide-configuration.rb +16 -6
- data/test/test-source.rb +15 -5
- data/test/test-utils.rb +15 -1
- metadata +55 -84
- data/lib/rabbit/renderer/print.rb +0 -31
- data/lib/rabbit/renderer/print/base.rb +0 -78
- data/lib/rabbit/renderer/print/cairo.rb +0 -122
- data/lib/rabbit/renderer/print/layout.rb +0 -123
- data/lib/rabbit/renderer/print/multiple.rb +0 -202
- data/lib/rabbit/source/hiki.rb +0 -36
- data/lib/rabbit/source/slide-share.rb +0 -53
@@ -0,0 +1,236 @@
|
|
1
|
+
# Copyright (C) 2005-2019 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/rabbit"
|
18
|
+
|
19
|
+
require "rabbit/filename"
|
20
|
+
|
21
|
+
require "rabbit/renderer/base"
|
22
|
+
require "rabbit/renderer/engine/cairo"
|
23
|
+
require "rabbit/renderer/print-layout"
|
24
|
+
|
25
|
+
module Rabbit
|
26
|
+
module Renderer
|
27
|
+
class Printer
|
28
|
+
A4_WIDTH = 596
|
29
|
+
A4_HEIGHT = 842
|
30
|
+
|
31
|
+
include Renderer::Base
|
32
|
+
include Engine::Cairo
|
33
|
+
|
34
|
+
attr_writer :filename
|
35
|
+
|
36
|
+
def initialize(canvas)
|
37
|
+
super
|
38
|
+
@filename = nil
|
39
|
+
init_paper
|
40
|
+
init_color
|
41
|
+
update_layout
|
42
|
+
end
|
43
|
+
|
44
|
+
def width
|
45
|
+
@base_width
|
46
|
+
end
|
47
|
+
|
48
|
+
def height
|
49
|
+
@base_height
|
50
|
+
end
|
51
|
+
|
52
|
+
def page_width
|
53
|
+
@page_width - page_margin_left - page_margin_right
|
54
|
+
end
|
55
|
+
|
56
|
+
def page_height
|
57
|
+
@page_height - page_margin_top - page_margin_bottom
|
58
|
+
end
|
59
|
+
|
60
|
+
def paper_width=(value)
|
61
|
+
super
|
62
|
+
init_paper
|
63
|
+
end
|
64
|
+
|
65
|
+
def paper_height=(value)
|
66
|
+
super
|
67
|
+
init_paper
|
68
|
+
end
|
69
|
+
|
70
|
+
def slides_per_page=(slides)
|
71
|
+
super
|
72
|
+
init_paper
|
73
|
+
update_layout
|
74
|
+
end
|
75
|
+
|
76
|
+
def printable?
|
77
|
+
true
|
78
|
+
end
|
79
|
+
|
80
|
+
def filename
|
81
|
+
@filename || default_filename
|
82
|
+
end
|
83
|
+
|
84
|
+
def pre_print(slide_size)
|
85
|
+
init_context(create_context)
|
86
|
+
end
|
87
|
+
|
88
|
+
def post_print(canceled)
|
89
|
+
return if canceled
|
90
|
+
@context.target.finish
|
91
|
+
end
|
92
|
+
|
93
|
+
def pre_parse
|
94
|
+
end
|
95
|
+
|
96
|
+
def post_parse
|
97
|
+
end
|
98
|
+
|
99
|
+
def post_apply_theme
|
100
|
+
end
|
101
|
+
|
102
|
+
def post_move(old_index, index)
|
103
|
+
end
|
104
|
+
|
105
|
+
def post_move_in_slide(old_index, index)
|
106
|
+
end
|
107
|
+
|
108
|
+
def draw_slide(slide, simulation)
|
109
|
+
if simulation
|
110
|
+
yield
|
111
|
+
else
|
112
|
+
slide_width = @layout.slide_width
|
113
|
+
slide_height = @layout.slide_height
|
114
|
+
size = Size.new(@base_width,
|
115
|
+
@base_height,
|
116
|
+
slide_width,
|
117
|
+
slide_height,
|
118
|
+
@base_width.to_f / @base_height.to_f)
|
119
|
+
x = @layout.normalize_x(0)
|
120
|
+
y = @layout.normalize_y(0)
|
121
|
+
save_context do
|
122
|
+
translate_context(x, y)
|
123
|
+
clip_slide(0, 0, slide_width, slide_height)
|
124
|
+
draw_background(0, 0, slide_width, slide_height)
|
125
|
+
scale_context(*size.logical_scale)
|
126
|
+
translate_context(size.logical_margin_left,
|
127
|
+
size.logical_margin_top)
|
128
|
+
yield
|
129
|
+
if @slides_per_page > 1
|
130
|
+
draw_rectangle(false,
|
131
|
+
0,
|
132
|
+
0,
|
133
|
+
size.logical_width,
|
134
|
+
size.logical_height,
|
135
|
+
@black)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
@context.show_page if need_show_page?
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def clip_slide(x, y, w, h)
|
143
|
+
x, y = from_screen(x, y)
|
144
|
+
@context.rectangle(x, y, w, h)
|
145
|
+
@context.clip
|
146
|
+
end
|
147
|
+
|
148
|
+
def draw_background(x, y, w, h)
|
149
|
+
draw_rectangle(true, x, y, w, h, @background)
|
150
|
+
end
|
151
|
+
|
152
|
+
private
|
153
|
+
def default_filename
|
154
|
+
sanitized_title = Filename.sanitize(@canvas.title)
|
155
|
+
Filename.new("#{sanitized_title}.pdf").encode
|
156
|
+
end
|
157
|
+
|
158
|
+
def init_paper
|
159
|
+
if @slides_per_page > 1
|
160
|
+
@paper_width = A4_WIDTH
|
161
|
+
@paper_height = A4_HEIGHT
|
162
|
+
end
|
163
|
+
|
164
|
+
default_width_mm = 360
|
165
|
+
default_height_mm = 270
|
166
|
+
if @paper_width.nil? and @paper_height.nil?
|
167
|
+
size = Size.new(@base_width,
|
168
|
+
@base_height,
|
169
|
+
default_width_mm,
|
170
|
+
default_height_mm,
|
171
|
+
@base_width.to_f / @base_height.to_f)
|
172
|
+
@page_width = size.real_content_width
|
173
|
+
@page_height = size.real_content_height
|
174
|
+
else
|
175
|
+
@page_width = @paper_width || default_width_mm
|
176
|
+
@page_height = @paper_height || default_height_mm
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def init_color
|
181
|
+
super
|
182
|
+
@foreground = make_color("black")
|
183
|
+
@background = make_color(@background_color)
|
184
|
+
end
|
185
|
+
|
186
|
+
def init_dpi
|
187
|
+
super
|
188
|
+
@x_dpi = 300
|
189
|
+
@y_dpi = 300
|
190
|
+
end
|
191
|
+
|
192
|
+
def update_layout
|
193
|
+
@layout = PrintLayout.create(self, @canvas)
|
194
|
+
end
|
195
|
+
|
196
|
+
def create_context(output=nil)
|
197
|
+
surface = find_surface(filename, output)
|
198
|
+
surface.set_fallback_resolution(@x_dpi, @y_dpi)
|
199
|
+
::Cairo::Context.new(surface)
|
200
|
+
end
|
201
|
+
|
202
|
+
def create_pango_context
|
203
|
+
context = create_context(StringIO.new).create_pango_layout.context
|
204
|
+
set_font_resolution(context)
|
205
|
+
context
|
206
|
+
end
|
207
|
+
|
208
|
+
def find_surface(filename, output=nil)
|
209
|
+
args = [output || filename, @page_width, @page_height]
|
210
|
+
case File.extname(filename)
|
211
|
+
when /\.ps/i
|
212
|
+
::Cairo::PSSurface.new(*args)
|
213
|
+
when /\.pdf/i
|
214
|
+
::Cairo::PDFSurface.new(*args)
|
215
|
+
when /\.svg/i
|
216
|
+
surface = ::Cairo::SVGSurface.new(*args)
|
217
|
+
surface.restrict_to_version(::Cairo::SVG_VERSION_1_2)
|
218
|
+
surface
|
219
|
+
when /\.cs/i
|
220
|
+
args[0] = ::Cairo::ScriptDevice.new(args[0])
|
221
|
+
::Cairo::ScriptSurface.new(*args)
|
222
|
+
else
|
223
|
+
@canvas.logger.warn(_("can't find printer for %s") % filename)
|
224
|
+
args[0] = "default.ps"
|
225
|
+
::Cairo::PSSurface.new(*args)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def need_show_page?
|
230
|
+
@slides_per_page == 1 or
|
231
|
+
@canvas.last_slide? or
|
232
|
+
((@canvas.current_index + 1) % @slides_per_page).zero?
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
@@ -0,0 +1,288 @@
|
|
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 "forwardable"
|
18
|
+
|
19
|
+
require "rabbit/renderer/base"
|
20
|
+
|
21
|
+
require "rabbit/renderer/display/base"
|
22
|
+
require "rabbit/renderer/display/menu"
|
23
|
+
require "rabbit/renderer/display/progress"
|
24
|
+
require "rabbit/renderer/display/mask"
|
25
|
+
require "rabbit/renderer/display/search"
|
26
|
+
require "rabbit/renderer/display/gesture"
|
27
|
+
require "rabbit/renderer/display/graffiti"
|
28
|
+
require "rabbit/renderer/display/menu"
|
29
|
+
require "rabbit/renderer/display/button-handler"
|
30
|
+
require "rabbit/renderer/display/key-handler"
|
31
|
+
require "rabbit/renderer/display/scroll-handler"
|
32
|
+
require "rabbit/renderer/display/info"
|
33
|
+
require "rabbit/renderer/display/spotlight"
|
34
|
+
require "rabbit/renderer/display/magnifier"
|
35
|
+
|
36
|
+
require "rabbit/renderer/widget/drawing-area"
|
37
|
+
|
38
|
+
module Rabbit
|
39
|
+
module Renderer
|
40
|
+
class Screen
|
41
|
+
extend Forwardable
|
42
|
+
|
43
|
+
include Display::Base
|
44
|
+
|
45
|
+
include Display::Cursor
|
46
|
+
# include Display::Menu
|
47
|
+
# include Display::Graffiti
|
48
|
+
# include Display::Mask
|
49
|
+
# include Display::Progress
|
50
|
+
# include Display::Search
|
51
|
+
# include Display::Gesture
|
52
|
+
include Display::KeyHandler
|
53
|
+
# include Display::ButtonHandler
|
54
|
+
# include Display::ScrollHandler
|
55
|
+
# include Display::Info
|
56
|
+
# include Display::Spotlight
|
57
|
+
# include Display::Magnifier
|
58
|
+
|
59
|
+
def_delegators(:@slide_widget, :make_color)
|
60
|
+
def_delegators(:@slide_widget, :foreground=)
|
61
|
+
def_delegators(:@slide_widget, :background=)
|
62
|
+
def_delegators(:@slide_widget, :set_font_resolution)
|
63
|
+
|
64
|
+
def_delegators(:@slide_widget, :flag_size)
|
65
|
+
|
66
|
+
def_delegators(:@slide_widget, :draw_layout)
|
67
|
+
def_delegators(:@slide_widget, :draw_pixbuf)
|
68
|
+
def_delegators(:@slide_widget, :draw_line)
|
69
|
+
def_delegators(:@slide_widget, :draw_rectangle)
|
70
|
+
def_delegators(:@slide_widget, :draw_rsvg_handle)
|
71
|
+
def_delegators(:@slide_widget, :draw_link)
|
72
|
+
def_delegators(:@slide_widget, :draw_flag)
|
73
|
+
|
74
|
+
attr_accessor :filename
|
75
|
+
def initialize(canvas)
|
76
|
+
super
|
77
|
+
@filename = nil
|
78
|
+
init_ui
|
79
|
+
end
|
80
|
+
|
81
|
+
def attach_to(window, container=nil)
|
82
|
+
super
|
83
|
+
@window.add(@fixed)
|
84
|
+
@fixed.show
|
85
|
+
attach_key(@window)
|
86
|
+
end
|
87
|
+
|
88
|
+
def detach
|
89
|
+
detach_key(@window)
|
90
|
+
@fixed.hide
|
91
|
+
super
|
92
|
+
end
|
93
|
+
|
94
|
+
def widget
|
95
|
+
@fixed
|
96
|
+
end
|
97
|
+
|
98
|
+
def clear_slide
|
99
|
+
super
|
100
|
+
@slide_widget.clear_compiled_slide
|
101
|
+
redraw
|
102
|
+
end
|
103
|
+
|
104
|
+
def post_fullscreen
|
105
|
+
update_cursor(:blank, true)
|
106
|
+
@slide_widget.clear_compiled_slides
|
107
|
+
end
|
108
|
+
|
109
|
+
def post_unfullscreen
|
110
|
+
update_cursor(nil, true)
|
111
|
+
update_menu
|
112
|
+
end
|
113
|
+
|
114
|
+
def post_iconify
|
115
|
+
end
|
116
|
+
|
117
|
+
def post_apply_theme
|
118
|
+
@slide_widget.clear_compiled_slides
|
119
|
+
queue_draw
|
120
|
+
end
|
121
|
+
|
122
|
+
def post_move(old_index, index)
|
123
|
+
queue_draw
|
124
|
+
end
|
125
|
+
|
126
|
+
def post_move_in_slide(old_index, index)
|
127
|
+
queue_draw
|
128
|
+
end
|
129
|
+
|
130
|
+
def pre_parse
|
131
|
+
end
|
132
|
+
|
133
|
+
def post_parse
|
134
|
+
@slide_widget.clear_compiled_slides
|
135
|
+
end
|
136
|
+
|
137
|
+
def pre_toggle_index_mode
|
138
|
+
end
|
139
|
+
|
140
|
+
def post_toggle_index_mode
|
141
|
+
queue_draw
|
142
|
+
end
|
143
|
+
|
144
|
+
def pre_to_pixbuf(slide_size)
|
145
|
+
end
|
146
|
+
|
147
|
+
def to_pixbufing(i)
|
148
|
+
true
|
149
|
+
end
|
150
|
+
|
151
|
+
def post_to_pixbuf(canceled)
|
152
|
+
end
|
153
|
+
|
154
|
+
def index_mode_on
|
155
|
+
keep_cursor(:index)
|
156
|
+
update_cursor(nil, true)
|
157
|
+
end
|
158
|
+
|
159
|
+
def index_mode_off
|
160
|
+
restore_cursor(:index)
|
161
|
+
end
|
162
|
+
|
163
|
+
# TODO: screen?
|
164
|
+
def display?
|
165
|
+
true
|
166
|
+
end
|
167
|
+
|
168
|
+
def draw_slide(slide, simulation, &block)
|
169
|
+
set_size_ratio(slide.size_ratio || @default_size_ratio)
|
170
|
+
|
171
|
+
if simulation
|
172
|
+
@slide_widget.draw_slide(slide, simulation, &block)
|
173
|
+
else
|
174
|
+
@slide_widget.save_context do
|
175
|
+
@slide_widget.translate_context(@size.logical_margin_left,
|
176
|
+
@size.logical_margin_top)
|
177
|
+
@slide_widget.draw_slide(slide, simulation, &block)
|
178
|
+
end
|
179
|
+
|
180
|
+
unless @size.have_logical_margin?
|
181
|
+
return
|
182
|
+
end
|
183
|
+
|
184
|
+
margin_background = @slide_widget.make_color("black")
|
185
|
+
if @size.have_logical_margin_x?
|
186
|
+
@slide_widget.draw_rectangle(true,
|
187
|
+
0,
|
188
|
+
0,
|
189
|
+
@size.logical_margin_left,
|
190
|
+
@size.real_height,
|
191
|
+
margin_background)
|
192
|
+
@slide_widget.draw_rectangle(true,
|
193
|
+
@size.real_width - @size.logical_margin_right,
|
194
|
+
0,
|
195
|
+
@size.logical_margin_right,
|
196
|
+
@size.real_height,
|
197
|
+
margin_background)
|
198
|
+
end
|
199
|
+
if @size.have_logical_margin_y?
|
200
|
+
@slide_widget.draw_rectangle(true,
|
201
|
+
0,
|
202
|
+
0,
|
203
|
+
@size.real_width,
|
204
|
+
@size.logical_margin_top,
|
205
|
+
margin_background)
|
206
|
+
@slide_widget.draw_rectangle(true,
|
207
|
+
0,
|
208
|
+
@size.real_height - @size.logical_margin_bottom,
|
209
|
+
@size.real_width,
|
210
|
+
@size.logical_margin_bottom,
|
211
|
+
margin_background)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
private
|
217
|
+
def init_dpi
|
218
|
+
@x_dpi = ScreenInfo.screen_x_resolution
|
219
|
+
@y_dpi = ScreenInfo.screen_y_resolution
|
220
|
+
end
|
221
|
+
|
222
|
+
def init_ui
|
223
|
+
@fixed = Gtk::Fixed.new
|
224
|
+
@fixed.can_focus = true
|
225
|
+
set_map
|
226
|
+
set_size_allocate
|
227
|
+
|
228
|
+
set_key_press_event(@fixed)
|
229
|
+
|
230
|
+
@slide_widget = Widget::DrawingArea.new(@canvas)
|
231
|
+
@slide_widget.raw.show
|
232
|
+
@fixed.put(@slide_widget.raw, 0, 0)
|
233
|
+
end
|
234
|
+
|
235
|
+
def depth
|
236
|
+
@fixed.window.depth
|
237
|
+
end
|
238
|
+
|
239
|
+
def set_map
|
240
|
+
@fixed.signal_connect_after(:map) do |widget|
|
241
|
+
mapped(widget)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def mapped(widget)
|
246
|
+
allocation = widget.allocation
|
247
|
+
set_default_size(allocation.width,
|
248
|
+
allocation.height)
|
249
|
+
end
|
250
|
+
|
251
|
+
def set_size_allocate
|
252
|
+
@fixed.signal_connect(:size_allocate) do |widget, allocation|
|
253
|
+
w = allocation.width
|
254
|
+
h = allocation.height
|
255
|
+
@slide_widget.raw.allocation = allocation
|
256
|
+
update_size(w, h)
|
257
|
+
reload_theme
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
def reload_theme(&callback)
|
262
|
+
callback ||= Utils.process_pending_events_proc
|
263
|
+
@canvas.activate("ReloadTheme", &callback)
|
264
|
+
end
|
265
|
+
|
266
|
+
def grab
|
267
|
+
@fixed.grab_add
|
268
|
+
Gdk.pointer_grab(@fixed.window, false,
|
269
|
+
Gdk::EventMask::BUTTON_PRESS_MASK |
|
270
|
+
Gdk::EventMask::BUTTON_RELEASE_MASK |
|
271
|
+
Gdk::EventMask::SCROLL_MASK |
|
272
|
+
Gdk::EventMask::POINTER_MOTION_MASK,
|
273
|
+
nil, nil,
|
274
|
+
Gdk::CURRENT_TIME)
|
275
|
+
end
|
276
|
+
|
277
|
+
def ungrab
|
278
|
+
@fixed.grab_remove
|
279
|
+
Gdk.pointer_ungrab(Gdk::CURRENT_TIME)
|
280
|
+
end
|
281
|
+
|
282
|
+
def pointer
|
283
|
+
window, x, y, mask = @fixed.window.pointer
|
284
|
+
[x, y, mask]
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|