Tk Source Code

Check-in [5a1e3c46]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Implementation for Carbon.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-382
Files: files | file ages | folders
SHA1: 5a1e3c46df6f976a02f44b57bad063e84b4cc6f2
User & Date: dgp 2011-10-17 20:10:41
Context
2011-10-19
15:03
add docs Closed-Leaf check-in: a66e998b user: dgp tags: tip-382
2011-10-17
20:10
Implementation for Carbon. check-in: 5a1e3c46 user: dgp tags: tip-382
19:54
Fix up the implementation to account for shared options enumeration. check-in: de044a4c user: dgp tags: tip-382
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to macosx/tkMacOSXDialog.c.

80
81
82
83
84
85
86
87

88
89
90
91
92
93
94
...
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
...
418
419
420
421
422
423
424

425
426
427
428
429
430
431
432
433
434

435
436
437
438

439
440
441
442
443
444
445
...
504
505
506
507
508
509
510






511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
...
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
...
774
775
776
777
778
779
780

781
782
783
784
785
786
787
...
795
796
797
798
799
800
801



802
803
804
805
806
807
808
			    NavCBRecPtr callBackParms,
			    NavCallBackUserData callBackUD);
static void		InitFileDialogs(void);
static int		NavServicesGetFile(Tcl_Interp *interp,
			    OpenFileData *ofd, AEDesc *initialDescPtr,
			    char *initialFile, AEDescList *selectDescPtr,
			    CFStringRef title, CFStringRef message,
			    const char *initialType, int multiple, int isOpen,

			    Tk_Window parent);
static int		HandleInitialDirectory(Tcl_Interp *interp,
			    char *initialFile, char *initialDir, FSRef *dirRef,
			    AEDescList *selectDescPtr, AEDesc *dirDescPtr);

/*
 * Have we initialized the file dialog subsystem
................................................................................
	initialPtr = &initialDesc;
    }
    if (typeVariablePtr) {
	initialtype = Tcl_GetVar(interp, Tcl_GetString(typeVariablePtr),
		TCL_GLOBAL_ONLY);
    }
    result = NavServicesGetFile(interp, &ofd, initialPtr, NULL, &selectDesc,
	    title, message, initialtype, multiple, OPEN_FILE, parent);

    if (typeVariablePtr) {
	FileFilter *filterPtr = ofd.fl.filters;
	int i = ofd.curType;

	while (filterPtr && i-- > 0) {
	    filterPtr = filterPtr->next;
................................................................................
Tk_GetSaveFileObjCmd(
    ClientData clientData,	/* Main window associated with interpreter. */
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of arguments. */
    Tcl_Obj *CONST objv[])	/* Argument objects. */
{
    int i, result = TCL_ERROR;

    char *initialFile = NULL;
    Tk_Window parent = NULL;
    AEDesc initialDesc = {typeNull, NULL};
    AEDesc *initialPtr = NULL;
    FSRef dirRef;
    CFStringRef title = NULL, message = NULL;
    OpenFileData ofd;
    static const char *saveOptionStrings[] = {
	"-defaultextension", "-filetypes", "-initialdir", "-initialfile",
	"-message", "-parent", "-title", "-typevariable", NULL

    };
    enum saveOptions {
	SAVE_DEFAULT, SAVE_FILETYPES, SAVE_INITDIR, SAVE_INITFILE,
	SAVE_MESSAGE, SAVE_PARENT, SAVE_TITLE, SAVE_TYPEVARIABLE,

    };

    if (!fileDlgInited) {
	InitFileDialogs();
    }

    TkInitFileFilters(&ofd.fl);
................................................................................
	    choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
	    if (title) {
		CFRelease(title);
	    }
	    title = CFStringCreateWithBytes(NULL, (unsigned char *) choice,
		    choiceLen, kCFStringEncodingUTF8, false);
	    break;






	}
    }

    if (initialDesc.descriptorType == typeFSRef) {
	initialPtr = &initialDesc;
    }
    result = NavServicesGetFile(interp, &ofd, initialPtr, initialFile, NULL,
	    title, message, NULL, false, SAVE_FILE, parent);
    TkFreeFileFilters(&ofd.fl);
  end:
    if (initialDesc.dataHandle) {
	ChkErr(AEDisposeDesc, &initialDesc);
    }
    if (title) {
	CFRelease(title);
................................................................................

    TkInitFileFilters(&ofd.fl);
    ofd.usePopup = 0;
    if (initialDesc.descriptorType == typeFSRef) {
	initialPtr = &initialDesc;
    }
    result = NavServicesGetFile(interp, &ofd, initialPtr, NULL, NULL, title,
	    message, NULL, false, CHOOSE_FOLDER, parent);
    TkFreeFileFilters(&ofd.fl);
  end:
    if (initialDesc.dataHandle) {
	ChkErr(AEDisposeDesc, &initialDesc);
    }
    if (title) {
	CFRelease(title);
................................................................................
    AEDesc *initialDescPtr,
    char *initialFile,
    AEDescList *selectDescPtr,
    CFStringRef title,
    CFStringRef message,
    const char *initialtype,
    int multiple,

    int isOpen,
    Tk_Window parent)
{
    NavHandlerUserData data;
    NavDialogCreationOptions options;
    NavDialogRef dialogRef = NULL;
    CFStringRef *menuItemNames = NULL;
................................................................................
	return result;
    }
    options.optionFlags = kNavDontAutoTranslate | kNavDontAddTranslateItems
	    | kNavSupportPackages | kNavAllFilesInPopup;
    if (multiple) {
	options.optionFlags |= kNavAllowMultipleFiles;
    }



    options.modality = kWindowModalityAppModal;
    if (parent && ((TkWindow *) parent)->window != None &&
	    TkMacOSXHostToplevelExists(parent)) {
	options.parentWindow = TkMacOSXDrawableWindow(Tk_WindowId(parent));
	TK_IF_HI_TOOLBOX (5,
	    /*
	     * Impossible to modify dialog modality with the Cocoa-based






|
>







 







|







 







>









|
>




>







 







>
>
>
>
>
>







|







 







|







 







>







 







>
>
>







80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
...
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
...
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
...
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
...
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
...
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
			    NavCBRecPtr callBackParms,
			    NavCallBackUserData callBackUD);
static void		InitFileDialogs(void);
static int		NavServicesGetFile(Tcl_Interp *interp,
			    OpenFileData *ofd, AEDesc *initialDescPtr,
			    char *initialFile, AEDescList *selectDescPtr,
			    CFStringRef title, CFStringRef message,
			    const char *initialType, int multiple,
			    int confirmOverwrite, int isOpen,
			    Tk_Window parent);
static int		HandleInitialDirectory(Tcl_Interp *interp,
			    char *initialFile, char *initialDir, FSRef *dirRef,
			    AEDescList *selectDescPtr, AEDesc *dirDescPtr);

/*
 * Have we initialized the file dialog subsystem
................................................................................
	initialPtr = &initialDesc;
    }
    if (typeVariablePtr) {
	initialtype = Tcl_GetVar(interp, Tcl_GetString(typeVariablePtr),
		TCL_GLOBAL_ONLY);
    }
    result = NavServicesGetFile(interp, &ofd, initialPtr, NULL, &selectDesc,
	    title, message, initialtype, multiple, false, OPEN_FILE, parent);

    if (typeVariablePtr) {
	FileFilter *filterPtr = ofd.fl.filters;
	int i = ofd.curType;

	while (filterPtr && i-- > 0) {
	    filterPtr = filterPtr->next;
................................................................................
Tk_GetSaveFileObjCmd(
    ClientData clientData,	/* Main window associated with interpreter. */
    Tcl_Interp *interp,		/* Current interpreter. */
    int objc,			/* Number of arguments. */
    Tcl_Obj *CONST objv[])	/* Argument objects. */
{
    int i, result = TCL_ERROR;
    int confirmOverwrite = 1;
    char *initialFile = NULL;
    Tk_Window parent = NULL;
    AEDesc initialDesc = {typeNull, NULL};
    AEDesc *initialPtr = NULL;
    FSRef dirRef;
    CFStringRef title = NULL, message = NULL;
    OpenFileData ofd;
    static const char *saveOptionStrings[] = {
	"-defaultextension", "-filetypes", "-initialdir", "-initialfile",
	"-message", "-parent", "-title", "-typevariable",
	"-confirmoverwrite", NULL
    };
    enum saveOptions {
	SAVE_DEFAULT, SAVE_FILETYPES, SAVE_INITDIR, SAVE_INITFILE,
	SAVE_MESSAGE, SAVE_PARENT, SAVE_TITLE, SAVE_TYPEVARIABLE,
	SAVE_CONFIRMOW
    };

    if (!fileDlgInited) {
	InitFileDialogs();
    }

    TkInitFileFilters(&ofd.fl);
................................................................................
	    choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen);
	    if (title) {
		CFRelease(title);
	    }
	    title = CFStringCreateWithBytes(NULL, (unsigned char *) choice,
		    choiceLen, kCFStringEncodingUTF8, false);
	    break;
	case SAVE_CONFIRMOW:
	    if (Tcl_GetBooleanFromObj(interp, objv[i + 1], &confirmOverwrite)
		    != TCL_OK) {
		return TCL_ERROR;
	    }
	    break;
	}
    }

    if (initialDesc.descriptorType == typeFSRef) {
	initialPtr = &initialDesc;
    }
    result = NavServicesGetFile(interp, &ofd, initialPtr, initialFile, NULL,
	    title, message, NULL, false, confirmOverwrite, SAVE_FILE, parent);
    TkFreeFileFilters(&ofd.fl);
  end:
    if (initialDesc.dataHandle) {
	ChkErr(AEDisposeDesc, &initialDesc);
    }
    if (title) {
	CFRelease(title);
................................................................................

    TkInitFileFilters(&ofd.fl);
    ofd.usePopup = 0;
    if (initialDesc.descriptorType == typeFSRef) {
	initialPtr = &initialDesc;
    }
    result = NavServicesGetFile(interp, &ofd, initialPtr, NULL, NULL, title,
	    message, NULL, false, false, CHOOSE_FOLDER, parent);
    TkFreeFileFilters(&ofd.fl);
  end:
    if (initialDesc.dataHandle) {
	ChkErr(AEDisposeDesc, &initialDesc);
    }
    if (title) {
	CFRelease(title);
................................................................................
    AEDesc *initialDescPtr,
    char *initialFile,
    AEDescList *selectDescPtr,
    CFStringRef title,
    CFStringRef message,
    const char *initialtype,
    int multiple,
    int confirmOverwrite,
    int isOpen,
    Tk_Window parent)
{
    NavHandlerUserData data;
    NavDialogCreationOptions options;
    NavDialogRef dialogRef = NULL;
    CFStringRef *menuItemNames = NULL;
................................................................................
	return result;
    }
    options.optionFlags = kNavDontAutoTranslate | kNavDontAddTranslateItems
	    | kNavSupportPackages | kNavAllFilesInPopup;
    if (multiple) {
	options.optionFlags |= kNavAllowMultipleFiles;
    }
    if (!confirmOverwrite) {
	options.optionFlags |= kNavDontConfirmReplacement;
    }
    options.modality = kWindowModalityAppModal;
    if (parent && ((TkWindow *) parent)->window != None &&
	    TkMacOSXHostToplevelExists(parent)) {
	options.parentWindow = TkMacOSXDrawableWindow(Tk_WindowId(parent));
	TK_IF_HI_TOOLBOX (5,
	    /*
	     * Impossible to modify dialog modality with the Cocoa-based