4
// Copyright (c) 2006 Novell, Inc.
8
using System.Collections;
15
public class NotificationMessage : HBox {
17
private static Gtk.Style style;
19
private Gtk.Image icon;
20
private Gtk.Label title;
21
private Gtk.Label message;
22
private Gtk.Box action_box;
24
private NotificationArea area;
26
static NotificationMessage ()
28
Gtk.Window temp_win = new Gtk.Window (WindowType.Popup);
29
temp_win.Name = "gtk-tooltips";
30
temp_win.EnsureStyle ();
32
style = temp_win.Style.Copy ();
35
public NotificationMessage () : this (null, null) { }
37
public NotificationMessage (string t, string m) : base (false, 5)
43
icon = new Image (Stock.DialogInfo, IconSize.Dialog);
44
this.PackStart (icon, false, true, 5);
46
VBox vbox = new VBox (false, 5);
47
this.PackStart (vbox, true, true, 0);
50
title.SetAlignment (0.0f, 0.5f);
52
vbox.PackStart (title, false, true, 0);
54
message = new Label ();
55
message.LineWrap = true;
56
message.SetSizeRequest (500, -1); // ugh, no way to sanely reflow a gtk label
57
message.SetAlignment (0.0f, 0.0f);
59
vbox.PackStart (message, true, true, 0);
61
action_box = new HBox (false, 3);
63
Button hide_button = new Button (Catalog.GetString ("Hide"));
64
hide_button.Clicked += OnHideClicked;
65
action_box.PackEnd (hide_button, false, true, 0);
67
Alignment action_align = new Alignment (1.0f, 0.5f, 0.0f, 0.0f);
68
action_align.Add (action_box);
69
vbox.PackStart (action_align, false, true, 0);
72
protected override bool OnExposeEvent (Gdk.EventExpose e)
74
Style.PaintBox (Style, GdkWindow, StateType.Normal,
75
ShadowType.Out, e.Area, this, "notification area",
76
Allocation.X, Allocation.Y,
77
Allocation.Width, Allocation.Height);
79
return base.OnExposeEvent (e);
82
public void AddAction (string name, EventHandler e)
84
Button action = new Button (name);
89
action_box.PackStart (action, false, true, 0);
92
private void OnHideClicked (object o, EventArgs args)
98
get { return title.Text; }
99
set { title.Markup = "<big><b>" + value + "</b></big>"; }
102
public string Message {
103
get { return message.Text; }
104
set { message.Markup = value; }
108
set { icon.SetFromStock (value, Gtk.IconSize.Dialog); }
111
public Gdk.Pixbuf Pixbuf {
112
set { icon.Pixbuf = value; }
115
public NotificationArea Area {
116
set { area = value; }
120
public class NotificationArea : Frame {
122
private NotificationMessage message;
124
public NotificationArea ()
127
ShadowType = ShadowType.Out;
130
public new void Display (NotificationMessage m)