2 // created on 24/01/2005 at 20:14
3 // Taken pretty much wholesale from Tomboy
7 public class HigMessageDialog
: Gtk
.Dialog
9 Gtk
.AccelGroup accel_group
;
11 public HigMessageDialog (Gtk
.Window parent
,
12 Gtk
.DialogFlags flags
,
14 Gtk
.ButtonsType buttons
,
24 ActionArea
.Layout
= Gtk
.ButtonBoxStyle
.End
;
26 accel_group
= new Gtk
.AccelGroup ();
27 AddAccelGroup (accel_group
);
29 Gtk
.HBox hbox
= new Gtk
.HBox (false, 12);
32 VBox
.PackStart (hbox
, false, false, 0);
34 Gtk
.Image image
= null;
37 case Gtk
.MessageType
.Error
:
38 image
= new Gtk
.Image (Gtk
.Stock
.DialogError
, Gtk
.IconSize
.Dialog
);
40 case Gtk
.MessageType
.Question
:
41 image
= new Gtk
.Image (Gtk
.Stock
.DialogQuestion
, Gtk
.IconSize
.Dialog
);
43 case Gtk
.MessageType
.Info
:
44 image
= new Gtk
.Image (Gtk
.Stock
.DialogInfo
, Gtk
.IconSize
.Dialog
);
46 case Gtk
.MessageType
.Warning
:
47 image
= new Gtk
.Image (Gtk
.Stock
.DialogWarning
, Gtk
.IconSize
.Dialog
);
52 hbox
.PackStart (image
, false, false, 0);
54 Gtk
.VBox label_vbox
= new Gtk
.VBox (false, 0);
56 hbox
.PackStart (label_vbox
, true, true, 0);
58 string title
= String
.Format ("<span weight='bold' size='larger'>{0}" +
64 label
= new Gtk
.Label (title
);
65 label
.UseMarkup
= true;
66 label
.Justify
= Gtk
.Justification
.Left
;
67 label
.LineWrap
= true;
68 label
.SetAlignment (0.0f
, 0.5f
);
70 label_vbox
.PackStart (label
, false, false, 0);
72 label
= new Gtk
.Label (msg
);
73 label
.UseMarkup
= true;
74 label
.Justify
= Gtk
.Justification
.Left
;
75 label
.LineWrap
= true;
76 label
.SetAlignment (0.0f
, 0.5f
);
78 label_vbox
.PackStart (label
, false, false, 0);
81 case Gtk
.ButtonsType
.None
:
83 case Gtk
.ButtonsType
.Ok
:
84 AddButton (Gtk
.Stock
.Ok
, Gtk
.ResponseType
.Ok
, true);
86 case Gtk
.ButtonsType
.Close
:
87 AddButton (Gtk
.Stock
.Close
, Gtk
.ResponseType
.Close
, true);
89 case Gtk
.ButtonsType
.Cancel
:
90 AddButton (Gtk
.Stock
.Cancel
, Gtk
.ResponseType
.Cancel
, true);
92 case Gtk
.ButtonsType
.YesNo
:
93 AddButton (Gtk
.Stock
.No
, Gtk
.ResponseType
.No
, false);
94 AddButton (Gtk
.Stock
.Yes
, Gtk
.ResponseType
.Yes
, true);
96 case Gtk
.ButtonsType
.OkCancel
:
97 AddButton (Gtk
.Stock
.Cancel
, Gtk
.ResponseType
.Cancel
, false);
98 AddButton (Gtk
.Stock
.Ok
, Gtk
.ResponseType
.Ok
, true);
103 TransientFor
= parent
;
105 if ((int) (flags
& Gtk
.DialogFlags
.Modal
) != 0)
108 if ((int) (flags
& Gtk
.DialogFlags
.DestroyWithParent
) != 0)
109 DestroyWithParent
= true;
112 // constructor for a HIG confirmation alert with two buttons
113 public HigMessageDialog (Gtk
.Window parent
,
114 Gtk
.DialogFlags flags
,
115 Gtk
.MessageType type
,
119 : this (parent
, flags
, type
, Gtk
.ButtonsType
.Cancel
, header
, msg
)
121 AddButton (ok_caption
, Gtk
.ResponseType
.Ok
, false);
124 void AddButton (string stock_id
, Gtk
.ResponseType response
, bool is_default
)
126 Gtk
.Button button
= new Gtk
.Button (stock_id
);
127 button
.CanDefault
= true;
130 AddActionWidget (button
, response
);
133 DefaultResponse
= response
;
134 button
.AddAccelerator ("activate",
136 (uint) Gdk
.Key
.Escape
,
138 Gtk
.AccelFlags
.Visible
);
142 //run and destroy a standard dialog
143 public static Gtk
.ResponseType
RunHigMessageDialog(Gtk
.Window parent
,
144 Gtk
.DialogFlags flags
,
145 Gtk
.MessageType type
,
146 Gtk
.ButtonsType buttons
,
150 HigMessageDialog hmd
= new HigMessageDialog(parent
, flags
, type
, buttons
, header
, msg
);
152 return (Gtk
.ResponseType
)hmd
.Run();
158 //Run and destroy a standard confirmation dialog
159 public static Gtk
.ResponseType
RunHigConfirmation(Gtk
.Window parent
,
160 Gtk
.DialogFlags flags
,
161 Gtk
.MessageType type
,
166 HigMessageDialog hmd
= new HigMessageDialog(parent
, flags
, type
, header
, msg
, ok_caption
);
168 return (Gtk
.ResponseType
)hmd
.Run();