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,39 @@
|
|
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 "glib2"
|
18
|
+
|
19
|
+
module Rabbit
|
20
|
+
class Filename
|
21
|
+
class << self
|
22
|
+
def sanitize(string)
|
23
|
+
string.gsub(/[\r\n]/, "").gsub(/[\/\\:]/, "-")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(filename)
|
28
|
+
@utf8_filename = filename.encode("UTF-8")
|
29
|
+
end
|
30
|
+
|
31
|
+
def encode
|
32
|
+
if GLib.const_defined?(:Win32)
|
33
|
+
GLib::Win32.locale_filename_from_utf8(@utf8_filename)
|
34
|
+
else
|
35
|
+
GLib.filename_from_utf8(@utf8_filename)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/rabbit/formatter.rb
CHANGED
@@ -28,18 +28,6 @@ module Rabbit
|
|
28
28
|
module SpanTextFormatter
|
29
29
|
include Formatter
|
30
30
|
|
31
|
-
PANGO2CSS = {
|
32
|
-
"font_family" => Proc.new do |name, value|
|
33
|
-
["font-family", "'#{value}'"]
|
34
|
-
end,
|
35
|
-
"foreground" => "color",
|
36
|
-
"size" => Proc.new do |name, value|
|
37
|
-
["font-size", "#{(value / Pango::SCALE) * 2}px"]
|
38
|
-
end,
|
39
|
-
"style" => "font-style",
|
40
|
-
"weight" => "font-weight",
|
41
|
-
}
|
42
|
-
|
43
31
|
attr_reader :value
|
44
32
|
|
45
33
|
def initialize(value)
|
@@ -55,26 +43,24 @@ module Rabbit
|
|
55
43
|
end
|
56
44
|
|
57
45
|
def format(text)
|
58
|
-
tagged_text(text, "span",
|
46
|
+
tagged_text(text, "span", {name => pango_value})
|
59
47
|
end
|
60
48
|
|
61
49
|
def html_format(text)
|
62
|
-
css_name, css_value = pango2css(name, @value)
|
63
50
|
tagged_text(text, "span", {'style' => "#{css_name}: #{css_value};"})
|
64
51
|
end
|
65
52
|
|
53
|
+
def pango_value
|
54
|
+
@value
|
55
|
+
end
|
56
|
+
|
66
57
|
private
|
67
|
-
def
|
68
|
-
|
58
|
+
def css_name
|
59
|
+
name
|
69
60
|
end
|
70
61
|
|
71
|
-
def
|
72
|
-
|
73
|
-
if css_name.respond_to?(:call)
|
74
|
-
css_name.call(name, value)
|
75
|
-
else
|
76
|
-
[css_name || name, value]
|
77
|
-
end
|
62
|
+
def css_value
|
63
|
+
value
|
78
64
|
end
|
79
65
|
end
|
80
66
|
|
@@ -93,17 +79,62 @@ module Rabbit
|
|
93
79
|
EOC
|
94
80
|
end
|
95
81
|
|
96
|
-
class
|
97
|
-
|
98
|
-
|
99
|
-
|
82
|
+
class FontFamily
|
83
|
+
private
|
84
|
+
def css_name
|
85
|
+
"font-family"
|
86
|
+
end
|
87
|
+
|
88
|
+
def css_value
|
89
|
+
"'#{@value}'"
|
100
90
|
end
|
101
91
|
end
|
102
92
|
|
103
93
|
class Foreground
|
104
|
-
def
|
105
|
-
|
106
|
-
|
94
|
+
def pango_value
|
95
|
+
Renderer::Color.parse(@value).to_gdk_format
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
def css_name
|
100
|
+
"color"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class Size
|
105
|
+
def pango_value
|
106
|
+
if @value > Pango::SCALE # For backward compatibility
|
107
|
+
@value.ceil
|
108
|
+
else
|
109
|
+
(@value * Pango::SCALE).ceil
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
def css_name
|
115
|
+
"font-size"
|
116
|
+
end
|
117
|
+
|
118
|
+
def css_value
|
119
|
+
if value > Pango::SCALE # For backward compatibility
|
120
|
+
"#{(value / Pango::SCALE) * 2}px"
|
121
|
+
else
|
122
|
+
"#{value * 2}px"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
class Style
|
128
|
+
private
|
129
|
+
def css_name
|
130
|
+
"font-style"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
class Weigth
|
135
|
+
private
|
136
|
+
def css_name
|
137
|
+
"font-weight"
|
107
138
|
end
|
108
139
|
end
|
109
140
|
|
data/lib/rabbit/frame.rb
CHANGED
@@ -25,13 +25,12 @@ module Rabbit
|
|
25
25
|
def_delegators(:@canvas, :rss_base_uri=, :use_gl?, :use_gl=)
|
26
26
|
|
27
27
|
attr_reader :window, :logger
|
28
|
-
attr_accessor :geometry
|
28
|
+
attr_accessor :geometry
|
29
29
|
|
30
30
|
def initialize(logger, canvas)
|
31
31
|
@logger = logger
|
32
32
|
@canvas = canvas
|
33
33
|
@geometry = nil
|
34
|
-
@force_keep_above = nil
|
35
34
|
end
|
36
35
|
|
37
36
|
def destroyed?
|
@@ -88,11 +87,6 @@ module Rabbit
|
|
88
87
|
init_window(width, height, window_type)
|
89
88
|
@fullscreen = false
|
90
89
|
@main_window = main_window
|
91
|
-
if @main_window
|
92
|
-
@window.keep_above = @force_keep_above unless @force_keep_above.nil?
|
93
|
-
else
|
94
|
-
@window.keep_above = true
|
95
|
-
end
|
96
90
|
@window.show
|
97
91
|
@canvas.post_init_gui
|
98
92
|
end
|
@@ -122,24 +116,13 @@ module Rabbit
|
|
122
116
|
set_window_signal_destroy
|
123
117
|
end
|
124
118
|
|
125
|
-
def update_keep_above(keep_above)
|
126
|
-
if @main_window
|
127
|
-
keep_above = @force_keep_above unless @force_keep_above.nil?
|
128
|
-
@window.keep_above = keep_above
|
129
|
-
else
|
130
|
-
@window.keep_above = true
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
119
|
def set_window_signal_window_state_event
|
135
120
|
@window.signal_connect("window_state_event") do |widget, event|
|
136
121
|
if event.changed_mask.fullscreen?
|
137
122
|
@fullscreen = event.new_window_state.fullscreen?
|
138
123
|
if @fullscreen
|
139
|
-
@window.keep_above = true
|
140
124
|
@canvas.fullscreened
|
141
125
|
else
|
142
|
-
update_keep_above(false)
|
143
126
|
@canvas.unfullscreened
|
144
127
|
end
|
145
128
|
elsif event.changed_mask.iconified?
|
@@ -191,7 +174,6 @@ module Rabbit
|
|
191
174
|
def_null_methods(:icon, :icon=, :set_icon)
|
192
175
|
def_null_methods(:icon_list, :icon_list=, :set_icon_list)
|
193
176
|
def_null_methods(:update_title, :geometry, :geometry=)
|
194
|
-
def_null_methods(:force_keep_above, :force_keep_above=)
|
195
177
|
|
196
178
|
def_null_methods(:fullscreen?, :quit)
|
197
179
|
|
data/lib/rabbit/front.rb
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# Copyright (C) 2005-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 "monitor"
|
2
18
|
|
3
19
|
require "rabbit/rabbit"
|
@@ -29,11 +45,16 @@ module Rabbit
|
|
29
45
|
AVAILABLE_INTERFACES << [name, PublicLevel::MOVE, false]
|
30
46
|
end
|
31
47
|
|
32
|
-
%w(width height paper_width paper_height).each do |name|
|
48
|
+
%w(width height base_width base_height paper_width paper_height).each do |name|
|
33
49
|
AVAILABLE_INTERFACES << [name, PublicLevel::READ_SIZE, false]
|
34
50
|
end
|
35
51
|
|
36
|
-
|
52
|
+
# Deprecated. Use #base_width= and #base_height= instead.
|
53
|
+
%w(width= height=).each do |name|
|
54
|
+
AVAILABLE_INTERFACES << [name, PublicLevel::CHANGE_SIZE, true]
|
55
|
+
end
|
56
|
+
|
57
|
+
%w(base_width= base_height= paper_width= paper_height=).each do |name|
|
37
58
|
AVAILABLE_INTERFACES << [name, PublicLevel::CHANGE_SIZE, true]
|
38
59
|
end
|
39
60
|
|
@@ -1,3 +1,19 @@
|
|
1
|
+
# Copyright (C) 2006-2017 Kouhei Sutou <kou@cozmixng.org>
|
2
|
+
#
|
3
|
+
# This program is free software; you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation; either version 2 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along
|
14
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
15
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
16
|
+
|
1
17
|
require 'rabbit/gtk'
|
2
18
|
|
3
19
|
require 'rabbit/rabbit'
|
@@ -79,7 +95,8 @@ module Rabbit
|
|
79
95
|
def draw(renderer)
|
80
96
|
if @back_color.alpha == 1.0 or
|
81
97
|
(@back_color.alpha < 1.0 and renderer.alpha_available?)
|
82
|
-
|
98
|
+
size = renderer.size
|
99
|
+
args = [true, 0, 0, size.real_width, size.real_height]
|
83
100
|
args << @back_color
|
84
101
|
renderer.draw_rectangle(*args)
|
85
102
|
end
|
@@ -160,7 +177,9 @@ module Rabbit
|
|
160
177
|
icon = nil
|
161
178
|
icon = act.create_icon(Gtk::IconSize::DIALOG) if act
|
162
179
|
if icon
|
163
|
-
|
180
|
+
stock, = icon.stock
|
181
|
+
icon_size = icon.icon_size
|
182
|
+
pixbuf = icon.render_icon_pixbuf(stock, icon_size)
|
164
183
|
x -= pixbuf.width / 2.0
|
165
184
|
y -= pixbuf.height / 2.0
|
166
185
|
renderer.draw_pixbuf(pixbuf, x, y)
|
@@ -7,16 +7,18 @@ module Rabbit
|
|
7
7
|
class ConfigDialog
|
8
8
|
include GetText
|
9
9
|
|
10
|
-
attr_reader :color, :line_width
|
11
10
|
def initialize(color, line_width)
|
12
|
-
@original_color =
|
13
|
-
@original_line_width =
|
11
|
+
@original_color = color
|
12
|
+
@original_line_width = line_width
|
14
13
|
end
|
15
14
|
|
16
15
|
def run(&block)
|
17
16
|
@callback = block
|
18
17
|
init_dialog
|
19
|
-
if @dialog.run
|
18
|
+
if @dialog.run == Gtk::ResponseType::OK
|
19
|
+
@callback.call(Renderer::Color.new(@dialog.rgba),
|
20
|
+
nil)
|
21
|
+
else
|
20
22
|
@callback.call(@original_color, @original_line_width)
|
21
23
|
end
|
22
24
|
@dialog.destroy
|
@@ -24,20 +26,12 @@ module Rabbit
|
|
24
26
|
|
25
27
|
private
|
26
28
|
def init_dialog
|
27
|
-
@dialog = Gtk::
|
28
|
-
|
29
|
-
|
30
|
-
colorsel.has_palette = true
|
31
|
-
r, g, b, a = @original_color.to_gdk_rgba
|
32
|
-
colorsel.set_current_color(Gdk::Color.new(r, g, b))
|
33
|
-
colorsel.set_current_alpha(a)
|
29
|
+
@dialog = Gtk::ColorChooserDialog.new
|
30
|
+
@dialog.use_alpha = true
|
31
|
+
@dialog.rgba = @original_color.to_gdk_rgba
|
34
32
|
add_line_width_control
|
35
|
-
|
36
|
-
|
37
|
-
color.have_alpha = true
|
38
|
-
alpha = colorsel.current_alpha / Renderer::Color::GDK_COLOR_NORMALIZE
|
39
|
-
color.alpha = alpha
|
40
|
-
@callback.call(color, nil)
|
33
|
+
@dialog.signal_connect(:color_activated) do |gdk_color|
|
34
|
+
@callback.call(Renderer::Color.new(gdk_color), nil)
|
41
35
|
end
|
42
36
|
end
|
43
37
|
|
@@ -52,7 +46,10 @@ module Rabbit
|
|
52
46
|
hbox.pack_end(spin, :expand => false, :fill => false, :padding => 5)
|
53
47
|
hbox.pack_end(label, :expand => false, :fill => false, :padding => 5)
|
54
48
|
hbox.show_all
|
55
|
-
@dialog.
|
49
|
+
@dialog.child.pack_end(hbox,
|
50
|
+
:expand => false,
|
51
|
+
:fill => false,
|
52
|
+
:padding => 5)
|
56
53
|
end
|
57
54
|
end
|
58
55
|
end
|
data/lib/rabbit/gtk.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2018 Kouhei Sutou <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,193 +14,4 @@
|
|
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 "
|
18
|
-
|
19
|
-
if ENV["RABBIT_GTK_VERSION"] == "3"
|
20
|
-
require "gtk3"
|
21
|
-
Gtk.init if Gtk.respond_to?(:init)
|
22
|
-
else
|
23
|
-
require "cairo"
|
24
|
-
require "gio2"
|
25
|
-
require "gtk2"
|
26
|
-
end
|
27
|
-
|
28
|
-
module Cairo
|
29
|
-
class Region
|
30
|
-
unless public_method_defined?(:each_rectangle)
|
31
|
-
def each_rectangle
|
32
|
-
num_rectangles.times do |i|
|
33
|
-
yield(self[i])
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
module Pango
|
41
|
-
unless const_defined?(:WrapMode)
|
42
|
-
WrapMode = Layout::WrapMode
|
43
|
-
end
|
44
|
-
|
45
|
-
unless const_defined?(:Alignment)
|
46
|
-
Alignment = Layout::Alignment
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
module Gdk
|
51
|
-
class Event
|
52
|
-
STOP = true unless const_defined?(:STOP)
|
53
|
-
PROPAGATE = false unless const_defined?(:PROPAGATE)
|
54
|
-
end
|
55
|
-
|
56
|
-
class Window
|
57
|
-
unless method_defined?(:width)
|
58
|
-
def width
|
59
|
-
size[0]
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
unless method_defined?(:height)
|
64
|
-
def height
|
65
|
-
size[1]
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
unless const_defined?(:EventType)
|
71
|
-
EventType = Event::Type
|
72
|
-
end
|
73
|
-
|
74
|
-
unless const_defined?(:ModifierType)
|
75
|
-
ModifierType = Window::ModifierType
|
76
|
-
end
|
77
|
-
|
78
|
-
unless const_defined?(:EventMask)
|
79
|
-
EventMask = Event::Mask
|
80
|
-
end
|
81
|
-
|
82
|
-
module Keyval
|
83
|
-
constants.each do |name|
|
84
|
-
if /\AGDK_KEY_/ =~ name.to_s
|
85
|
-
const_set("KEY_#{$POSTMATCH}", const_get(name))
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
class Screen
|
91
|
-
unless method_defined?(:get_monitor_geometry)
|
92
|
-
alias_method :get_monitor_geometry, :monitor_geometry
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
unless const_defined?(:ScrollDirection)
|
97
|
-
ScrollDirection = Gdk::EventScroll::Direction
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
module Gtk
|
102
|
-
unless const_defined?(:Actionable)
|
103
|
-
class Action
|
104
|
-
alias_method :initialize_raw, :initialize
|
105
|
-
def initialize(name, options={})
|
106
|
-
initialize_raw(name,
|
107
|
-
options[:label],
|
108
|
-
options[:tooltip],
|
109
|
-
options[:stock_id])
|
110
|
-
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
unless const_defined?(:Application)
|
116
|
-
class Application < Gio::Application
|
117
|
-
attr_reader :windows
|
118
|
-
def initialize(id, flags)
|
119
|
-
super
|
120
|
-
signal_connect_after("activate") do
|
121
|
-
Gtk.main unless @windows.empty?
|
122
|
-
end
|
123
|
-
@windows = []
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
unless const_defined?(:ApplicationWindow)
|
129
|
-
class ApplicationWindow
|
130
|
-
class << self
|
131
|
-
def new(application)
|
132
|
-
window = Window.new
|
133
|
-
application.windows << window
|
134
|
-
window.signal_connect("destroy") do
|
135
|
-
windows = application.windows
|
136
|
-
windows.delete(window)
|
137
|
-
Gtk.main_quit if windows.empty?
|
138
|
-
end
|
139
|
-
window
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
class Widget
|
146
|
-
unless public_method_defined?(:drag_dest_set)
|
147
|
-
def drag_dest_set(flags, targets, actions)
|
148
|
-
Gtk::Drag.dest_set(self, flags, targets, actions)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
unless public_method_defined?(:shape_combine_region)
|
153
|
-
def shape_combine_region(cairo_region)
|
154
|
-
gdk_region = cairo_region_to_gdk_region(cairo_region)
|
155
|
-
window.shape_combine_region(gdk_region, 0, 0)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
private
|
160
|
-
def cairo_region_to_gdk_region(cairo_region)
|
161
|
-
return nil if cairo_region.nil?
|
162
|
-
|
163
|
-
gdk_region = Gdk::Region.new
|
164
|
-
cairo_region.each_rectangle do |rectangle|
|
165
|
-
gdk_region.union(Gdk::Rectangle.new(*rectangle))
|
166
|
-
end
|
167
|
-
gdk_region
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
if Box.gtype.abstract?
|
172
|
-
class HBox
|
173
|
-
class << self
|
174
|
-
alias_method :new_raw, :new
|
175
|
-
def new(*arguments)
|
176
|
-
new_raw(*arguments)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
class VBox
|
182
|
-
class << self
|
183
|
-
alias_method :new_raw, :new
|
184
|
-
def new(*arguments)
|
185
|
-
new_raw(*arguments)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
class Box
|
191
|
-
class << self
|
192
|
-
def new(type)
|
193
|
-
case type
|
194
|
-
when :horizontal
|
195
|
-
HBox.new
|
196
|
-
when :vertical
|
197
|
-
VBox.new
|
198
|
-
else
|
199
|
-
raise ArgumentError,
|
200
|
-
"Box type must be :horizontal or :vertical: #{type.inspect}"
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
17
|
+
require "gtk3"
|