5
// Aaron Bockover <abockover@novell.com>
7
// Copyright (C) 2007 Novell, Inc.
9
// Permission is hereby granted, free of charge, to any person obtaining
10
// a copy of this software and associated documentation files (the
11
// "Software"), to deal in the Software without restriction, including
12
// without limitation the rights to use, copy, modify, merge, publish,
13
// distribute, sublicense, and/or sell copies of the Software, and to
14
// permit persons to whom the Software is furnished to do so, subject to
15
// the following conditions:
17
// The above copyright notice and this permission notice shall be
18
// included in all copies or substantial portions of the Software.
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
namespace Hyena.Widgets
33
public class HigMessageDialog : Gtk.Dialog
35
private Gtk.Image image;
36
private Gtk.VBox inner_vbox;
37
private Gtk.VBox label_vbox;
38
private Gtk.Label message_label;
40
public HigMessageDialog(Gtk.Window parent,
41
Gtk.DialogFlags flags,
43
Gtk.ButtonsType buttons,
52
SkipTaskbarHint = true;
55
ActionArea.Layout = Gtk.ButtonBoxStyle.End;
57
Gtk.HBox hbox = new Gtk.HBox (false, 12);
60
VBox.PackStart (hbox, false, false, 0);
65
case Gtk.MessageType.Error:
66
image = new Gtk.Image (Gtk.Stock.DialogError, Gtk.IconSize.Dialog);
68
case Gtk.MessageType.Question:
69
image = new Gtk.Image (Gtk.Stock.DialogQuestion, Gtk.IconSize.Dialog);
71
case Gtk.MessageType.Info:
72
image = new Gtk.Image (Gtk.Stock.DialogInfo, Gtk.IconSize.Dialog);
74
case Gtk.MessageType.Warning:
75
image = new Gtk.Image (Gtk.Stock.DialogWarning, Gtk.IconSize.Dialog);
81
hbox.PackStart (image, false, false, 0);
83
inner_vbox = new Gtk.VBox (false, 12);
85
hbox.PackStart (inner_vbox, true, true, 0);
87
label_vbox = new Gtk.VBox (false, 0);
89
inner_vbox.PackStart (label_vbox, true, true, 0);
91
string title = String.Format ("<span weight='bold' size='larger'>{0}" +
97
label = new Gtk.Label (title);
98
label.UseMarkup = true;
99
label.Justify = Gtk.Justification.Left;
100
label.LineWrap = true;
101
label.SetAlignment (0.0f, 0.5f);
103
label_vbox.PackStart (label, false, false, 0);
105
message_label = label = new Gtk.Label ();
107
label.UseMarkup = true;
108
label.Justify = Gtk.Justification.Left;
109
label.LineWrap = true;
110
label.SetAlignment (0.0f, 0.5f);
112
label_vbox.PackStart (label, false, false, 0);
115
case Gtk.ButtonsType.None:
117
case Gtk.ButtonsType.Ok:
118
AddButton (Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
120
case Gtk.ButtonsType.Close:
121
AddButton (Gtk.Stock.Close, Gtk.ResponseType.Close, true);
123
case Gtk.ButtonsType.Cancel:
124
AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, true);
126
case Gtk.ButtonsType.YesNo:
127
AddButton (Gtk.Stock.No, Gtk.ResponseType.No, false);
128
AddButton (Gtk.Stock.Yes, Gtk.ResponseType.Yes, true);
130
case Gtk.ButtonsType.OkCancel:
131
AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false);
132
AddButton (Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
137
TransientFor = parent;
139
if ((int) (flags & Gtk.DialogFlags.Modal) != 0)
142
if ((int) (flags & Gtk.DialogFlags.DestroyWithParent) != 0)
143
DestroyWithParent = true;
146
// constructor for a HIG confirmation alert with two buttons
147
public HigMessageDialog (Gtk.Window parent,
148
Gtk.DialogFlags flags,
149
Gtk.MessageType type,
153
: this (parent, flags, type, Gtk.ButtonsType.Cancel, header, msg)
155
AddButton (ok_caption, Gtk.ResponseType.Ok, false);
158
public Gtk.Button AddCustomButton (string message, Gtk.ResponseType response, bool isDefault)
160
Gtk.Button button = new Gtk.Button ();
161
button.Label = message;
162
button.CanDefault = true;
164
AddButton (button, response, isDefault);
168
public void AddButton (string stock_id, Gtk.ResponseType response, bool isDefault)
170
Gtk.Button button = new Gtk.Button (stock_id);
171
button.CanDefault = true;
173
AddButton (button, response, isDefault);
176
private void AddButton (Gtk.Button button, Gtk.ResponseType response, bool isDefault)
178
AddActionWidget (button, response);
182
DefaultResponse = response;
183
button.GrabDefault ();
187
//run and destroy a standard dialog
188
public static Gtk.ResponseType RunHigMessageDialog(Gtk.Window parent,
189
Gtk.DialogFlags flags,
190
Gtk.MessageType type,
191
Gtk.ButtonsType buttons,
195
HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, buttons, header, msg);
197
return (Gtk.ResponseType)hmd.Run();
203
//Run and destroy a standard confirmation dialog
204
public static Gtk.ResponseType RunHigConfirmation(Gtk.Window parent,
205
Gtk.DialogFlags flags,
206
Gtk.MessageType type,
211
HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, header, msg, ok_caption);
213
return (Gtk.ResponseType)hmd.Run();
219
public Gdk.Pixbuf Image {
221
image.Pixbuf = value;
229
public Gtk.Label MessageLabel {
230
get { return message_label; }
233
public Gtk.VBox LabelVBox {
234
get { return inner_vbox; }