[gtksourceview] Do not depend on gtkmacintegration for locale dir



commit 4bf401661a4ca1b204a62bddfc99aacb56f429ce
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Wed Aug 20 12:47:57 2014 +0200

    Do not depend on gtkmacintegration for locale dir

 configure.ac                       |    2 -
 gtksourceview/Makefile.am          |    5 +++
 gtksourceview/gtksourceview-i18n.c |   61 +++++++++++++++++++++++++++++-------
 3 files changed, 54 insertions(+), 14 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c8a7435..941a4f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,8 +113,6 @@ AM_CONDITIONAL([OS_OSX], [ test "$os_osx" = "yes" ])
 
 if test "$os_osx" = "yes"; then
        AC_DEFINE([OS_OSX], [1], [Defined if os is Mac OSX])
-
-       PKG_CHECK_MODULES(GTK_MAC, gtk-mac-integration >= 2.0.0)
 fi
 
 # Check for Glade3
diff --git a/gtksourceview/Makefile.am b/gtksourceview/Makefile.am
index e25237a..5dd626f 100644
--- a/gtksourceview/Makefile.am
+++ b/gtksourceview/Makefile.am
@@ -145,6 +145,11 @@ libgtksourceview_core_la_LDFLAGS = \
        -no-undefined                   \
        $(CODE_COVERAGE_LDFLAGS)
 
+if OS_OSX
+libgtksourceview_core_la_CFLAGS += -xobjective-c
+libgtksourceview_core_la_LDFLAGS += -framework Cocoa
+endif
+
 # The real library
 lib_LTLIBRARIES = libgtksourceview-3.0.la
 
diff --git a/gtksourceview/gtksourceview-i18n.c b/gtksourceview/gtksourceview-i18n.c
index 25b9009..cbecb3f 100644
--- a/gtksourceview/gtksourceview-i18n.c
+++ b/gtksourceview/gtksourceview-i18n.c
@@ -23,14 +23,58 @@
 #include <config.h>
 #endif
 
-#ifdef OS_OSX
-#include <gtkosxapplication.h>
-#endif
-
 #include <string.h>
 
 #include "gtksourceview-i18n.h"
 
+#ifdef OS_OSX
+
+#include <Cocoa/Cocoa.h>
+
+static gchar *
+dirs_os_x_get_bundle_resource_dir ()
+{
+  NSAutoreleasePool *pool;
+  gchar *str = NULL;
+  NSString *path;
+
+  pool = [[NSAutoreleasePool alloc] init];
+  path = [[NSBundle mainBundle] resourcePath];
+
+  if (!path)
+    {
+      [pool release];
+      return NULL;
+    }
+
+  str = g_strdup ([path UTF8String]);
+  [pool release];
+  return str;
+}
+
+static gchar *
+dirs_os_x_get_locale_dir ()
+{
+  gchar *res_dir;
+  gchar *ret;
+
+  res_dir = dirs_os_x_get_bundle_resource_dir ();
+
+  if (res_dir == NULL)
+    {
+      ret = g_build_filename (DATADIR, "locale", NULL);
+    }
+  else
+    {
+      ret = g_build_filename (res_dir, "share", "locale", NULL);
+      g_free (res_dir);
+    }
+
+  return ret;
+}
+
+#endif
+
 static gchar *
 get_locale_dir (void)
 {
@@ -45,14 +89,7 @@ get_locale_dir (void)
 
        g_free (win32_dir);
 #elif defined (OS_OSX)
-       if (gtkosx_application_get_bundle_id () != NULL)
-       {
-               locale_dir = g_build_filename (gtkosx_application_get_resource_path (), "share", "locale", 
NULL);
-       }
-       else
-       {
-               locale_dir = g_build_filename (DATADIR, "locale", NULL);
-       }
+       locale_dir = dirs_os_x_get_locale_dir ();
 #else
        locale_dir = g_build_filename (DATADIR, "locale", NULL);
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]