C0 code coverage information
Generated on Tue Oct 16 11:40:51 -0400 2007 with rcov 0.8.0
Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
1 # Copyright (C) 2004-2006 Laurent Sansonetti
2 #
3 # Alexandria is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License as
5 # published by the Free Software Foundation; either version 2 of the
6 # License, or (at your option) any later version.
7 #
8 # Alexandria 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 GNU
11 # General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public
14 # License along with Alexandria; see the file COPYING. If not,
15 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 # Boston, MA 02111-1307, USA.
17
18 class Gdk::Pixbuf
19 def tag(tag_pixbuf)
20 # Computes some tweaks.
21 tweak_x = tag_pixbuf.width / 3
22 tweak_y = tag_pixbuf.height / 3
23
24 # Creates the destination pixbuf.
25 new_pixbuf = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB,
26 true,
27 8,
28 self.width + tweak_x,
29 self.height + tweak_y)
30
31 # Fills with blank.
32 new_pixbuf.fill!(0)
33
34 # Copies the current pixbuf there (south-west).
35 self.copy_area(0, 0,
36 self.width, self.height,
37 new_pixbuf,
38 0, tweak_y)
39
40 # Copies the tag pixbuf there (north-est).
41 tag_pixbuf_x = self.width - (tweak_x * 2)
42 new_pixbuf.composite!(tag_pixbuf,
43 0, 0,
44 tag_pixbuf.width + tag_pixbuf_x,
45 tag_pixbuf.height,
46 tag_pixbuf_x, 0,
47 1, 1,
48 Gdk::Pixbuf::INTERP_HYPER, 255)
49 return new_pixbuf
50 end
51 end
52
53 module Alexandria
54 module UI
55 module Icons
56 def self.init
57 icons_dir = File.join(Alexandria::Config::DATA_DIR, "icons")
58 Dir.entries(icons_dir).each do |file|
59 next unless file =~ /\.png$/ # skip non '.png' files
60 name = File.basename(file, ".png").upcase
61 const_set(name, Gdk::Pixbuf.new(File.join(icons_dir, file)))
62 end
63 end
64
65 def self.cover(library, book)
66 filename = library.cover(book)
67 if File.exists?(filename)
68 begin
69 return Gdk::Pixbuf.new(filename)
70 rescue Exception => err
71 # report load error; FIX should go to a Logger...
72 puts err.message
73 puts "Failed to load Gdk::Pixbuf, please ensure that from #{filename} is a valid image file"
74 end
75 end
76 BOOK_ICON
77 end
78
79 def self.blank?(filename)
80 pixbuf = Gdk::Pixbuf.new(filename)
81 pixbuf.width == 1 and pixbuf.height == 1
82 end
83 end
84 end
85 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.0.