Commit a41b5f9d authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

macosx_dialog_provider: Propagate window close.

parent 23c70ac8
...@@ -115,6 +115,18 @@ static void destroyProgressPanel (void *); ...@@ -115,6 +115,18 @@ static void destroyProgressPanel (void *);
@synthesize widget; @synthesize widget;
@end @end
@interface VLCDialogWindow : NSWindow
{
extension_dialog_t *dialog;
}
@property (readwrite) extension_dialog_t *dialog;
@end
@implementation VLCDialogWindow
@synthesize dialog;
@end
@interface VLCDialogList : NSTableView @interface VLCDialogList : NSTableView
{ {
extension_widget_t *widget; extension_widget_t *widget;
...@@ -466,16 +478,6 @@ static void destroyProgressPanel (void *); ...@@ -466,16 +478,6 @@ static void destroyProgressPanel (void *);
return size; return size;
} }
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize
{
NSRect rect = NSMakeRect(0, 0, 0, 0);
rect.size = frameSize;
rect = [sender contentRectForFrameRect:rect];
rect.size = [self flexSize:rect.size];
rect = [sender frameRectForContentRect:rect];
return rect.size;
}
@end @end
...@@ -911,6 +913,30 @@ bool checkProgressPanel (void *priv) ...@@ -911,6 +913,30 @@ bool checkProgressPanel (void *priv)
} }
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize
{
NSView *contentView = [sender contentView];
assert([contentView isKindOfClass:[VLCDialogGridView class]]);
VLCDialogGridView *gridView = contentView;
NSRect rect = NSMakeRect(0, 0, 0, 0);
rect.size = frameSize;
rect = [sender contentRectForFrameRect:rect];
rect.size = [gridView flexSize:rect.size];
rect = [sender frameRectForContentRect:rect];
return rect.size;
}
- (BOOL)windowShouldClose:(id)sender
{
assert([sender isKindOfClass:[VLCDialogWindow class]]);
VLCDialogWindow *window = sender;
extension_dialog_t *dialog = [window dialog];
extension_DialogClosed(dialog);
dialog->p_sys_intf = NULL;
return YES;
}
static NSView *createControlFromWidget(extension_widget_t *widget, id self) static NSView *createControlFromWidget(extension_widget_t *widget, id self)
{ {
assert(!widget->p_sys_intf); assert(!widget->p_sys_intf);
...@@ -1183,16 +1209,17 @@ static void updateControlFromWidget(NSView *control, extension_widget_t *widget) ...@@ -1183,16 +1209,17 @@ static void updateControlFromWidget(NSView *control, extension_widget_t *widget)
if (!dialog->i_width || !dialog->i_height) if (!dialog->i_width || !dialog->i_height)
size = NSMakeSize(640, 480); size = NSMakeSize(640, 480);
NSWindow *window = dialog->p_sys_intf; VLCDialogWindow *window = dialog->p_sys_intf;
if (!window && !shouldDestroy) if (!window && !shouldDestroy)
{ {
NSRect content = NSMakeRect(0, 0, 1, 1); NSRect content = NSMakeRect(0, 0, 1, 1);
window = [[NSWindow alloc] initWithContentRect:content styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask backing:NSBackingStoreBuffered defer:NO]; window = [[VLCDialogWindow alloc] initWithContentRect:content styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask backing:NSBackingStoreBuffered defer:NO];
[window setDelegate:self];
[window setDialog:dialog];
[window setTitle:[NSString stringWithUTF8String:dialog->psz_title]]; [window setTitle:[NSString stringWithUTF8String:dialog->psz_title]];
VLCDialogGridView *gridView = [[VLCDialogGridView alloc] init]; VLCDialogGridView *gridView = [[VLCDialogGridView alloc] init];
[gridView setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable]; [gridView setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
[window setContentView:gridView]; [window setContentView:gridView];
[window setDelegate:gridView];
[gridView release]; [gridView release];
dialog->p_sys_intf = window; dialog->p_sys_intf = window;
} }
...@@ -1204,6 +1231,7 @@ static void updateControlFromWidget(NSView *control, extension_widget_t *widget) ...@@ -1204,6 +1231,7 @@ static void updateControlFromWidget(NSView *control, extension_widget_t *widget)
[window setDelegate:nil]; [window setDelegate:nil];
[window close]; [window close];
dialog->p_sys_intf = NULL; dialog->p_sys_intf = NULL;
window = nil;
} }
if (!dialog->b_hide && ![window isVisible]) { if (!dialog->b_hide && ![window isVisible]) {
......
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