33
33
internal partial class GtkErrorDialog : Gtk.Dialog
35
TextTag tagWrap, tagNoWrap;
36
TextView detailsTextView;
38
public GtkErrorDialog (Window parent)
39
public GtkErrorDialog (Window parent, string title, string message, AlertButton[] buttons)
41
this.Title = BrandingService.ApplicationName;
41
if (string.IsNullOrEmpty (title))
42
throw new ArgumentException ();
44
throw new ArgumentException ();
46
Title = BrandingService.ApplicationName;
42
47
TransientFor = parent;
43
descriptionLabel.ModifyBg (StateType.Normal, new Gdk.Color (255,0,0));
49
WindowPosition = Gtk.WindowPosition.CenterOnParent;
53
this.VBox.BorderWidth = 2;
55
var hbox = new HBox () {
60
var errorImage = new Image (Gtk.Stock.DialogError, IconSize.Dialog) {
63
hbox.PackStart (errorImage, false, false, 0);
66
var vbox = new VBox () {
69
hbox.PackEnd (vbox, true, true, 0);
71
var titleLabel = new Label () {
72
Markup = "<b>" + GLib.Markup.EscapeText (title) + "</b>",
75
vbox.PackStart (titleLabel, false, false, 0);
77
if (!string.IsNullOrWhiteSpace (message)) {
78
message = message.Trim ();
79
var descriptionLabel = new Label (message) {
83
descriptionLabel.LineWrap = true;
84
descriptionLabel.WidthRequest = 500;
85
descriptionLabel.ModifyBg (StateType.Normal, new Gdk.Color (255,0,0));
86
vbox.PackStart (descriptionLabel, false, false, 0);
89
expander = new Expander (GettextCatalog.GetString ("Details")) {
93
vbox.PackEnd (expander, true, true, 0);
95
var sw = new ScrolledWindow () {
97
ShadowType = ShadowType.Out,
101
detailsTextView = new TextView () {
104
sw.Add (detailsTextView);
106
var aa = this.ActionArea;
108
aa.LayoutStyle = ButtonBoxStyle.End;
110
aa.Homogeneous = true;
112
expander.Activated += delegate {
113
this.AllowGrow = expander.Expanded;
114
GLib.Timeout.Add (100, delegate {
115
Resize (DefaultWidth, 1);
45
120
tagNoWrap = new TextTag ("nowrap");
46
121
tagNoWrap.WrapMode = WrapMode.None;
50
125
tagWrap.WrapMode = WrapMode.Word;
51
126
detailsTextView.Buffer.TagTable.Add (tagWrap);
53
expander.Visible = false;
56
public string Message {
57
get { return descriptionLabel.Text; }
59
string message = value;
60
while (message.EndsWith ("\r") || message.EndsWith ("\n"))
61
message = message.Substring (0, message.Length - 1);
62
if (!message.EndsWith (".")) message += ".";
63
descriptionLabel.Text = message;
128
this.Buttons = buttons;
129
for (int i = 0; i < Buttons.Length; i++) {
131
button = new Gtk.Button (Buttons[i].Label);
133
AddActionWidget (button, i);
140
public AlertButton[] Buttons {
67
144
public void AddDetails (string text, bool wrapped)
69
146
TextIter it = detailsTextView.Buffer.EndIter;