summaryrefslogtreecommitdiff
path: root/gtk/gtkquartz.c
diff options
context:
space:
mode:
authorJohn Ralls <jralls@ceridwen.us>2011-09-11 16:45:06 -0700
committerJohn Ralls <jralls@ceridwen.us>2011-10-08 15:02:38 -0700
commit6dc34c1f5e744e52fccc23610923d12b492a3c91 (patch)
tree4ee160b1321fbd3a404a002f5b1bfd2e398287ae /gtk/gtkquartz.c
parentd172f1ce22b8f30ca49c2eeb91c4cd0d8f28733b (diff)
downloadgtk+-6dc34c1f5e744e52fccc23610923d12b492a3c91.tar.gz
Bug 658772: Directory paths for resource directories are hard coded.
Provide dynamic path discovery functions as are provided for win32.
Diffstat (limited to 'gtk/gtkquartz.c')
-rw-r--r--gtk/gtkquartz.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/gtk/gtkquartz.c b/gtk/gtkquartz.c
index b9ea2ec1ff..e15890e7ed 100644
--- a/gtk/gtkquartz.c
+++ b/gtk/gtkquartz.c
@@ -310,3 +310,71 @@ _gtk_quartz_set_selection_data_for_pasteboard (NSPasteboard *pasteboard,
freeWhenDone:NO]
forType:type];
}
+
+/*
+ * Bundle-based functions for various directories. These almost work
+ * even when the application isn't in a bundle, becuase mainBundle
+ * paths point to the bin directory in that case. It's a simple matter
+ * to test for that and remove the last element.
+ */
+
+static gchar *
+get_bundle_path()
+{
+ gchar *base, *path;
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ gchar *resource_path = g_strdup([[[NSBundle mainBundle] resourcePath] UTF8String]);
+ [pool drain];
+ base = g_path_get_basename(resource_path);
+ if (strcmp(base, "bin") == 0)
+ path = g_path_get_dirname(resource_path);
+ else
+ path = strdup(resource_path);
+ g_free(resource_path);
+ g_free(base);
+ return path;
+}
+
+const gchar *
+_gtk_get_datadir (void)
+{
+ gchar *resource_dir = get_bundle_path();
+ gchar *retval = g_build_filename(resource_dir, "share", NULL);
+ g_free(resource_dir);
+ return retval;
+}
+
+const gchar *
+_gtk_get_libdir (void)
+{
+ gchar *resource_dir = get_bundle_path();
+ gchar *retval = g_build_filename(resource_dir, "lib", NULL);
+ g_free(resource_dir);
+ return retval;
+}
+
+const gchar *
+_gtk_get_localedir (void)
+{
+
+ gchar *resource_dir = get_bundle_path();
+ gchar *retval = g_build_filename(resource_dir, "share", "locale", NULL);
+ g_free(resource_dir);
+ return retval;
+}
+
+const gchar *
+_gtk_get_sysconfdir (void)
+{
+ gchar *resource_dir = get_bundle_path();
+ gchar *retval = g_build_filename(resource_dir, "etc", NULL);
+ g_free(resource_dir);
+ return retval;
+}
+
+const gchar *
+_gtk_get_data_prefix (void)
+{
+ return get_bundle_path();
+}
+