~ubuntu-branches/ubuntu/jaunty/beagle/jaunty-security

« back to all changes in this revision

Viewing changes to search/NotificationArea.cs

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2008-05-04 00:31:32 UTC
  • mfrom: (1.1.21 upstream)
  • Revision ID: james.westby@ubuntu.com-20080504003132-2tkm5o8moo5952ri
Tags: 0.3.7-2ubuntu1
 * Merge from Debian unstable. (LP: #225746) Remaining Ubuntu changes:
  - debian/control:
    + Rename ice{weasel,dove}-beagle to {mozilla,thunderbird}-beagle and
      and update the dependencies accordingly.
    + Change Maintainer to Ubuntu Mono Team.
  - debian/rules:
    + Install the mozilla-beagle and thunderbird-beagle extensions.
  - ice{dove,weasel}.dirs:
    + Renamed to {mozilla,thunderbird}-beagle.dirs.
    + Fixed paths to point to usr/lib/{firefox,thunderbird}

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// NotificationArea.cs
3
 
//
4
 
// Copyright (c) 2006 Novell, Inc.
5
 
//
6
 
 
7
 
using System;
8
 
using System.Collections;
9
 
 
10
 
using Gtk;
11
 
using Mono.Unix;
12
 
 
13
 
namespace Search {
14
 
 
15
 
        public class NotificationMessage : HBox {
16
 
 
17
 
                private static Gtk.Style style;
18
 
 
19
 
                private Gtk.Image icon;
20
 
                private Gtk.Label title;
21
 
                private Gtk.Label message;
22
 
                private Gtk.Box action_box;
23
 
 
24
 
                private NotificationArea area;
25
 
 
26
 
                static NotificationMessage ()
27
 
                {
28
 
                        Gtk.Window temp_win = new Gtk.Window (WindowType.Popup);
29
 
                        temp_win.Name = "gtk-tooltips";
30
 
                        temp_win.EnsureStyle ();
31
 
 
32
 
                        style = temp_win.Style.Copy ();
33
 
                }
34
 
 
35
 
                public NotificationMessage () : this (null, null) { }
36
 
 
37
 
                public NotificationMessage (string t, string m) : base (false, 5)
38
 
                {
39
 
                        this.Style = style;
40
 
 
41
 
                        BorderWidth = 5;
42
 
 
43
 
                        icon = new Image (Stock.DialogInfo, IconSize.Dialog);
44
 
                        this.PackStart (icon, false, true, 5);
45
 
 
46
 
                        VBox vbox = new VBox (false, 5);
47
 
                        this.PackStart (vbox, true, true, 0);
48
 
 
49
 
                        title = new Label ();
50
 
                        title.SetAlignment (0.0f, 0.5f);
51
 
                        this.Title = t;
52
 
                        vbox.PackStart (title, false, true, 0);
53
 
 
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);
58
 
                        this.Message = m;                       
59
 
                        vbox.PackStart (message, true, true, 0);
60
 
 
61
 
                        action_box = new HBox (false, 3);
62
 
 
63
 
                        Button hide_button = new Button (Catalog.GetString ("Hide"));
64
 
                        hide_button.Clicked += OnHideClicked;
65
 
                        action_box.PackEnd (hide_button, false, true, 0);
66
 
 
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);
70
 
                }
71
 
 
72
 
                protected override bool OnExposeEvent (Gdk.EventExpose e)
73
 
                {
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);
78
 
 
79
 
                        return base.OnExposeEvent (e);
80
 
                }
81
 
 
82
 
                public void AddAction (string name, EventHandler e)
83
 
                {
84
 
                        Button action = new Button (name);
85
 
                        
86
 
                        if (e != null)
87
 
                                action.Clicked += e;
88
 
 
89
 
                        action_box.PackStart (action, false, true, 0);
90
 
                }
91
 
 
92
 
                private void OnHideClicked (object o, EventArgs args)
93
 
                {
94
 
                        area.Hide ();
95
 
                }
96
 
 
97
 
                public string Title {
98
 
                        get { return title.Text; }
99
 
                        set { title.Markup = "<big><b>" + value + "</b></big>"; }
100
 
                }
101
 
 
102
 
                public string Message {
103
 
                        get { return message.Text; }
104
 
                        set { message.Markup = value; }
105
 
                }
106
 
 
107
 
                public string Icon {
108
 
                        set { icon.SetFromStock (value, Gtk.IconSize.Dialog); }
109
 
                }
110
 
 
111
 
                public Gdk.Pixbuf Pixbuf {
112
 
                        set { icon.Pixbuf = value; }
113
 
                }
114
 
 
115
 
                public NotificationArea Area {
116
 
                        set { area = value; }
117
 
                }
118
 
        }
119
 
 
120
 
        public class NotificationArea : Frame {
121
 
 
122
 
                private NotificationMessage message;
123
 
                
124
 
                public NotificationArea ()
125
 
                {
126
 
                        NoShowAll = true;
127
 
                        ShadowType = ShadowType.Out;
128
 
                }
129
 
 
130
 
                public new void Display (NotificationMessage m)
131
 
                {
132
 
                        if (message != m) {
133
 
                                if (message != null)
134
 
                                        Remove (message);
135
 
 
136
 
                                Add (m);
137
 
 
138
 
                                message = m;
139
 
                                m.Area = this;
140
 
                                m.ShowAll ();
141
 
                        }
142
 
 
143
 
                        this.Show ();
144
 
                }
145
 
        }
146
 
}