[gimp/metadata-browser] Move gimpdir and thumbnails to proper places on OSX
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] Move gimpdir and thumbnails to proper places on OSX
- Date: Thu, 13 Sep 2012 00:14:00 +0000 (UTC)
commit f2be50bf79bcb88f8783167e7db8098e31212db3
Author: Michael Natterer <mitch gimp org>
Date: Sat May 12 14:39:44 2012 +0200
Move gimpdir and thumbnails to proper places on OSX
gimpdir goes to ~/Library/Gimp/x.y
thumbnails go to ~/Library/Caches/org.freedesktop.thumbnails
The thumbnail location is not standardized yet, but is the only
location that makes sense. Also fix user install to search old
gimpdirs to migrate in both Library and the classic location.
Remove the obsolete CABON_CFLAGS from all makefiles.
app/Makefile.am | 1 -
app/core/gimp-user-install.c | 25 +++++++++++++++++++------
configure.ac | 4 ++++
libgimpbase/Makefile.am | 25 ++++++++++++++++---------
libgimpbase/gimpenv.c | 25 +++++++++++++++++++++++++
libgimpthumb/Makefile.am | 11 +++++++++--
libgimpthumb/gimpthumb-utils.c | 34 ++++++++++++++++++++++++++++++----
7 files changed, 103 insertions(+), 22 deletions(-)
---
diff --git a/app/Makefile.am b/app/Makefile.am
index 57ec5cb..8cc2e3d 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -145,7 +145,6 @@ calm_down_linker = \
AM_LDFLAGS = \
$(munix) \
- $(CARBON_LDFLAGS) \
$(calm_down_linker) \
$(workaround_that_core_depends_on_xcf) \
$(workaround_that_core_depends_on_pdb) \
diff --git a/app/core/gimp-user-install.c b/app/core/gimp-user-install.c
index 4eae3aa..8e5124c 100644
--- a/app/core/gimp-user-install.c
+++ b/app/core/gimp-user-install.c
@@ -110,7 +110,8 @@ gimp_user_install_items[] =
};
-static gboolean gimp_user_install_detect_old (GimpUserInstall *install);
+static gboolean gimp_user_install_detect_old (GimpUserInstall *install,
+ const gchar *gimp_dir);
static void user_install_log (GimpUserInstall *install,
const gchar *format,
...) G_GNUC_PRINTF (2, 3);
@@ -141,7 +142,20 @@ gimp_user_install_new (gboolean verbose)
install->verbose = verbose;
- gimp_user_install_detect_old (install);
+ gimp_user_install_detect_old (install, gimp_directory ());
+
+#ifdef PLATFORM_OSX
+ if (! install->old_dir)
+ {
+ /* if the default old gimpdir was not found, try the "classic" one
+ * in the home folder
+ */
+ gchar *dir = g_strdup_printf ("%s/.gimp-%s",
+ g_get_home_dir (), GIMP_APP_VERSION);
+ gimp_user_install_detect_old (install, dir);
+ g_free (dir);
+ }
+#endif
return install;
}
@@ -206,14 +220,13 @@ gimp_user_install_set_log_handler (GimpUserInstall *install,
/* Local functions */
static gboolean
-gimp_user_install_detect_old (GimpUserInstall *install)
+gimp_user_install_detect_old (GimpUserInstall *install,
+ const gchar *gimp_dir)
{
- gchar *dir;
+ gchar *dir = g_strdup (gimp_dir);
gchar *version;
gboolean migrate = FALSE;
- dir = g_strdup (gimp_directory ());
-
version = strstr (dir, GIMP_APP_VERSION);
if (version)
diff --git a/configure.ac b/configure.ac
index fdf12fd..ec281a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1841,17 +1841,21 @@ AC_SUBST(SCREENSHOT)
# Check for Mac OS X
####################
+platform_osx=no
AC_MSG_CHECKING([if compiling for Mac OS X])
case "$target_or_host" in
*-*-darwin*)
AC_MSG_RESULT(yes)
AC_DEFINE(PLATFORM_OSX, 1, [define to 1 if compiling for Mac OS X])
+ platform_osx=yes
;;
*)
AC_MSG_RESULT(no)
;;
esac
+AM_CONDITIONAL(PLATFORM_OSX, test "x$platform_osx" = xyes)
+
####################################
# Check for Mac OS X TWAIN framework
diff --git a/libgimpbase/Makefile.am b/libgimpbase/Makefile.am
index 5113c42..cc8c930 100644
--- a/libgimpbase/Makefile.am
+++ b/libgimpbase/Makefile.am
@@ -4,6 +4,11 @@ if PLATFORM_WIN32
no_undefined = -no-undefined
endif
+if PLATFORM_OSX
+xobjective_c = "-xobjective-c"
+framework_cocoa = -framework Cocoa
+endif
+
if OS_WIN32
ole32_lib = -lole32
gimpbase_def = gimpbase.def
@@ -41,14 +46,15 @@ endif
libgimpbaseincludedir = $(includedir)/gimp-$(GIMP_API_VERSION)/libgimpbase
AM_CPPFLAGS = \
- -DPREFIX=\""$(prefix)"\" \
- -DGIMPDIR=\""$(gimpdir)"\" \
- -DDATADIR=\""$(gimpdatadir)"\" \
- -DLOCALEDIR=\""$(gimplocaledir)"\" \
- -DPLUGINDIR=\""$(gimpplugindir)"\" \
- -DSYSCONFDIR=\""$(gimpsysconfdir)"\" \
- -DGIMP_PACKAGE=\""@PACKAGE@"\" \
+ -DPREFIX=\""$(prefix)"\" \
+ -DGIMPDIR=\""$(gimpdir)"\" \
+ -DDATADIR=\""$(gimpdatadir)"\" \
+ -DLOCALEDIR=\""$(gimplocaledir)"\" \
+ -DPLUGINDIR=\""$(gimpplugindir)"\" \
+ -DSYSCONFDIR=\""$(gimpsysconfdir)"\" \
+ -DGIMP_PACKAGE=\""@PACKAGE@"\" \
-DGIMP_DATA_VERSION=\"$(GIMP_DATA_VERSION)\" \
+ -DGIMP_USER_VERSION=\"$(GIMP_USER_VERSION)\" \
-DGIMP_SYSCONF_VERSION=\"$(GIMP_SYSCONF_VERSION)\" \
-DGIMP_PLUGIN_VERSION=\"$(GIMP_PLUGIN_VERSION)\" \
-DG_LOG_DOMAIN=\"LibGimpBase\" \
@@ -62,7 +68,8 @@ INCLUDES = \
-I$(top_srcdir) \
$(GLIB_CFLAGS) \
$(BINRELOC_CFLAGS) \
- -I$(includedir)
+ -I$(includedir) \
+ $(xobjective_c)
EXTRA_DIST = \
gimpbase.def
@@ -152,7 +159,7 @@ libgimpbase_ GIMP_API_VERSION@_la_LDFLAGS = \
-version-info $(LT_VERSION_INFO) \
$(no_undefined) \
$(libgimpbase_export_symbols) \
- $(CARBON_LDFLAGS)
+ $(framework_cocoa)
libgimpbase_ GIMP_API_VERSION@_la_DEPENDENCIES = $(gimpbase_def)
diff --git a/libgimpbase/gimpenv.c b/libgimpbase/gimpenv.c
index aa64973..ce67d39 100644
--- a/libgimpbase/gimpenv.c
+++ b/libgimpbase/gimpenv.c
@@ -28,6 +28,10 @@
#include <unistd.h>
#endif
+#ifdef PLATFORM_OSX
+#include <AppKit/AppKit.h>
+#endif
+
#include <glib-object.h>
#include <glib/gstdio.h>
@@ -226,6 +230,25 @@ gimp_directory (void)
}
else
{
+#ifdef PLATFORM_OSX
+
+ NSAutoreleasePool *pool;
+ NSArray *path;
+ NSString *library_dir;
+
+ pool = [[NSAutoreleasePool alloc] init];
+
+ path = NSSearchPathForDirectoriesInDomains (NSLibraryDirectory,
+ NSUserDomainMask, YES);
+ library_dir = [path objectAtIndex:0];
+
+ gimp_dir = g_build_filename ([library_dir UTF8String], "Gimp", GIMP_USER_VERSION,
+ NULL);
+
+ [pool drain];
+
+#else /* ! PLATFORM_OSX */
+
if (home_dir)
{
gimp_dir = g_build_filename (home_dir, GIMPDIR, NULL);
@@ -262,6 +285,8 @@ gimp_directory (void)
g_free (user_name);
g_free (subdir_name);
}
+
+#endif /* PLATFORM_OSX */
}
return gimp_dir;
diff --git a/libgimpthumb/Makefile.am b/libgimpthumb/Makefile.am
index 4f07a62..081894b 100644
--- a/libgimpthumb/Makefile.am
+++ b/libgimpthumb/Makefile.am
@@ -4,6 +4,11 @@ if PLATFORM_WIN32
no_undefined = -no-undefined
endif
+if PLATFORM_OSX
+xobjective_c = "-xobjective-c"
+framework_cocoa = -framework Cocoa
+endif
+
if OS_WIN32
gimpthumb_def = gimpthumb.def
libgimpthumb_export_symbols = -export-symbols gimpthumb.def
@@ -47,7 +52,8 @@ INCLUDES = \
-I$(top_srcdir) \
$(GDK_PIXBUF_CFLAGS) \
$(GLIB_CFLAGS) \
- -I$(includedir)
+ -I$(includedir) \
+ $(xobjective_c)
EXTRA_DIST = \
gimpthumb.def
@@ -77,7 +83,8 @@ libgimpthumbinclude_HEADERS = \
libgimpthumb_ GIMP_API_VERSION@_la_LDFLAGS = \
-version-info $(LT_VERSION_INFO) \
$(no_undefined) \
- $(libgimpthumb_export_symbols)
+ $(libgimpthumb_export_symbols) \
+ $(framework_cocoa)
libgimpthumb_ GIMP_API_VERSION@_la_LIBADD = \
$(GDK_PIXBUF_LIBS) \
diff --git a/libgimpthumb/gimpthumb-utils.c b/libgimpthumb/gimpthumb-utils.c
index 07252ab..ea5e41e 100644
--- a/libgimpthumb/gimpthumb-utils.c
+++ b/libgimpthumb/gimpthumb-utils.c
@@ -32,6 +32,10 @@
#include <unistd.h>
#endif
+#ifdef PLATFORM_OSX
+#include <AppKit/AppKit.h>
+#endif
+
#include <glib-object.h>
#include <glib/gstdio.h>
@@ -118,13 +122,35 @@ gimp_thumb_init (const gchar *creator,
}
else
{
+#ifdef PLATFORM_OSX
+
+ NSAutoreleasePool *pool;
+ NSArray *path;
+ NSString *cache_dir;
+
+ pool = [[NSAutoreleasePool alloc] init];
+
+ path = NSSearchPathForDirectoriesInDomains (NSCachesDirectory,
+ NSUserDomainMask, YES);
+ cache_dir = [path objectAtIndex:0];
+
+ thumb_dir = g_build_filename ([cache_dir UTF8String], "org.freedesktop.thumbnails",
+ NULL);
+
+ [pool drain];
+
+#else
+
const gchar *home_dir = g_get_home_dir ();
if (home_dir && g_file_test (home_dir, G_FILE_TEST_IS_DIR))
{
thumb_dir = g_build_filename (home_dir, ".thumbnails", NULL);
}
- else
+
+#endif
+
+ if (! thumb_dir)
{
gchar *name = g_filename_display_name (g_get_tmp_dir ());
@@ -239,12 +265,12 @@ gimp_thumb_ensure_thumb_dir (GimpThumbSize size,
return TRUE;
if (g_file_test (thumb_dir, G_FILE_TEST_IS_DIR) ||
- (g_mkdir (thumb_dir, S_IRUSR | S_IWUSR | S_IXUSR) == 0))
+ (g_mkdir_with_parents (thumb_dir, S_IRUSR | S_IWUSR | S_IXUSR) == 0))
{
if (size == 0)
- g_mkdir (thumb_fail_subdir, S_IRUSR | S_IWUSR | S_IXUSR);
+ g_mkdir_with_parents (thumb_fail_subdir, S_IRUSR | S_IWUSR | S_IXUSR);
- g_mkdir (thumb_subdirs[size], S_IRUSR | S_IWUSR | S_IXUSR);
+ g_mkdir_with_parents (thumb_subdirs[size], S_IRUSR | S_IWUSR | S_IXUSR);
}
if (g_file_test (thumb_subdirs[size], G_FILE_TEST_IS_DIR))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]