merge macos.c and macos.m, update ios.*

* Merged macos.c into macos.m.
* Updated ios.h and ios.c to be compatible with the macos.* changes.
* Renamed ios.c to ios.m.
This commit is contained in:
Mark Kim 2022-02-06 11:29:19 -05:00
parent d697d3faca
commit c2ab6d461c
5 changed files with 83 additions and 101 deletions

View file

@ -159,7 +159,7 @@ ios_BUNDLE:=./TuxPaint-$(SDK).app
BUNDLE:=$($(OS)_BUNDLE)
windows_ARCH_LIBS:=obj/win32_print.o obj/resource.o obj/win32_trash.o
macos_ARCH_LIBS:=src/macos_print.m obj/macos.o obj/macosm.o
macos_ARCH_LIBS:=src/macos_print.m obj/macos.o
ios_ARCH_LIBS:=src/ios_print.m obj/ios.o
beos_ARCH_LIBS:=obj/BeOS_print.o
linux_ARCH_LIBS:=obj/postscript_print.o
@ -1302,23 +1302,17 @@ obj/postscript_print.o: src/postscript_print.c \
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/postscript_print.c -o obj/postscript_print.o
obj/macos.o: src/macos.c src/macos.h src/platform.h src/debug.h
obj/macos.o: src/macos.m src/macos.h src/platform.h src/debug.h
@echo
@echo "...Compiling macOS support (Part 1)..."
@echo "...Compiling macOS support..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/macos.c -o obj/macos.o
-c src/macos.m -o obj/macos.o
obj/macosm.o: src/macos.m src/macos.h src/platform.h src/debug.h
@echo
@echo "...Compiling macOS support (Part 2)..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/macos.m -o obj/macosm.o
obj/ios.o: src/ios.c src/ios.h src/platform.h src/debug.h
obj/ios.o: src/ios.m src/ios.h src/platform.h src/debug.h
@echo
@echo "...Compiling iOS support..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/ios.c -o obj/ios.o
-c src/ios.m -o obj/ios.o
obj/resource.o: win32/resources.rc win32/resource.h
@echo

View file

@ -22,6 +22,8 @@
#ifndef __IOS_H__
#define __IOS_H__
void apple_init(void);
const char *apple_fontsPath(void);
const char *apple_preferencesPath(void);
const char *apple_globalPreferencesPath(void);

View file

@ -43,6 +43,12 @@ static int _mkdir_r(const char *path)
}
void apple_init(void)
{
/* this function intentionally left blank */
}
const char *apple_fontsPath(void)
{
return IOS_FONTS_PATH;

View file

@ -1,87 +0,0 @@
/*
macos.c
Copyright (c) 2021-2022
http://www.tuxpaint.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "macos.h"
#define MACOS_FONTS_PATH "%s/Library/Fonts"
#define MACOS_PREFERENCES_PATH "%s/Library/Application Support/TuxPaint"
#define MACOS_GLOBAL_PREFERENCES_PATH "/Library/Application Support/TuxPaint"
#define MACOS_PICTURES_PATH "%s/Pictures"
const char *apple_fontsPath(void)
{
static char *p = NULL;
if(!p) {
const char *home = getenv("HOME") ? getenv("HOME") : "";
p = malloc(strlen(home) + strlen(MACOS_FONTS_PATH) + 1);
if(p) sprintf(p, MACOS_FONTS_PATH, home);
else perror("apple_fontsPath");
}
return p;
}
const char *apple_preferencesPath(void)
{
static char *p = NULL;
if(!p) {
const char *home = getenv("HOME") ? getenv("HOME") : "";
p = malloc(strlen(home) + strlen(MACOS_PREFERENCES_PATH) + 1);
if(p) sprintf(p, MACOS_PREFERENCES_PATH, home);
else perror("apple_preferencesPath");
}
return p;
}
const char *apple_globalPreferencesPath(void)
{
return MACOS_GLOBAL_PREFERENCES_PATH;
}
const char *apple_picturesPath(void)
{
static char *p = NULL;
if(!p) {
const char *home = getenv("HOME") ? getenv("HOME") : "";
p = malloc(strlen(home) + strlen(MACOS_PICTURES_PATH) + 1);
if(p) sprintf(p, MACOS_PICTURES_PATH, home);
else perror("apple_picturesPath");
}
return p;
}

View file

@ -1,7 +1,7 @@
/*
macos.m
Copyright (c) 2022
Copyright (c) 2021-2022
http://www.tuxpaint.org/
This program is free software; you can redistribute it and/or modify
@ -20,9 +20,18 @@
(See COPYING.txt)
*/
#import <Cocoa/Cocoa.h>
#import <stdio.h>
#import <stdlib.h>
#import <string.h>
#import <libintl.h>
#import <Cocoa/Cocoa.h>
#import "macos.h"
#import "debug.h"
#define MACOS_FONTS_PATH "%s/Library/Fonts"
#define MACOS_PREFERENCES_PATH "%s/Library/Application Support/TuxPaint"
#define MACOS_GLOBAL_PREFERENCES_PATH "/Library/Application Support/TuxPaint"
#define MACOS_PICTURES_PATH "%s/Pictures"
static void setupApplicationMenu(void)
@ -126,3 +135,61 @@ void apple_init(void)
setupWindowMenu();
removeSdlMenu();
}
const char *apple_fontsPath(void)
{
static char *p = NULL;
if(!p) {
const char *home = getenv("HOME") ? getenv("HOME") : "";
p = malloc(strlen(home) + strlen(MACOS_FONTS_PATH) + 1);
if(p) sprintf(p, MACOS_FONTS_PATH, home);
else perror("apple_fontsPath");
}
return p;
}
const char *apple_preferencesPath(void)
{
static char *p = NULL;
if(!p) {
const char *home = getenv("HOME") ? getenv("HOME") : "";
p = malloc(strlen(home) + strlen(MACOS_PREFERENCES_PATH) + 1);
if(p) sprintf(p, MACOS_PREFERENCES_PATH, home);
else perror("apple_preferencesPath");
}
return p;
}
const char *apple_globalPreferencesPath(void)
{
return MACOS_GLOBAL_PREFERENCES_PATH;
}
const char *apple_picturesPath(void)
{
static char *p = NULL;
if(!p) {
const char *home = getenv("HOME") ? getenv("HOME") : "";
p = malloc(strlen(home) + strlen(MACOS_PICTURES_PATH) + 1);
if(p) sprintf(p, MACOS_PICTURES_PATH, home);
else perror("apple_picturesPath");
}
return p;
}