1 | diff --git a/src/servers/notification/AppGroupView.cpp b/src/servers/notification/AppGroupView.cpp
|
---|
2 | index 38fec70..b01e1af 100644
|
---|
3 | --- a/src/servers/notification/AppGroupView.cpp
|
---|
4 | +++ b/src/servers/notification/AppGroupView.cpp
|
---|
5 | @@ -13,6 +13,7 @@
|
---|
6 |
|
---|
7 | #include <algorithm>
|
---|
8 |
|
---|
9 | +#include <Application.h>
|
---|
10 | #include <ControlLook.h>
|
---|
11 | #include <GroupLayout.h>
|
---|
12 | #include <GroupView.h>
|
---|
13 | @@ -172,7 +173,8 @@ void
|
---|
14 | AppGroupView::MessageReceived(BMessage* msg)
|
---|
15 | {
|
---|
16 | switch (msg->what) {
|
---|
17 | - case kRemoveView:
|
---|
18 | + case kViewClosed:
|
---|
19 | + case kTimeoutExpired:
|
---|
20 | {
|
---|
21 | NotificationView* view = NULL;
|
---|
22 | if (msg->FindPointer("view", (void**)&view) != B_OK)
|
---|
23 | @@ -184,7 +186,9 @@ AppGroupView::MessageReceived(BMessage* msg)
|
---|
24 |
|
---|
25 | fInfo.erase(vIt);
|
---|
26 | view->RemoveSelf();
|
---|
27 | - delete view;
|
---|
28 | +
|
---|
29 | + if (msg->what != kTimeoutExpired)
|
---|
30 | + delete view;
|
---|
31 |
|
---|
32 | fParent->PostMessage(msg);
|
---|
33 |
|
---|
34 | @@ -195,6 +199,12 @@ AppGroupView::MessageReceived(BMessage* msg)
|
---|
35 | fParent->PostMessage(&removeSelfMessage);
|
---|
36 | }
|
---|
37 |
|
---|
38 | + // Send message to add view to notification center
|
---|
39 | + if (msg->what == kTimeoutExpired) {
|
---|
40 | + msg->what = kAddView;
|
---|
41 | + be_app->PostMessage(msg);
|
---|
42 | + }
|
---|
43 | +
|
---|
44 | break;
|
---|
45 | }
|
---|
46 | default:
|
---|
47 | diff --git a/src/servers/notification/NotificationServer.cpp b/src/servers/notification/NotificationServer.cpp
|
---|
48 | index 27cf979..3ba3684 100644
|
---|
49 | --- a/src/servers/notification/NotificationServer.cpp
|
---|
50 | +++ b/src/servers/notification/NotificationServer.cpp
|
---|
51 | @@ -43,6 +43,7 @@ void
|
---|
52 | NotificationServer::ReadyToRun()
|
---|
53 | {
|
---|
54 | fWindow = new NotificationWindow();
|
---|
55 | + fCenter = new NotificationWindow();
|
---|
56 | }
|
---|
57 |
|
---|
58 |
|
---|
59 | @@ -68,6 +69,13 @@ NotificationServer::MessageReceived(BMessage* message)
|
---|
60 | BMessenger(fWindow).SendMessage(message);
|
---|
61 | break;
|
---|
62 | }
|
---|
63 | +
|
---|
64 | + case kAddView:
|
---|
65 | + {
|
---|
66 | + BMessenger(fCenter).SendMessage(message);
|
---|
67 | + break;
|
---|
68 | + }
|
---|
69 | +
|
---|
70 | default:
|
---|
71 | BApplication::MessageReceived(message);
|
---|
72 | }
|
---|
73 | diff --git a/src/servers/notification/NotificationServer.h b/src/servers/notification/NotificationServer.h
|
---|
74 | index 50122f5..d488aca 100644
|
---|
75 | --- a/src/servers/notification/NotificationServer.h
|
---|
76 | +++ b/src/servers/notification/NotificationServer.h
|
---|
77 | @@ -27,6 +27,7 @@ public:
|
---|
78 |
|
---|
79 | private:
|
---|
80 | NotificationWindow* fWindow;
|
---|
81 | + NotificationWindow* fCenter;
|
---|
82 | };
|
---|
83 |
|
---|
84 |
|
---|
85 | diff --git a/src/servers/notification/NotificationView.cpp b/src/servers/notification/NotificationView.cpp
|
---|
86 | index 2856b42..59986ff 100644
|
---|
87 | --- a/src/servers/notification/NotificationView.cpp
|
---|
88 | +++ b/src/servers/notification/NotificationView.cpp
|
---|
89 | @@ -61,6 +61,7 @@ NotificationView::NotificationView(NotificationWindow* win,
|
---|
90 | fParent(win),
|
---|
91 | fNotification(notification),
|
---|
92 | fTimeout(timeout),
|
---|
93 | + fTimeoutEnabled(true),
|
---|
94 | fRunner(NULL),
|
---|
95 | fBitmap(NULL),
|
---|
96 | fCloseClicked(false)
|
---|
97 | @@ -123,10 +124,12 @@ NotificationView::AttachedToWindow()
|
---|
98 | {
|
---|
99 | SetText();
|
---|
100 |
|
---|
101 | - BMessage msg(kRemoveView);
|
---|
102 | - msg.AddPointer("view", this);
|
---|
103 | + if (fTimeoutEnabled) {
|
---|
104 | + BMessage msg(kTimeoutExpired);
|
---|
105 | + msg.AddPointer("view", this);
|
---|
106 |
|
---|
107 | - fRunner = new BMessageRunner(BMessenger(Parent()), &msg, fTimeout, 1);
|
---|
108 | + fRunner = new BMessageRunner(BMessenger(Parent()), &msg, fTimeout, 1);
|
---|
109 | + }
|
---|
110 | }
|
---|
111 |
|
---|
112 |
|
---|
113 | @@ -396,7 +399,7 @@ NotificationView::MouseDown(BPoint point)
|
---|
114 | }
|
---|
115 |
|
---|
116 | // Remove the info view after a click
|
---|
117 | - BMessage remove_msg(kRemoveView);
|
---|
118 | + BMessage remove_msg(kViewClosed);
|
---|
119 | remove_msg.AddPointer("view", this);
|
---|
120 |
|
---|
121 | BMessenger msgr(Parent());
|
---|
122 | @@ -548,6 +551,13 @@ NotificationView::SetText(float newMaxWidth)
|
---|
123 | }
|
---|
124 |
|
---|
125 |
|
---|
126 | +void
|
---|
127 | +NotificationView::EnableTimeout(bool enabled)
|
---|
128 | +{
|
---|
129 | + fTimeoutEnabled = enabled;
|
---|
130 | +}
|
---|
131 | +
|
---|
132 | +
|
---|
133 | const char*
|
---|
134 | NotificationView::MessageID() const
|
---|
135 | {
|
---|
136 | @@ -555,6 +565,13 @@ NotificationView::MessageID() const
|
---|
137 | }
|
---|
138 |
|
---|
139 |
|
---|
140 | +const char*
|
---|
141 | +NotificationView::Group() const
|
---|
142 | +{
|
---|
143 | + return fNotification->Group();
|
---|
144 | +}
|
---|
145 | +
|
---|
146 | +
|
---|
147 | void
|
---|
148 | NotificationView::_CalculateSize()
|
---|
149 | {
|
---|
150 | diff --git a/src/servers/notification/NotificationView.h b/src/servers/notification/NotificationView.h
|
---|
151 | index da851cd..a323d4e 100644
|
---|
152 | --- a/src/servers/notification/NotificationView.h
|
---|
153 | +++ b/src/servers/notification/NotificationView.h
|
---|
154 | @@ -20,7 +20,9 @@ class BNotification;
|
---|
155 |
|
---|
156 | class NotificationWindow;
|
---|
157 |
|
---|
158 | -const uint32 kRemoveView = 'ReVi';
|
---|
159 | +const uint32 kViewClosed = 'ReVi';
|
---|
160 | +const uint32 kTimeoutExpired = 'TiEx';
|
---|
161 | +const uint32 kAddView = 'AdVi';
|
---|
162 |
|
---|
163 |
|
---|
164 | class NotificationView : public BView {
|
---|
165 | @@ -47,8 +49,10 @@ public:
|
---|
166 | virtual status_t GetSupportedSuites(BMessage* msg);
|
---|
167 |
|
---|
168 | void SetText(float newMaxWidth = -1);
|
---|
169 | + void EnableTimeout(bool enabled = true);
|
---|
170 |
|
---|
171 | const char* MessageID() const;
|
---|
172 | + const char* Group() const;
|
---|
173 |
|
---|
174 | private:
|
---|
175 | void _CalculateSize();
|
---|
176 | @@ -65,6 +69,7 @@ private:
|
---|
177 | NotificationWindow* fParent;
|
---|
178 | BNotification* fNotification;
|
---|
179 | bigtime_t fTimeout;
|
---|
180 | + bool fTimeoutEnabled;
|
---|
181 |
|
---|
182 | BMessageRunner* fRunner;
|
---|
183 |
|
---|
184 | diff --git a/src/servers/notification/NotificationWindow.cpp b/src/servers/notification/NotificationWindow.cpp
|
---|
185 | index 7a9d9aa..c5727cf 100644
|
---|
186 | --- a/src/servers/notification/NotificationWindow.cpp
|
---|
187 | +++ b/src/servers/notification/NotificationWindow.cpp
|
---|
188 | @@ -214,7 +214,48 @@ NotificationWindow::MessageReceived(BMessage* message)
|
---|
189 | message->SendReply(&reply);
|
---|
190 | break;
|
---|
191 | }
|
---|
192 | - case kRemoveView:
|
---|
193 | + case kAddView:
|
---|
194 | + {
|
---|
195 | + NotificationView* view = NULL;
|
---|
196 | + if (message->FindPointer("view", (void**)&view) != B_OK)
|
---|
197 | + return;
|
---|
198 | +
|
---|
199 | + // TODO can we assume it has already gone through filtering?
|
---|
200 | +/* bool allow = false;
|
---|
201 | + appfilter_t::iterator it = fAppFilters.find(info.signature);
|
---|
202 | +
|
---|
203 | + if (it == fAppFilters.end()) {
|
---|
204 | + AppUsage* appUsage = new AppUsage(notification->Group(),
|
---|
205 | + true);
|
---|
206 | +
|
---|
207 | + appUsage->Allowed(notification->Title(),
|
---|
208 | + notification->Type());
|
---|
209 | + fAppFilters[info.signature] = appUsage;
|
---|
210 | + allow = true;
|
---|
211 | + } else {
|
---|
212 | + allow = it->second->Allowed(notification->Title(),
|
---|
213 | + notification->Type());
|
---|
214 | + }
|
---|
215 | +
|
---|
216 | + if (allow) {*/
|
---|
217 | + BString groupName(view->Group());
|
---|
218 | + appview_t::iterator aIt = fAppViews.find(groupName);
|
---|
219 | + AppGroupView* group = NULL;
|
---|
220 | + if (aIt == fAppViews.end()) {
|
---|
221 | + group = new AppGroupView(this,
|
---|
222 | + groupName == "" ? NULL : groupName.String());
|
---|
223 | + fAppViews[groupName] = group;
|
---|
224 | + GetLayout()->AddView(group);
|
---|
225 | + } else
|
---|
226 | + group = aIt->second;
|
---|
227 | +
|
---|
228 | + view->EnableTimeout(false);
|
---|
229 | + group->AddInfo(view);
|
---|
230 | +
|
---|
231 | + _ShowHide();
|
---|
232 | + }
|
---|
233 | + case kViewClosed:
|
---|
234 | + case kTimeoutExpired:
|
---|
235 | {
|
---|
236 | NotificationView* view = NULL;
|
---|
237 | if (message->FindPointer("view", (void**)&view) != B_OK)
|
---|
238 | @@ -224,6 +265,7 @@ NotificationWindow::MessageReceived(BMessage* message)
|
---|
239 |
|
---|
240 | if (it != fViews.end())
|
---|
241 | fViews.erase(it);
|
---|
242 | +
|
---|
243 | break;
|
---|
244 | }
|
---|
245 | case kRemoveGroupView:
|
---|