Class: Mireru::Thumbnail

Inherits:
Object
  • Object
show all
Defined in:
lib/mireru/thumbnail.rb

Class Method Summary collapse

Class Method Details

.create(files, width, height) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mireru/thumbnail.rb', line 7

def create(files, width, height)
  nums_in_a_row = Math.sqrt(files.size)
  rows = Gtk::Box.new(:vertical)
  files.each_slice(nums_in_a_row) do |a_row_files|
    row = Gtk::Box.new(:horizontal)
    a_row_files.each do |file|
      cell_width  = width  / nums_in_a_row
      cell_height = height / nums_in_a_row
      if Widget.image?(file)
        image = image_from_file(file, cell_width, cell_height)
        row.add(image)
      else
        label = label_from_file(file, cell_width, cell_height)
        row.add(label)
      end
    end
    rows.add(row)
  end
  rows
end