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
59
60
61
62
|
# File 'lib/alexandria/ui/new_provider_dialog.rb', line 15
def initialize(parent)
super(title: _("New Provider"),
parent: parent,
flags: :modal,
buttons: [[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL]])
@add_button = add_button(Gtk::Stock::ADD,
Gtk::ResponseType::ACCEPT)
instances = BookProviders.abstract_classes.map(&:new)
@selected_instance = nil
@table = Gtk::Table.new(2, 2)
child.pack_start(@table)
label_name = Gtk::Label.new(_("_Name:"))
label_name.use_underline = true
label_name.xalign = 0
@table.attach_defaults(label_name, 0, 1, 0, 1)
entry_name = Gtk::Entry.new
entry_name.mandatory = true
label_name.mnemonic_widget = entry_name
@table.attach_defaults(entry_name, 1, 2, 0, 1)
label_type = Gtk::Label.new(_("_Type:"))
label_type.use_underline = true
label_type.xalign = 0
@table.attach_defaults(label_type, 0, 1, 1, 2)
combo_type = Gtk::ComboBoxText.new
instances.each do |instance|
combo_type.append_text(instance.name)
end
combo_type.signal_connect("changed") do |cb|
@selected_instance = instances[cb.active]
fill_table(@table, @selected_instance)
sensitize
end
combo_type.active = 0
label_type.mnemonic_widget = combo_type
@table.attach_defaults(combo_type, 1, 2, 1, 2)
end
|