mrp-paths-gnome.c 3.55 KB
Newer Older
1 2 3 4
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 2005 Imendio AB
 * Copyright (C) 2005 Jani Tiainen
5
 * Copyright (C) 2008 Maurice van der Pot
6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this library; if not, write to the
Josué Abarca's avatar
Josué Abarca committed
19 20
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
21 22 23 24 25 26 27 28 29 30
 */

/*
 * Path generation
 * Gnome specific versions
 */

#include <config.h>
#include "mrp-paths.h"

31 32 33 34
static const gchar *default_plugin_dir        = PLUGINDIR;
static const gchar *default_storagemodule_dir = STORAGEMODULEDIR;
static const gchar *default_file_modules_dir  = FILEMODULESDIR;
static const gchar *default_data_dir          = DATADIR;
35

36
static const gchar *locale_dir                = GNOMELOCALEDIR;
37 38 39 40

gchar *
mrp_paths_get_glade_dir (const gchar *filename)
{
41 42 43 44 45 46
	const gchar *env_data_dir = g_getenv ("PLANNER_DATADIR");
	return g_build_filename (env_data_dir ? env_data_dir
					      : default_data_dir,
				 "glade",
				 filename,
				 NULL);
47 48 49 50 51
}

gchar *
mrp_paths_get_image_dir (const gchar *filename)
{
52 53 54
	const gchar *env_data_dir = g_getenv ("PLANNER_DATADIR");
	return g_build_filename (env_data_dir ? env_data_dir
					      : default_data_dir,
55
				 "images",
56 57
				 filename,
				 NULL);
58 59 60 61
}

gchar *
mrp_paths_get_plugin_dir (const gchar *filename)
62
{
63 64 65 66 67
	const gchar *env_plugin_dir = g_getenv ("PLANNER_PLUGINDIR");
	return g_build_filename (env_plugin_dir ? env_plugin_dir
						: default_plugin_dir,
				 filename,
				 NULL);
68 69 70 71 72
}

gchar *
mrp_paths_get_dtd_dir (const gchar *filename)
{
73 74 75 76 77 78
	const gchar *env_data_dir = g_getenv ("PLANNER_DATADIR");
	return g_build_filename (env_data_dir ? env_data_dir
					      : default_data_dir,
				 "dtd",
				 filename,
				 NULL);
79 80 81 82 83
}

gchar *
mrp_paths_get_stylesheet_dir (const gchar *filename)
{
84 85 86 87 88 89
	const gchar *env_data_dir = g_getenv ("PLANNER_DATADIR");
	return g_build_filename (env_data_dir ? env_data_dir
					      : default_data_dir,
				 "stylesheets",
				 filename,
				 NULL);
90 91 92 93 94
}

gchar *
mrp_paths_get_storagemodule_dir (const gchar *filename)
{
95 96 97 98 99 100
	const gchar *env_storagemodule_dir = g_getenv ("PLANNER_STORAGEMODULEDIR");
	return g_build_filename (env_storagemodule_dir
					? env_storagemodule_dir
					: default_storagemodule_dir,
				 filename,
				 NULL);
101 102 103 104 105
}

gchar *
mrp_paths_get_file_modules_dir (const gchar *filename)
{
106 107 108 109 110 111
	const gchar *env_file_modules_dir = g_getenv ("PLANNER_FILEMODULESDIR");
	return g_build_filename (env_file_modules_dir
					? env_file_modules_dir
					: default_file_modules_dir,
				 filename,
				 NULL);
112 113 114 115 116
}

gchar *
mrp_paths_get_ui_dir (const gchar *filename)
{
117 118 119 120 121 122
	const gchar *env_data_dir = g_getenv ("PLANNER_DATADIR");
	return g_build_filename (env_data_dir ? env_data_dir
					      : default_data_dir,
				 "ui",
				 filename,
				 NULL);
123 124
}

125 126 127
gchar *
mrp_paths_get_sql_dir ()
{
128 129 130 131 132
	const gchar *env_data_dir = g_getenv ("PLANNER_DATADIR");
	return g_build_filename (env_data_dir ? env_data_dir
					      : default_data_dir,
				 "sql",
				 NULL);
133 134 135 136 137 138 139
}

gchar *
mrp_paths_get_locale_dir ()
{
	return g_strdup (locale_dir);
}