public
Description: Gem Document Viewer for Mac OS X
Homepage: http://www.robinlu.com/blog/goo/
Clone URL: git://github.com/robin/goo.git
robin (author)
Fri Aug 22 09:23:23 -0700 2008
commit  d51faf8c057b8295ad6907c572f243b64b9dc78f
tree    02fddb95fe477be9c35f240ad0d2ec87446d3cf9
parent  70f6f0ef8a620b49bda1b50c88144bc9c138d62a
goo / GooController.m
100644 90 lines (75 sloc) 2.704 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// GooController.m
// goo
//
// Created by Robin Lu on 8/22/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
 
#import "GooController.h"
#import "GemSpecs.h"
#import <WebKit/WebKit.h>
 
@implementation GooController
static NSString *zoomFactorIdentifier = @"zoom factor";
 
- (void)awakeFromNib
{
float zoomFactor = [[NSUserDefaults standardUserDefaults] floatForKey:zoomFactorIdentifier];
if(0!=zoomFactor)
{
[webView setTextSizeMultiplier:zoomFactor];
}
}
 
#pragma mark table view delegate
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
{
[gemInfoView reloadData];
 
NSDictionary *selected = [[gemArrayController selectedObjects] objectAtIndex:0];
NSString *path = [NSString stringWithFormat:@"%@/index.html", [selected objectForKey:@"doc_path"]];
 
NSURL *url;
NSFileManager *fileManager = [NSFileManager defaultManager];
if ( ![fileManager fileExistsAtPath:path isDirectory:NULL] ) {
path = @"about:blank";
url = [NSURL URLWithString:path];
}
else
url = [NSURL fileURLWithPath:path];
 
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[[webView mainFrame] loadRequest:request];
}
 
#pragma mark window view delegate
- (void)windowWillClose:(NSNotification *)notification
{
float zoomFactor = [webView textSizeMultiplier];
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setFloat:zoomFactor forKey:zoomFactorIdentifier];
[userDefaults synchronize];
}
 
#pragma mark table view menu
- (IBAction)openInFinder:(id)sender
{
NSDictionary *selected = [[gemArrayController selectedObjects] objectAtIndex:0];
NSString *path = [selected objectForKey:@"path"];
[[NSWorkspace sharedWorkspace] openFile:path];
}
 
- (IBAction)openInEditor:(id)sender
{
NSDictionary *selected = [[gemArrayController selectedObjects] objectAtIndex:0];
NSString *path = [selected objectForKey:@"path"];
[[NSWorkspace sharedWorkspace] openFile:path withApplication:@"TextMate"];
}
 
- (IBAction)openInHomepage:(id)sender
{
NSDictionary *selected = [[gemArrayController selectedObjects] objectAtIndex:0];
NSString *path = [selected objectForKey:@"homepage"];
NSURL *url = [NSURL URLWithString:path];
[[NSWorkspace sharedWorkspace] openURL:url];
}
 
#pragma mark Links
- (IBAction)donate:(id)sender
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=iamawalrus%40gmail%2ecom&item_name=Goo&amount=4%2e99&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8"]];
}
 
- (IBAction)homepage:(id)sender
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.robinlu.com/blog/goo"]];
}
 
@end