[gimp/gimp-2-8] libgimpbase: add gimp_installation_directory()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-8] libgimpbase: add gimp_installation_directory()
- Date: Wed, 23 May 2012 09:52:51 +0000 (UTC)
commit 91665198d4e37e8c3c0f9081635448979f21fbb2
Author: Michael Natterer <mitch gimp org>
Date: Wed May 23 11:49:07 2012 +0200
libgimpbase: add gimp_installation_directory()
which returns the toplevel directory of the running GIMP installation.
(cherry picked from commit 010b28f39e99e97fae4c5174ad774a6c83a7b96a)
It's not exactly clean to add new API in 2.8.1, but this is so useful
for proper relocation, I've made an exception.
libgimpbase/gimpbase.def | 1 +
libgimpbase/gimpenv.c | 28 +++++++++++++++++++++++-----
libgimpbase/gimpenv.h | 1 +
3 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/libgimpbase/gimpbase.def b/libgimpbase/gimpbase.def
index 88e18e7..336633f 100644
--- a/libgimpbase/gimpbase.def
+++ b/libgimpbase/gimpbase.def
@@ -41,6 +41,7 @@ EXPORTS
gimp_icon_type_get_type
gimp_image_base_type_get_type
gimp_image_type_get_type
+ gimp_installation_directory
gimp_interpolation_type_get_type
gimp_locale_directory
gimp_major_version
diff --git a/libgimpbase/gimpenv.c b/libgimpbase/gimpenv.c
index 39baf74..e43f22d 100644
--- a/libgimpbase/gimpenv.c
+++ b/libgimpbase/gimpenv.c
@@ -321,8 +321,26 @@ DllMain (HINSTANCE hinstDLL,
#endif
-static const gchar *
-gimp_toplevel_directory (void)
+/**
+ * gimp_installation_directory:
+ *
+ * Returns the top installation directory of GIMP. On Unix the
+ * compile-time defined installation prefix is used. On Windows, the
+ * installation directory as deduced from the executable's full
+ * filename is used. On OSX we ask [NSBundle mainBundle] for the
+ * resource path to check if GIMP is part of a relocatable bundle.
+ *
+ * The returned string is owned by GIMP and must not be modified or
+ * freed. The returned string is in the encoding used for filenames by
+ * GLib, which isn't necessarily UTF-8. (On Windows it always is
+ * UTF-8.)
+ *
+ * Since: GIMP 2.8
+ *
+ * Returns: The toplevel installation directory of GIMP.
+ **/
+const gchar *
+gimp_installation_directory (void)
{
static gchar *toplevel = NULL;
@@ -655,7 +673,7 @@ gimp_path_runtime_fix (gchar **path)
* real one on this machine.
*/
p = *path;
- *path = g_strconcat (gimp_toplevel_directory (),
+ *path = g_strconcat (gimp_installation_directory (),
"\\",
*path + strlen (PREFIX "/"),
NULL);
@@ -674,7 +692,7 @@ gimp_path_runtime_fix (gchar **path)
gchar *p = *path;
if (!g_path_is_absolute (p))
{
- *path = g_build_filename (gimp_toplevel_directory (), *path, NULL);
+ *path = g_build_filename (gimp_installation_directory (), *path, NULL);
g_free (p);
}
#else
@@ -687,7 +705,7 @@ gimp_path_runtime_fix (gchar **path)
* real one on this machine.
*/
p = *path;
- *path = g_build_filename (gimp_toplevel_directory (),
+ *path = g_build_filename (gimp_installation_directory (),
*path + strlen (PREFIX G_DIR_SEPARATOR_S),
NULL);
g_free (p);
diff --git a/libgimpbase/gimpenv.h b/libgimpbase/gimpenv.h
index d156303..64fc537 100644
--- a/libgimpbase/gimpenv.h
+++ b/libgimpbase/gimpenv.h
@@ -48,6 +48,7 @@ GIMPVAR const guint gimp_micro_version;
const gchar * gimp_directory (void) G_GNUC_CONST;
+const gchar * gimp_installation_directory (void) G_GNUC_CONST;
const gchar * gimp_data_directory (void) G_GNUC_CONST;
const gchar * gimp_locale_directory (void) G_GNUC_CONST;
const gchar * gimp_sysconf_directory (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]