1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009,2010,2011,2012,2013 Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
24 /* Whether the program is running installed or uninstalled */
25 gboolean is_installed
= TRUE
;
27 /* The base directory where all files must be referred,
28 * usually left unset _adg_init() on POSIX systems. */
29 gchar
*basedir
= NULL
;
33 _demo_init(gint argc
, gchar
*argv
[])
37 if (argc
< 1 || argv
== NULL
|| argv
[0] == NULL
) {
38 g_error(_("Invalid arguments: arg[0] not set"));
39 g_assert_not_reached();
42 name
= g_path_get_basename(argv
[0]);
44 is_installed
= strstr(name
, "uninstalled") == NULL
;
48 basedir
= g_path_get_dirname(argv
[0]);
50 basedir
= g_strdup("");
54 _demo_file(const gchar
*file_name
)
56 static gchar
*pkg_data_dir
= NULL
;
59 /* Running uninstalled: look up the file in BUILDDIR before and
60 * in SRCDIR after, returning the first match */
61 return adg_find_file(file_name
, BUILDDIR
, SRCDIR
, NULL
);
64 /* Otherwise, look up the file only in PKGDATADIR */
65 if (pkg_data_dir
== NULL
) {
67 /* On windows, PKGDATADIR is relative to basedir */
68 pkg_data_dir
= g_build_filename(basedir
, PKGDATADIR
, NULL
);
70 pkg_data_dir
= g_strdup(PKGDATADIR
);
74 return adg_find_file(file_name
, pkg_data_dir
, NULL
);