Commit 8bb48ac5 authored by Michael Natterer's avatar Michael Natterer 😴

Bug 555525 - 64 Bit Build on Mac OS X Leopard fails...

...because of TWAIN interface

Remove all Mac TWAIN stuff, we will get proper OS X scanner support
pretty soon.
parent 4f99c729
......@@ -1979,28 +1979,6 @@ fi
AM_CONDITIONAL(PLATFORM_OSX_QUARTZ, test "x$gtk_mac_integration_ok" = xyes)
####################################
# Check for Mac OS X TWAIN framework
####################################
AC_ARG_WITH(mac-twain, [ --without-mac-twain don't build the Mac TWAIN plug-in])
mac_twain_ok=no
if test "x$with_mac_twain" != xno; then
AC_MSG_CHECKING([for Mac OS X TWAIN support])
AC_PREPROC_IFELSE(
[AC_LANG_SOURCE([[
#include <Carbon/Carbon.h>
#include <TWAIN/TWAIN.h>
#ifdef __x86_64__
#error Please somebody port this to non-deprecated and non-removed APIs
#endif]])],
[mac_twain_ok=yes])
AC_MSG_RESULT($mac_twain_ok)
fi
AM_CONDITIONAL(HAVE_MAC_TWAIN, test "x$mac_twain_ok" = xyes)
##########################################################
# Determine where to install the desktop & mime info files
......@@ -2517,7 +2495,6 @@ Optional Plug-Ins:
Python 2: $enable_python
Script-Fu: $have_script_fu
SVG: $have_librsvg
TWAIN (MacOS X): $mac_twain_ok
TWAIN (Win32): $os_win32
Webpage: $have_webkit
WMF: $have_libwmf
......
......@@ -20,10 +20,6 @@ if BUILD_SCRIPT_FU
script_fu = script-fu
endif
if HAVE_MAC_TWAIN
twain = twain
endif
if OS_WIN32
twain = twain
win_snap = win-snap
......
......@@ -24,15 +24,6 @@ include $(top_srcdir)/build/windows/gimprc-plug-ins.rule
twain_RC = twain.rc.o
endif
if HAVE_MAC_TWAIN
twain_LDFLAGS = -framework Carbon -framework TWAIN
twainplatform = tw_mac.c
twaindatadir = $(gimpdatadir)/twain
twaindata_DATA = gimp-twain.png
endif
twain_SOURCES = \
tw_func.c \
......@@ -50,8 +41,7 @@ EXTRA_DIST = \
gimp-twain.png \
tw_dump.c \
tw_dump.h \
tw_win.c \
tw_mac.c
tw_win.c
AM_CPPFLAGS = \
-I$(top_srcdir) \
......
/*
* TWAIN Plug-in
* Copyright (C) 1999 Craig Setera
* Craig Setera <setera@home.com>
* 03/31/1999
*
* Updated for Mac OS X support
* Brion Vibber <brion@pobox.com>
* 07/22/2004
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
/*
* Platform-specific code for Mac OS X
*/
#include "config.h"
#include <libgimp/gimp.h>
#include "tw_platform.h"
#include "tw_func.h"
#include "tw_util.h"
#include "tw_local.h"
TW_UINT16 twainCallback(pTW_IDENTITY pOrigin,
pTW_IDENTITY pDest,
TW_UINT32 DG,
TW_UINT16 DAT,
TW_UINT16 MSG,
TW_MEMREF pData);
extern pTW_SESSION initializeTwain ();
/*
* callDSM
*
* Call the specified function on the data source manager.
*/
TW_UINT16
callDSM(pTW_IDENTITY pOrigin,
pTW_IDENTITY pDest,
TW_UINT32 DG,
TW_UINT16 DAT,
TW_UINT16 MSG,
TW_MEMREF pData)
{
/* Call the function */
return DSM_Entry (pOrigin, pDest, DG, DAT, MSG, pData);
}
/*
* twainIsAvailable
*
* Return boolean indicating whether TWAIN is available
*/
int
twainIsAvailable(void)
{
return TRUE;
}
TW_HANDLE
twainAllocHandle(size_t size)
{
return NewHandle(size);
}
TW_MEMREF
twainLockHandle (TW_HANDLE handle)
{
return *handle;
}
void
twainUnlockHandle (TW_HANDLE handle)
{
/* NOP */
}
void
twainFreeHandle (TW_HANDLE handle)
{
DisposeHandle (handle);
}
gboolean
twainSetupCallback (pTW_SESSION twSession)
{
TW_CALLBACK callback;
/* We need to set up our callback to receive messages */
callback.CallBackProc = (TW_MEMREF)twainCallback;
callback.RefCon = (TW_UINT32)twSession;
callback.Message = 0;
twSession->twRC = callDSM(APP_IDENTITY(twSession), NULL,
DG_CONTROL, DAT_CALLBACK, MSG_REGISTER_CALLBACK,
(TW_MEMREF) &callback);
if (twSession->twRC != TWRC_SUCCESS) {
LogMessage("Couldn't set callback function (retval %d)", (int)(twSession->twRC));
return FALSE;
}
return TRUE;
}
/*
* unloadTwainLibrary
*
* Unload the TWAIN dynamic link library
*/
int
unloadTwainLibrary(pTW_SESSION twSession)
{
/* We're statically linked; just clear the session */
DS_IDENTITY(twSession)->Id = 0;
/* We are now back at state 1 */
twSession->twainState = 1;
LogMessage("Source Manager successfully closed\n");
return TRUE;
}
TW_UINT16 twainCallback(pTW_IDENTITY pOrigin,
pTW_IDENTITY pDest,
TW_UINT32 DG,
TW_UINT16 DAT,
TW_UINT16 MSG,
TW_MEMREF pData)
{
pTW_SESSION twSession = (pTW_SESSION)(((TW_CALLBACK *)pData)->RefCon);
LogMessage("twainCallback! DG 0x%x, DAT 0x%x, MSG 0x%x\n",
(int)DG, (int)DAT, (int)MSG);
processTwainMessage (MSG, twSession);
return TWRC_SUCCESS;
}
void twainQuitApplication (void)
{
QuitApplicationEventLoop();
}
/* main bits */
/* http://lists.wxwidgets.org/archive/wxPython-mac/msg00117.html */
extern OSErr CPSSetProcessName (ProcessSerialNumber *psn, char *processname);
extern OSErr CPSEnableForegroundOperation( ProcessSerialNumber *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
static void
doGetImage (EventLoopTimerRef inTimer, void *inUserData)
{
if (! scanImage ())
QuitApplicationEventLoop ();
}
static void twainSetupMacUI()
{
ProcessSerialNumber psn;
GetCurrentProcess (&psn);
CPSSetProcessName (&psn, "GIMP TWAIN");
/* Need to do some magic here to get the UI to work */
CPSEnableForegroundOperation (&psn, 0x03, 0x3C, 0x2C, 0x1103);
SetFrontProcess (&psn);
/* We end up with the ugly console dock icon; let's override it */
gchar *iconfile = g_build_filename (gimp_data_directory (),
"twain",
"gimp-twain.png",
NULL);
CFURLRef url = CFURLCreateFromFileSystemRepresentation (kCFAllocatorDefault,
iconfile,
strlen (iconfile),
FALSE);
g_free (iconfile);
CGDataProviderRef png = CGDataProviderCreateWithURL (url);
CGImageRef icon = CGImageCreateWithPNGDataProvider (png, NULL, TRUE,
kCGRenderingIntentDefault);
/* Voodoo magic fix inspired by java_swt launcher */
/* Without this the icon setting doesn't work about half the time. */
CGrafPtr p = BeginQDContextForApplicationDockTile();
EndQDContextForApplicationDockTile(p);
SetApplicationDockTileImage (icon);
}
int
twainMain(void)
{
EventLoopTimerRef timer;
OSStatus err;
twainSetupMacUI();
/* Ok, back to work! */
initializeTwain ();
/* Set this up to run once the event loop is started */
err = InstallEventLoopTimer (GetMainEventLoop (),
0, 0, /* Immediately, once only */
NewEventLoopTimerUPP (doGetImage),
NULL, &timer);
if (err)
{
g_warning ("InstallEventLoopTimer returned error %d", (int)err);
g_message ("Something went horribly awry.");
return -1;
}
RunApplicationEventLoop();
return 0;
}
......@@ -4,10 +4,6 @@
* Craig Setera <setera@home.com>
* 03/31/1999
*
* Updated for Mac OS X support
* Brion Vibber <brion@pobox.com>
* 07/22/2004
*
* 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 3 of the License, or
......@@ -25,24 +21,6 @@
#ifndef _TW_PLATFORM_H
#define _TW_PLATFORM_H
#ifdef __APPLE__
/* Mac OS X */
#include <Carbon/Carbon.h>
#include <TWAIN/TWAIN.h>
#define DEBUG_LOGFILE "/tmp/twain.log"
#define DUMP_FILE "/tmp/twaincap.bin"
#define DUMP_NAME "dtwain"
#define READDUMP_NAME "rtwain"
#define _stricmp strcasecmp
#else
/* Win32 */
#include <windows.h>
#include "twain.h"
......@@ -57,5 +35,3 @@
#define TWAIN_ALTERNATE_MAIN
#endif
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment