gio: Check __APPLE__ in a few places instead of HAVE_COCOA

`HAVE_COCOA` should be used only in the places where we’re actually
depending on the Cocoa toolkit. It should not be used as a general way
of detecting building on a Darwin-based OS such as macOS.

Conversely, there are a few places in the code where we do want to
specifically detect the Cocoa toolkit (and others where we specifically
want to detect Carbon), so keep `HAVE_COCOA` and `HAVE_CARBON` around.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2802
This commit is contained in:
Philip Withnall 2022-11-03 18:22:18 +00:00
parent ad4c59c3c6
commit 5af339aedf
5 changed files with 10 additions and 10 deletions

View File

@ -23,7 +23,7 @@
#include <gio/gio.h>
#if defined(G_OS_UNIX) && !defined(HAVE_COCOA)
#if defined(G_OS_UNIX) && !defined(__APPLE__)
#include <gio/gdesktopappinfo.h>
#endif
@ -40,7 +40,7 @@ handle_launch (int argc, char *argv[], gboolean do_help)
{
GOptionContext *context;
GError *error = NULL;
#if defined(G_OS_UNIX) && !defined(HAVE_COCOA)
#if defined(G_OS_UNIX) && !defined(__APPLE__)
int i;
GAppInfo *app = NULL;
GAppLaunchContext *app_context = NULL;
@ -83,7 +83,7 @@ handle_launch (int argc, char *argv[], gboolean do_help)
g_option_context_free (context);
#if !defined(G_OS_UNIX) || defined(HAVE_COCOA)
#if !defined(G_OS_UNIX) || defined(__APPLE__)
print_error (_("The launch command is not currently supported on this platform"));
retval = 1;
#else

View File

@ -23,7 +23,7 @@
#include <gio/gio.h>
#if defined(G_OS_UNIX) && !defined(HAVE_COCOA)
#if defined(G_OS_UNIX) && !defined(__APPLE__)
#include <gio/gdesktopappinfo.h>
#endif

View File

@ -61,14 +61,14 @@
#endif
#include <glib/gstdio.h>
#if defined(G_OS_UNIX) && !defined(HAVE_COCOA)
#if defined(G_OS_UNIX) && !defined(__APPLE__)
#include "gdesktopappinfo.h"
#endif
#ifdef HAVE_COCOA
#include "gosxappinfo.h"
#endif
#ifdef HAVE_COCOA
#ifdef __APPLE__
#include <AvailabilityMacros.h>
#endif
@ -1192,7 +1192,7 @@ _g_io_modules_ensure_extension_points_registered (void)
if (g_once_init_enter (&registered_extensions))
{
#if defined(G_OS_UNIX) && !defined(HAVE_COCOA)
#if defined(G_OS_UNIX) && !defined(__APPLE__)
#if !GLIB_CHECK_VERSION (3, 0, 0)
ep = g_io_extension_point_register (G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME);
g_io_extension_point_set_required_type (ep, G_TYPE_DESKTOP_APP_INFO_LOOKUP);

View File

@ -1380,7 +1380,7 @@ get_content_type (const char *basename,
content_type = g_content_type_guess (basename, NULL, 0, &result_uncertain);
#if !defined(G_OS_WIN32) && !defined(HAVE_COCOA)
#if !defined(G_OS_WIN32) && !defined(__APPLE__)
if (!fast && result_uncertain && path != NULL)
{
guchar sniff_buffer[4096];

View File

@ -2472,7 +2472,7 @@ get_size_from_du (const gchar *path, guint64 *size)
GError *error = NULL;
gchar *du_path = NULL;
#ifndef HAVE_COCOA
#ifndef __APPLE__
du_path = g_find_program_in_path ("du");
#endif
@ -3556,7 +3556,7 @@ test_query_zero_length_content_type (void)
NULL, &error);
g_assert_no_error (error);
#ifndef HAVE_COCOA
#ifndef __APPLE__
g_assert_cmpstr (g_file_info_get_content_type (file_info), ==, "text/plain");
#else
g_assert_cmpstr (g_file_info_get_content_type (file_info), ==, "public.text");