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 # Ideally this would be a subclass of GtkComboBox, but...
19 class Gtk::ComboBox
20 include GetText
21 extend GetText
22 GetText.bindtextdomain(Alexandria::TEXTDOMAIN, nil, nil, "UTF-8")
23
24 def populate_with_libraries(libraries, selected_library)
25 libraries_names = libraries.map { |x| x.name }
26 if selected_library
27 libraries_names.delete selected_library.name
28 libraries_names.unshift selected_library.name
29 end
30 self.clear
31 self.set_row_separator_func do |model, iter|
32 iter[1] == '-'
33 end
34 self.model = Gtk::ListStore.new(Gdk::Pixbuf, String, TrueClass)
35 libraries_names.each do |library_name|
36 iter = self.model.append
37 iter[0] = Alexandria::UI::Icons::LIBRARY_SMALL
38 iter[1] = library_name
39 iter[2] = false
40 end
41 self.model.append[1] = '-'
42 iter = self.model.append
43 iter[0] = Alexandria::UI::Icons::LIBRARY_SMALL
44 iter[1] = _('New Library')
45 iter[2] = true
46 renderer = Gtk::CellRendererPixbuf.new
47 self.pack_start(renderer, false)
48 self.set_attributes(renderer, :pixbuf => 0)
49 renderer = Gtk::CellRendererText.new
50 self.pack_start(renderer, true)
51 self.set_attributes(renderer, :text => 1)
52 self.active = 0
53 self.sensitive = libraries.length > 1
54 end
55
56 def selection_from_libraries(libraries)
57 iter = self.active_iter
58 is_new = false
59 library = nil
60 if iter[2]
61 name = Alexandria::Library.generate_new_name(libraries)
62 library = Alexandria::Library.load(name)
63 libraries << library
64 is_new = true
65 else
66 library = libraries.find do |x|
67 x.name == self.active_iter[1]
68 end
69 end
70 raise unless library
71 return [library, is_new]
72 end
73 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.0.