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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/ManqodHelp/FormatsEditor.rb', line 6
def initialize(help)
@help=help
super()
set_transient_for(help)
set_modal(true)
add(Gtk::VBox.new.
pack_start(Gtk::HBox.new.pack_start(@names=Gtk::ComboBox.new).
pack_start(@new_format=Gtk::Button.new(Gtk::Stock::NEW),false,false).
pack_start(@remove_format=Gtk::Button.new(Gtk::Stock::REMOVE),false,false)
).
pack_start(@props=Gtk::Table.new(2,1))
)
append_widget("Name(unique):",@name=Gtk::Entry.new)
append_widget("Code(regexp escaped):",@code=Gtk::Entry.new)
append_widget("Font:",@font=Gtk::FontButton.new)
append_widget("Foreground:",Gtk::HBox.new.pack_start(@foreground=Gtk::ColorButton.new).pack_start(@foreground_set=Gtk::ToggleButton.new("set"),false,false))
append_widget("Background:",Gtk::HBox.new.pack_start(@background=Gtk::ColorButton.new).pack_start(@background_set=Gtk::ToggleButton.new("set"),false,false))
append_widget("Justification:",@justification=FormatJustificationWidget.new(self))
append_widget(nil,Gtk::HBox.new.pack_start(@underline=Gtk::ToggleButton.new(Gtk::Stock::UNDERLINE)).pack_start(@strikethrough=Gtk::ToggleButton.new(Gtk::Stock::STRIKETHROUGH)))
@code.signal_connect('changed'){|me|
if tag=tag_table.lookup(@names.active_text)
tag.set_code(me.text).save
end
}
@font.signal_connect("font-set"){|me|
if tag=tag_table.lookup(@names.active_text)
tag.set_font(me.font_name).save
end
}
@foreground.signal_connect("color-set"){|me|
if tag=tag_table.lookup(@names.active_text)
tag.set_foreground_gdk(me.color).save
end
}
@foreground_set.signal_connect('toggled'){|me|
if tag=tag_table.lookup(@names.active_text)
tag.set_foreground_set(me.active?).save
end
}
@background.signal_connect("color-set"){|me|
if tag=tag_table.lookup(@names.active_text)
tag.set_background_gdk(me.color).set_background_set(true).save
end
}
@background_set.signal_connect('toggled'){|me|
if tag=tag_table.lookup(@names.active_text)
tag.set_background_set(me.active?).save
end
}
@underline.signal_connect("toggled"){|me|
if tag=tag_table.lookup(@names.active_text)
tag.set_underline(me.active? ? Pango::AttrUnderline::SINGLE : Pango::AttrUnderline::NONE).set_underline_set(me.active?).save
end
}
@strikethrough.signal_connect("toggled"){|me|
if tag=tag_table.lookup(@names.active_text)
tag.set_strikethrough(me.active?).set_strikethrough_set(me.active?).save
end
}
set_width_request(500)
@names.signal_connect("changed"){|me|
populate
}
@new_format.signal_connect('clicked',self){|me,fe|
w=Gtk::Dialog.new("New format name",fe,Gtk::Dialog::MODAL|Gtk::Dialog::DESTROY_WITH_PARENT,[Gtk::Stock::NEW,Gtk::Dialog::RESPONSE_ACCEPT],[Gtk::Stock::CANCEL,Gtk::Dialog::RESPONSE_REJECT]).set_default_response(Gtk::Dialog::RESPONSE_ACCEPT)
w.vbox.pack_start(Gtk::Label.new("Format Name(only use names that can't be links):"),false,false).pack_start(e=Gtk::Entry.new,false,false)
w.show_all.run{|response|
if response == Gtk::Dialog::RESPONSE_ACCEPT
tag_table.add({"name"=>e.text})
populate_names(e.text)
tag=tag_table.lookup(e.text)
ManqodDB.instance.manqod_db.save_help_format(e.text,tag.export)
end
w.destroy
}
}
@remove_format.signal_connect('clicked'){|me|
if tag=tag_table.lookup(@names.active_text)
tag_table.remove(tag)
populate_names
ManqodDB.instance.manqod_db.remove_help_format(@names.active_text)
end
}
end
|