mireru 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +8 -0
- data/README.md +4 -0
- data/lib/mireru/command/mireru.rb +1 -1
- data/lib/mireru/container.rb +4 -0
- data/lib/mireru/thumbnail.rb +44 -0
- data/lib/mireru/version.rb +1 -1
- data/lib/mireru/widget.rb +7 -4
- data/lib/mireru/window.rb +12 -3
- data/test/test-container.rb +9 -0
- data/test/test-thumbnail.rb +15 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de717adbc118c32f4864dec868df30fcf776f14f
|
4
|
+
data.tar.gz: a23cab13d3c32ffc8ad88483970228cdf718719e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bbbfdd3d3126049269bf5db794641594f795a3144283f2a80357dabcac655c6a5718a4787dbf05f50a3e663123e7b4e33d7fa832dab3a59e70a562772b2034a
|
7
|
+
data.tar.gz: 8742ac1289baf9921e5c322a4e5ea849def9f1d1f745158059edc64cf85567465817744a65774e8fbca4de495ef7ec5759fbcf9c3d04eadb8aa9472b656d9368
|
data/NEWS.md
CHANGED
data/README.md
CHANGED
data/lib/mireru/container.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "gtk3"
|
2
|
+
require "mireru/widget"
|
3
|
+
|
4
|
+
module Mireru
|
5
|
+
class Thumbnail
|
6
|
+
class << self
|
7
|
+
def create(files, width, height)
|
8
|
+
nums_in_a_row = Math.sqrt(files.size)
|
9
|
+
rows = Gtk::Box.new(:vertical)
|
10
|
+
files.each_slice(nums_in_a_row) do |a_row_files|
|
11
|
+
row = Gtk::Box.new(:horizontal)
|
12
|
+
a_row_files.each do |file|
|
13
|
+
cell_width = width / nums_in_a_row
|
14
|
+
cell_height = height / nums_in_a_row
|
15
|
+
if Widget.image?(file)
|
16
|
+
image = image_from_file(file, cell_width, cell_height)
|
17
|
+
row.add(image)
|
18
|
+
else
|
19
|
+
label = label_from_file(file, cell_width, cell_height)
|
20
|
+
row.add(label)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
rows.add(row)
|
24
|
+
end
|
25
|
+
rows
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def image_from_file(file, width=100, height=100)
|
30
|
+
image = Gtk::Image.new
|
31
|
+
pixbuf = Gdk::Pixbuf.new(file, width, height)
|
32
|
+
image.pixbuf = pixbuf
|
33
|
+
image
|
34
|
+
end
|
35
|
+
|
36
|
+
def label_from_file(file, width=100, height=100)
|
37
|
+
label = Gtk::Label.new(File.basename(file))
|
38
|
+
label.set_size_request(width, height)
|
39
|
+
label.wrap = true
|
40
|
+
label
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/mireru/version.rb
CHANGED
data/lib/mireru/widget.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "gtk3"
|
2
|
+
require "gtksourceview3"
|
3
3
|
|
4
4
|
module Mireru
|
5
5
|
class Error < StandardError
|
@@ -7,10 +7,13 @@ module Mireru
|
|
7
7
|
|
8
8
|
class Widget
|
9
9
|
class << self
|
10
|
-
def create(file, width=
|
10
|
+
def create(file, width=10000, height=10000)
|
11
11
|
if image?(file)
|
12
12
|
image = Gtk::Image.new
|
13
|
+
pixbuf = Gdk::Pixbuf.new(file)
|
14
|
+
if pixbuf.width > width || pixbuf.height > height
|
13
15
|
pixbuf = Gdk::Pixbuf.new(file, width, height)
|
16
|
+
end
|
14
17
|
image.pixbuf = pixbuf
|
15
18
|
widget = image
|
16
19
|
else
|
@@ -21,7 +24,7 @@ module Mireru
|
|
21
24
|
end
|
22
25
|
view = GtkSource::View.new(buffer)
|
23
26
|
view.show_line_numbers = true
|
24
|
-
lang = GtkSource::LanguageManager.new.get_language(
|
27
|
+
lang = GtkSource::LanguageManager.new.get_language("ruby")
|
25
28
|
view.buffer.language = lang
|
26
29
|
view.buffer.highlight_syntax = true
|
27
30
|
view.buffer.highlight_matching_brackets = true
|
data/lib/mireru/window.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "gtk3"
|
2
2
|
require "mireru/widget"
|
3
|
+
require "mireru/thumbnail"
|
3
4
|
|
4
5
|
module Mireru
|
5
6
|
class Window < Gtk::Window
|
@@ -47,6 +48,9 @@ module Mireru
|
|
47
48
|
pixbuf = Gdk::Pixbuf.new(@file)
|
48
49
|
@widget.pixbuf = pixbuf
|
49
50
|
end
|
51
|
+
when Gdk::Keyval::GDK_KEY_T
|
52
|
+
files = @container.instance_variable_get(:@files)
|
53
|
+
self.add_from_file(files)
|
50
54
|
when Gdk::Keyval::GDK_KEY_plus
|
51
55
|
if Mireru::Widget.image?(@file)
|
52
56
|
width = @widget.pixbuf.width
|
@@ -103,14 +107,19 @@ module Mireru
|
|
103
107
|
@scroll.hadjustment.value = 0
|
104
108
|
@scroll.vadjustment.value = 0
|
105
109
|
@scroll.each {|child| @scroll.remove(child) }
|
106
|
-
|
110
|
+
if file.is_a?(Enumerable)
|
111
|
+
@widget = Mireru::Thumbnail.create(file, *self.size)
|
112
|
+
self.title = "Thumbnails: #{file.size} / #{file.size}"
|
113
|
+
else
|
114
|
+
@widget = Mireru::Widget.create(file, *self.size)
|
115
|
+
self.title = File.basename(file)
|
116
|
+
end
|
107
117
|
@widget.override_font(Pango::FontDescription.new(@font)) if @font
|
108
118
|
if @widget.is_a?(Gtk::Scrollable)
|
109
119
|
@scroll.add(@widget)
|
110
120
|
else
|
111
121
|
@scroll.add_with_viewport(@widget)
|
112
122
|
end
|
113
|
-
self.title = File.basename(file)
|
114
123
|
self.show_all
|
115
124
|
end
|
116
125
|
end
|
data/test/test-container.rb
CHANGED
@@ -5,6 +5,15 @@ class ContainerTest < Test::Unit::TestCase
|
|
5
5
|
@container = Mireru::Container.new
|
6
6
|
end
|
7
7
|
|
8
|
+
def test_size
|
9
|
+
assert_equal(0, @container.size)
|
10
|
+
files = @container.instance_variable_get(:@files)
|
11
|
+
files << __FILE__
|
12
|
+
assert_equal(1, @container.size)
|
13
|
+
files << __FILE__
|
14
|
+
assert_equal(2, @container.size)
|
15
|
+
end
|
16
|
+
|
8
17
|
def test_no_argument
|
9
18
|
valid = @container.__send__(:file?, nil)
|
10
19
|
assert_false(valid)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "mireru/thumbnail"
|
2
|
+
|
3
|
+
class ThumbnailTest < Test::Unit::TestCase
|
4
|
+
def test_image_from_file
|
5
|
+
widget = Mireru::Thumbnail.__send__(:image_from_file,
|
6
|
+
"test/fixtures/nijip.png")
|
7
|
+
assert_equal(Gtk::Image, widget.class)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_label_from_fil
|
11
|
+
widget = Mireru::Thumbnail.__send__(:label_from_file,
|
12
|
+
__FILE__)
|
13
|
+
assert_equal(Gtk::Label, widget.class)
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mireru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masafumi Yokoyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gtk3
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- lib/mireru/command/mireru.rb
|
131
131
|
- lib/mireru/container.rb
|
132
132
|
- lib/mireru/logger.rb
|
133
|
+
- lib/mireru/thumbnail.rb
|
133
134
|
- lib/mireru/version.rb
|
134
135
|
- lib/mireru/widget.rb
|
135
136
|
- lib/mireru/window.rb
|
@@ -142,6 +143,7 @@ files:
|
|
142
143
|
- test/test-container.rb
|
143
144
|
- test/test-logger.rb
|
144
145
|
- test/test-mireru.rb
|
146
|
+
- test/test-thumbnail.rb
|
145
147
|
- test/test-widget.rb
|
146
148
|
- test/test-window.rb
|
147
149
|
homepage: https://github.com/myokoym/mireru
|
@@ -177,6 +179,7 @@ test_files:
|
|
177
179
|
- test/test-container.rb
|
178
180
|
- test/test-logger.rb
|
179
181
|
- test/test-mireru.rb
|
182
|
+
- test/test-thumbnail.rb
|
180
183
|
- test/test-widget.rb
|
181
184
|
- test/test-window.rb
|
182
185
|
has_rdoc:
|