In NotificationWindow, delete AppGroupViews when closed.

This is preferable to having them kick around for as long as the server
is running. They don't yet close when all of the notifications for the
view time out, that's coming next.
This commit is contained in:
Alex Wilson
2012-04-01 11:54:13 +12:00
parent 94cefc8f79
commit cbdd108a09
4 changed files with 38 additions and 15 deletions
+9 -12
View File
@@ -156,10 +156,7 @@ AppGroupView::Draw(BRect updateRect)
void
AppGroupView::MouseDown(BPoint point)
{
bool changed = false;
if (fCloseRect.Contains(point)) {
changed = true;
int32 children = fInfo.size();
for (int32 i = 0; i < children; i++) {
GetLayout()->RemoveView(fInfo[i]);
@@ -169,7 +166,7 @@ AppGroupView::MouseDown(BPoint point)
fInfo.clear();
// Remove ourselves from the parent view
BMessage message(kRemoveView);
BMessage message(kRemoveGroupView);
message.AddPointer("view", this);
fParent->PostMessage(&message);
}
@@ -188,17 +185,10 @@ AppGroupView::MouseDown(BPoint point)
fInfo[i]->Show();
}
}
changed = true;
Invalidate(); // Need to redraw the collapse indicator and title
BMessage message(kRemoveView);
// Do not actually remive anything, but update size
fParent->PostMessage(&message);
}
if (changed) {
_ResizeViews();
}
}
@@ -266,6 +256,13 @@ AppGroupView::AddInfo(NotificationView* view)
}
const BString&
AppGroupView::Group() const
{
return fLabel;
}
void
AppGroupView::_ResizeViews()
{
+2
View File
@@ -32,6 +32,8 @@ public:
void AddInfo(NotificationView* view);
const BString& Group() const;
private:
void _ResizeViews();
@@ -10,8 +10,6 @@
* Mikael Eiman, [email protected]
* Pier Luigi Fiorini, [email protected]
*/
#include "NotificationWindow.h"
#include <algorithm>
@@ -21,7 +19,6 @@
#include <Catalog.h>
#include <File.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <Layout.h>
#include <NodeMonitor.h>
#include <Path.h>
@@ -31,6 +28,7 @@
#include "AppGroupView.h"
#include "AppUsage.h"
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "NotificationWindow"
@@ -216,6 +214,29 @@ NotificationWindow::MessageReceived(BMessage* message)
_ResizeAll();
break;
}
case kRemoveGroupView:
{
AppGroupView* view = NULL;
if (message->FindPointer("view", (void**)&view) != B_OK)
return;
// It's possible that between sending this message, and us receiving
// it, the view has become used again, in which case we shouldn't
// delete it.
if (view->HasChildren())
return;
// this shouldn't happen
if (fAppViews.erase(view->Group()) < 1)
break;
if (GetLayout()->RemoveView(view))
delete view;
if (fAppViews.size() == 0)
Hide();
break;
}
default:
BWindow::MessageReceived(message);
}
@@ -37,6 +37,9 @@ extern const float kCloseSize;
extern const float kExpandSize;
extern const float kPenSize;
const uint32 kRemoveGroupView = 'RGVi';
class NotificationWindow : public BWindow {
public:
NotificationWindow();