Tk Source Code

Check-in [16bee760]
Login

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

Overview
Comment:Ensure ::tk::mac::GetAppPath is included
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | mac_services
Files: files | file ages | folders
SHA3-256: 16bee760c44578217f39fb4fa6163aa9ce24ad205a3414fc2781453d1f695371
User & Date: kevin_walzer 2019-03-09 03:16:05.140
Context
2019-03-16
02:09
Fix comment check-in: 43f384df user: kevin_walzer tags: mac_services
2019-03-09
03:16
Ensure ::tk::mac::GetAppPath is included check-in: 16bee760 user: kevin_walzer tags: mac_services
2019-03-08
03:44
Remove tkMacOSXLaunch.c from TIP; adds too many extraneous commands. Re-focus on URL and print events, and Services check-in: 53616eef user: kevin_walzer tags: mac_services
Changes
Unified Diff Ignore Whitespace Patch
Changes to macosx/tkMacOSXInit.c.
129
130
131
132
133
134
135


136
137
138
139
140
141
142
     * Process events to ensure that the root window is fully
     * initialized. See ticket 56a1823c73.
     */
    
    [NSApp _lockAutoreleasePool];
    while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT)) {}
    [NSApp _unlockAutoreleasePool];


}

- (void) _setup: (Tcl_Interp *) interp
{
    /*
     * Remember our interpreter.
     */







>
>







129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
     * Process events to ensure that the root window is fully
     * initialized. See ticket 56a1823c73.
     */
    
    [NSApp _lockAutoreleasePool];
    while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT)) {}
    [NSApp _unlockAutoreleasePool];

    Tk_MacOSXServices_Init(_eventInterp);
}

- (void) _setup: (Tcl_Interp *) interp
{
    /*
     * Remember our interpreter.
     */
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
    }

    if (scriptPath[0] != '\0') {
	Tcl_SetVar2(interp, "auto_path", NULL, scriptPath,
		TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
    }

    Tk_MacOSXServices_Init(interp);

    Tcl_CreateObjCommand(interp, "::tk::mac::standardAboutPanel",
	    TkMacOSXStandardAboutPanelObjCmd, NULL, NULL);
    Tcl_CreateObjCommand(interp, "::tk::mac::registerServiceWidget",
	    TkMacOSXRegisterServiceWidgetObjCmd, NULL, NULL);
    Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap",
	    TkMacOSXIconBitmapObjCmd, NULL, NULL);
    Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", TkMacOSXGetAppPath,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    

    /*
     * Workaround for 3efbe4a397; console not accepting keyboard input on 10.14
     * if displayed before main window. This places console in background and it
     * accepts input after being raised.
     */

    while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}

    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *







<
<







<
<
<
<
<
<
<
<
<







372
373
374
375
376
377
378


379
380
381
382
383
384
385









386
387
388
389
390
391
392
    }

    if (scriptPath[0] != '\0') {
	Tcl_SetVar2(interp, "auto_path", NULL, scriptPath,
		TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
    }



    Tcl_CreateObjCommand(interp, "::tk::mac::standardAboutPanel",
	    TkMacOSXStandardAboutPanelObjCmd, NULL, NULL);
    Tcl_CreateObjCommand(interp, "::tk::mac::registerServiceWidget",
	    TkMacOSXRegisterServiceWidgetObjCmd, NULL, NULL);
    Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap",
	    TkMacOSXIconBitmapObjCmd, NULL, NULL);
    Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", TkMacOSXGetAppPath,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);










    return TCL_OK;
}

/*
 *----------------------------------------------------------------------
 *
427
428
429
430
431
432
433





































434
435
436
437
438
439
440
    } else {
	p = strrchr(name, '/');
	if (p != NULL) {
	    name = p+1;
	}
    }
    Tcl_DStringAppend(namePtr, name, -1);





































}

/*
 *----------------------------------------------------------------------
 *
 * TkpDisplayWarning --
 *







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
    } else {
	p = strrchr(name, '/');
	if (p != NULL) {
	    name = p+1;
	}
    }
    Tcl_DStringAppend(namePtr, name, -1);
}

/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXGetAppPath --
 *
 *	Returns the path of the Wish application bundle.
 *
 * Results:
 *	Returns the application path.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 *//*Tcl function to get path to app bundle.*/
int TkMacOSXGetAppPath(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {

  CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());

  
  /* Convert the URL reference into a string reference. */
  CFStringRef appPath = CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
 
  /* Get the system encoding method. */
  CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
 
  /* Convert the string reference into a C string. */
  char *path = CFStringGetCStringPtr(appPath, encodingMethod);

  Tcl_SetResult(ip, path, NULL);

  CFRelease(mainBundleURL);
  CFRelease(appPath);
  return TCL_OK;

}

/*
 *----------------------------------------------------------------------
 *
 * TkpDisplayWarning --
 *
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
	    obj = Tcl_NewObj();
	    Tcl_SetObjLength(obj, len);
	    CFStringGetBytes(str, all, kCFStringEncodingUTF8, 0, false,
		    (UInt8*) obj->bytes, len, NULL);
	}
    }
    return obj;
}

/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXGetAppPath --
 *
 *	Retrieves the path to the current installed Wish application.
 *
 * Results:
 *	Returns the application name path.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

int TkMacOSXGetAppPath(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {

  CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());

  
  /* Convert the URL reference into a string reference. */
  CFStringRef appPath = CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
 
  /* Get the system encoding method. */
  CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
 
  /* Convert the string reference into a C string. */
  char *path = CFStringGetCStringPtr(appPath, encodingMethod);

  Tcl_SetResult(ip, path, NULL);

  CFRelease(mainBundleURL);
  CFRelease(appPath);
  return TCL_OK;

}

/*
 * Local Variables:
 * mode: objc
 * c-basic-offset: 4
 * fill-column: 79
 * coding: utf-8
 * End:
 */







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










608
609
610
611
612
613
614






































615
616
617
618
619
620
621
622
623
624
	    obj = Tcl_NewObj();
	    Tcl_SetObjLength(obj, len);
	    CFStringGetBytes(str, all, kCFStringEncodingUTF8, 0, false,
		    (UInt8*) obj->bytes, len, NULL);
	}
    }
    return obj;






































}

/*
 * Local Variables:
 * mode: objc
 * c-basic-offset: 4
 * fill-column: 79
 * coding: utf-8
 * End:
 */
Changes to macosx/tkMacOSXServices.c.
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
- (BOOL)acceptsFirstResponder {
  return YES;
}
- (BOOL)becomeFirstResponder {
  return YES;
}

//get selected text, copy to pasteboard
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard  types:(NSArray *)types { 
  NSArray *typesDeclared; 
  if ([types containsObject:NSStringPboardType] == NO) { 
    return NO; 
  } 

  Tcl_Eval(ServicesInterp,"clipboard get");







|







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
- (BOOL)acceptsFirstResponder {
  return YES;
}
- (BOOL)becomeFirstResponder {
  return YES;
}

/*Get selected text, copy to pasteboard.*/
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard  types:(NSArray *)types { 
  NSArray *typesDeclared; 
  if ([types containsObject:NSStringPboardType] == NO) { 
    return NO; 
  } 

  Tcl_Eval(ServicesInterp,"clipboard get");
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197

//initalize the package in the tcl interpreter, create tcl commands
int Tk_MacOSXServices_Init (Tcl_Interp *interp) {

  /* Set up an autorelease pool. */
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];


  /* Initialize instance of TclServices to provide service functionality. */
  TkService *service = [[TkService alloc] init];
  ServicesInterp = interp;
  [NSApp setServicesProvider:service];

  [pool release];
      
  return TCL_OK;
	
}










<





|







177
178
179
180
181
182
183

184
185
186
187
188
189
190
191
192
193
194
195
196

//initalize the package in the tcl interpreter, create tcl commands
int Tk_MacOSXServices_Init (Tcl_Interp *interp) {

  /* Set up an autorelease pool. */
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];


  /* Initialize instance of TclServices to provide service functionality. */
  TkService *service = [[TkService alloc] init];
  ServicesInterp = interp;
  [NSApp setServicesProvider:service];

  [pool drain];
      
  return TCL_OK;
	
}