mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-20 05:13:58 -07:00
Pass authtoken in from user, and add a wrapper for web UI on Mac.
This commit is contained in:
parent
e58047eaa0
commit
5b54612d91
68 changed files with 7537 additions and 1 deletions
94
ext/mac-ui-macgap1-wrapper/MacGap/Classes/Window.m
Normal file
94
ext/mac-ui-macgap1-wrapper/MacGap/Classes/Window.m
Normal file
|
@ -0,0 +1,94 @@
|
|||
#import "Window.h"
|
||||
|
||||
@implementation Window
|
||||
|
||||
@synthesize windowController, webView;
|
||||
|
||||
- (id) initWithWebView:(WebView*)view
|
||||
{
|
||||
if(self = [super init]) {
|
||||
self.webView = view;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) open:(NSDictionary *)properties
|
||||
{
|
||||
self.windowController = [[WindowController alloc] initWithURL:[properties valueForKey:@"url"]];
|
||||
[self.windowController showWindow: [NSApplication sharedApplication].delegate];
|
||||
[self.windowController.window makeKeyWindow];
|
||||
}
|
||||
|
||||
- (void) minimize {
|
||||
[[NSApp mainWindow] miniaturize:[NSApp mainWindow]];
|
||||
}
|
||||
|
||||
- (void) toggleFullscreen {
|
||||
[[NSApp mainWindow] toggleFullScreen:[NSApp mainWindow]];
|
||||
}
|
||||
|
||||
- (void) maximize {
|
||||
CGRect a = [NSApp mainWindow].frame;
|
||||
_oldRestoreFrame = CGRectMake(a.origin.x, a.origin.y, a.size.width, a.size.height);
|
||||
[[NSApp mainWindow] setFrame:[[NSScreen mainScreen] visibleFrame] display:YES];
|
||||
}
|
||||
|
||||
- (Boolean) isMaximized {
|
||||
NSRect a = [NSApp mainWindow].frame;
|
||||
NSRect b = [[NSScreen mainScreen] visibleFrame];
|
||||
return a.origin.x == b.origin.x && a.origin.y == b.origin.y && a.size.width == b.size.width && a.size.height == b.size.height;
|
||||
}
|
||||
|
||||
- (CGFloat) getX {
|
||||
NSRect frame = [self.webView window].frame;
|
||||
return frame.origin.x;
|
||||
}
|
||||
|
||||
- (CGFloat) getY {
|
||||
NSRect frame = [self.webView window].frame;
|
||||
return frame.origin.y;
|
||||
}
|
||||
|
||||
- (void) move:(NSDictionary *)properties
|
||||
{
|
||||
NSRect frame = [self.webView window].frame;
|
||||
frame.origin.x = [[properties valueForKey:@"x"] doubleValue];
|
||||
frame.origin.y = [[properties valueForKey:@"y"] doubleValue];
|
||||
[[self.webView window] setFrame:frame display:YES];
|
||||
|
||||
}
|
||||
|
||||
- (void) resize:(NSDictionary *) properties
|
||||
{
|
||||
NSRect frame = [self.webView window].frame;
|
||||
frame.size.width = [[properties valueForKey:@"width"] doubleValue];
|
||||
frame.size.height = [[properties valueForKey:@"height"] doubleValue];
|
||||
[[self.webView window] setFrame:frame display:YES];
|
||||
}
|
||||
|
||||
|
||||
+ (BOOL) isSelectorExcludedFromWebScript:(SEL)selector
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (NSString*) webScriptNameForSelector:(SEL)selector{
|
||||
id result = nil;
|
||||
|
||||
if (selector == @selector(open:)) {
|
||||
result = @"open";
|
||||
}else if (selector == @selector(move:)){
|
||||
result = @"move";
|
||||
}else if (selector == @selector(resize:)){
|
||||
result = @"resize";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
+ (BOOL) isKeyExcludedFromWebScript:(const char*)name
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
Loading…
Add table
Add a link
Reference in a new issue