* Copyright 2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <superstippi@gmx.de>
*/
#include "UnassignPathCommand.h"
#include <Catalog.h>
#include <Locale.h>
#include "PathSourceShape.h"
#include "VectorPath.h"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Icon-O-Matic-UnassignPathCmd"
UnassignPathCommand::UnassignPathCommand(PathSourceShape* shape,
VectorPath* path)
: Command(),
fShape(shape),
fPath(path),
fPathRemoved(false)
{
}
UnassignPathCommand::~UnassignPathCommand()
{
if (fPathRemoved && fPath)
fPath->ReleaseReference();
}
status_t
UnassignPathCommand::InitCheck()
{
return fShape && fPath ? B_OK : B_NO_INIT;
}
status_t
UnassignPathCommand::Perform()
{
fShape->Paths()->RemoveItem(fPath);
fPathRemoved = true;
return B_OK;
}
status_t
UnassignPathCommand::Undo()
{
fShape->Paths()->AddItem(fPath);
fPathRemoved = false;
return B_OK;
}
void
UnassignPathCommand::GetName(BString& name)
{
name << B_TRANSLATE("Unassign path");
}