4 // Copyright (c) 2006 Novell, Inc.
8 using System
.Collections
;
14 public class NotificationMessage
: HBox
{
16 private static Gtk
.Style style
;
18 private Gtk
.Image icon
;
19 private Gtk
.Label title
;
20 private Gtk
.Label message
;
21 private Gtk
.Box action_box
;
23 private NotificationArea area
;
25 static NotificationMessage ()
27 Gtk
.Window temp_win
= new Gtk
.Window (WindowType
.Popup
);
28 temp_win
.Name
= "gtk-tooltips";
29 temp_win
.EnsureStyle ();
31 style
= temp_win
.Style
.Copy ();
34 public NotificationMessage () : this (null, null) { }
36 public NotificationMessage (string t
, string m
) : base (false, 5)
42 icon
= new Image (Stock
.DialogInfo
, IconSize
.Dialog
);
43 this.PackStart (icon
, false, true, 5);
45 VBox vbox
= new VBox (false, 5);
46 this.PackStart (vbox
, true, true, 0);
49 title
.SetAlignment (0.0f
, 0.5f
);
51 vbox
.PackStart (title
, false, true, 0);
53 message
= new Label ();
54 message
.LineWrap
= true;
55 message
.SetSizeRequest (500, -1); // ugh, no way to sanely reflow a gtk label
56 message
.SetAlignment (0.0f
, 0.0f
);
58 vbox
.PackStart (message
, true, true, 0);
60 action_box
= new HBox (false, 3);
62 Button hide_button
= new Button ("Hide");
63 hide_button
.Clicked
+= OnHideClicked
;
64 action_box
.PackEnd (hide_button
, false, true, 0);
66 Alignment action_align
= new Alignment (1.0f
, 0.5f
, 0.0f
, 0.0f
);
67 action_align
.Add (action_box
);
68 vbox
.PackStart (action_align
, false, true, 0);
71 protected override bool OnExposeEvent (Gdk
.EventExpose e
)
73 Style
.PaintBox (Style
, GdkWindow
, StateType
.Normal
,
74 ShadowType
.Out
, e
.Area
, this, "notification area",
75 Allocation
.X
, Allocation
.Y
,
76 Allocation
.Width
, Allocation
.Height
);
78 return base.OnExposeEvent (e
);
81 public void AddAction (string name
, EventHandler e
)
83 Button action
= new Button (name
);
88 action_box
.PackStart (action
, false, true, 0);
91 private void OnHideClicked (object o
, EventArgs args
)
97 get { return title.Text; }
98 set { title.Markup = "<big><b>" + value + "</b></big>"; }
101 public string Message
{
102 get { return message.Text; }
103 set { message.Markup = value; }
107 set { icon.SetFromStock (value, Gtk.IconSize.Dialog); }
110 public NotificationArea Area
{
111 set { area = value; }
115 public class NotificationArea
: Frame
{
117 private NotificationMessage message
;
119 public NotificationArea ()
122 ShadowType
= ShadowType
.Out
;
125 public new void Display (NotificationMessage m
)