-
Notifications
You must be signed in to change notification settings - Fork 0
/
photolist.rb
59 lines (45 loc) · 1.28 KB
/
photolist.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require 'parallel'
class PhotoList < Gtk::IconView
attr_reader :bgthread
def initialize()
super()
@bgthread = nil
@db = nil
set_pixbuf_column(1)
set_text_column(2)
set_selection_mode(Gtk::SELECTION_MULTIPLE)
set_columns(0)
set_item_width(DEFAULT_IMAGE_WIDTH+10)
# Setup ListStore:
# Full Path; Thumbnail; Filename
@model = Gtk::ListStore.new(Image, Gdk::Pixbuf, String)
set_model(@model)
@pixbufs = []
end
def update()
return if (!@db)
@model.clear
@db.images.each{|im|
next if (!im.display)
iter = @model.append
@model.set_value(iter, 0, im)
@model.set_value(iter, 1, im.thumbnail)
name = im.filename
name += " (#{im.rank})" if (im.rank > 0)
@model.set_value(iter, 2, name)
}
@bgthread.kill if (@bgthread)
@bgthread = Thread.new {
list = []
@model.each{|model, path, iter|
im = @model.get_value(iter, 0)
im.genthumbnail
@model.set_value(iter, 1, im.thumbnail)
}
}
end
def set_database(db)
@db = db
update()
end
end