mireru 0.1.4 → 0.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b487538b444efd4c0338a983d8c497314b4f842
4
- data.tar.gz: 056e6e0490665009c82c0a4b345783346f50b6f1
3
+ metadata.gz: de717adbc118c32f4864dec868df30fcf776f14f
4
+ data.tar.gz: a23cab13d3c32ffc8ad88483970228cdf718719e
5
5
  SHA512:
6
- metadata.gz: 8c0c370545a91cfbed851113b8bf0c39c00ea1ee3441b5d20849ffe8a05af99cb5585c17fcc6203d46f9d855c3d57aab300b9032f67faf84fb7aa64a42343d0f
7
- data.tar.gz: a363a6d984ee976bded96de7f1ed9b456001512fe351636178558615f58465116c7b1f2d57cfcce368a28627b6557c91770a061ab0f462c5207193eb57811508
6
+ metadata.gz: 7bbbfdd3d3126049269bf5db794641594f795a3144283f2a80357dabcac655c6a5718a4787dbf05f50a3e663123e7b4e33d7fa832dab3a59e70a562772b2034a
7
+ data.tar.gz: 8742ac1289baf9921e5c322a4e5ea849def9f1d1f745158059edc64cf85567465817744a65774e8fbca4de495ef7ec5759fbcf9c3d04eadb8aa9472b656d9368
data/NEWS.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # NEWS
2
2
 
3
+ ## 0.1.5: 2013-08-29
4
+
5
+ ### Changes
6
+
7
+ * Improvements
8
+ * Use original-size as default if it is smaller than window-size.
9
+ * Supported thumbnail view.
10
+
3
11
  ## 0.1.4: 2013-07-09
4
12
 
5
13
  ### Changes
data/README.md CHANGED
@@ -46,6 +46,10 @@ l: right<br />
46
46
  +: larger<br />
47
47
  -: smaller<br />
48
48
 
49
+ #### Special
50
+
51
+ T: thumbnail
52
+
49
53
  #### Image
50
54
 
51
55
  f: fits window size<br />
@@ -1,4 +1,4 @@
1
- require 'gtk3'
1
+ require "gtk3"
2
2
  require "mireru/logger"
3
3
  require "mireru/window"
4
4
  require "mireru/container"
@@ -8,6 +8,10 @@ module Mireru
8
8
  @files.empty?
9
9
  end
10
10
 
11
+ def size
12
+ @files.size
13
+ end
14
+
11
15
  def pop(complement_file=nil)
12
16
  @files.unshift(complement_file) if complement_file
13
17
  @files.pop
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Mireru
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/mireru/widget.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'gtk3'
2
- require 'gtksourceview3'
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=nil, height=nil)
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('ruby')
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 'gtk3'
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
- @widget = Mireru::Widget.create(file, *self.size)
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
@@ -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
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-07-09 00:00:00.000000000 Z
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: