From 30968a56c3caaad6b1872904c12eca96059cdd50 Mon Sep 17 00:00:00 2001 From: mjwybrow Date: Mon, 5 Feb 2007 01:37:43 +0000 Subject: [PATCH] * packaging/macosx/ScriptExec/main.c, packaging/macosx/Resources/script: Present a new message to OS X users describing the delay when starting Inkscape for the first time, as well as the fact that Inkscape windows will be part of the X11 application. Also, bounce the dock icon so that users will actually see this message. --- packaging/macosx/Resources/script | 14 +++-- packaging/macosx/ScriptExec/main.c | 94 ++++++++++++++++-------------- 2 files changed, 59 insertions(+), 49 deletions(-) diff --git a/packaging/macosx/Resources/script b/packaging/macosx/Resources/script index a343227c9..5608f7423 100755 --- a/packaging/macosx/Resources/script +++ b/packaging/macosx/Resources/script @@ -5,6 +5,7 @@ CWD="`dirname \"$0\"`" + ps -wx -ocommand | grep -e '[X]11' > /dev/null if [ "$?" != "0" -a ! -f ~/.xinitrc ]; then echo "rm -f ~/.xinitrc" > ~/.xinitrc @@ -24,11 +25,14 @@ export DISPLAY="`cat /tmp/display.$UID`" ps -wx -ocommand | grep -e '[X]11' > /dev/null || exit 11 -VERSION=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 -d'.'` -if [ "$VERSION" -eq "4" ]; then - # We're on tiger. So need to update fc-cache if it hasn't been done - test -f ~/.inkscape/.fccache || exit 12 -fi +# Old OS X version specific test: +# +#VERSION=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 -d'.'` +#if [ "$VERSION" -eq "4" ]; then + +# Warn the user about time-consuming generation of fontconfig caches. +test -f ~/.inkscape/.fccache-new || exit 12 + BASE="`echo "$0" | sed -e 's/\/Contents\/Resources\/script/\//'`" cd "$BASE" diff --git a/packaging/macosx/ScriptExec/main.c b/packaging/macosx/ScriptExec/main.c index 979d85057..c4b30b3b3 100644 --- a/packaging/macosx/ScriptExec/main.c +++ b/packaging/macosx/ScriptExec/main.c @@ -160,8 +160,45 @@ int main(int argc, char* argv[]) #pragma mark - +static void RequestUserAttention(void) +{ + NMRecPtr notificationRequest = (NMRecPtr) NewPtr(sizeof(NMRec)); + + memset(notificationRequest, 0, sizeof(*notificationRequest)); + notificationRequest->qType = nmType; + notificationRequest->nmMark = 1; + notificationRequest->nmIcon = 0; + notificationRequest->nmSound = 0; + notificationRequest->nmStr = NULL; + notificationRequest->nmResp = NULL; + + verify_noerr(NMInstall(notificationRequest)); +} + + +static void ShowFirstStartWarningDialog(void) +{ + SInt16 itemHit; + + AlertStdAlertParamRec params; + params.movable = true; + params.helpButton = false; + params.filterProc = NULL; + params.defaultText = (void *) kAlertDefaultOKText; + params.cancelText = NULL; + params.otherText = NULL; + params.defaultButton = kAlertStdAlertOKButton; + params.cancelButton = kAlertStdAlertCancelButton; + params.position = kWindowDefaultPosition; + + StandardAlert(kAlertNoteAlert, "\pInkscape on Mac OS X", + "\pWhile Inkscape is open, its windows can be displayed or hidden by displaying or hiding the X11 application.\n\nThe first time this version of Inkscape is run it may take several minutes before the main window is displayed while font caches are built.", + ¶ms, &itemHit); +} + + ////////////////////////////////// -// Handler for when X11 fails to start +// Handler for when fontconfig caches need to be generated ////////////////////////////////// static OSStatus FCCacheFailedHandler(EventHandlerCallRef theHandlerCall, EventRef theEvent, void *userData) @@ -169,51 +206,19 @@ static OSStatus FCCacheFailedHandler(EventHandlerCallRef theHandlerCall, pthread_join(tid, NULL); if (odtid) pthread_join(odtid, NULL); - - SInt16 itemHit; - AlertStdAlertParamRec params; - params.movable = true; - params.helpButton = false; - params.filterProc = NULL; - params.defaultText = "\pRun fc-cache"; - params.cancelText = "\pIgnore"; - params.otherText = NULL; - params.defaultButton = kAlertStdAlertOKButton; - params.cancelButton = kAlertStdAlertCancelButton; - params.position = kWindowDefaultPosition; - - StandardAlert(kAlertStopAlert, "\pFont caches may need to be updated", - "\pA problem occurs on OS X 10.4 where X11 does not always generate the necessary fontconfig caches. This can be corrected by running fc-cache as root.\n\nThis can take several minutes, with high processor usage. Please do not close Inkscape.", - ¶ms, &itemHit); - - if (itemHit == kAlertStdAlertOKButton) - { - OSStatus err = FixFCCache(); + // Bounce Inkscape Dock icon + RequestUserAttention(); + // Need to show warning to the user, then carry on. + ShowFirstStartWarningDialog(); - if (err == errAuthorizationSuccess) - { - params.defaultText = (void *) kAlertDefaultOKText; - params.cancelText = NULL; - - StandardAlert(kAlertNoteAlert, "\pFont caches have been updated", - "\pPlease re-run Inkscape.", ¶ms, &itemHit); - system("test -d \"$HOME/.inkscape\" || mkdir \"$HOME/.inkscape\"; touch \"$HOME/.inkscape/.fccache\""); - } - } - else - { - params.defaultText = (void *) kAlertDefaultOKText; - params.cancelText = NULL; - - StandardAlert(kAlertNoteAlert, "\pFont caches have not been updated", - "\pThey can be updated manually by running the following:\n sudo /usr/X11R6/bin/fc-cache -f\nOnce you have dealt with this, please re-run Inkscape.", ¶ms, &itemHit); - system("test -d \"$HOME/.inkscape\" || mkdir \"$HOME/.inkscape\"; touch \"$HOME/.inkscape/.fccache\""); - } - - ExitToShell(); + // Note that we've seen the warning. + system("test -d \"$HOME/.inkscape\" || mkdir \"$HOME/.inkscape\"; " + "touch \"$HOME/.inkscape/.fccache-new\""); + // Rerun now. + OSErr err = ExecuteScript(scriptPath, &pid); - return noErr; + return err; } @@ -326,6 +331,7 @@ static OSStatus FixFCCache (void) return err; } + /////////////////////////////////// // Execution thread starts here /////////////////////////////////// @@ -344,7 +350,7 @@ static void *Execute (void *arg) else if (err == (OSErr)12) { CreateEvent(NULL, kEventClassRedFatalAlert, kEventKindFCCacheFailed, 0, kEventAttributeNone, &event); - PostEventToQueue(GetMainEventQueue(), event, kEventPriorityStandard); + PostEventToQueue(GetMainEventQueue(), event, kEventPriorityHigh); } else ExitToShell(); return 0; -- 2.30.2