1// Aseprite
2// Copyright (C) 2020 Igara Studio S.A.
3// Copyright (C) 2001-2016 David Capello
4//
5// This program is distributed under the terms of
6// the End-User License Agreement for Aseprite.
7
8#ifdef HAVE_CONFIG_H
9#include "config.h"
10#endif
11
12#include "app/gui_xml.h"
13
14#include "app/resource_finder.h"
15#include "app/xml_document.h"
16#include "app/xml_exception.h"
17#include "base/fs.h"
18
19namespace app {
20
21static std::unique_ptr<GuiXml> g_singleton;
22
23// static
24GuiXml* GuiXml::instance()
25{
26 if (!g_singleton)
27 g_singleton = std::make_unique<GuiXml>();
28 return g_singleton.get();
29}
30
31// static
32void GuiXml::destroyInstance()
33{
34 g_singleton.reset();
35}
36
37GuiXml::GuiXml()
38{
39 LOG("GUIXML: Loading gui.xml file\n");
40
41 ResourceFinder rf;
42 rf.includeDataDir("gui.xml");
43 if (!rf.findFirst())
44 throw base::Exception("gui.xml was not found");
45
46 // Load the XML file. As we've already checked "path" existence,
47 // in a case of exception we should show the error and stop.
48 m_doc = app::open_xml(rf.filename());
49}
50
51} // namespace app
52