[gimp/gimp-2-8] Move gimpdir and thumbnails to proper places on OSX



commit 46127dc789762b5ac1b614f7399f5f610394be72
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.
    (cherry picked from commit 9112d68488f44408774f571e7d8fb48e41402674)

 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 7cdad79..cba479e 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -142,7 +142,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 171d80f..e37648e 100644
--- a/app/core/gimp-user-install.c
+++ b/app/core/gimp-user-install.c
@@ -109,7 +109,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);
@@ -140,7 +141,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;
 }
@@ -205,14 +219,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 8e50170..f1d389c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1839,17 +1839,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 89a81c0..57f683c 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
@@ -147,7 +154,7 @@ libgimpbase_2_0_la_LDFLAGS = \
 	-version-info $(LT_VERSION_INFO)	\
 	$(no_undefined) 			\
 	$(libgimpbase_export_symbols)		\
-	$(CARBON_LDFLAGS)
+	$(framework_cocoa)
 
 libgimpbase_2_0_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 07c157b..761c4b9 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_2_0_la_LDFLAGS = \
 	-version-info $(LT_VERSION_INFO)	\
 	$(no_undefined)				\
-	$(libgimpthumb_export_symbols)
+	$(libgimpthumb_export_symbols)		\
+	$(framework_cocoa)
 
 libgimpthumb_2_0_la_LIBADD = $(GDK_PIXBUF_LIBS) $(GLIB_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]