Added two more menu items "Save" (non-functional) and "Remove from File"

(working).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6717 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2004-02-24 09:40:01 +00:00
parent e9e26839cc
commit 36a7951646
2 changed files with 43 additions and 2 deletions

View File

@ -9,10 +9,14 @@
#include <MenuBar.h>
#include <MenuItem.h>
#include <Alert.h>
#include <stdio.h>
static const uint32 kMsgRemoveAttribute = 'rmat';
AttributeWindow::AttributeWindow(BRect rect, entry_ref *ref, const char *attribute,
const BMessage *settings)
: ProbeWindow(rect, ref),
@ -29,6 +33,10 @@ AttributeWindow::AttributeWindow(BRect rect, entry_ref *ref, const char *attribu
BMenu *menu = new BMenu("Attribute");
menu->AddItem(new BMenuItem("Save", NULL, 'S', B_COMMAND_KEY));
menu->AddItem(new BMenuItem("Remove from File", new BMessage(kMsgRemoveAttribute)));
menu->AddSeparatorItem();
// the ProbeView file menu items will be inserted here
menu->AddSeparatorItem();
@ -41,7 +49,7 @@ AttributeWindow::AttributeWindow(BRect rect, entry_ref *ref, const char *attribu
BRect rect = Bounds();
rect.top = menuBar->Bounds().Height() + 1;
ProbeView *probeView = new ProbeView(rect, ref, attribute, settings);
probeView->AddFileMenuItems(menu, 0);
probeView->AddFileMenuItems(menu, menu->CountItems() - 2);
AddChild(probeView);
probeView->UpdateSizeLimits();
@ -54,6 +62,38 @@ AttributeWindow::~AttributeWindow()
}
void
AttributeWindow::MessageReceived(BMessage *message)
{
switch (message->what) {
case kMsgRemoveAttribute:
{
char buffer[1024];
snprintf(buffer, sizeof(buffer),
"Do you really want to remove the attribute \"%s\" from the file \"%s\"?\n\n"
"The contents of the attribute will get lost if you click on \"Remove\".",
fAttribute, Ref().name);
int32 chosen = (new BAlert("DiskProbe request",
buffer, "Remove", "Cancel", NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go();
if (chosen == 0) {
BNode node(&Ref());
if (node.InitCheck() == B_OK)
node.RemoveAttr(fAttribute);
PostMessage(B_QUIT_REQUESTED);
}
break;
}
default:
ProbeWindow::MessageReceived(message);
break;
}
}
bool
AttributeWindow::Contains(const entry_ref &ref, const char *attribute)
{

View File

@ -15,7 +15,8 @@ class AttributeWindow : public ProbeWindow {
const BMessage *settings = NULL);
virtual ~AttributeWindow();
bool Contains(const entry_ref &ref, const char *attribute);
virtual void MessageReceived(BMessage *message);
virtual bool Contains(const entry_ref &ref, const char *attribute);
private:
char *fAttribute;