Oops, fix a scale problem with the RSS size calculation
[beagle.git] / search / NotificationArea.cs
blob5d24991dc1bcb1eb168242ae5af25841483beb99
1 //
2 // NotificationArea.cs
3 //
4 // Copyright (c) 2006 Novell, Inc.
5 //
7 using System;
8 using System.Collections;
10 using Gtk;
12 namespace Search {
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)
38 this.Style = style;
40 BorderWidth = 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);
48 title = new Label ();
49 title.SetAlignment (0.0f, 0.5f);
50 this.Title = t;
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);
57 this.Message = m;
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);
85 if (e != null)
86 action.Clicked += e;
88 action_box.PackStart (action, false, true, 0);
91 private void OnHideClicked (object o, EventArgs args)
93 area.Hide ();
96 public string Title {
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; }
106 public string Icon {
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 ()
121 NoShowAll = true;
122 ShadowType = ShadowType.Out;
125 public new void Display (NotificationMessage m)
127 if (message != m) {
128 if (message != null)
129 Remove (message);
131 Add (m);
133 message = m;
134 m.Area = this;
135 m.ShowAll ();
138 this.Show ();