Permalink
Browse files

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.
  • Loading branch information...
1 parent cf442d3 commit 9112d68488f44408774f571e7d8fb48e41402674 @mitchfoo mitchfoo committed May 12, 2012
Showing with 103 additions and 22 deletions.
  1. +0 −1 app/Makefile.am
  2. +19 −6 app/core/gimp-user-install.c
  3. +4 −0 configure.ac
  4. +16 −9 libgimpbase/Makefile.am
  5. +25 −0 libgimpbase/gimpenv.c
  6. +9 −2 libgimpthumb/Makefile.am
  7. +30 −4 libgimpthumb/gimpthumb-utils.c
View
@@ -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) \
@@ -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)
View
@@ -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
@@ -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)
View
@@ -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;
@@ -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) \
@@ -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))

0 comments on commit 9112d68

Please sign in to comment.