r19198 - gnucash/trunk/src/core-utils - Update binreloc to use Cocoa-based GtkOSXApplication instead of ige-mac-bundle.

John Ralls jralls at code.gnucash.org
Fri May 21 18:45:34 EDT 2010


Author: jralls
Date: 2010-05-21 18:45:34 -0400 (Fri, 21 May 2010)
New Revision: 19198
Trac: http://svn.gnucash.org/trac/changeset/19198

Modified:
   gnucash/trunk/src/core-utils/binreloc.c
Log:
Update binreloc to use Cocoa-based GtkOSXApplication instead of ige-mac-bundle.

Modified: gnucash/trunk/src/core-utils/binreloc.c
===================================================================
--- gnucash/trunk/src/core-utils/binreloc.c	2010-05-21 20:45:05 UTC (rev 19197)
+++ gnucash/trunk/src/core-utils/binreloc.c	2010-05-21 22:45:34 UTC (rev 19198)
@@ -19,7 +19,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #ifdef MAC_INTEGRATION
-#include <igemacintegration/ige-mac-bundle.h>
+#include <igemacintegration/gtkosxapplication.h>
 #endif
 #endif /* ENABLE_BINRELOC */
 #include <stdio.h>
@@ -30,9 +30,6 @@
 #include <glib.h>
 
 G_BEGIN_DECLS
-#if defined ENABLE_BINRELOC && defined MAC_INTEGRATION
-static IgeMacBundle *bundle = NULL;
-#endif
 
 /** @internal
  * Find the canonical filename of the executable. Returns the filename
@@ -66,27 +63,10 @@
     g_free (prefix);
     return result;
 #elif defined MAC_INTEGRATION
-    gchar *prefix = NULL, *result = NULL;
+    GtkOSXApplication *theApp;
     g_type_init();
-    bundle = ige_mac_bundle_new();
-    if (!bundle)
-    {
-        *error = GNC_GBR_INIT_ERROR_MAC_NOT_BUNDLE;
-        return NULL;
-    }
-    if (!ige_mac_bundle_get_is_app_bundle (bundle))
-    {
-        g_object_unref(bundle);
-        bundle = NULL;
-        *error = GNC_GBR_INIT_ERROR_MAC_NOT_APP_BUNDLE;
-        return NULL;
-    }
-    ige_mac_bundle_setup_environment(bundle);
-    prefix = g_strdup(ige_mac_bundle_get_path(bundle));
-    result = g_build_filename(prefix, "Contents/MacOS",
-                              "gnucash-bin", NULL);
-    g_free(prefix);
-    return result;
+    theApp  = g_object_new (GTK_TYPE_OSX_APPLICATION, NULL);
+    return gtk_osxapplication_get_executable_path(theApp);
 #else
     char *path, *path2, *line, *result;
     size_t buf_size;
@@ -300,12 +280,6 @@
     case GNC_GBR_INIT_ERROR_INVALID_MAPS:
         error_message = "The file format of /proc/self/maps is invalid.";
         break;
-    case GNC_GBR_INIT_ERROR_MAC_NOT_BUNDLE:
-        error_message = "Binreloc did not find a bundle";
-        break;
-    case GNC_GBR_INIT_ERROR_MAC_NOT_APP_BUNDLE:
-        error_message = "Binreloc found that the bundle is not an app bundle";
-        break;
     case GNC_GBR_INIT_ERROR_DISABLED:
         error_message = "Binary relocation support is disabled.";
         break;
@@ -389,23 +363,20 @@
 gchar *
 gnc_gbr_find_prefix (const gchar *default_prefix)
 {
-    gchar *dir1, *dir2;
-
 #if defined ENABLE_BINRELOC && defined MAC_INTEGRATION
-    gchar *prefix = NULL, *result = NULL;
-    if (bundle == NULL)
-    {
-        /* BinReloc not initialized. */
-        if (default_prefix != NULL)
-            return g_strdup (default_prefix);
-        else
-            return NULL;
+    GtkOSXApplication* theApp  = g_object_new (GTK_TYPE_OSX_APPLICATION, NULL);
+    gchar *id = gtk_osxapplication_get_bundle_id (theApp);
+    gchar *path = gtk_osxapplication_get_resource_path (theApp);
+    if (id == NULL) {
+	gchar *dirname = g_path_get_dirname (path);
+	g_free (path);
+	g_free (id);
+	return dirname;
     }
-    prefix = g_strdup(ige_mac_bundle_get_path(bundle));
-    result = g_build_filename(prefix, "Contents/Resources", NULL);
-    g_free(prefix);
-    return result;
+    g_free (id);
+    return path;
 #else
+    gchar *dir1, *dir2;
 
     if (exe == NULL)
     {
@@ -440,21 +411,6 @@
 gnc_gbr_find_bin_dir (const gchar *default_bin_dir)
 {
     gchar *prefix, *dir;
-#if defined ENABLE_BINRELOC && defined MAC_INTEGRATION
-    if (bundle == NULL)
-    {
-        /* BinReloc not initialized. */
-        if (default_bin_dir != NULL)
-            return g_strdup (default_bin_dir);
-        else
-            return NULL;
-    }
-    prefix = g_strdup(ige_mac_bundle_get_path(bundle));
-    dir = g_build_filename(prefix, "Contents/MacOS", NULL);
-    g_free(prefix);
-    return dir;
-#else
-
     prefix = gnc_gbr_find_prefix (NULL);
     if (prefix == NULL)
     {
@@ -468,7 +424,6 @@
     dir = g_build_filename (prefix, "bin", NULL);
     g_free (prefix);
     return dir;
-#endif //ENABLE_BINRELOC && MAC_INTEGRATION
 }
 
 



More information about the gnucash-changes mailing list