]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/ghelpers.C
Search the src tree for glade files, so preventing an unnecessary crash
[lyx.git] / src / frontends / gtk / ghelpers.C
1 /**
2  * \file ghelpers.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "ghelpers.h"
14
15 #include "debug.h"
16
17 #include "support/filetools.h"
18 #include "support/path_defines.h"
19
20 using std::string;
21
22 string const findGladeFile(string const & name)
23 {
24         // First, search in the installation directories.
25
26         string filename =
27                 lyx::support::LibFileSearch("glade", name, "glade");
28
29         if (!filename.empty())
30                 return filename;
31
32         // Second, search in the src tree.
33         string const dir =
34                 lyx::support::AddPath(lyx::support::top_srcdir(),
35                                       "src/frontends/gtk/glade");
36
37         filename = lyx::support::ChangeExtension(name, ".glade");
38         filename = lyx::support::AddName(dir, filename);
39
40         if (!lyx::support::IsFileReadable(filename)) {
41                 lyxerr << "Unable to find glade file \"" << name
42                        << "\". libglade is going to crash..." << std::endl;
43         }
44
45         return filename;
46 }