summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macosx/tkMacOSXDialog.c62
-rw-r--r--macosx/tkMacOSXEmbed.c21
-rw-r--r--macosx/tkMacOSXInit.c8
-rw-r--r--macosx/tkMacOSXPrivate.h1
-rw-r--r--macosx/tkMacOSXScrlbr.c8
-rw-r--r--macosx/tkMacOSXWindowEvent.c6
6 files changed, 86 insertions, 20 deletions
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index a66939a..ea456a6 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -24,12 +24,12 @@ enum colorOptions {
static const char *const openOptionStrings[] = {
"-defaultextension", "-filetypes", "-initialdir", "-initialfile",
"-message", "-multiple", "-parent", "-title", "-typevariable",
- "-command", NULL
+ "-command", "-allbutton", "-allbuttontip", NULL
};
enum openOptions {
OPEN_DEFAULT, OPEN_FILETYPES, OPEN_INITDIR, OPEN_INITFILE,
OPEN_MESSAGE, OPEN_MULTIPLE, OPEN_PARENT, OPEN_TITLE,
- OPEN_TYPEVARIABLE, OPEN_COMMAND,
+ OPEN_TYPEVARIABLE, OPEN_COMMAND, OPEN_ALLBUTTON, OPEN_ALLBUTTONTIP
};
static const char *const saveOptionStrings[] = {
"-defaultextension", "-filetypes", "-initialdir", "-initialfile",
@@ -221,6 +221,35 @@ static const short alertNativeButtonIndexAndTypeToButtonIndex[][3] = {
}
@end
+ @interface TKOpenDialog : NSControl
+ @property(assign) NSOpenPanel *openPanel;
+ @property(assign) NSMutableArray *openFileTypes;
+ - (void)openUnrecognizedFiles:(id)sender;
+ @end
+
+ @implementation TKOpenDialog
+ - (id)init {
+ self = [super init];
+ if (self) {
+ _openPanel = nil;
+ _openFileTypes = nil;
+ }
+ return self;
+ }
+
+ - (void)openUnrecognizedFiles:(id)sender
+ {
+ if ([sender state]) {
+ self.openPanel.allowedFileTypes = [NSArray arrayWithObjects:@"public.data", nil];
+ } else {
+ self.openPanel.allowedFileTypes = self.openFileTypes;
+ }
+ [self.openPanel setDirectoryURL:self.openPanel.directoryURL];
+ [self.openPanel validateVisibleColumns];
+ }
+
+ @end
+
#pragma mark -
/*
@@ -366,11 +395,14 @@ Tk_GetOpenFileObjCmd(
FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct;
NSString *directory = nil, *filename = nil;
NSString *message, *title, *type;
+ NSString *allbutton, *allbuttontip;
NSWindow *parent;
NSMutableArray *fileTypes = nil;
NSOpenPanel *panel = [NSOpenPanel openPanel];
NSInteger returnCode = NSAlertErrorReturn;
+ allbutton = nil;
+ allbuttontip = nil;
TkInitFileFilters(&fl);
for (i = 1; i < objc; i += 2) {
if (Tcl_GetIndexFromObjStruct(interp, objv[i], openOptionStrings,
@@ -437,6 +469,14 @@ Tk_GetOpenFileObjCmd(
case OPEN_COMMAND:
cmdObj = objv[i+1];
break;
+ case OPEN_ALLBUTTON:
+ allbutton = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ break;
+ case OPEN_ALLBUTTONTIP:
+ allbuttontip = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ break;
}
}
if (fl.filters) {
@@ -472,6 +512,24 @@ Tk_GetOpenFileObjCmd(
}
}
[panel setAllowsMultipleSelection:multiple];
+
+ if (allbutton) {
+ TKOpenDialog *tkDialog = [TKOpenDialog alloc];
+ tkDialog.openPanel = panel;
+ tkDialog.openFileTypes = fileTypes;
+
+ NSButton *openPanelAccessoryView = [[[NSButton alloc] initWithFrame:NSMakeRect(0.0, 0.0, 224.0, 22.0)] autorelease];
+ if (allbuttontip) {
+ [openPanelAccessoryView setToolTip:allbuttontip];
+ }
+ [openPanelAccessoryView setButtonType:NSSwitchButton];
+ [openPanelAccessoryView setBezelStyle:0];
+ [openPanelAccessoryView setTitle:allbutton];
+ [openPanelAccessoryView setAction:@selector(openUnrecognizedFiles:)];
+ [openPanelAccessoryView setTarget:tkDialog];
+ [panel setAccessoryView:openPanelAccessoryView];
+ }
+
if (cmdObj) {
callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo));
if (Tcl_IsShared(cmdObj)) {
diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c
index 1d66b82..f9700f6 100644
--- a/macosx/tkMacOSXEmbed.c
+++ b/macosx/tkMacOSXEmbed.c
@@ -207,6 +207,7 @@ TkpUseWindow(
MacDrawable *parent, *macWin;
Container *containerPtr;
+
if (winPtr->window != None) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't modify container after widget is created", -1));
@@ -247,14 +248,14 @@ TkpUseWindow(
* Container structure, since we only allow the case where both container
* and embedded app. are in the same process.
*/
-
+
for (containerPtr = firstContainerPtr; containerPtr != NULL;
- containerPtr = containerPtr->nextPtr) {
- if (containerPtr->parent == (Window) parent) {
- winPtr->flags |= TK_BOTH_HALVES;
- containerPtr->parentPtr->flags |= TK_BOTH_HALVES;
- break;
- }
+ containerPtr = containerPtr->nextPtr) {
+ if (containerPtr->parent == (Window) parent) {
+ winPtr->flags |= TK_BOTH_HALVES;
+ containerPtr->parentPtr->flags |= TK_BOTH_HALVES;
+ break;
+ }
}
/*
@@ -313,9 +314,10 @@ TkpUseWindow(
if (tkMacOSXEmbedHandler == NULL ||
tkMacOSXEmbedHandler->registerWinProc((long) parent,
(Tk_Window) winPtr) != TCL_OK) {
+
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "The window ID %s does not correspond to a valid Tk Window",
- string));
+ "The window ID %s does not correspond to a valid Tk Window",
+ string));
Tcl_SetErrorCode(interp, "TK", "EMBED", "HANDLE", NULL);
return TCL_ERROR;
}
@@ -391,7 +393,6 @@ TkpMakeContainer(
* sure the argument to -use is valid.
*/
- Tk_MakeWindowExist(tkwin);
containerPtr = ckalloc(sizeof(Container));
containerPtr->parent = Tk_WindowId(tkwin);
containerPtr->parentPtr = winPtr;
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index aaeb348..00df93e 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -91,11 +91,9 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
- (void) _setupEventLoop
{
- _running = 1;
- if (!_appFlags._hasBeenRun) {
- _appFlags._hasBeenRun = YES;
- [self finishLaunching];
- }
+
+ /*Remove private API flags here.*/
+ [self finishLaunching];
[self setWindowsNeedUpdate:YES];
}
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h
index adc7106..599317d 100644
--- a/macosx/tkMacOSXPrivate.h
+++ b/macosx/tkMacOSXPrivate.h
@@ -326,6 +326,7 @@ VISIBILITY_HIDDEN
BOOL _subviewsSetAside;
#endif
NSString *privateWorkingText;
+ BOOL _in_event;
}
@end
diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c
index ebb99f3..00f6088 100644
--- a/macosx/tkMacOSXScrlbr.c
+++ b/macosx/tkMacOSXScrlbr.c
@@ -50,11 +50,15 @@ NSRect TkMacOSXGetScrollFrame(TkScrollbar *scrlPtr);
NSRect Tkframe = TkMacOSXGetScrollFrame(scrollPtr);
/* Do not draw if the widget is misplaced or unmapped. */
if ( NSIsEmptyRect(Tkframe) ||
- ! macWin->winPtr->flags & TK_MAPPED ||
- ! NSEqualRects(Tkframe, [self frame])
+ ! (macWin->winPtr->flags & TK_MAPPED)
) {
return;
}
+ for (Tk_Window parent_win = tkwin; parent_win != NULL;parent_win = Tk_Parent(parent_win)) {
+ if (!Tk_IsMapped(parent_win)) {
+ return;
+ }
+ }
/*
* Do not draw if the widget is completely outside of its parent.
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index d016790..361b2e2 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -831,7 +831,11 @@ ExposeRestrictProc(
HIShapeUnionWithRect(drawShape, &r);
}
if (CFRunLoopGetMain() == CFRunLoopGetCurrent()) {
- [self generateExposeEvents:drawShape];
+ if (!_in_event) {
+ _in_event = true;
+ [self generateExposeEvents:drawShape];
+ _in_event = false;
+ }
} else {
[self performSelectorOnMainThread:@selector(generateExposeEvents:)
withObject:(id)drawShape waitUntilDone:NO