[libpeas/wip/1.10.1-osx] Improved dependency-less support for OS X
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas/wip/1.10.1-osx] Improved dependency-less support for OS X
- Date: Wed, 20 Aug 2014 11:01:37 +0000 (UTC)
commit 3403cbe36922517be8e19fdf506274d54d29fd92
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Wed Aug 20 12:39:25 2014 +0200
Improved dependency-less support for OS X
configure.ac | 2 -
libpeas-gtk/Makefile.am | 5 ++
libpeas-gtk/peas-gtk-plugin-manager.c | 2 +-
libpeas/Makefile.am | 7 ++-
libpeas/peas-dirs.c | 120 +++++++++++++++++++++++----------
5 files changed, 95 insertions(+), 41 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index bc806f4..d81f8b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -140,8 +140,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(IGE_MAC, ige-mac-integration)
fi
dnl ================================================================
diff --git a/libpeas-gtk/Makefile.am b/libpeas-gtk/Makefile.am
index 6013011..acc3e19 100644
--- a/libpeas-gtk/Makefile.am
+++ b/libpeas-gtk/Makefile.am
@@ -19,6 +19,11 @@ libpeas_gtk_1_0_la_LIBADD = \
$(PEAS_GTK_LIBS) \
$(top_builddir)/libpeas/libpeas-1.0.la
+if OS_OSX
+AM_CPPFLAGS += -xobjective-c
+libpeas_gtk_1_0_la_LDFLAGS += -framework Cocoa
+endif
+
INST_H_FILES = \
peas-gtk-configurable.h \
peas-gtk-plugin-manager.h \
diff --git a/libpeas-gtk/peas-gtk-plugin-manager.c b/libpeas-gtk/peas-gtk-plugin-manager.c
index 41173cd..36221f1 100644
--- a/libpeas-gtk/peas-gtk-plugin-manager.c
+++ b/libpeas-gtk/peas-gtk-plugin-manager.c
@@ -30,7 +30,7 @@
#include <girepository.h>
#ifdef OS_OSX
-#include <Carbon/Carbon.h>
+#import <Cocoa/Cocoa.h>
#endif
#include <libpeas/peas-engine.h>
diff --git a/libpeas/Makefile.am b/libpeas/Makefile.am
index 9a24522..ccf5b21 100644
--- a/libpeas/Makefile.am
+++ b/libpeas/Makefile.am
@@ -16,7 +16,12 @@ libpeas_1_0_la_LDFLAGS = \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
-export-dynamic -no-undefined -export-symbols-regex "^[^_].*"
-libpeas_1_0_la_LIBADD = $(PEAS_LIBS) $(IGE_MAC_LIBS)
+if OS_OSX
+AM_CPPFLAGS += -xobjective-c
+libpeas_1_0_la_LDFLAGS += -framework Cocoa
+endif
+
+libpeas_1_0_la_LIBADD = $(PEAS_LIBS)
INST_H_FILES = \
peas-plugin-info.h \
diff --git a/libpeas/peas-dirs.c b/libpeas/peas-dirs.c
index a93bf73..09e80f5 100644
--- a/libpeas/peas-dirs.c
+++ b/libpeas/peas-dirs.c
@@ -23,11 +23,88 @@
#include <config.h>
#endif
+#include "peas-dirs.h"
+
#ifdef OS_OSX
-#include <ige-mac-bundle.h>
-#endif
-#include "peas-dirs.h"
+#import <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_resource_dir (const gchar *subdir, const gchar *default_dir)
+{
+ gchar *res_dir;
+ gchar *ret;
+
+ res_dir = dirs_os_x_get_bundle_resource_dir ();
+
+ if (res_dir == NULL)
+ {
+ ret = g_build_filename (default_dir, "libpeas-1.0", NULL);
+ }
+ else
+ {
+ ret = g_build_filename (res_dir, subdir, "libpeas-1.0", NULL);
+ g_free (res_dir);
+ }
+
+ return ret;
+}
+
+static gchar *
+dirs_os_x_get_data_dir ()
+{
+ return dirs_os_x_get_resource_dir ("share", DATADIR);
+}
+
+static gchar *
+dirs_os_x_get_lib_dir ()
+{
+ return dirs_os_x_get_resource_dir ("lib", LIBDIR);
+}
+
+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
gchar *
peas_dirs_get_data_dir (void)
@@ -42,18 +119,7 @@ peas_dirs_get_data_dir (void)
data_dir = g_build_filename (win32_dir, "share", "libpeas-1.0", NULL);
g_free (win32_dir);
#elif defined (OS_OSX)
- IgeMacBundle *bundle = ige_mac_bundle_get_default ();
-
- if (ige_mac_bundle_get_is_app_bundle (bundle))
- {
- const gchar *bundle_data_dir = ige_mac_bundle_get_datadir (bundle);
-
- data_dir = g_build_filename (bundle_data_dir, "libpeas-1.0", NULL);
- }
- else
- {
- data_dir = g_build_filename (DATADIR, "libpeas-1.0", NULL);
- }
+ data_dir = dirs_os_x_get_data_dir ();
#else
data_dir = g_build_filename (DATADIR, "libpeas-1.0", NULL);
#endif
@@ -74,18 +140,7 @@ peas_dirs_get_lib_dir (void)
lib_dir = g_build_filename (win32_dir, "lib", "libpeas-1.0", NULL);
g_free (win32_dir);
#elif defined (OS_OSX)
- IgeMacBundle *bundle = ige_mac_bundle_get_default ();
-
- if (ige_mac_bundle_get_is_app_bundle (bundle))
- {
- const gchar *path = ige_mac_bundle_get_resourcesdir (bundle);
-
- lib_dir = g_build_filename (path, "lib", "libpeas-1.0", NULL);
- }
- else
- {
- lib_dir = g_build_filename (LIBDIR, "libpeas-1.0", NULL);
- }
+ lib_dir = dirs_os_x_get_lib_dir ();
#else
lib_dir = g_build_filename (LIBDIR, "libpeas-1.0", NULL);
#endif
@@ -126,16 +181,7 @@ peas_dirs_get_locale_dir (void)
g_free (win32_dir);
#elif defined (OS_OSX)
- IgeMacBundle *bundle = ige_mac_bundle_get_default ();
-
- if (ige_mac_bundle_get_is_app_bundle (bundle))
- {
- locale_dir = g_strdup (ige_mac_bundle_get_localedir (bundle));
- }
- 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]