1// Aseprite
2// Copyright (C) 2001-2017 David Capello
3//
4// This program is distributed under the terms of
5// the End-User License Agreement for Aseprite.
6
7#ifdef HAVE_CONFIG_H
8#include "config.h"
9#endif
10
11#include "app/commands/command.h"
12#include "app/context.h"
13#include "app/context_access.h"
14#include "app/doc.h"
15#include "app/launcher.h"
16
17namespace app {
18
19class OpenInFolderCommand : public Command {
20public:
21 OpenInFolderCommand();
22
23protected:
24 bool onEnabled(Context* context) override;
25 void onExecute(Context* context) override;
26};
27
28OpenInFolderCommand::OpenInFolderCommand()
29 : Command(CommandId::OpenInFolder(), CmdUIOnlyFlag)
30{
31}
32
33bool OpenInFolderCommand::onEnabled(Context* context)
34{
35 const ContextReader reader(context);
36 return
37 reader.document() &&
38 reader.document()->isAssociatedToFile();
39}
40
41void OpenInFolderCommand::onExecute(Context* context)
42{
43 launcher::open_folder(context->activeDocument()->filename());
44}
45
46Command* CommandFactory::createOpenInFolderCommand()
47{
48 return new OpenInFolderCommand;
49}
50
51} // namespace app
52